akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
string s,t;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m>>s>>t;
    ll ans=lcm(n,m);
    ll temp1=ans/n;
    ll temp2=ans/m;
    ll temp3=lcm(temp1,temp2);
    ll temp4=temp3/temp1;
    ll temp5=temp3/temp2;
    ll a=1;
    ll b=1;
    while(true){
        if(a>s.size()||b>t.size()){
            break;
        }
        if(s[a-1]!=t[b-1])return cout<<-1<<"\n",0;
        a+=temp4;
        b+=temp5;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    rep(i,s.size()-1){
        if(s.at(i)==s.at(i+1)){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>   

# define F first
# define S second
# define mp make_pair
# define pii pair<int,int>

# define long long long
# define pb push_back
# define sz(a) (int)(a.size())

# define y1     tipa_y1
# define left   tipa_left
# define right  tipa_right

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 4611686018427387903;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
}           
int a, b, c;
                 
set <pair <pii, int> > s;

int main()
{
  Read_rap ();
  cin >> a >> b >> c;

  int t = 0;
        
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int x, y, z;
    x = b/2 + c/2;
    y = a/2 + c/2;
    z = b/2 + a/2;
    a = x, b = y, c = z;
    if (s.count (mp (mp (b, c), a))) {
      cout << -1;
      return 0;
    }

    s.insert (mp (mp (b, c), a));
    t ++;
  }
  cout << t;


  return 0;
}









// Coded by Z...


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n;
	string s;cin >> s;
	cin >> k;
	k--;
	rep(i,n) if(s.at(i)!=s.at(k)) s.at(i)='*';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
ll dp[2][3001][3001]; 

ll min_self(ll a, ll b){
    return a<b?a:b; 
}
ll max_self(ll a, ll b){
    return a>b?a:b; 
}
ll sol(ll* arr, int st, int en, int pl){
    //trace3(st, en, pl);
    if(st > en){
        return 0; 
    }
    if(dp[pl][st][en] != -1){
        return dp[pl][st][en];
    }
    if(pl == 0){
        dp[0][st][en] = max_self(arr[st] - sol(arr, st+1, en, 1),arr[en] - sol(arr, st, en-1, 1));
        return dp[0][st][en];
    }
    else{
        dp[1][st][en] = max_self(arr[st] - sol(arr, st+1, en, 0), arr[en] - sol(arr, st, en-1, 0));
        return dp[1][st][en]; 
    }
}

int main(){
	FAST_IO;
    int n; 
    cin >> n; 
    ll a[n]; 
    for(int i=0; i < n; i++){
        cin >> a[i]; 
    }
    for(int i=0; i < 2 ; i++){
        for(int j= 0 ; j < 3001; j++){
            for(int k = 0; k < 3001; k++){
                dp[i][j][k] = -1; 
            }
        }
    }
    sol(a, 0, n-1, 0);
    

   /* for(int i=0; i < 2 ; i++){
        for(int j= 0 ; j < n; j++){
            for(int k = 0; k < n; k++){
                cout << dp[i][j][k] <<" ";
            }
            cout << endl;
        }
        cout << endl;
    }*/

    

    cout << dp[0][0][n-1] <<endl; 
    return 0; 
 }

Measured memory_bytes: 141184
#include <iostream>
using namespace std;
int n, MOD = 1e9+7; string s;

int main() {
    cin >> n >> s;
    if(s[0] == 'W' || s[n*2-1] == 'W') { cout << 0 << endl; return 0; }

    for(int i = 0; i < n*2; i+=2) s[i] = (s[i]=='B' ? 'W' : 'B');

    long A=1, L=0, R=0;
    for(int i=0; i < n*2; ++i) {
        if(s[i]=='W') L++;
        else A = A*(L - R++)%MOD;
    }
    if(L != R) { cout << 0 << endl; return 0; }

    for(; n>1; A = A*n%MOD, --n);
    cout << A << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair< int,int > ii;
typedef pair< int,ii > iii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 100005;
const int MOD = 1e9+7;
const double EPS = 1e-6;
const double PI = acos(-1.0);

struct point {
    int x , y;
} P[ N ];

LL SQ( LL x ) {
    return x*x;
}
LL Dist( int i , int j ) {
    int x1 = P[i].x , y1 = P[i].y;
    int x2 = P[j].x , y2 = P[j].y;
    return SQ(x1-x2)+SQ(y1-y2);
}
int main( int argc, char const *argv[] ) {
    int n;
    cin >> n;
    int x = 0 , y = 0;
    bool f = true;
    for( int i = 1; i <= n; i++ ) {
        int t , a , b;
        cin >> t >> a >> b;
        int d = abs(a-x)+abs(b-y);
        if( d <= t && (d%2 == t%2) ) continue;
        else f = false;
        x = a , y = b;
    }
    if( f ) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 384
package main
  
import (
    "fmt"
    "strconv"
)

func main() {
    var n int
    fmt.Scan(&n)
    var cnt int
    for i := 1; i <= n; i++ {
        if len([]byte(strconv.Itoa(i)))%2 == 1 {
            cnt++
        }
    }
    fmt.Println(cnt)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int h,w,k;
  cin >> h >> w >> k;
  int dp[h+1][w];
  fill(dp[0],dp[h+1],0);
  dp[0][0] = 1;
  rep(i,0,h){
    for(int mask = 0;mask < (1<<(w-1));mask++){
      bool ng = false;
      rep(j,0,w-2){
        if((mask>>j & 3) == 3) ng = true;
      }
      if(ng) continue;
      rep(j,0,w){
        if(j != w-1){
          if((mask>>(w-2-j))&1){
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= MOD;
            dp[i+1][j] += dp[i][j+1];
            dp[i+1][j] %= MOD;
            j++;
          }
          else{
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
          }
        }
        else{
          dp[i+1][j] += dp[i][j];
          dp[i+1][j] %= MOD;
        }
      }
    }
  }
  cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 256
use std::collections::BTreeSet;

fn main() {
    let stick_cnt = read::<usize>()[0];
    let stick_lengthes = read::<u64>();
    let mut result = 0;
    'root: for i in 0..stick_cnt {
        if i == stick_cnt {
            break;
        }
        for j in (i+1)..stick_cnt {
            if j == stick_cnt {
                continue'root;
            }
            for k in (j+1)..stick_cnt {
                let i_len = stick_lengthes[i];
                let j_len = stick_lengthes[j];
                let k_len = stick_lengthes[k];
                if i_len == j_len || j_len == k_len || i_len == k_len {
                    continue
                }
                if i_len + j_len > k_len && j_len + k_len > i_len && i_len + k_len > j_len {
                    result += 1;
                }
                // if i_len + j_len > k_len {
                //     result += 1;
                // }
            }
        }
    }
    println!("{}", result);
}

use std::io::{self, BufRead, Read};
use std::vec::Vec;
fn read<T: std::str::FromStr>() -> Vec<T> {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.lock().read_line(&mut buf).unwrap();
    parse_line(&buf)
}

fn read_lines<T: std::str::FromStr>(count: usize) -> Vec<Vec<T>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let mut result = Vec::<Vec<T>>::with_capacity(count);
    for _ in 0..count {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        result.push(parse_line(&buf));
    }
    result
}

fn parse_line<T: std::str::FromStr>(string: &str) -> Vec<T> {
    string.trim().split(' ').map(|s| T::from_str(s).ok().unwrap()).collect()
}


Measured memory_bytes: 2172
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 20

typedef long long ll;
using namespace std;

int main(){
    ll N ;
    ll dig = 1,dig_find=26;
    int lt_num[20];
    cin >> N;
    
    while(dig_find < N){
        dig_find = (dig_find + 1) *26;
        dig++;
    }
    N -= (dig_find/26 - 1);
    for(int i = 0 ; i < 20 ; i++){
        lt_num[i] = 0;
    }
    for(int i = 1 ; i <= dig ; i++){
        ll num = (N-1) / pow(26,dig-(i));
        string x = "a";
        x[0] += num;
        cout << x;
        N -= num*pow(26,dig-i);
    }
  	cout << endl;
    return 0;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
ll ans,n,x;
void work(ll a,ll b){	
	if(!a){ans+=-b;return;}
	ans+=2ll*(b/a)*a;
	work(b%a,a);
}
int main(){
	scanf("%lld%lld",&n,&x);
	ans+=n;
	work(min(n-x,x),max(n-x,x));	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
i_nums = []
x = True
while x == True:
    i_nums.append(list(map(int, input().split())))
    if i_nums[-1][0] == i_nums[-1][1] == 0:
        x = False
i_nums.pop()

for nums in i_nums:
    for i in range(nums[0]):
        for j in range(nums[1]):
            print('#', end='')
        print('')
    print('')


Measured memory_bytes: 7016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var a = Console.ReadLine().ToInt();
		
		var q = n - (n / 500) * 500;
		if(q <= a)
		{
			Console.WriteLine("Yes");
			return;
		}
		Console.WriteLine("No");
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;
int P[10], Q[10];
bool Pb[10],Qb[10];

int kaijo(int n)
{
  int ans=1;
  for(int i=1;i<=n;i++)
  {
    ans*=i;
  }
  return ans;
}

int check_p()
{
  int ans=INF;
  FOR(i,1,N+1)
  {
    if(!Pb[i])return i;
  }
  return 0;
}

int check_q()
{
  FOR(i,1,N+1)
  {
    if(!Qb[i])return i;
  }
  return 0;
}

int cp(int m)
{
  int cnt=0;
  FOR(i,1,m)
  {
    if(!Pb[i])cnt++;
  }
  return cnt;
}
int cq(int m)
{
  int cnt=0;
  FOR(i,1,m)
  {
    if(!Qb[i])cnt++;
  }
  return cnt;
}

int main(){
    cin >> N;
    FOR(i,1,N+1)cin >> P[i];
    FOR(i,1,N+1)cin >> Q[i];
    int a=1, b=1;
    int p_min=1,q_min=1;
    FOR(i,1,N)
    {
      int k=kaijo(N-i);
      a += cp(P[i])*k;
      b += cq(Q[i])*k;
      Pb[P[i]]=true;
      Qb[Q[i]]=true;
      if(P[i]==p_min)p_min=check_p();
      if(Q[i]==q_min)q_min=check_q();
    }
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	
	int n; cin >> n;
	const int p = 26;
	vector<vector<int>> num(n, vector<int>(p, 0));
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < s.size(); j++) {
			num[i][s[j] - 'a']++;
		}
	}
	vector<int> ans(p, 1000);
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < n; j++) {
			ans[i] = min(ans[i], num[j][i]);
		}
	}
	string res = "";
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < ans[i]; j++) {
			string tmp{ (char)(i + 'a') };
			res += tmp;
		}		
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define M 32769

