akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	ll C;
	cin >> n >> C;
	vi h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	struct Line {
		ll k, b;
		ll eval(int x) {
			return k * x + b;
		}
	};
	auto isec = [](const Line& a, const Line& b) {
		return (ld)(a.b - b.b) / (b.k - a.k);
	};
	vector<Line> hull;
	int pt = 0;
	auto add = [&](const Line& h) {
		while (!hull.empty() && isec(h, hull.back()) < isec(hull.back(), hull[sz(hull) - 2])) {
			hull.pop_back();
		}
		hull.pb(h);
		pt = min(pt, sz(hull) - 1);
	};
	auto shift = [&](int x) {
		while (pt < sz(hull) - 1 && isec(hull[pt], hull[pt + 1]) <= x) {
			pt++;
		}
	};
	auto get = [&](int x) {
		shift(x);
		return hull[pt].eval(x);
	};
	hull.pb({ -h[0], (ll)h[0] * h[0] });
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ll cur = (ll)h[i] * h[i] + C + get(2 * h[i]);
		ans = cur;
		add({ -h[i], (ll)h[i] * h[i] + cur });
	}
	cout << ans;
}


Measured memory_bytes: 7152
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  
  rep(i,s.size()) {
  s.at(i) = 'x';}
  
  cout << s;
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   int n, max_l=0, total=0, temp;
   cin >> n;
   for(int i=0; i<n; i++){
       cin >> temp;
       if(temp > max_l) max_l = temp;
       total += temp;
   }
   if(max_l < total - max_l)
       cout << "Yes";
   else cout << "No";
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e6;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = n;
    rep(i, n-1) {
        if(s[i] != s[i+1]) {
            int now = max(i+1, n-i-1);
            ans = min(ans, now);
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int A, B, K; cin >> A >> B >> K;

  for (int i = A; i <= min(A + K - 1, B); ++i) cout << i << endl;
  for (int i = max(B - K + 1, A + K); i <= B; ++i) cout << i << endl;
}

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

int main(void) {

    int a, b;

    cin >> a >> b;
    if ((a+b)%2 == 0) {
        cout << (a+b) / 2 << endl;
    } else {
        cout << (a+b) / 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    //char[] alpha = new char[26];
    //char c = 'a';
    char a = 'A';
    //for (int i = 0; i < 26; i++){
    //    alphabet[i] = c++;
    //}
    int num = Integer.parseInt(scan.nextLine()) % 26;
    char[] pre = scan.nextLine().toCharArray();
    char[] now = new char[pre.length];
    for(int i = 0;i < pre.length;i ++){
      now[i] = (char)((num + pre[i] - a) % 26 + a); 
    }
    System.out.println(String.valueOf(now));
  }
}

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

using namespace std;

int main()
{
  int i,j,k;
  int ans=0;
  int N;
  scanf("%d",&N);
  if( N<3 ){
    printf("0\n");
    exit(0);
  }
  int bar[N+2];
  for(i=0;i<N;i++){
    scanf("%d",&bar[i]);
  }
  
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if( bar[i] == bar[j] ){
        continue;
      }
      for(k=j+1;k<N;k++){
        if( bar[i] == bar[k] || bar[j] == bar[k] ){
          continue;
        }
        if( (bar[i]+bar[j])>bar[k] && (bar[i]+bar[k])>bar[j] && (bar[j]+bar[k])>bar[i] ){
          ans++;
        }
      }
    }
  }
  
  printf("%d\n",ans);
  
  return 0; 
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    int x[n][d];
    rep(i, n) rep(j, d) cin >> x[i][j];

    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            float dist = 0;
            rep(k, d) dist += pow(x[i][k] - x[j][k], 2);
            dist = sqrt(dist);
            if (floor(dist) == dist) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)(b);++i)

