akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc167/tasks/abc167_d

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define int long long
#define all(x) (x).begin(), (x).end()

const int maxn = 200500;

// seen when we had x left
int A[maxn], seen[maxn];

void timeOut() {
    while(1) {

    }
}

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

    for(int i = 0; i < maxn; i++) {
        seen[i] = -1;
    }

    int N, K;
    cin >> N >> K;

    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    bool modded = false;
    int cur = 1;
    
    while(K > 0) {
        seen[cur] = K;
        int next = A[cur];

        if(seen[next] != -1 and !modded) {
            int cycleLen = seen[next]-seen[cur]+1;
            K %= cycleLen;
            modded = true;
            continue;
        }

        cur = next;
        K--;
    }
    
    cout << cur << endl;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<vector<int>,vector<char> > P;

string str;
map<P, vector<int> > m;

int calc(int a, int b, char c){
	if(c == '+') return a+b;
	if(c == '*') return a*b;
	if(c == '-') return a-b;
	if(b == 0){
		return MOD;
	} else{
		return a/b;
	}
}

vector<int> fu(vector<int> v, vector<char> c){
	if(m[P(v,c)].size() > 0) return m[P(v,c)];
	vector<int> ret;
	if(c.size() == 0){
		ret.push_back(v[0]);
		m[P(v,c)] = ret;
		return ret;
	}
	vector<int> V;
	vector<char> C;
	rep(i,c.size()){
		V.clear();
		C.clear();
		bool ok = true;
		rep(j,v.size()){
			if(i != j){
				V.push_back(v[j]);
				if(j != v.size()-1) C.push_back(c[j]);
			} else{
				int tmp = calc(v[j],v[j+1],c[j]);
				if(tmp == MOD){
					ok = false;
					break;
				}
				V.push_back(tmp);
				if(j+1 != v.size()-1) C.push_back(c[j+1]);
				j++;
			}
		}
		if(!ok) continue;
		V = fu(V,C);
		rep(j,V.size()) ret.push_back(V[j]);
	}
	m[P(v,c)] = ret;
	return ret;
}

vector<int> fun(vector<vector<int> > v, vector<char> c, vector<int> z, int cnt){
	vector<int> x;
	if(v[cnt].size() == 0){
		return fu(z,c);
	}
	vector<int> tmp;
	rep(i,v[cnt].size()){
		z.push_back(v[cnt][i]);
		tmp.clear();
		tmp = fun(v,c,z,cnt+1);
		rep(j,tmp.size()) x.push_back(tmp[j]);
		z.pop_back();
	}
	return x;
}

vector<int> func(string s){
	int cont = 0;
	vector<vector<int> > v;
	v.resize(12);
	vector<char> c;
	rep(i,s.size()){
		if(s[i] == '('){
			int cnt = 0;
			string tmp;
			while(true){
				i++;
				if(s[i] == '(') cnt++;
				if(s[i] == ')' && cnt == 0) break;
				if(s[i] == ')') cnt--;
				tmp.push_back(s[i]);
			}
			v[cont] = func(tmp);
		} else if('0' <= s[i] && s[i] <= '9'){
			int num = s[i]-'0';
			while(true){
				if(i == s.size()-1) break;
				if('0'<=s[i+1]&&s[i+1]<='9'){
					i++;
					num *= 10;
					num += s[i]-'0';
				} else break;
			}
			v[cont].push_back(num);
		} else{
			c.push_back(s[i]);
			cont++;
		}
	}
	vector<int> z;
	return fun(v, c, z, 0);
}

void solve(){
	m.clear();
	vector<int> v = func(str);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout << v.size() << endl;
}

int main(){
	while(true){
		cin >> str;
		if(str == "#") break;
		solve();
	}
}

Measured memory_bytes: 16728
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    h,w=map(int, input().split())
    l=[]
    for i in range(h):
        ll=list(input())
        l.append(ll)
    # 行と列のチェックリストを作る。gyou[0]は0行目を示す
    gyou= [False] * w
    retu= [False] * h
    for jretu in range(h):
        for kgyou in range(w):
            # 同じ行or列に１個でも'#'があればその時点でその行or列は消えない
            # '#'があった列と行をTrueにしていく
            if l[jretu][kgyou]=='#':
                retu[jretu]=True
                gyou[kgyou]=True
    for jretu in range(h):
        if retu[jretu]:
            for kgyou in range(w):
                if gyou[kgyou]:
                    print(l[jretu][kgyou],end='')
            print('')
resolve()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