int main(void){

  int i,j;
  int n;
  char *a;
  int count;

  a = (char *)malloc(sizeof(char)*M);

  for(i=2;i<M;i++)a[i] = 1;
  a[0]=0;
  a[1]=0;

  i=2;
  while(i<M){
    for(j=2*i;j<M;j+=i)a[j] = 0;
    while(!a[++i]);
  }

  while(1){
    scanf("%d",&n);
    if(n==0)break;
    count = 0;

    for(i=1;i<=n/2;i++)if(a[i] && a[n-i])count++;

    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	int n;
	cin>>n;
	if(n%1000==0)
        cout<<0;
    else
	cout<<1000-n%1000;
	}
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <time.h>
#include <set>


int main() {
    int N;
    std::cin >>N;
    std::vector<double> vals;
    int n = 0;
    vals.reserve(N);
    while( n++<N) {
        double d;
        std::cin>>d;
        vals.push_back(d);
    }
    std::sort(vals.begin(),vals.end());
    double ans =0.0;
    auto it = vals.begin();
    ans = *it;
    ++it;
    ans = (ans + *it)/2.0;
    ++it;
    for(;it != vals.end();++it) {
        ans = (ans +*it)/2.0;
    }
    
    std::cout << ans <<std::endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s;
  cin >> s;
  ll n=s.size();
  ll a=0;
  for(ll i=0;i<n;i++){
    a+=s[i]-'0';
    a%=9;
  }
  
  if(a%9==0)cout << "Yes" << endl;
  else cout << "No" << endl;


}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <cmath>

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<pair<int,int>>

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

set<int> s;

bool check (int n) {
    s.clear();
    int limit = sqrt(n) + 1;
    for (int i = 1; i < limit; i++) {
        if (n%i == 0) {
            s.insert(i);
            s.insert(n/i);
        }
    }
    return s.size() == 8;
}

int main (void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int ans[201];
    memset(ans, 0, sizeof(ans));
    for (int i = 103; i <= 200; i++) {
        if (i%2 && check(i)) ans[i] = ans[i-1] + 1;
        else ans[i] = ans[i-1];
    }

    int x;
    cin >> x;
    cout << ans[x] << endl;

    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c,n;
	cin>>a>>b>>c>>n;
	int out=0;
	rep(i,a+1)rep(j,b+1)rep(k,c+1){
		if(i*500+j*100+k*50==n)out++;
	}
	cout<<out<<endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,long double> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int h,w,a,b;
const int MOD=1e9+7;
ll fact[200010],rfact[200010];

ll calc(int r,int n) {
	//cout<<"r,n "<<r<<' '<<n<<endl;
	if(r<0||n<0||r>n) return 0;
	return fact[n]*rfact[r]%MOD*rfact[n-r]%MOD;
}

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	fact[0]=rfact[0]=1;
	FOR(i,1,200010) fact[i]=fact[i-1]*(ll)i%MOD,rfact[i]=mypow(fact[i],MOD-2,MOD);

	cin>>h>>w>>a>>b;
	ll ans=0;
	FOR(i,b+1,w+1) {
		ans+=calc(i-1,(i-1)+(h-a-1))*calc(w-i,(w-i)+(a-1))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;

	//REP(i,h+w+1) cout<<fact[i]<<' '<<rfact[i]<<endl;

	return 0;
}


Measured memory_bytes: 3456
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		MyStack stack = new MyStack();

		while(in.hasNext()) {
			stack.push(in.next());
		}

		System.out.println(stack.peek());
	}

	static class MyStack{
		long[] arr;
		int tail;

		MyStack() {
			arr = new long[100];
			tail = -1;
		}

		void push(String str) {

			try {
				long v = Long.parseLong(str);
				//System.out.println("insert" + v);
                arr[++tail] = v;
                //System.out.println("tail" + tail);
			}catch(Exception e) {
                //System.out.println("calc operetion requested");
				char op = str.charAt(0);

				switch(op) {
					case '+': 
						long eq1 = arr[tail - 1] + arr[tail];
                        arr[tail - 1] = eq1;
                        tail--;
						break;

					case '-':
						long eq2 = arr[tail - 1] - arr[tail];
						arr[--tail] = eq2;
						break;

					case '*':
						long eq3 = arr[tail - 1] * arr[tail];
						arr[--tail] = eq3;
						break;
				}
			}
		}

		long peek() {
			return arr[tail];
		}
	}

}