void solve()
{
  int N; cin>>N;
  vector<int> L(N);
  rep(i,N)cin>>L[i];
  sort(L.begin(),L.end());
  long long ans = 0;
  rep(i,N)repi(j,i+1,N){
    int sum = L[i] + L[j];
    int idx = lower_bound(L.begin(),L.end(),sum)-L.begin()-1;
    ans += max(0, idx-j);
  }
  cout << ans << endl;
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);
  solve();
  return 0; 
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 21;

const int mod = 1e9+7;

int n;
bool can[N][N];
int mem[N][1 << N];

int add(int & a , int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int go(int idx , int msk){
    if(idx == n){
        return msk == (1 << n) - 1;
    }
    if(~mem[idx][msk])
        return mem[idx][msk];
    int ways = 0;
    for(int i = 0; i < n; i++){
        if(can[idx][i] && !(msk & (1 << i)) ){
            add(ways , go(idx + 1 , msk | (1 << i)));
        }
    }
    return mem[idx][msk] = ways;
}

int main(){
    scanf("%d" , &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d" , &can[i][j]);
        }
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(0 , 0));
}


Measured memory_bytes: 172288
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main(){

 long long int N,M,X;
  scanf("%lld %lld %lld",&N,&M,&X);

/*
  char A[];
  scanf("%s",A);
  */

  
  long long int A[M+1];
  long long int mon;
  mon =0;
  long long int ans;
  ans = 0;
  long long int i,j,k,l;
  for(i=1;i<=M;i++){
    A[i]=0;
  }
  long long int B[N+1][M+1];
  long long int C[N+1];
  int cou;
  cou = 0;

  for(i=1;i<=N;i++){

   scanf("%lld",&C[i]);
   for(j=1;j<=M;j++){
   scanf("%lld",&B[i][j]);
   }
   }
  k = pow(2,N);
  for(i=0;i<k;i++){
   for(j=0;j<N;j++){
     if(i>>j & 1){
       mon += C[j+1];
       for(l=1;l<=M;l++){
         A[l]+=B[j+1][l];
       }
       }
   }
       for(l=1;l<=M;l++){
         if(A[l]<X){
           cou = 1;
         }
       }
       if ( cou == 0){
         if(ans==0){
           ans = mon;
         }
         else if(mon<ans){
           ans = mon;
         }
        else{}
       }
       cou = 0;
       mon = 0;
  for(l=1;l<=M;l++){
    A[l]=0;
  }
  }
if(ans != 0){
           printf("%lld",ans);
}
else{
  printf("-1");
}




 /* long long int a,b,c;
  a=B[1][1];
  b=1;
for(i=2;i<=N;i++){
  if(a<=B[i][1]){
    a=B[i][1];
    b=i;
  }
}
  mon += C[b];
  c = B[b][1];
  for(i=1;i<=M;i++){
    A[i] += B[b][i];
    if(
  
for(i=1;i<=N;i++){
  for(j=1;j<=M;j++){
    A[j]+=B[i][j];
    Ac[j]=A[j];
  }
  mon += C[i];
}

for(i=1;i<=M;i++){
  if(A[i]<X){
    printf("-1");
    return(0);
  }
}
long long int check;
long long int monc,monmoto;
monc = mon;
monmoto = mon;
for(i=1;i<=N;i++){
  monc = monmoto;
  for(l=i;l<=N;l++){
 check =0;

 for (j=1;j<=M;j++){
   if(Ac[j]-B[l][j]>=X){
     new[j]=Ac[j]-B[l][j];
   }
   else{
     check =1;
   }
 }
 if (check == 0){
   for (k=1;k<=M;k++){
     Ac[k]=new[k];
   }
     monc = monc - C[l];
 }


  }


  for(l=1;l<=M;l++){
    Ac[l]=A[l];
  }
  if(monc<=mon){
mon = monc;
}
}
printf("%lld",mon);
*/






 return(0);
 }