bool sq(int x){
    bool b = false;
    rep(i,x){
        if(i*i==x) b=true;
    }
    return b;
}

void solve(){
    int a,b;
    cin >> a >> b;
    int connect;
    if(b<10) connect = 10*a+b;
    else if(b<100) connect = 100*a+b;
    else connect = 1000*a+b;

    if(sq(connect)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define MAXN 30
#define MAXNN 900

using namespace std;

int solve(int a[MAXNN][MAXNN],int w,int h,int min[MAXNN]){
	int result=0;
	int sel;
	bool flg[MAXNN];

	for(int i=0;i<MAXNN;i++) flg[i]=false;
	
	queue<int> q;
	q.push(0);
	flg[0]=1;
	int dis=0;
	min[0]=dis;

	while(!q.empty()){
		sel=q.front();
		q.pop();
		for(int i=0;i<MAXNN;i++){
			if(flg[i]==0 && a[sel][i]==1){
				q.push(i);
				flg[i]=1;
				min[i]=min[sel]+1;
			}
		}
	}

	return min[(h-1)*MAXN+(w-1)]+1;
}

int main(void){
	int w,h,d;

	int a[MAXNN][MAXNN];
	int adX[2]={1,0};
	int adY[2]={0,1};
	int min[MAXNN];

	while(1){
		for(int i=0;i<MAXNN;i++){
			for(int j=0;j<MAXNN;j++)a[i][j]=0;
			min[i]=-1;
		}
		cin >> w;
		if(w==0) return 0;
		cin >> h;

		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if((x+1)<w){
					a[y*MAXN+x][y*MAXN+x+1]=1;
					a[y*MAXN+x+1][y*MAXN+x]=1;
				}
				if((y+1)<h){
					a[y*MAXN+x][(y+1)*MAXN+x]=1;
					a[(y+1)*MAXN+x][y*MAXN+x]=1;
				}
			}
		}

		for(int y=0;y<2*h-1;y++){
			for(int x=0;x<w;x++){
				if(y%2==0){
					if(x==w-1) break;
					cin >> d;
					if(d==1){
						a[(y/2)*MAXN+x][(y/2)*MAXN+x+1]=0;
						a[(y/2)*MAXN+x+1][(y/2)*MAXN+x]=0;
					}
				}
				else{
					cin >> d;
					if(d==1){
						a[(y/2)*MAXN+x][((y/2)+1)*MAXN+x]=0;
						a[((y/2)+1)*MAXN+x][(y/2)*MAXN+x]=0;
					}
				}
			}
		}

		cout << solve(a,w,h,min) << endl;;
	}

	return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  ll n, k;
  cin >> n >> k;
  if (n <= k)
  {
    cout << min(abs(n-k),n) << "\n";
  }
  else
  {
    cout << min(n%k,abs(n%k-k)) << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[2005];
P p[2005];
llint dp[2005][2005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		p[i] = P(a[i], i);
	}
	sort(p+1, p+n+1);
	reverse(p+1, p+n+1);
	
	for(int i = 0; i <= n; i++){
		for(int l = 0; l <= n; l++){
			dp[i][l] = -inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int l = 0; l <= n; l++){
			llint r = i - l;
			r = (n+1) - r;
			if(l+1 <= n) chmax(dp[i+1][l+1], dp[i][l] + abs((l+1)-p[i+1].second) * p[i+1].first);
			chmax(dp[i+1][l], dp[i][l] + abs((r-1)-p[i+1].second) * p[i+1].first);
		}
	}
	llint ans = -inf;
	for(int i = 0; i <= n; i++) ans = max(ans, dp[n][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 35012
import io

nim, mike, kite = map(int, input().split(' '))
tim = list(map(int, input().split(' ')))
data = 0
for _ in range(nim):
    a = list(map(int, input().split(' ')))
    if sum([x * y for x, y in zip(a, tim)]) + kite > 0:
        data += 1
print(data)

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

using int64 = long long;

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

void solve(long long N, std::vector<long long> A){
    unordered_map<i64, i64> mp;
    rep(i, N) mp[A[i]]++;
    i64 ans = 0;
    rep(i, N){
        if(mp[A[i]] >= 2) continue;
        auto d = divisor(A[i]);
        bool flag = true;
        rep(j, d.size()){
            if(mp[d[j]] >= 1 && d[j] != A[i]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 33308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B){
  vector<ll> dp(H+1+10000,1000000000000LL);
  dp[0]=0;
  set<ll> q;
  q.insert(0);
  while(!q.empty()){
    auto tmp=*q.begin();q.erase(tmp);
    REP(N){
      dp[tmp+A[i]]=min(dp[tmp+A[i]],dp[tmp]+B[i]);
      if(tmp+A[i]<H)q.insert(tmp+A[i]);
    }
  }
  ll ans=1000000000000LL;
  FOR(i,H,dp.size()){
    ans=min(ans,dp[i]);
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 512
s = input()

ans_i = 0
ans_j = 0

for s_i in s:
    if s_i == 'C':
        ans_i = 1

    if ans_i == 1 and s_i == 'F':
        ans_j = 1

if ans_i and ans_j:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#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;
typedef ll 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<double,int,double> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,MOD=1000000007;
	cin>>n;
	vi in;
	while(n--){
		char c;cin>>c;
		if(c=='U')in.pb(0);
		if(c=='D')in.pb(1);
	}
	n=in.size();
	vvi dp(n+1,vi(n+1));
	dp[0][0]=1;
	rep(i,n)rep(j,n)if(dp[i][j]){
		if(in[i]){
			(dp[i+1][j]+=dp[i][j]*j)%=MOD;
			if(j)(dp[i+1][j-1]+=dp[i][j]*j*j)%=MOD;
		}else{
			(dp[i+1][j+1]+=dp[i][j])%=MOD;
			(dp[i+1][j]+=dp[i][j]*j)%=MOD;
		}
	}
	cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 3240
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int f = (int)(s[0]-'7')*(int)(s[1]-'7')*(int)(s[2]-'7');
  if (!f) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi 3.1415926535897
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define sz(v) ((int)(v).size())
#define mod 1000000007
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define RREPA(i,a,n) for(ll i=a;i>=(n);i--)
#define REPA(i,a,n) for(ll i=a;i<=(n);i++)
using namespace std;
 
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
//////
// prime Seive
/*
bitset<1000005> bt;
//unordered_map<ll,bool> is_prime;
vector<ll> primes;
void pS(ll n){
    ll val = min(n+1,(ll)1000006);
    for(ll i=3;i<=val;i+=2){
        bt[i] =true;
    }
    bt[0] =false;
    bt[1] =false;
    bt[2] =false;
    //is_prime[2] =true;
    primes.pb((ll)2);
    for(ll i=3;i<=val;i+=2){
        if(bt[i])
            for(ll j=i*i;j<=val;j+=2*i)
                bt[j] =false;
    }
    for(ll i=3;i<=val;i+=2){
        if(bt[i]){primes.pb(i);
        //is_prime[i]=true;
        //cout<<i<<" :PRIME\n";
        }
    }
    return;
}
   */          
/////
// Fenwick Tree
/*
BIT[200005] ={0};
//BUILD BIT
// for(int i=1;i<1;i++){ cin>>a[i];update(i,a[i],n);};
 
void update(int i,int val,int n){
    while(i<=n){
    BIT[i]+= inc;
    i+= (i&(-i));
    }
}
ll query(int i){
    ll ans =0;
    while(i>0){
        ans+= BIT[i];
        i-=(i&(-i));
    }
    return ans;
}
 
*/
//__builtin_popcount(4)
ll logPow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans*=a;
        }
        a*=a;
        b= b>>1;
    }
    return ans;
}



int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    */
    int t=1;
    
    //memset(arr,0,sizeof(arr));
    //cin>>t;
    //pS(INT_MAX);
    while(t--){
      ll a,b; cin>>a>>b;
      cout<<a*b<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[4];
int32_t main(){
CODE_START;
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if(a[0]==a[1]&&a[0]==5&&a[2]==7){
    rc("YES");
}else rc("NO");
return 0;}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 105;
int n, k;
char tmp[maxn];
string s;

bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  scanf("%d", &k);
  return true;
}

void solve() {
  long long res = 0;
  for (int j = 0; j < n;) {
    int i = j;
    while (j < n && s[i] == s[j]) {
      j++;
    }
    if (j < n || s[i] != s[0]) {
      res += (long long) ((j - i) / 2) * k;
    } else if (i == 0) {
      res += ((long long) (j - i) * k) / 2;
    } else {
      int l = 0;
      while (l < n && s[0] == s[l]) {
        l++;
      }
      res += (long long) ((j - i + l) / 2) * (k - 1);
      res += (long long) ((j - i) / 2);
      res -= (long long) (l / 2) * (k - 1);
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

const ll ha=998244353;
ll C[505][505],f[505][505],n,m,r;

ll P(ll a,ll b){r=1;while(b){if(b&1)r=(r*a)%ha;a=(a*a)%ha;b>>=1;}return r;}

int main(){

	int A[205],n;

	cin>>n;

	for(int i=1;i<=n*2;++i)cin>>A[i];

	std::sort(A+1,A+n*2+1);

	int ans=0;

	for(int i=1;i<=n*2;i+=2)ans+=A[i];

	cout<<ans;
	return 0;

}


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

using namespace std;

int main(){
	int n; cin >> n;
	for(int i = 1;i < 10;i++){
		for(int j = 1;j < 10;j++){
			if(i * j == n){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long A = sc.nextLong();
	long B = sc.nextLong();
        
	for(int i=1;i<=B;i++){
	    if((i*A)%B==0){
		System.out.print(i*A);
		break;
	    }
	}
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for(int i =1 ;i<=9;i++){
    for(int k=i;k<=9;k++){
	 if(i*k == N){
       cout << "Yes" << endl;
       return 0;
     }
    }
}
 cout << "No" << endl;
}

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

int main() {
  vector<int> A(3);
  int K;
  cin >> A.at(0) >> A.at(1) >> A.at(2) >> K;
  sort(A.begin(), A.end());
  
  for( int i = 0; i < K; i++ ){
    A.at(2) *= 2;
  }
  cout << A.at(0) + A.at(1) + A.at(2) << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    while(true)
    {
        int h,w;
        std::cin >> h >> w;
        
        if(h==0 && w==0)    break;
        
        for(int i=0;i<w;i++)    std::cout << "#";
        std::cout << std::endl;
        
        for(int i=0;i<h-2;i++)
        {
            std::cout << "#";
            for(int i=0;i<w-2;i++)  std::cout << ".";
            std::cout << "#" << std::endl;
        }
        
        for(int i=0;i<w;i++)    std::cout << "#";
        std::cout << std::endl << std::endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MAX_N = 100000;

// vector<int> dp(100000, 1e9);

int main()
{
    ll A[3][3];
    ll B[3][3];
    ll flg[4][4];
    ll b[10];
    ll N;
    bool ans = false;
    // ll digit = 1;
    // ll A[1005];
    rep(i,3){
        rep(j,3){
            flg[i][j] = 0;
            cin >> A[i][j];
        }
    }
    cin >> N;
    rep(k,N){
        cin >> b[k];
        rep(i, 3)        {
            rep(j, 3)            {
                if( A[i][j]==b[k])
                    flg[i][j] = 1;
            }
        }
    }

    rep(i,N){
        if((flg[i][0]+flg[i][1]+flg[i][2])==3)
            ans = true;
        if((flg[1][i]+flg[2][i]+flg[0][i])==3)
            ans = true;
        if ((flg[1][1] + flg[2][2] + flg[0][0]) == 3)
            ans = true;
        if ((flg[2][0] + flg[1][1] + flg[0][2]) == 3)
            ans = true;
    }
    if(ans) printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
 
ll fact[MAX];
ll rfact[MAX];
 
ll comb(ll n, ll k) {
    return fact[n]*rfact[k]%MOD*rfact[n-k]%MOD;
}
 
ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
 
int main(void) {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll i, j;
    fact[0]=rfact[0]=1;
    for(i=1; i<MAX; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    ll ans=0;
    for(j=B; j<W; j++) {
        ans+=comb(H-1-A+j, j)*comb(A+W-j-2, W-1-j)%MOD;
        ans%=MOD;
    }
    prin(ans);
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        vector< pair<int,pair<int,int> > > logs(m);
        for(int i=0; i<m; i++){
            int t,s,d;
            cin >> t >> s >> d;
            logs[i] = make_pair(t, make_pair(s,d));
        }
        sort(logs.begin(), logs.end());

        vector<bool> dead(n+1, false);
        dead[1]=true;
        int cnt=1;
        for(int i=0; i<m; i++){
            int send = logs[i].second.first;
            int dest = logs[i].second.second;
            if(dead[send] && !dead[dest]){
                dead[dest]=true;
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

int N;
ll K;
vector<ll>A,F;

bool time_check(ll T){
    ll needs = 0;
    rep(i,N){
        ll cost = T/F[i];
        needs += max(A[N-1-i]-cost,0ll);
    }
    if(needs <= K) return true;
    else return false; 
}

void solve(ll start,ll end){
    // start : impossible, end : possible
    if(end == start + 1){
        cout<<end<<endl;
        return ;
    }
    ll t = (end+start)/2;
    if(time_check(t)) solve(start,t);
    else solve(t,end);
}

int main(){
    ll a,f;
    cin>>N>>K;
    ll sum = 0;
    rep(i,N){
        cin>>a;
        A.push_back(a);
        sum+=a;
    }
    if(sum<=K){
        cout<<0<<endl;
        return 0;
    }
    rep(i,N) {
        cin>>f;
        F.push_back(f);
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end());
    // rep(i,N) cout<<A[i]<<" ";
    // cout<<endl;
    // rep(i,N) cout<<F[i]<<" ";
    // cout<<endl;
    solve(0ll,(ll)10000000000000);
    return 0;
}

Measured memory_bytes: 4848
import java.util.Arrays;
import java.util.Scanner;
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
import java.io.IOException;

// ALDS1_5_A
// BufferedReaderだとTime limitに引っかかる
public class Main {
	void coutingSort(int[] A, int[] B, int k) {
		int[] C = new int[k];
		Arrays.fill(B, 0);
		for (int i = 0; i < A.length; i++) 
			C[A[i]]++;
		
		for (int i = 1; i < k; i++) 
			C[i] += C[i - 1];
		
		for (int i = A.length - 1; i > -1; i--) {
			B[C[A[i]] - 1] = A[i];
			C[A[i]]--;
		}
	}
	
	void run() throws IOException {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//int n = Integer.parseInt(br.readLine());
		//String[] str = br.readLine().split(" ");
		StringBuilder build = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		int[] B = new int[n];
		int k = 0;
		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
			if (A[i] > k) k = A[i];
		}
		coutingSort(A, B, k+1);
		build.append(B[0]);
		for (int i = 1; i < n; i++) {
			build.append(" " + B[i]);
		}
		System.out.println(build);
		sc.close();
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 565688
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, v[3002];
long long dp[3002][3002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = n; i >= 1; --i)
        for(int j = i+1; j <= n+1; ++j)
            dp[i][j] = max(v[i] - dp[i+1][j], v[j-1] - dp[i][j-1]);
    cout << dp[1][n+1] << '\n';
    return 0;
}


Measured memory_bytes: 70016
#他人のを参考に手直し
import numpy as np
import itertools
import sys
input = sys.stdin.readline  #文字列入力では注意！

N,C = map(int,input().split())
D = np.array([list(map(int,input().split()))for _ in range(C)], dtype=np.int64)
c = np.array([list(map(int,input().split()))for _ in range(N)], dtype=np.int64)
c0 = np.zeros(C,dtype=np.int64)
c1 = np.zeros(C,dtype=np.int64)
c2 = np.zeros(C,dtype=np.int64)
for i in range(N):
    for j in range(N):
        if (i+j)%3 == 0:
            c0[c[i,j]-1] += 1
        if (i+j)%3 == 1:
            c1[c[i,j]-1] += 1
        if (i+j)%3 == 2:
            c2[c[i,j]-1] += 1
# c0~2はXの情報
r = np.arange(C)	#先にnp.sumしておく
s0 = np.sum(D[:,r]*c0[:,None],axis=0)
s1 = np.sum(D[:,r]*c1[:,None],axis=0)
s2 = np.sum(D[:,r]*c2[:,None],axis=0)

lis = itertools.permutations(range(C),3)
ans = float("inf")
for l0,l1,l2 in lis:    # l0~2はYの情報
    tmp = s0[l0]+s1[l1]+s2[l2]
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 17868
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

/*Binary Indexed Tree*/
template<typename Type>
struct BIT{
	int n;
	vector<Type> dat;//i:=[1,n].
	
	BIT(int n_):n(n_),dat(n_+1,0){}
	
	void init(){fill(ALL(dat),0);}
	void add(int i,Type x){//i番目の要素にxを足す.
		if(i<=0 or n<i) return;
		for(;i<=n;i+=(i&-i)) dat[i]+=x;
	}
	Type sum(int i){//[1,i]間の和を求める.
		if(i<=0 or n<i) return 0;
		Type res=0;
		for(;i>0;i-=(i&-i)) res+=dat[i];
		return res;
	}
	Type range_sum(int l,int r){return sum(r)-sum(l-1);}//[l,r]間の和を求める.
};

int main(){
	int n,q;
	cin>>n>>q;
	
	vi c(n+1);
	FOR(i,1,n) cin>>c[i];
	
	vector<vector<pii> > qv(n+1);
	REP(i,q){
		int l,r;
		cin>>l>>r;
		qv[r].emplace_back(l,i);
	}
	
	vi ans(q);
	BIT<int> bit(n);
	vi cp(n+1,-1);
	FOR(i,1,n){
		if(cp[c[i]]!=-1) bit.add(cp[c[i]],-1);
		bit.add(i,1);
		cp[c[i]]=i;
		
		for(auto elem:qv[i]){
			int l,p;
			tie(l,p)=elem;
			ans[p]=bit.range_sum(l,i);
		}
	}
	//line(cp);
	
	for(auto elem:ans) cout<<elem<<endl;
}

Measured memory_bytes: 33244
#include <stdio.h>
int main(){
  char eki[3];
  for(int i=0;i<3;i++){
    scanf("%c",&eki[i]);
  }
  if(eki[0]==eki[1]){
      if(eki[1]==eki[2]){
        printf("No");
      }else{
        printf("Yes");
      }
  }else{
  printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
///...................................*****.................................................///
/// Author : Tanvir Ahmed ///
/// Department of Computer Science ///
/// & Engineering ///
/// Comilla University , Bangladesh. ///
///...................................*****.................................................///

/*....................................Values................................................*/
#define inf 1<<30
#define p5 100007
#define p6 1000007
#define PI acos(-1)

/*....................................Functions.............................................*/
#define sqr(x) x*x
#define sc scanf
#define pf printf
#define scin(x) sc("%d",&(x))
#define scin2(x,y) sc("d",&(x),&(y))
#define scin3(x,y,z) sc("d%d",&(x),&(y),&(z))
#define scln(x) sc("%lld",&(x))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(), v.end()
#define ok cout << "ok" << endl
#define mem(x,y) memset(x,y,sizeof(x))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

/*...................................Data_Types............................................*/
#define lli long long int
#define ull unsigned long long int
#define pii pair < int, int>
#define pll pair < ll, ll>
#define veci vector<int>
#define vecl vector<long long int>
#define vecp vector< pair<int,int> >
#define mapstrint map< string , int >
#define mapstrstr map< string , string >
#define mapint map< int, int >
#define uset unordered_set
#define umap unordered_map
#define pq priority_queue

#define pb push_back
#define mp make_pair
#define ss stringstream

/*.....................................Loops...............................................*/
#define rep( i , a , b ) for( i=a ; i<b ; i++)
#define rev( i , a , b ) for( i=a ; i>=b ; i--)
#define repx( i ,a,b, x) for( i=a ; i<b ; i+=x)

#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)

//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//long power(long int x, long int y){ int temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; }
/*lli gcd(lli x,lli y)
{
if(x==0) return y;
return gcd(y%x,x);
}*/
/*
int dx[5] = {1, -1, 0, 0 };
int dy[5] = {0, 0, 1, -1};
*/

using namespace std;

lli M = 100000000000007;

lli n,k,h[200000],dp[200000];

lli dynamic(int pos)
{
    if(dp[pos]!=10000000000)
        return dp[pos];
    if(pos==0)
        return 0;
    if(pos==1)
        return dp[pos]=abs(h[1]-h[0]);
    int limit=pos-k;
    for(int i=pos-1;i>=0 and i>=limit;i--)
    {
        lli dis=abs(h[i]-h[pos]);
        dp[pos]=min(dp[pos],dis+dynamic(i));
    }
    return dp[pos];
}

int main()
{
    scln(n);
    scln(k);
    for(int i=0;i<n;i++)
    {
        scln(h[i]);
        dp[i]=10000000000;
    }
   // memset(dp,100000000000,sizeof(dp));
    //cout<<dp[4]<<endl;
    lli res=dynamic(n-1);
    cout<<res<<endl;
    //printf("%lld\n",res);
    return 0;
}


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

#define ALL(x) x.begin(), x.end()
#define mfor(i,a,b) for(int i=(a);i<=(b);i++)

void solve() {
    int N, L; cin >> N >> L;
    vector<string> V(N);

    mfor(i, 0, N - 1)
        cin >> V[i];
    sort(ALL(V));

    string ans;
    for (string s : V)
        ans += s;

    cout << ans << '\n';
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	int N;
	cin >> N;
	int num[3] = {-1, -1, -1};
	long long int ans = 1;
	for(int loop = 0; loop < N; loop++){
		int A;
		cin >> A;
		int cnt = 0;
		for(int i = 0; i < 3; i++){
			if(num[i] + 1 == A){
				cnt += 1;
			}
		}
		ans *= cnt;
		ans %= MOD;
		for(int i = 0; i < 3; i++){
			if(num[i] + 1 == A){
				num[i] = A;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	string a,b;
	cin>>a>>b;
	int la=a.length();
	int lb=b.length();
	
	int dp[la+1][lb+1];
	int i,j;
	for(i=0;i<=la;i++)
	{
		for(j=0;j<=lb;j++)
		{
			if(i==0 || j==0)
			dp[i][j]=0;
			else
			if(a[i-1]==b[j-1])
			dp[i][j]=1+dp[i-1][j-1];
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	i=la;j=lb;
	
    int index=dp[la][lb];
    char ch[index+1];
    
    while(i>0 && j>0)
    {
    	if(a[i-1]==b[j-1])
		{
			ch[index]=a[i-1];
			i--;
			j--;
			index--;
		}
		else
		if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	
	for(i=1;i<=dp[la][lb];i++)
	cout<<ch[i];
	

	
}


Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

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



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

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

    for(int i=1; i<=N; ++i){
        if ( i%3 == 0 or i%10 == 3){
            cout << " " << i;
        } else{
            int x = i;
            while (x > 0) {
              if (x % 10 == 3) {
                cout << " " << i;
                break;
              }
              x/=10;
            }
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <array>

using namespace std;

int main(void){
    int N;
    cin >> N;
    int num[4] = {};
    int size = 3;
    while (N) {
        num[size]  = N%10;
        N =N/10;
        size--;
    }
  
  for(int i = 0; i < 8; ++i){
      int ans = num[0];
      string s = "";
    for(int j = 0; j < 3; ++j) {
        
      if (1 & (i >> j)) {
          ans += num[j+1]; 
          s+="+";
      } else {
          ans -= num[j+1]; 
          s+="-";
      }
    }
    if (ans == 7){
        cout << num[0] << s[0] << num[1] << s[1] << num[2] << s[2] << num[3] << "=7"<< endl; 
        return 0;
    }
  }
}


Measured memory_bytes: 256
// AtCoder template
// 最近sabaがかまってくれないからキレて暴れてる
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    double a,b,h,m; cin >> a >> b >> h >> m;
    h = M_PI*(h+m/60.0)/6.0;
    m = m*M_PI/30.0;
    double x = a*a + b*b - 2*a*b*cos(abs(h-m));
    cout << fixed << setprecision(16) << sqrt(x) << endl;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[110];
    cin >> N;
    rep(i,0,N) cin >> a[i];
    sort(a, a+N, greater<ll>());
    ll ans = 0;
    rep(i,0,N){
        if(i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }
    print(ans);

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<stdio.h>
using namespace std;

static const int INFTY = (1<<21);
enum Color{
    WHITE,
    GRAY,
    BLACK
};
int n;

//int M[100][100];
vector<pair<int,int> > adj[10000];   //隣接リスト
priority_queue<pair<int, int> > PQ; 
Color color[10000];
int d[10000];

void dijkstra(){
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;
    
    while(!PQ.empty()){
        pair<int,int> f = PQ.top(); 
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        if(d[u] < f.first*(-1)) continue;

        for(int j=0, size = adj[u].size(); j<size;  j++){
            int v = adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << i << " " << ((d[i]==INFTY)? -1:d[i]) << endl;
    }
}

int main(){

    cin >> n;
    for(int i=0; i<n; i++){
        int u, k;
        cin >> u >> k;
        for(int j=0; j<k; j++){
        int v, g;
        cin >> v >> g;
        adj[u].push_back(make_pair(v, g));
        }
    }

    dijkstra();
    return 0;
}


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

int main(){
    size_t N;
    scanf("%ld", &N);
    vector<pair<int_fast64_t, int_fast64_t>> a(N, pair<int_fast64_t, int_fast64_t>(0, 1));
    for(size_t i = 0; i < N; ++i)scanf("%ld", &(a[i].first));
    sort(a.begin(), a.end());
    uint_fast64_t A(0);
    for(size_t i = N; i;){
        --i;
        if(a[i].second){
            auto k = pair<int_fast64_t, int_fast64_t>((1LL << (64 - __builtin_clzll(a[i].first))) - a[i].first, 1LL);
            auto t = lower_bound(a.begin(), a.end(), k);
            if(t - a.begin() != i && t -> first == k.first){
                ++A;
                t -> second = 0;
            }
        }
    }
    cout << A << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;++i)
    #define Fdr(i,x,y) for(int i=x;i>=y;--i)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 1000011
#define int ll
int p[N];
signed main(){
    ll a,b,t;
    in>>a>>b;
    t=GCD(a,b);
    int d=0;
    ll len=MIN(sqrt(a),sqrt(b))+1,ans=0;
    Fur(i,2,len){
        if(a%i==0&&b%i==0)ans++;
        while(a%i==0)a/=i;
        while(b%i==0)b/=i;
    }
    len=sqrt(a)+1;
    Fur(i,2,len)
        while(a%i==0)a/=i;
    len=sqrt(b)+1;
    Fur(i,2,len)
        while(b%i==0)b/=i;
    if(a==b&&a!=1&&b!=1)ans++;
    out<<ans+1<<ln;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
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; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    int k; cin >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    

    sort(all(a));
    if(a.at(n-1) < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    } 
    int temp = a.at(0);
    rep(i,n-1){ 
        temp = __gcd(temp,a.at(i+1)); 
        if(temp == 1){
            cout << "POSSIBLE" << endl;
            return 0;
        } 
    }
    if(k%temp == 0){
        cout << "POSSIBLE" << endl;
        return 0;
    } 
    else{
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
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;}
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
int N;
vector<int>fac(5050,0);
vector<int>g[5050];

vector<vector<int>>dfs(int now,int par){
	auto dp = make_v<int>(2,2);
	fill_v(dp,0);
	dp[1][0] = 1;
	for(auto e:g[now]){
		if(e==par)continue;
		auto tmp = dfs(e,now);
		int n = dp.size();
		int m = tmp.size();
		auto ndp = make_v<int>(n+m-1,2);
		fill_v(ndp,0);
		rep(i,1,n){
			rep(j,1,m){
				/*
				rep(k,0,2){
					rep(l,0,2){
						(ndp[i+j][(k+l)%2] +=(dp[i][k]*tmp[j][l])%MOD)%=MOD;
						(ndp[i][((k+l)+1)%2] += (fac[j]*(dp[i][k]*tmp[j][l])%MOD)%MOD)%=MOD;
					}
				}
				*/
				ndp[i+j][0]+=dp[i][0]*tmp[j][0]%MOD+dp[i][1]*tmp[j][1]%MOD;
				ndp[i+j][0]%=MOD;
				ndp[i+j][1]+=dp[i][1]*tmp[j][0]%MOD+dp[i][0]*tmp[j][1]%MOD;
				ndp[i+j][1]%=MOD;
				ndp[i][1]+=fac[j]*dp[i][0]%MOD*tmp[j][0]%MOD+fac[j]*dp[i][1]%MOD*tmp[j][1]%MOD;
				ndp[i][1]%=MOD;
				ndp[i][0]+=fac[j]*dp[i][0]%MOD*tmp[j][1]%MOD+fac[j]*dp[i][1]%MOD*tmp[j][0]%MOD;
				ndp[i][0]%=MOD;
			}
		}
		dp = ndp;
	}
	return dp;
}

signed main()
{
	//IOS();
	cin>>N;
	rep(i,0,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fac[2]=1;
	rep(i,4,5050){
		fac[i]=(fac[i-2]*(i-1))%MOD;
	}
	auto dp = dfs(0,-1);
	int ans = fac[N];
	rep(i,1,N){
		ans -= fac[i]*dp[i][1];
		ans += fac[i]*dp[i][0];
		ans%=MOD;
	}
	cout<<(ans+MOD)%MOD<<endl;
}


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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k) {
    cout << s << endl;
  } else {
    for(int i=0; i<k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
//ll MOD = 1000000007;
ll MOD = 2019;

void solve()
{
	ll l, r; cin >> l >> r;
	int ans = 0;
	if(l/MOD != r/MOD)ans = 0;
	else
	{
		l %= MOD;
		r %= MOD;
		ll tmp = MOD*MOD;
		mreps(i,l, r)mreps(j,i+1,r)
		{
			chmin(tmp,(i*j)%MOD);
		}
		ans = tmp;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  ll sowa = accumulate(a.begin(), a.end(), 0ll);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      ans = max(ans, sowa - b[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 08/12/19.
//  Copyright © 2019 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <string>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin>>s;
    ll int l,i,j,k;
    l=s.length();j=0;
    for (i=0; i<(l/2); i++) {
        if (s[i] != s[l-1-i]) {
            j=j+1;
        }
        //cout<<s[i]<<"    "<<s[l-1-i]<<endl;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 256