Measured memory_bytes: 26152
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


void hurui(int n, vector<bool> &nums, vector<ll> &fc){
    nums.resize(n+1, true);
    fc.resize(n+1, 1);
    nums[1] = false;
    IFOR(i, 2, n){
        if(!nums[i]) continue;
        fc[i] = 2;
        for(int j=2;i*j<=n;j++){
            nums[i*j] = false;
            int tmp = i*j;
            int cnt = 0;
            while(tmp % i == 0){
                tmp /= i;
                cnt++;
            }
            fc[i*j] *= (cnt + 1);
        }
    }
}
int main() {
    int k;
    cin >> k;

    vector<bool> nums;
    vector<ll> fc;
    hurui(k, nums, fc);
    ll ans = 0;
    for(ll i = 1; i<=k;i++){
        ll fk = 1;
        ans += i * fc[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 82272
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	set<int> I;
	vector<int> ord(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> ord[i];
		if(i & 1)
			I.insert(ord[i]);
	}

	sort(ord.begin(), ord.end());
	for(int i = 1; i < n; i += 2)
		I.erase(ord[i]);

	cout << I.size() << endl;

	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;

    bool even=true;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]%2!=0){
            even=false;
        }
    }

    int count=0;

    while(even==true){
        for(int i=0; i<n; i++){
            a[i]/=2;
            if(a[i]%2!=0){
                even=false;
            }
        }
        count++;
    }

    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,k;
    cin >> k >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<int> d(n);
    d[0] = a[0] + k - a[n - 1];
    for(int i = 1;i < n;i++){
        d[i] = a[i] - a[i - 1];
    }
    int ans = k;
    for(int i = 0;i < n;i++){
        ans = min(ans,k - d[i]);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = pow(10,9) + 7;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

int main(){

    int N;
    cin >> N;

    vector<int> dp(N+1, N);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int pow6 = 1; i + pow6 <= N; pow6 *= 6){
            chmin(dp[i+pow6], dp[i] + 1);
        }
        for(int pow9 = 1; i + pow9 <= N; pow9 *= 9){
            chmin(dp[i+pow9], dp[i] + 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 640
N, M, C = gets.split(' ')
B = gets.split(' ')
count = 0
N.to_i.times do
    tmp = gets.split(' ')
    i = 0
    sum = 0
    M.to_i.times do
        sum = sum + tmp[i].to_i*B[i].to_i
        i = i + 1
    end
    if sum + C.to_i > 0 then
        count = count + 1
    end
end

print count

Measured memory_bytes: 1788
sx, sy, tx, ty = map(int, input().split())

tx_sx = tx - sx
ty_sy = ty - sy


ans = ""
for i in range(ty_sy):
    ans += "U"

for i in range(tx_sx):
    ans += "R"


for i in range(ty_sy):
    ans += "D"

for i in range(tx_sx):
    ans += "L"

ans += "L"

for i in range(ty_sy + 1):
    ans += "U"

for i in range(tx_sx + 1):
    ans += "R"
ans += "DR"

for i in range(ty_sy + 1):
    ans += "D"

for i in range(tx_sx + 1):
    ans += "L"

ans += "U"
print(ans)


Measured memory_bytes: 9040
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> a(n);
	FOR(i, 0, n) {
		cin >> a[i];
	}

	set<int> nums;
	int cnt = 0;
	int maxx = 0;
	int maxnum = 0;

	nums.insert(a[n - 1]);
	maxnum = a[n - 1];
	RFOR(i, n - 2, 0) {
		int t = a[i];
		if (maxx < maxnum - t) {
			maxx = maxnum - t;
			cnt = 0;
		}
		bool exist = nums.find(maxx + t) != nums.end();
		if (exist)
			cnt++;
		nums.insert(t);
		maxnum = max(maxnum, t);
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<int> cnt(200020,-1);
    ll dp[200020];
    dp[0] = 1;
    for(int i = 0;i < N;i++) {
        dp[i + 1] = dp[i];
        if(cnt.at(vec.at(i)) >= 0 && cnt.at(vec.at(i)) < i - 1) {
            dp[i + 1] = (dp[i + 1] + dp[cnt.at(vec.at(i)) + 1]) % MOD;
        }
        cnt.at(vec.at(i)) = i;
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 3328
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

def fav(d,c):
  return( s[d] - sum( c*(d-last) ) + c*(d-last) )
#
c2 = c*2
v = 0
for d in range(D):
  av = fav( d, c )
  av2 = fav( d, c2 )
  av2 += av
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      last[t] = d
      v += av[t]
      print(t+1)
      break
#


Measured memory_bytes: 26640
n = int(input())
a = list(map(int, input().split()))
a.sort()

if a[0] == 0:
    print(0)
    exit(0)

lim = 10 ** 18
ans = 1

for x in a:
    ans *= x
    if ans > lim:
        print(-1)
        exit(0)

print(ans)


Measured memory_bytes: 21652
#include<bits/stdc++.h>
using namespace std;

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

string ans;

void toLetter(ll n){
  while(n>0){
    n--;
    ans+=(n%26)+'a';
    n /= 26;
  }
}

int main(){___
  ll n; cin >> n;
  toLetter(n);
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int button[N];
    for(int i=0; i<N; i++){
        cin >> button[i];
    }
    int num=1;
    int ans=0;
    while(num!=2){
        ans++;
        int tmp=num;
        num=button[num-1];
        button[tmp-1]=0;
        if(num==0){
            ans=-1;
            break;
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm;

void main() {
    enum cs = "MARCH";
    size_t[char] d;
    foreach (c; cs) {
        d[c] = 0;
    }
    foreach (s; stdin.byLine) {
        if (s[0] in d) {
            ++d[s[0]];
        }
    }
    size_t ret = 0;
    foreach (i, c0; cs[0..$-2]) {
        if (d[c0] == 0) continue;
        foreach (j, c1; cs[i+1..$-1]) {
            if (d[c1] == 0) continue;
            foreach (k, c2; cs[i+1+j+1..$]) {
                if (d[c2] == 0) continue;
                ret += d[c0] * d[c1] * d[c2];
            }
        }
    }
    writeln(ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 62;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

vector<llong> divisor(llong n) {
    vector<llong> ret;
    for(llong i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong n;
    cin >> n;

    vector<llong> res = divisor(n);

    llong ans = INF;
    for (int i = 0; i < (int)res.size(); ++i) {
      ans = min(ans, abs(res[i] - 1) + abs(n / res[i] - 1));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{	
	int N, K;
	cin >> N >> K;

	set<int> D;
	rep(i, K)
	{
		int tmp;
		cin >> tmp;
		D.insert(tmp);
	}


	string s = to_string(N);
	reverse(all(s));

	string t = "";

	//使用できる数字の最小値
	int c = 0;
	rep(i, 10)
	{
		if (D.count(i) == 0)
		{
			c = i;
			break;
		}
	}

	bool flg = false;

	rep(i, s.size())
	{
		int d = s[i] - '0';

		//繰り上がり
		if (flg) d++;

		flg = false;

		int j;
		for(j=d;j<=9;j++)
		{
			//使える数字を使う
			if (D.count(j) == 0) break;
		}
		
		if(j > d)
		{
			if (j == 10)
			{
				//繰り上がり
				j = c;
				flg = true;
			}

			//下位の桁を使用可能な最小の数字で埋める。
			t = string(t.size(), '0' + c);
			t += to_string(j);
		}
		else
		{
			t += to_string(j);
		}
	}

	if (flg) t += to_string(c==0? 1:c);
	reverse(all(t));

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;


bool primeCheck(lli n)
{
	for(lli i = 2; i*i <= n; i++)
	{
		if(n%i == 0) 
			return false;
	}
	return true;
}

int main() 
{
	char ch;
	cin >> ch;
	if(ch>='A' && ch<='Z')
		cout << 'A';
	else
		cout << 'a';
	return 0;
}
   








Measured memory_bytes: 3616
import sys

def main():
    n, w = map(int, input().split())
    a = [list(map(int, x.split())) for x in sys.stdin.readlines()]
    dp = [[0]*(w+1) for _ in range(n+1)]

    for i in range(n):
        for j in range(w+1):
            if j - a[i][0] >= 0:
                dp[i+1][j] = max(dp[i+1][j] , dp[i][j - a[i][0]] + a[i][1])

            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    print(dp[n][w])

if __name__ == '__main__':
    main()

Measured memory_bytes: 146736
i,x,n,m,a;int main(){int j[104];for(;scanf("%d",&a)&&a;x=0,n=0,m=0){for(i=0;i<101;i++)j[i]=0;j[i++]=-1;j[i]=1001;for(i=0;a-i&&scanf("%d",&j[i]);i++){if(j[101]<j[i])j[101]=j[i];if(j[102]>j[i])j[102]=j[i];m+=j[i];}printf("%d\n",m=(m-(j[101]+j[102]))/(a-2));}exit(0);}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    ll A,B,C,K;
    scanf("%lld%lld%lld%lld",&A,&B,&C,&K);
    if(A==B && B==C){
        printf("0");
        return 0;
    }
    rep(i,K){
        ll temp1=0,temp2=0;
        temp1=A+B;
        temp2=A+C;
        A=B+C;
        B=temp2;
        C=temp1;
    }
    if(A-B>1000000000000000000||A-B<-1000000000000000000){
        printf("Unfair");
        return 0;
    }else{
        printf("%lld",A-B);
    }
    
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N=1e6+9;

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int vis[N]={0},f[N]={0};
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        f[a[i]]++;
        if(vis[a[i]])continue;
        vis[a[i]]=1;
        for(int j=2*a[i];j<N;j+=a[i])
            vis[j]=2;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(vis[a[i]]==1 and f[a[i]]==1)ans++;
    }
    cout << ans;
}

Measured memory_bytes: 20828
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;

map<string, int> T;

int calc(string s)
{
	if (T.count(s)) {
		return T[s];
	} else if (s == "") {
		return T[s] = 1;
	}

	int res = calc(s.substr(1));

	if (s[0] == '1') {
		res = res * 2 % MOD;
	}

	for (int l = 1; l * 2 <= s.size(); ++l) {
		string t;
		rep(i, l) t.pb('1');

		for (int i = 0, n = 1; n * l <= s.size(); ++n, i += l) {
			rep(j, l) {
				t[j] = min(t[j], s[i + j]);
			}

			if (n >= 2) res = (res + (ll)calc(t) * calc(s.substr(i + l))) % MOD;
		}
	}
	return T[s] = res;
}


int main() {
	string s;
	cin >> s;
	cout << calc(s) << endl;
	return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;
public class Main {

	static Scanner scan = new Scanner(System.in);
	/**
	 * 大小関係を判定するプログラム
	 * @param args　入力a,b
	 */
	public static void main(String[] args){
		int a,b;
//		a = Integer.parseInt(args[0]);
//		b = Integer.parseInt(args[1]);
		a = scan.nextInt();
		b = scan.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}

}



Measured memory_bytes: 26204
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if((abs(b-a) <= d && abs(c - b) <= d) || abs(c - a) <= d){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 256
/*
[abc166] A - A?C
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

string s;

string solve() { return s == "ABC" ? "ARC" : "ABC"; }

int main() {
    cin >> s;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3596
import sys

dominoes = [
    """
    aa.
    ..a
    ..a
    """,
    """
    aabc
    ddbc
    bcaa
    bcdd
    """,
    """
    aabba
    bcc.a
    b..cb
    a..cb
    abbaa
    """,
    """
    aabc..
    ddbc..
    ..aabc
    ..ddbc
    bc..aa
    bc..dd
    """,
    """
    aabbcc.
    dd.dd.a
    ..d..da
    ..d..db
    dd.dd.b
    ..d..dc
    ..d..dc
    """
]


dominoes = [domino.replace(' ', '').strip('\n') for domino in dominoes]

n = int(input())

if n == 2:
    print(-1)
    exit(0)

if n == 3:
    print(dominoes[0])
    exit(0)

dominoes = [dom.split('\n') for dom in dominoes[1:]]


def write(ix, col):
    for j in range(ix + 4):
        for i in range(col):
            sys.stdout.write('.')
        sys.stdout.write(dominoes[ix][j])
        for i in range(n - col - (ix + 4)):
            sys.stdout.write('.')
        sys.stdout.write('\n')


col = 0
write(n % 4, col)
col += 4 + n % 4
rem = n - col

while rem > 0:
    write(0, col)
    col += 4
    rem -= 4


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
using namespace  std;

void fnTrace(vector<int> argviSort)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &argviSort)
{
  for (int ixSorting = 1; ixSorting < argviSort.size(); ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - 1;
    while (iTarget  < argviSort[ixSorted] &&
           ixSorted >= 0                    )
    {
      argviSort[ixSorted + 1] = argviSort[ixSorted];
      ixSorted--;
    }
    argviSort[ixSorted + 1] = iTarget;
    fnTrace(argviSort);
  }
}

int main()
{
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnTrace(viSort);
  fnInsertionSort(viSort);

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pli pair<long long,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

bool sot(pli a,pli b)
{
	return a.fi>b.fi;
}

int main()
{
	LL n,m;
	LL mx1=-1;
	cin>>n>>m;
	vector <LL> x(n),y(n),z(n);
	vector <pli> mx2(n);
	rep(i,n) cin>>x[i]>>y[i]>>z[i];
	for(LL j=-1;j<=1;j+=2)
		for(LL k=-1;k<=1;k+=2)
			for(LL p=-1;p<=1;p+=2)
			{
				rep(i,n)
				{
					LL tmp=x[i]*j+y[i]*k+z[i]*p;
					mx2[i].fi=tmp;
					mx2[i].se=i;
				}
				sort(mx2.begin(),mx2.end(),sot);
				vector <LL> pla(m);
				rep(d,m) pla[d]=mx2[d].se;
				LL sum1=0,sum2=0,sum3=0;
				rep(i,m)
				{
					sum1+=x[pla[i]];
					sum2+=y[pla[i]];
					sum3+=z[pla[i]];
				}
				mx1=max(mx1,abs(sum1)+abs(sum2)+abs(sum3));
			}
	cout<<mx1<<endl;
  rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <vector>
typedef long long ll;
//vector <ll > v[100];
//ll b1[10005][1];

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a<b) cout<<a*n<<endl;
    else cout<<b<<endl;

    return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll counter = 0;
	char l,before;
	string S;
	cin >> S;
	ll N = S.size();
	vector<ll> v;
	for (ll i= 0;i< N;i++){
		if (i == 0){
			before = S[i];
		}
		if (S[i] == before){
			counter++;
		}
		else{
			v.pb(counter);
			before = S[i];
			counter = 1;
			// cout << i << ' ' << counter << endl;
		}
	}
	v.pb(counter);
	int flag = 0;
	ll ans = 0;
	if (S[0] == '>'){
		flag = 1;
	}
	for(ll i = 0;i < v.size();i++){
		if (flag == 1 && i == 0){
			ans += (v[i] - 1)*(v[i])/2;
			ans += v[i];
			flag = 0;
		}
		else if(flag == 0 && v.size() == 1){
			ans += (v[i] + 1)*(v[i])/2;
		}
		else if (flag == 1){
			ans += (v[i] - 1)*(v[i])/2;
			flag = 0;
		}
		else{
			ans += (v[i] - 1)*(v[i])/2;
			if (i < v.size() - 1){
				ans += max(v[i],v[i+1]);
			}
			else{
				ans += v[i];
			}
			flag = 1;
		}
		// cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3068
o = input()
e = input()

if len(o) == len(e):
    for i in range(len(o)):
        print(o[i],end='')
        print(e[i],end='')
else:
    for i in range(len(o)-1):
        print(o[i],end='')
        print(e[i],end='')
    print(o[len(o)-1],end='')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s1,s2;
  cin>>s1;
  s2=s1;
  reverse(all(s1));
  rep(i,s1.size())
    if(s1[i]=='b')s1[i]='d';
    else if(s1[i]=='d')s1[i]='b';
    else if(s1[i]=='p')s1[i]='q';
    else if(s1[i]=='q')s1[i]='p';
  if(s1==s2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<vector<double>> dp(n + 1, vector<double>(n + 1));
  vector<double> p(n);
  for(int i = 0; i < n; i++) scanf("%lf", &p[i]);
  dp[0][0] = 1;
  for(int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);
    for(int j = 1; j <= i; j++)
      dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
  }
  double o = 0;
  for(int i = n / 2 + 1; i <= n; i++) o += dp[n][i];
  printf("%.10lf\n", o);
}

Measured memory_bytes: 70656
n=int(input())
L=sorted(list(map(int,input().split())))
a=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if L[i]+L[j]>L[k] and len(set([L[i],L[j],L[k]]))==3:
        a+=1
      elif L[i]+L[j]<=L[k]:
        break
print(a)

Measured memory_bytes: 9188