Measured memory_bytes: 2524
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int i,ans=0;;
		for(i=0;i<2;i++) {
			if(a<b) {
				ans=ans+b;
				b=b-1;
			}else {
				ans=ans+a;
				a=a-1;
			}
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
    int n, m;
    cin >> n;
    vector<int> time(n);
    for(int i = 0; i < n; i++){
        cin >> time[i];
    }
    cin >> m;
    vector<p> drink;
    for(int i = 0; i < m; i++){
        int y, x;
        cin >> y >> x;
        drink.push_back(p(y, x));
    }

    for(p z : drink){
        int ans = 0;
        for(int j = 0; j < n; j++){
            if(z.first == j + 1) ans += z.second;
            else ans += time[j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3612
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int p[55];

int main(){
    cin >> n;
    REP(i, n)cin >> p[i];
    int pre = p[0];
    bool flg = true;
    for(int i = 1;i < n;i++){
        if(pre > p[i]){
            flg = false;
        }
        pre = p[i];
    }
    if(flg){
        cout << "YES" << endl;
        return 0;
    }
    REP(i, n)REP(j, n){
        swap(p[i], p[j]);
        int pr = p[0];
        bool fl = true;
        for(int k = 1;k < n;k++){
            if(pr > p[k]){
                fl = false;
            }
            pr = p[k];
        }
        if(fl){
            cout << "YES" << endl;
            return 0;
        }
        swap(p[i], p[j]);
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
from fractions import gcd
import functools

def gcd_list(l):
    return functools.reduce(gcd, l)

def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    d = gcd_list(A)
    ret = False
    if K > max(A):
        print('IMPOSSIBLE')
        return
    
    for a in A:
        if (a-K)%d == 0:
            ret = True
            break
            
    print('POSSIBLE' if ret else 'IMPOSSIBLE')
    
solve()

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
const int INF = 1e9;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    cin>>n;
    int dp[n+1][3]={};
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i=1;i<=n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        dp[i][0] = a + max( dp[i-1][1],dp[i-1][2] );
        dp[i][1] = b + max( dp[i-1][0],dp[i-1][2] );
        dp[i][2] = c + max( dp[i-1][0],dp[i-1][1] );
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#3-2-mod-p-%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E9%80%86%E5%85%83
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main(){
    ll ans=0,n,a,b;
    cin>>n>>a>>b;

    ll pa=1;
    ll pb=1;
    for(int i=1;i<=a;i++){
        pa=(((pa*((n-i+1)))%MAX)*modinv(i,MAX))%MAX;
    }
    for(int i=1;i<=b;i++){
        pb=(((pb*(n-i+1))%MAX)*modinv(i,MAX))%MAX;
    }
    ans=modpow(2,n,MAX);
    ans+=(ans<0)?(MAX):0;
    ans=ans%MAX;
    ans--;
    ans+=(ans<0)?(MAX):0;
    ans=ans%MAX;
    ans-=pa;
    ans+=(ans<0)?(MAX):0;
    ans=ans%MAX;
    ans-=pb;
    ans+=(ans<0)?(MAX):0;
    ans=ans%MAX;

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] k = new int[M];
		int cnt=0;
		List<int[]> s = new ArrayList<int[]>();
		for (int i=0;i<M;i++) {
			k[i]=sc.nextInt();
			int[] S = new int[k[i]];
			for (int j=0;j<k[i];j++) {
				S[j]=sc.nextInt();
			}
			s.add(S);
		}
		int[] p = new int[M];
		for (int i=0;i<M;i++) {
			p[i]=sc.nextInt();
		}

		int[] stri=new int[N];
		for (int i=0;i<N;i++) {
			stri[i]=i+1;
		}
		for (int i=0;i<1<<N;i++) {
			int[] sw = new int[N];
			for (int j=0;j<N;j++) {
				if ((1&i>>j)==1) {
					sw[j]=1;
				}
			}

			loop:for (int j=0;j<M;j++) {
				int[] tmp=s.get(j);
				int sum=0;
				for (int l=0;l<k[j];l++) {
					sum+=sw[tmp[l]-1];
				}
				if (sum%2!=p[j]) {
					break loop;
				}
				if (j==M-1) {
					cnt++;
				}
			}
		}
	System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 10000007
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}

int32_t main()
{
fastio;
int n;in n;
int k;in k;
int q;in q;
int arr[n+1];
for(int i=1;i<=n;i++)
arr[i]=0;
//printArray(arr,n+1);
for(int i=0;i<q;i++){
    int a;in a;
    arr[a]+=1;
}
//printArray(arr,n+1);
for(int i=1;i<=n;i++){
int wrong=q-arr[i];
if(wrong<k)
    out "Yes"<<endl;
else out "No"<<endl;
}
return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
 
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

void solve(){
	
}

int main(){
	load;
    string s, t;
    cin >> s >> t;
    fori(i, s.size()){
    	if(s[i] != t[i]){
    		cout << "No\n";
    		return 0;
    	}
    }
    cout << "Yes\n";
	return 0;
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
#define sz(x) (ll)x.size()
using namespace std;
 
 
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
 


const ll N =(1e5+5);

ll fact[N];

long long binpow(long long a, long long b) {
     a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
     res%=MOD;
    return res;
}
void ini(){
    fact[0] = 1;
    for(int i = 1;i < N;i++){
        fact[i] = (fact[i-1] * i)%MOD;
    }
}
ll ncr(ll n,ll r){
    ll ret = fact[n];
    ret = (ret * binpow(fact[r],MOD-2))%MOD;
    ret = (ret * binpow(fact[n-r],MOD-2))%MOD;
    return ret;
}
ll a[N];
map<ll,ll> cnt;
void solve(){
    ll n;
    cin >> n;

    for(int i =1;i<=n;i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(a+1,a+n+1,greater<ll>());
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        if(cnt[a[i]] <= 0)continue;
        bool poss=false;
        ll pp = -1;
        cnt[a[i]]--;
        for(ll p = 1;p<=32;p++){
            if((1ll<<p) < a[i]) continue;
            if(cnt[(1ll<<p)-a[i]] > 0){
                poss = true;
                pp = p;
                break;
            }
        }
        if(poss){
            ans ++ ;
            cnt[(1ll<<pp)-a[i]]--;
            //cnt[a[i]]--;
         //   cout << a[i] << " "<< (1ll<<pp)-a[i] << endl;
        }   
        else{
            cnt[a[i]]++;
        }
    }
    cout << ans << endl;
}


 
   
 
 
 /*
 2 3 4 5 6 
 3 6 10 15 21 
 4 10 20 35 56 
 5 15 35 70 126 
 6 21 56 126 252 
*/
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
       
 
    ll tt=1;
    while(tt--){
        solve();
    }    
}

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

struct UnionFind{
    vector<long long> root;
    vector<long long> sizes;
    UnionFind(long long n): root(n + 1), sizes(n + 1,1){
        for(long long i = 0; i <= n; i++) root[i] = i;
    }
    long long find(long long x){
        if(x == root[x]) return x;
        return root[x] = find(root[x]);
    }
    void unite(long long x, long long y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x,y);
        root[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;
    }
    bool same(long long x, long long y){
        return find(x) == find(y);
    }
};

int main(){
    long long N,M;
    cin >> N >> M;
    UnionFind uf(N);
    long long i;
    long long A,B;
    for(i=1; i<=M; i++){
        cin >> A >> B;
        uf.unite(A,B);
    }
    long long ans=0;
    for(i=1; i<=N; i++){
        ans=max(ans,uf.sizes[i]);
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

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

int main() {
string s,t;
cin >> s >> t;
bool a = true;
for(int i=0; i<s.length(); i++){
if(s[i] != t[i]){
a = false;
break;
}
}
if(a) cout << "Yes" << endl;
else cout << "No" << endl;
}

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

using namespace std;

int main(void) {
    long n, m;
    cin >> n >> m;

    vector<pair<long,long>> ab(n);
    for(auto &x: ab) cin >> x.first >> x.second;

    sort(ab.begin(), ab.end());

    priority_queue<long> q;

    auto it = ab.begin();

    long r = 0;

    for(int d=1; d<=m; d++) {
        while(it != ab.end() && it->first <= d) {
            q.push(it->second);
            it++;
        }

        if(!q.empty()) {
            r += q.top(); q.pop();
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 2936
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n;
	cin >> n;
	Graph g(n);
	REP(i, n) {
		ll aa;
		cin >> aa;
		REP(j, aa) {
			ll x, y;
			cin >> x >> y;
			x--;
			add_edge(g,i,x,y,false,0);
		}
	}

	ll ans = 0;
	REP(bit, (1LL << n)) {
		
		ll con = 0;
		Array mem(n, 0);
		REP(i, n) {
			if (bit & (1LL << i)) {
				con++;
				mem[i] = 1;
			}
		}

		bool flag = true;
		REP(i, n) {
			if (mem[i] == 1) {
				for (auto e : g[i]) {
					if (mem[e.to] == e.cap) continue;
					flag = false;
					break;
				}
			}
			if (!flag) break;
		}

		if (flag) chmax(ans, con);
	}
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool color[8];
int main(){
    int N;
    cin >> N;
    int all = 0;
    REP(i,N){
        int a;
        cin >> a;
        REP(k,8){
            if(a < 400*(k+1)) {
                color[k] = true;
                break;
            }
            if(k == 7) all++;
        }
    }

    int ans = 0;
    REP(i,8){
        if(color[i]) ans++;
    }
    //int ans_max = min(8, ans+all);
    int ans_max = ans+all;
    int ans_min = max(1, ans);

    printf("%d %d\n", ans_min, ans_max);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int,vector<bool> > P;
typedef long long int ll;


struct Edge{int to;};
vector<Edge> G[10];

int N,M;
int cnt=0;

bool check(vector<bool>& used){
	for(int i=1;i<=N;i++){
		if(!used[i]) return false;
	}
	return true;
}

void solve(int v, vector<bool>& used){

	//cout<<"["<<v<<"]";
	//for(int i=1;i<=N;i++) 
	//	cout<<used[i]<<" ";


	if(check(used)){
		cnt++;
		return;
	}

	for(int i=0;i<G[v].size();i++){
		int u=G[v][i].to;
		if(used[u]) continue;
		vector<bool> us(used);
		us[u]=true;
		//cout<<"->"<<u<<endl;
		solve(u, us);
	}

}

int main(){

	cin>>N>>M;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		Edge e1,e2;
		e1.to = b; e2.to = a;
		G[a].push_back(e1);
		G[b].push_back(e2);
	}
	vector<bool> used(N+1);
	fill(used.begin(),used.end(),false);
	used[0]=true; used[1]=true;

	solve(1,used);
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 256
import collections

N = int(input())
S_list = []
for n in range(N):
  S_list.append(input())

c = collections.Counter(S_list)
max_list = []
_max_value = 0
for idx, value in enumerate(c.most_common()):
  if idx == 0:
    max_list.append(value[0])
    _max = value[1]
    continue
  if _max == value[1]:
    max_list.append(value[0])
  else:
    break

for answer in sorted(max_list):
  print(answer)

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int a = 0, b = 0;
  for (int i=0; i<n; i+=2) a += vec.at(i); 
  for (int i=1; i<n; i+=2) b += vec.at(i);
  cout << a-b << endl;}


Measured memory_bytes: 3632
X = int(input())

if 400<=X<=599:
    print(8)
elif 600<=X<=799:
    print(7)
elif 800<=X<=999:
    print(6)
elif 1000<=X<=1199:
    print(5)
elif 1200<=X<=1399:
    print(4)
elif 1400<=X<=1599:
    print(3)
elif 1600<=X<=1799:
    print(2)
elif 1800<=X<=1999:
    print(1)


Measured memory_bytes: 9176
#include <cstdio>
#include <iostream>
using namespace std;
#define INF 1e15

const int MAXN = 100000;
int n , x;
long long dp[ 3 ][ MAXN + 5 ];

void Read( int &x ) {
	x = 0; int f = 1;
	char s = getchar( );
	for( ; s < '0' || s > '9' ; s = getchar( ) ) f = s == '-' ? -f : f;
	for( ; s >= '0' && s <= '9' ; s = getchar( ) ) x = x * 10 + s - '0';
	x *= f;
}

int main( ) {
	scanf("%d",&n);
	dp[ 0 ][ 0 ] = 0 , dp[ 1 ][ 0 ] = dp[ 2 ][ 0 ] = -INF;
	for( int i = 1 ; i <= n ; i ++ ) {
		Read( x );
		
		dp[ 0 ][ i ] = max( dp[ 0 ][ i - 1 ] , dp[ 1 ][ i - 1 ] );
		dp[ 1 ][ i ] = max( dp[ 1 ][ i - 1 ] , dp[ 2 ][ i - 1 ] );
		dp[ 2 ][ i ] = dp[ 2 ][ i - 1 ];
		dp[ 0 ][ i ] += x , dp[ 1 ][ i ] -= x , dp[ 2 ][ i ] += x;
		
		if( x < 0 ) {
			dp[ 2 ][ i ] = max( dp[ 2 ][ i ] , dp[ 1 ][ i ] );
			dp[ 1 ][ i ] = max( dp[ 1 ][ i ] , dp[ 0 ][ i ] );
		}
	}
	printf("%lld", max( dp[ 0 ][ n ] , max( dp[ 1 ][ n ] , dp[ 2 ][ n ] ) ) );
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#define INF 2000000000

 int main(void)
 {
 	int n,t,a;
 	int res=1,min=INF,diff=0;
 	scanf("%d %d",&n,&t);
 	for(int i=0;i<n;i++){
 		scanf("%d",&a);
 		if(a<min) min=a;
 		else if(a-min>diff) res=1,diff=a-min;
 		else if(a-min==diff) res++;
 	}
 	printf("%d\n",res);
 	return 0;
 }

Measured memory_bytes: 128
#include<iostream>

int main()
{
    long long a, b, x;
    std::cin >> a >> b >> x;
    long long answer = (b / x) - (a / x);
    if(a % x == 0){
        answer = answer + 1;
    }
    std::cout << answer << std::endl;
    return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
def main():
    mod = 1000000007
    N = int(input())
    mp = {}
    zero = 0
    for _ in range(N):
        x , y = map(int, input().split())
        if x == 0 and y == 0:
            zero += 1
        else:
            g = math.gcd(x, y)
            x //= g
            y //= g
            rot = 0
            if x == 0:
                y = 1
            else:
                if y == 0:
                    rot = 1
                    x = 0
                    y = 1
                else:
                    if x < 0 and y < 0:
                        x *= -1
                        y *= -1
                    elif x < 0:
                        rot = 1
                        x *= -1
                        x, y = y, x
                    elif y < 0:
                        rot = 1
                        y *= -1
                        x, y = y, x
            if (x, y) not in mp.keys():
                mp[x, y] = [0, 0]
                mp[x, y][rot] = 1
            else:
                mp[x, y][rot] += 1
        #print(mp)    
    #print(mp)
    ans = 1
    for (a, b) in mp.keys():
        now = 1
        #now += np.power(2, mp[a, b][0]) -1 
        #now += np.power(2, mp[a, b][1]) -1
        now += pow(2, mp[a, b][0], mod) -1 
        now += pow(2, mp[a, b][1], mod) -1
        ans *= now % mod
    ans += zero - 1
    print(ans % mod)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 81568
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	sort.Ints(a)
	b := make([]int, n)
	for i := range b {
		b[i] = readInt()
	}
	sort.Ints(b)
	c := make([]int, n)
	for i := range c {
		c[i] = readInt()
	}
	sort.Ints(c)

	dp1 := make([]int, n)
	var j int
	for i := 0; i < n; i++ {
		for j < n && a[j] < b[i] {
			j++
		}
		dp1[i] = j
	}

	var ans int64
	dp2 := make([]int64, n)
	j = 0
	for i := 0; i < n; i++ {
		if 0 < i {
			dp2[i] = dp2[i-1]
		}
		for j < n && b[j] < c[i] {
			dp2[i] += int64(dp1[j])
			j++
		}
		ans += dp2[i]
	}
	println(ans)
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main(){
    int n,m;
    cin >> n >> m;
    Graph G(n);
    vector<P> pai;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        pai.push_back(make_pair(a,b));
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        UnionFind uf(n);
        for(int j=0;j<m;j++){
            if(i==j) continue;
            uf.unite(pai[j].first,pai[j].second);
        }
        if(!uf.same(pai[i].first,pai[i].second)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i<n;i++)
		cin >> a[i];
	vector<int> need;
	for(int i = 1;i<=n;i++)
	{
		need.pb(i);
	}
	int cnt = 0;
	for(int i  = 0 ;i<n;i++)
	{
		if(a[i] != need[i])
			cnt++;
	}
	if(cnt==0 || cnt==2){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int N;
    cin >> N;
    int p[51];
    int cnt = 0;
    rep(i,N){
        cin >> p[i];
        if(p[i] != i + 1) cnt++;
    }
    
    if(cnt > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: i32,
    }

    for i in 1..=9 {
        if N % i == 0 {
            if N / i <= 9 {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}


Measured memory_bytes: 2112
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        s: chars,
    }

    //tabで移動
    if s.contains(&'A') && s.contains(&'B') {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()

using namespace std;

typedef pair<string,string> pss;

int dist(string s,string t) {
  int d[20][20];
  fill(d[0],d[20],INF);

  int n=s.size(),m=t.size();
  for(int i=0;i<=n;i++)d[i][0]=i;
  for(int i=0;i<=m;i++)d[0][i]=i;
  
  int sp[128],tp[128];
  fill(sp,sp+128,-1);
  for(int i=0;i<n;sp[s[i]]=i,i++){
    fill(tp,tp+128,-1);
    for(int j=0;j<m;tp[t[j]]=j,j++){
      int cost=(s[i]!=t[j]);
      int ii=sp[t[j]],jj=tp[s[i]];
      d[i+1][j+1]=min(min(d[i][j+1],d[i+1][j])+1,d[i][j]+cost);
      if(ii>=0 && jj>=0)
	d[i+1][j+1]=min(d[i+1][j+1],d[ii][jj]+i-ii+j-jj-1);
    }
  }
  return d[n][m]; 
}

int main(void){

  int n,d;
  while(cin >> n,n){
    cin >> d;
    vector<string> v(n);
    for(int i=0;i<n;i++)cin >> v[i];

    vector<pair<string,string> >res;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(dist(v[i],v[j])<=d){
	  res.push_back(pss(min(v[i],v[j]),max(v[i],v[j])));
	}
      }
    }
    sort(all(res));
    for(int i=0;i<res.size();i++)
      cout << res[i].first << "," << res[i].second << endl;
    cout << res.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
	int n;
	int ret = 0;
	cin >> n;
	while(n--) {
		int t;
		cin >> t;
		ret = __gcd(ret, t);
	}
	cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include<stdio.h>

int n;
int A[20];

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;

  int res = solve(i+1,m) || solve(i+1, m-A[i]);

  return res;
}

int main(void){
  int i,q,m;

  scanf("%d",&n);

  for(i=0; i<n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);

  for(i=0; i<q; i++){
    scanf("%d",&m);
    if(solve(0,m) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2084
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll h, w;in(h),in(w);
  if (h%3==0 or w%3==0) {
    print(0);
    return 0;
  }
  
  ll min_ = 10000000000000;
  ll hh = h/2;
  ll s = h*w;
  loop(i,0,2) {
    swap(h,w);
    hh = h/2;
    loop(x,0,w) {
      {
        vector<ll> S(3);
        S[0] = x*h;
        S[1] = (w-x)*hh;
        S[2] = s-(S[0]+S[1]);
        sort(S.begin(), S.end());
        min_ = min(min_, S[2]-S[0]);
      }
      {
        vector<ll> S(3);
        S[0] = x*h;
        S[1] = ((w-x)/2)*h;
        S[2] = s-(S[0]+S[1]);
        sort(S.begin(), S.end());
        min_ = min(min_, S[2]-S[0]);
      }
    }
  }
  
  print(min_);
  return 0;
}


Measured memory_bytes: 3628
#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;
typedef long long ll;
ll arr[300005];
ll mod=1000000007LL;
ll pre[100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    pre[0]=1LL;
    for(ll i=1;i<=61;i++)
    {
        pre[i]=pre[i-1]*2LL;
        pre[i] %=mod;
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll sum=0;
    for(ll i=0;i<61;i++)
    {
        ll req=0;
        ll ev=0;
        ll od=0;
        for(int j=0;j<n;j++)
        {
            if(arr[j]%2==0) ev++;
            else od++;
            arr[j] =arr[j]/2;
        }
        req=((od%mod) * (ev%mod))%mod;
        req=((req%mod)*(pre[i]%mod))%mod;
        sum=(sum%mod) + (req%mod);
        sum %=mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define x first
#define y second
#define mp make_pair
#define db double
#define pb push_back
#define all(a) a.begin(), a.end()
main(){
    srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int T=n;
    while (T%2==0) T/=2;
    if (T==1){
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    for (int i=2; i + 1 <= n; i+=2){
        cout << 1 << " " << i << endl;
        cout << i << " " << i+1 << endl;
        cout << 1 << " " << n+i+1 << endl;
        cout << n+i+1 << " " << n+i << endl;
    }
    cout << n+1 << " " << 3 << endl;
    if (n%2==0){
        for (int i=2; i < n; i++){
            int V = i^1^n;
            if (V < n){
                if (i%2==0) cout << n << " " << i << endl;
                else cout << n << " " << n+i << endl;
                if (V%2==0) cout << 2*n << " " << V << endl;
                else cout << 2*n << " " << n+V << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 2304
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    string s;cin >> s;
    int ans = 7;
    for (int i = 0; i < 3; ++i)
    {
        if(s[i] == 'o')ans++;
    }
    printf("%d\n", 100*ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000LL;
const int MAX_N = 105;
const int MAX_V = 100005;

int n;
ll W;
ll w[MAX_N], v[MAX_N];
ll dp[MAX_N][MAX_V];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < MAX_V; j++)
			dp[i][j] = INF;
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];

	for (int i = 0; i < n - 1; i++)
		for (int j = 0; j < MAX_V; j++)
		{
			if (dp[i][j] == INF)
				continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] + w[i + 1] <= W)
				dp[i + 1][j + v[i + 1]] = min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
		}

	for (int i = MAX_V - 1; i >= 0; i--)
		if (dp[n - 1][i] != INF)
		{
			cout << i << endl;
			return 0;
		}
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (auto& i : p)   cin >> i;
    for (auto& i : q)   cin >> i;
    for (auto& i : r)   cin >> i;
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    priority_queue<int, vector<int>, greater<int> > pq;
    for (int i = 0; i < x; ++i) pq.push(p[i]);
    for (int i = 0; i < y; ++i) pq.push(q[i]);
    for (int i = 0; i < c; ++i) {
        if (pq.top() < r[i]) {
            pq.pop();
            pq.push(r[i]);
        } else  break;
    }
    ll sum = 0;
    while (!pq.empty()) {
        int tp= pq.top();
        sum += tp;
        pq.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2552