akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split())
c = list(map(int, input().split()))
e_odd = False
for i in c:
    if i % 2 == 1:
        e_odd = not e_odd
        break
if not e_odd:
    if b == 1:
        print(0)
    else:
        print(2 ** a)
else:
    print(2 ** (a-1))


Measured memory_bytes: 2940
#include<stdio.h>

#include<algorithm>


using namespace std ;

typedef long long llong ;

struct Data
{
	llong size ;
	llong value ;
} ;

#define N_MAX 500000
Data art[ N_MAX ] ;

bool cmp( const Data& a ,const Data& b )
{
	return a.size == b.size ? a.value < b.value : a.size < b.size ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	sort( art ,art + N ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "No" << endl
#define yes cout << "Yes" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll s, t; cin >> s >> t;
    _for(i,0,max(s,t)) cout << min(s,t);
}

Measured memory_bytes: 3640
a=int(input())
b=''
while a>0:
  c=a%26
  if c==0:
    b=b+'z'
    a=a-26
  elif c==1:
    b=b+'a'
    a=a-1
  elif c==2:
    b=b+'b'
    a=a-2
  elif c==3:
    b=b+'c'
    a=a-3
  elif c==4:
    b=b+'d'
    a=a-4
  elif c==5:
    b=b+'e'
    a=a-5
  elif c==6:
    b=b+'f'
    a=a-6
  elif c==7:
    b=b+'g'
    a=a-7
  elif c==8:
    b=b+'h'
    a=a-8
  elif c==9:
    b=b+'i'
    a=a-9
  elif c==10:
    b=b+'j'
    a=a-10
  elif c==11:
    b=b+'k'
    a=a-11
  elif c==12:
    b=b+'l'
    a=a-12
  elif c==13:
    b=b+'m'
    a=a-13
  elif c==14:
    b=b+'n'
    a=a-14
  elif c==15:
    b=b+'o'
    a=a-15
  elif c==16:
    b=b+'p'
    a=a-16
  elif c==17:
    b=b+'q'
    a=a-17
  elif c==18:
    b=b+'r'
    a=a-18
  elif c==19:
    b=b+'s'
    a=a-19
  elif c==20:
    b=b+'t'
    a=a-20
  elif c==21:
    b=b+'u'
    a=a-21
  elif c==22:
    b=b+'v'
    a=a-22
  elif c==23:
    b=b+'w'
    a=a-23
  elif c==24:
    b=b+'x'
    a=a-24
  elif c==25:
    b=b+'y'
    a=a-25
  a=a/26
print(b[::-1])

Measured memory_bytes: 9356
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

bool dp[N+1];
void solve()
{
    memset(dp,0,sizeof(dp));
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<=k;i++)
    {
        bool z=0;
        for(int j=0;j<n;j++)
        {
            if(i>=a[j])
            z=z|(!dp[i-a[j]]);
        }
        if(z)
            dp[i]=1;
        else
            dp[i]=0;
    }
    if(dp[k])
    {
        cout<<"First"<<endl;
    }
    else
        cout<<"Second"<<endl;
    
    
    
    
    
}


int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






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


int main(){
    int n,m;
    bool ok=true;
    cin>>n>>m;
    vector<pair<int,int>> p(m);
    vector<int> ans(n);
    rep(i,n){
        ans[i]=-1;
    }

    rep(i,m){
        cin>>p[i].first>>p[i].second;
        if(ans[p[i].first-1]!=-1 && ans[p[i].first-1]!=p[i].second){
            ok=false;
        }
        ans[p[i].first-1]=p[i].second;
    }

    rep(i,n){
        if(ans[i]==-1){
            if(i==0 && n>1){
                ans[i]=1;
            }
            else{
                ans[i]=0;
            }
        }
    }
    if(n>2 && ans[0]==0) ok=false;

    int a=0;
    rep(i,n){
        a+=ans[i]*pow(10,n-i-1);
    }

    if(ok==false){
        cout<<-1<<endl;
        return 0;
    }
    cout<<a<<endl;
    return 0;
}

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

int n, k;
string str;

int main()
{
	scanf("%d %d", &n, &k); getchar();
 	getline(cin, str);
 	str[k-1] += 32;	
 	cout << str << endl;
}

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

#define REP(i,n) for (auto i=0;i<(n);i++)

#define vstring(v,n) vector<string> v(n); REP(i,n) cin >> v[i];



int main(int argc, char const *argv[]) {
  vstring(v, 3)
  std::cout << "A"<<v[1].at(0)<<"C"<< '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define S_MAX 100000
#define T_MAX 50000

int binarySearch(int key,int*A,int n){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left+right)/2;
    if(A[mid]==key)
      return 1;
    else if(key < A[mid])
      right=mid;
    else left = mid+1;
  }
  return 777;
}

int main(){
  
  int i,n,q;
  int cnt=0,jude;
  int S[S_MAX],T[T_MAX];
   
  scanf("%d",&n);  
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
 
  scanf("%d",&q); 
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
  jude=binarySearch(T[i],S,n);
  if(jude==1)
    cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main(){
    string s;
    cin >> s;
    int ori = 753;
    int ans = 1 << 30;
    rep(i, size(s) - 2){
        string tmp;
        for(int j = i; j < i + 3; ++j){
            tmp += s[j];
        }

        int t = stoi(tmp);
        int sub = abs(t - ori);
        ans = min(ans, sub);
    }

    println(ans);
}

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

using namespace std;
using Int = long long;

signed main(){
    Int w, h, x, y;
    cin >> w >> h >> x >> y;
    double max_s = w * h / 2.0;
    cout << fixed << setprecision(6) << max_s << " " << ((x == w/2.0 && y == h/2.0) ? 1 : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]

N = int(input())
A = LI()+[-1]


ans = 0
l = 0
r = 0
xor = 0
s = 0

while r < N:

    if xor & A[r] == 0:
        xor ^= A[r]
        r += 1
        ans += (r - l)
    else:
        s = xor & A[r]
        while s:
            s -= s & A[l]
            xor ^= A[l]
            l += 1
#            if l == r : break
print (ans)

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(c >= a && c <= b)
		cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int A = sc.nextInt();

   for(int i=1;;i++){
    H=H-A;
     if(H<=0){
     
       System.out.println(i);
       break;
     }
   }
   
 }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  ll b=0;
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(a/2)-vec.at(a/2-1)<<endl;
  return 0;
}


Measured memory_bytes: 3988
# 初期入力
import math
import sys
input = sys.stdin.readline
A,B,H,M = (int(x) for x in input().split())
#分針位置
min_deg =math.radians(360//60*M)
min_x =B *math.sin(min_deg)
min_y =B *math.cos(min_deg)

#時針位置
hor_deg =math.radians(360//12*(H +M/60))
hor_x =A *math.sin(hor_deg)
hor_y =A *math.cos(hor_deg)
xx =min_x -hor_x
yy =min_y -hor_y
distance =math.sqrt(xx**2 + yy**2)
print(distance)

Measured memory_bytes: 9552
s = raw_input().rstrip()
t = s
s = s[::-1]
s = s.replace("b", "t")
s = s.replace("p", "s")
s = s.replace("d", "b")
s = s.replace("q", "p")
s = s.replace("t", "d")
s = s.replace("s", "q")
print ((s == t) * "Yes") or "No"

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 1;i<=n;++i)
typedef long long ll;
 
int main(){
  int h,w;
  cin >> h >> w;
  char A[h][w];
  int count = 0;
  rep(i,h){
    rep(j,w){
      cin >> A[i][j];
      if(A[i][j] == '#'){
        ++count;
      }      
    }
  }
  if(count != h+w-1){
    cout << "Impossible" << endl;
    return 0;
  }
  else{
    rep(i,h){
      rep(j,w){
        if(i < h && j < w){
          if(A[i][j] == '#'){
            if(A[i+1][j] == '#' && A[i][j+1] == '#'){
              cout << "Impossible" << endl;
              return 0;
            }
            if(A[i+1][j] == '.' && A[i][j+1] == '.'){
              cout << "Impossible" << endl;
              return 0;
            }
         }
         if(i == h && j < w){
           if(A[i][j] == '#' && A[i][j+1] == '.'){
             cout << "Impossible" << endl;
             return 0;
           }
         }
         if(i < h && j == w){
           if(A[i][j] == '#' && A[i+1][j] == '.'){
             cout << "Impossible" << endl;
             return 0;
           }
         } 
      }
    }
  }
}
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;




int main(){
   int n;
   cin >> n;
   vector<ll> t(n), a(n);
   rep(i, n)cin >> a[i];
   rep(i, n)cin >> t[i];

   bool f = true;
   vector<ll> mnt(n, -1);
   rep(i, n){
      if(i == 0 || a[i] != a[i - 1]){
         if(a[i] > t[i])f = false;
         mnt[i] = a[i];
      }
   }
   for(int i = n - 1; i >= 0; i--){
      if(i == n - 1 || t[i] != t[i + 1]){
         if(t[i] > a[i])f = false;
         //if(mnt[i] != t[i])f = false;
         mnt[i] = t[i];
      }
   }

   if(!f){
      cout << 0 << endl;
      return 0;
   }
   ll res = 1;
   rep(i, n){
      //cout << mnt[i] << " ";
      if(mnt[i] != -1)continue;
      res = (res * min(a[i], t[i])) % MOD;
      if(res < 0)res += MOD;
   }
   res %= MOD;
   cout << res << endl;
}


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int y[200];
int comD(int a,int b, int k){
	int sum = 0;
	int jg;
	for(int i=1 ; i<=max(a,b); i++){
		if(a%i == 0 && b%i == 0){
			y[sum] = i;
			sum++;
		}
	}
	return y[sum-k];
}
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	cout<<comD(a,b,k)<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
syougen=[[] for x in range(n+1)]
for i in range(1,n+1):
    a=int(input())
    for j in range(a):
        x,y=map(int, input().split())
        syougen[i].append([x,y])

ans=0

for katei in range(2**n):
    hantei=katei
    muzyun=False
    for i in range(1,n+1):
        if hantei & 1:
            for j in range(len(syougen[i])):
                taisyou=syougen[i][j][0]
                if katei>>taisyou-1 & 1 != syougen[i][j][1]:
                    muzyun=True
                    break
        hantei>>=1
    if muzyun==False:
        ans=max(bin(katei).count("1"),ans)

print(ans)

Measured memory_bytes: 68764
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; ++i){
        string s1 = to_string(i);
        string s2 = s1;
        reverse(all(s1));
        if(s1 == s2) ans++;
    }
    cout << ans ;
}

Measured memory_bytes: 3608
t = list(input())
tl = len(t)

for i in range(tl):
    if t[i] != '?':
        continue

    if tl == 1:
        t[i] = 'D'
    elif i == tl - 1:
        t[i] = 'D'
    elif t[i-1] == 'P':
        t[i] = 'D'
    elif t[i+1] == '?':
        t[i] = 'P'
    elif t[i+1] == 'D':
        t[i] = 'P'
    else:
        t[i] = 'D'

print(''.join(t))


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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){
    std::cout << std::fixed;
    long double n,m,d;
    cin >> n>>m>> d;
    if(d == 0){
        cout << (m-1)/n;
        
    }else{
        cout << (m-1)*2/n*(n-d)/n;
    }

}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())
    
    if a == b == c and a % 2 == 0: 
        print(-1)
    elif (a+b+c) % 2:
        print(0)
    else:
        d = [abs(a+b), abs(b+c), abs(c+a)]
        c = []
        for i in d:
            cnt = 0
            while i % 2 == 0 and i != 2:
                i //= 2
                cnt += 1
            c.append(cnt)
        
        print(min(c))
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#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;
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define null 0
#define pi 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define d0(x) cout<<x<<" ";
#define d1(x) cout<<x<<"\n";
#define d2(x,y) cout<<x<<" "<<y<<"\n";
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
 
//#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;} 
template<typename T, typename U> static inline void amax(T &x, U y){if (y > x)x = y;} 
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const  ll mod= 1000000007  ; 
const long long inf = (ll)1e18+17;
const int inff = 1500000000;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll po(ll a,ll b){
    if(b==0)return 1;
    if(b==1)return a;
    ll op=po(a,b/2);
    op=((op*op)%mod);
    if(b%2==1) op=(op*a)%mod;
    return op;
}
int test_case=0;
void solve(){
    ll n;cin>>n;
    ll tot=po(10,n);
    ll to=(2*po(9,n) - po(8,n) + 10*mod)%mod;
    tot =(tot-to+10*mod)%mod;
    cout<<tot<<endl;
}
 
int main()
{  
    clock_t tt;tt = clock(); 
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    if(test_case==1)
    cin>>t;
    //pre();
    for(int i=1;i<=t;i++){
       //cout<<"Case #"<<i<<": ";
       solve();
    }
    tt = clock() - tt; double time_taken = ((double)tt)/CLOCKS_PER_SEC;   
    //printf("code took %f seconds to execute \n", time_taken); 
    return 0;
}
 
// ============== Notes =============== //
// common bugs
// - remove ios_base for interactive problems
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 3632
AB = input()  # "3 4"
S = input()  # 269-6650

A, B = AB.split()  # "3", "4"
A = int(A)  # 3
B = int(B)  # 4

# 333-4444
# 3-3-44-4
# 444444-5

def is_zip_ok(A, B, S):
  for i in range(0, A):
    if not S[i].isdecimal():
      return False

  if S[A] != '-':
    return False

  for i in range(A + 1, A + B + 1):
    if not S[i].isdecimal():
      return False

  return True

if is_zip_ok(A, B, S):
  print("Yes")
else:
  print("No")


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  string s; cin >> s;
  map<char, int> mp; rep(i, sz(s)) mp[s[i]]++;
  bool f = true;
  if(mp['W'] > 0 and mp['E'] == 0) f = false;
  if(mp['E'] > 0 and mp['W'] == 0) f = false;
  if(mp['S'] > 0 and mp['N'] == 0) f = false;
  if(mp['N'] > 0 and mp['S'] == 0) f = false;
  if(f) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll l,r;
    cin>>l>>r;
    if(r-l>2019) cout<<0<<endl;
    else{
        ll c=2019;
        for(ll i=l;i<r;++i) for(int j=i+1;j<=r;++j) c=min(c,(i*j)%2019);
        cout<<c<<endl;
    }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int h,n;
     cin>>h>>n;
     int sum=0;
     while(n--)
     {
          int x;
          cin>>x;
          sum+=x;
     }
     sum>=h ? cout<<"Yes\n" : cout<<"No\n";
     time();
     return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int N; cin >> N;
    vector<long long> A(N + 1); REP(i, N + 1) cin >> A[i];
    vector<long long> B(N); REP(i, N) cin >> B[i];

    long long cnt = 0;
    long long min_n = 0;
    for(int i = 0; i < N; ++i) {
        min_n = min(A[i], B[i]);
        A[i] = A[i] - min_n;
        B[i] = B[i] - min_n;
        cnt += min_n;
        
        min_n = min(A[i + 1], B[i]);
        A[i + 1] = A[i + 1] - min_n;
        B[i] = B[i] - min_n;
        cnt += min_n;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a,b,c,d,e=0;
  c4(a,b,c,d);
  rep(i,0,a+1){
    rep(j,0,b+1){
      rep(k,0,c+1){
        if(500*i+100*j+50*k==d) e++;
      }
    }
  }
  co(e);
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key)
{
	int i = 0;
	A[n] = key;
	while(A[i] != key) i++;
	return i != n;
}

int main()
{
	int i, n, A[10000+1], q, key, sum = 0;

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

	scanf("%d", &q);
	for(i = 0; i < q; i++) {
		scanf("%d", &key);
		if(search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	return 0;
}



Measured memory_bytes: 2120
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
int n, a[345678];
signed main() {
	cin >> n;
	int ans = 0, p = 1;
	for1(i, n)cin >> a[i];
	bool b;
	do{
		b = 0;
		int a0 = 0, a1 = 0;
		for1(i, n) {
			if (a[i] % 2)a1++;
			else a0++;
			a[i] /= 2; if (a[i] > 0)b = 1;
		}
		ans += (a0 * a1)% mod * p % mod; ans %= mod;
		p *= 2; p %= mod;
	} while (b);
	cout << ans << endl;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
vector<int> edge[200];



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

	cin >> n;
	rep(i,n) {
		char c;
		rep(j,n) {
			cin >> c;
			if (c == '1') {
				edge[i].push_back(j);
			}
		}
	}
	int ans = -1;
	rep(i, n) {
		vector<int> vi(n, -1);
		queue<int> q;
		q.push(i);
		vi[i] = 1;
		bool ok = true;
		int cnt = 0;

		while(!q.empty()) {
			int u = q.front();
			q.pop();
			cnt = vi[u];
			for (int v: edge[u]) {
				if (vi[v] ==-1) {
					vi[v] = vi[u] + 1;
					q.push(v);
				}
				else if(abs(vi[v] - vi[u]) == 1){
				}
				else {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			ans = max(ans, cnt);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
string S,ans;
cin >> S;

if(S[0] != S[1] && S[1] != S[2] && S[0] != S[2]){
  ans = "Yes";
}else{ 
  ans = "No"; 
}
	
 cout << ans << endl;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 int main()
{
	char s[2000000];
	int a,z;
	scanf("%s",s);
	for(a=0;s[a]!='A';a++);
	for(z=strlen(s)-1;s[z]!='Z';z--);
	printf("%d\n",z-a+1);
	return 0;
}

Measured memory_bytes: 384
from itertools import permutations
N = int(input())
S = input()
ans = 0
memo = {
    "R": [0] * (N+1),
    "G": [0] * (N+1),
    "B": [0] * (N+1),
}
for i in range (N-1, -1, -1):
    memo["R"][i] = memo["R"][i+1] + int(S[i] == "R")
    memo["G"][i] = memo["G"][i+1] + int(S[i] == "G")
    memo["B"][i] = memo["B"][i+1] + int(S[i] == "B")
for a, b, c in permutations(['R', 'G', 'B']):
    i = -1
    while i < N-3:
        i += 1
        if S[i] != a: continue
        j = i
        while j < N-2:
            j += 1
            if S[j] != b: continue
            ans += memo[c][j]
            if j + (j-i) < N: ans -= int(S[j+(j-i)] == c)
print(ans)

Measured memory_bytes: 68996
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::fmt::Debug;
use std::i64::MAX;
use std::collections::BinaryHeap;
use std::cmp::Ordering;
use std::collections::VecDeque;
use std::collections::BTreeSet;

struct State {
    s: String,
    v: usize,
}

fn main() {
    let mut sc = Scanner::new();
    let a = sc.parse::<String>().into_bytes();
    let n = a.len();
    let mut pos = (0..26).map(|_| {
        VecDeque::new()
    }).collect::<Vec<_>>();
    for i in 0..n {
        let c = (a[i] - 'a' as u8) as usize;
        pos[c].push_back(i);
    }

    let mut graph = (0..(n + 2)).map(|_| { Vec::new() }).collect::<Vec<_>>();
    let source = n;
    let sink = n + 1;

    for next in 0..26 {
        if pos[next].is_empty() {
            graph[source].push(sink);
        } else {
            let x = pos[next].front().unwrap();
            graph[source].push(*x);
        }
    }

    for i in 0..n {
        let c = (a[i] - 'a' as u8) as usize;
        pos[c].pop_front();
        for next in 0..26 {
            if pos[next].is_empty() {
                graph[i].push(sink);
            } else {
                let x = pos[next].front().unwrap();
                graph[i].push(*x);
            }
        }
    }

    let mut q = VecDeque::new();
    let mut dist = vec![n * 2; n + 2];
    q.push_back(State { s: "".to_owned(), v: source });
    dist[source] = 0;
    while !q.is_empty() {
        let state = q.pop_front().unwrap();
        if state.v == sink {
            println!("{}", state.s);
            return;
        }

        for i in 0..26 {
            let c = (i as u8 + 'a' as u8) as char;
            let next = graph[state.v][i];
            if dist[next] <= dist[state.v] + 1 {
                continue;
            }
            dist[next] = dist[state.v] + 1;
            q.push_back(State { s: state.s.clone() + &c.to_string(), v: next });
        }
    }
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 65788
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int m1 = sc.nextInt();
      	int di = sc.nextInt();
      	int m2 = sc.nextInt();
      	int d2 = sc.nextInt();
      	if(m1 != m2) System.out.println(1);
      	else System.out.println(0);
    }
}

Measured memory_bytes: 35636
import numpy as np

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x = int(input())

for i in range(10**5):
  if is_prime(x+i) == True:
    print(x+i)
    break

Measured memory_bytes: 21492
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstring>
#include<iomanip>
#include<list>
#include<algorithm>
using namespace std;

int main()
{
	int a[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	sort(a,a+4);
	if(a[0]==a[1]&&a[2]==a[3])cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> cash(N);
	long long ans = 0;
	int minP = 1;
	for (int i = 0; i < N; ++i){
		cin >> cash[i];
	}

	ans += cash[0] - 1;
	minP = 2;
	for (int i = 1; i < N;++i){
		if (minP <= (cash[i] - 1)){
			ans += (cash[i] - 1) / minP;
		}
		else{
			minP = max(minP, cash[i] + 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  if(s == "ARC")
    out("ABC");
  else
    out("ARC");
  memi;
}

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

int main() {
  int N;
  cin>>N;
  double A=0;
  for(int i=0;i<N;i++){
    double a;
    cin>>a;
    A+=1/a;
  }
  cout << fixed << setprecision(10);
  cout<<1/A<<endl;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s, t; cin>>s>>t;
    string res="";
    int ps=0, pt=0;
    while(ps<sz(s)||pt<sz(t)){
        res+=s[ps++];
        if(!(ps<sz(s)||pt<sz(t)))break;
        res+=t[pt++];
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
// failed to generate code

#include <bits/stdc++.h>
using namespace std;

int main(){	
	ios::sync_with_stdio(false);
	int H,W;
	cin >> H >> W;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			string s;
			cin >> s;
			if( s == "snuke"){
				cout << (char)('A'+j) << i+1 <<  endl;
				return 0;	
			}
		}
	}	
}


Measured memory_bytes: 764
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            String line=s.nextLine();
            for(int i=0;i<26;i++){
                String now="";
                for(int j=0;j<line.length();j++){
                    if(line.charAt(j)>='a'&&line.charAt(j)<='z'){
                        now+=(char)('a'+(line.charAt(j)-'a'+i)%26);
                    }else now+=line.charAt(j);
                }
                boolean ok=false;
                for(int j=0;j<now.length()-2;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'&&now.charAt(j+2)=='e')ok=true;
                }
                for(int j=0;j<now.length()-3;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'){
                        if(now.charAt(j+2)=='i'&&now.charAt(j+3)=='s')ok=true;
                        if(now.charAt(j+2)=='a'&&now.charAt(j+3)=='t')ok=true;
                    }
                }
                if(ok){
                    System.out.println(now);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 26576
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

#define M 1000000007


// 入力

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;

    multiset<ll> s;
    for (auto & a : A) {
        auto iter = s.lower_bound(a);
        if (iter != s.begin()) s.erase(--iter);
        s.insert(a);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string S;
  cin >> S;

  for(int i = 0;i < S.size();i++) {
    if((i+1) % 2 == 0) {
      if(S.at(i) == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }else {
      if(S.at(i) == 'L') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int a;
int n[1000];

scanf("%d",&a);
for(int i = 1; i <= a; i++){
scanf("%d",&n[i]);
}

for(int i = a; i >= 2; i--){
printf("%d ",n[i]);
}
printf("%d\n",n[1]);

return 0;
}


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

int A[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    long long ans = 0;
    sort(A+1, A+1+N);
    
    long long ans1 = 0, ans2 = 0;
        
    if(N % 2 == 0)
    {
        int ptr = N;
        
        for(int k=0; k<N/2-1; k++)
            ans1 += A[ptr--] * 2;
        
        ans1 += A[ptr--];
        ans1 -= A[ptr--];
        
        for(int k=0; k<N/2-1; k++)
            ans1 -= A[ptr--] * 2;
    }
    else
    {
        int ptr1 = N, ptr2 = N;
        
        for(int k=0; k<N/2; k++)
            ans1 += A[ptr1--] * 2;
        
        ans1 -= A[ptr1--];
        ans1 -= A[ptr1--];
        
        for(int k=0; k<(N+1)/2-2; k++)
            ans1 -= A[ptr1--] * 2;
        
        for(int k=0; k<(N+1)/2-2; k++)
            ans2 += A[ptr2--] * 2;
        
        ans2 += A[ptr2--];
        ans2 += A[ptr2--];
        
        for(int k=0; k<N/2; k++)
            ans2 -= A[ptr2--] * 2;
    }

    cout << max(ans1, ans2) << "\n";
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int a,b,c;cn(a,b,c)
  if (( a==b && a!= c )||( a==c && b!= c )||( c==b && a!= c )){
    co("Yes")
  }else{
    co("No")
  }
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 3;
    if (a == b)
        ans--;
    if (a == c)
        ans--;
    if (ans != 1 && b == c)
        ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int m=0;
  string s,t;
  cin>>s>>t;
  int l=s.size();
  for(int i=0;i<l;i++)
  {
    if(s[i]!=t[i])
     m++;
  }
    cout<<m;
     return 0;
}

Measured memory_bytes: 3904
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.lang.StringBuilder;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            StringBuilder sba = new StringBuilder();
            StringBuilder sbb = new StringBuilder();
            for (int i = 0; i < b; i++) {
                sba.append(a);
            }
            for (int i = 0; i < a; i++) {
                sbb.append(b);
            }
            if (sba.toString().compareTo(sbb.toString()) > 0) {
                out.println(sbb.toString());
            } else {
                out.println(sba.toString());
            }


        }

    }
}



Measured memory_bytes: 20688
import collections

n = int(input())
a = list(map(int, input().split()))
a_ = collections.Counter(a)
sum = 0
for x in a_.items():
    sum += x[0]*x[1]
q = int(input())
res = []
for _ in range(q):
    b, c = map(int, input().split())
    d = a_.get(b, 0)
    if d != 0:
        a_[b] = 0
        a_[c] += d
    sum += (c-b)*d
    res.append(sum)
for x in res:
    print(x)

Measured memory_bytes: 22212
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    if( s=="Y" ){ cout << "Four" << endl; return 0; }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 3600
N, K = map(int, input().split())
S = input()

zero = []
tmp_zero_cnt = 0
tmp_zero_idx = -1
for i in range(N):
    if S[i] == "0":
        if tmp_zero_cnt == 0:
            tmp_zero_idx = i
        tmp_zero_cnt += 1
    else:
        if tmp_zero_cnt != 0:
            zero.append([tmp_zero_idx, tmp_zero_cnt])
            tmp_zero_cnt = 0
if tmp_zero_cnt != 0:
    zero.append([tmp_zero_idx, tmp_zero_cnt])

if len(zero) <= K:
    print(N)
else:
    zero = [[-1, 1]] + zero + [[N, 1]]
    M = len(zero)
    ans = 0
    for i in range(1, M - K):
        num = (zero[i + K][0] - 1) - (zero[i - 1][0] + zero[i - 1][1]) + 1
        if num > ans:
            ans = num
    print(ans)


Measured memory_bytes: 10484
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from collections import defaultdict

n = ni()
dic = defaultdict(int)

for _ in range(n):
    s = ns()
    cnts = [0]*26
    for si in s:
        cnts[ord(si)-ord('a')] += 1

    dic[tuple(cnts)] += 1

ans = 0
for _, v in dic.items():
    ans += v*(v-1) // 2

print(ans)



Measured memory_bytes: 36316
from collections import UserList


class Vector(UserList):
    def push_back(self, v):
        self.data.append(v)

    def pop_back(self):
        return self.data.pop()


def run():
    vec = Vector()
    count = int(input())

    for i in range(count):
        com, *val = [int(x) for x in input().split()]
        if com == 0:
            vec.push_back(val[0])
        elif com == 1:
            print(vec[val[0]])
        elif com == 2:
            vec.pop_back()
        else:
            ValueError('invalid command')


if __name__ == '__main__':
    run()



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

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n, -1) {}
  int root(int x) { return (par[x] < 0) ? x : par[x] = root(par[x]); }
  bool isSame(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y) {   // x is the ancestor of y
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] += par[y];
    par[y] = x;
  }
};

int main() {
  int n, q;
  while (cin >> n >> q, n) {
    vector<int> p(n);
    for (int i = 1; i < n; i++) {
      cin >> p[i], p[i]--;
    }
    UnionFind uf(n);
    vector<bool> marked(n, false);
    vector<P> op;
    for (int i = 0; i < q; i++) {
      char c;
      int v;
      cin >> c >> v, v--;
      if (c == 'Q') {
        op.push_back({0, v});
      } else {
        if (!marked[v]) op.push_back({1, v});
        marked[v] = true;
      }
    }
    marked[0] = true;
    for (int i = 0; i < n; i++) {
      if (!marked[i]) uf.unite(p[i], i);
    }
    ll ans = 0LL;
    for (int i = op.size() - 1; i >= 0; i--) {
      int v = op[i].second;
      if (op[i].first) {
        uf.unite(p[v], v);
      } else {
        ans += uf.root(v) + 1;
      }
    }
    cout << ans << endl;
  }
}



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

int N, M, K;
int** squares;

bool searchInSquares(int target_num)
{
	for (int i = 0; i <= M; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			if (squares[i][j] == target_num)
			{
				return true;
			}
		}
	}
	return false;
}

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

	squares = (int**)malloc(sizeof(int*)*(M + 1));
	for (int i = 0; i <= M; i++)
	{
		squares[i] = (int*)malloc(sizeof(int)*(N + 1));
		for (int j = 0; j <= N; j++)
		{
			if (i == 0 || j == 0)
			{
				squares[i][j] = N*i + M*j;
				continue;
			}
			squares[i][j] = (N - j)*i + (M - i)*j;
		}
	}

	if (searchInSquares(K))
		cout << "Yes";
	else
		cout << "No";

	for (int i = 0; i <= M; i++)
		free(squares[i]);
	free(squares);

	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007


int main() {
  IN(N);

  VI A(N+1), B(N);
  REP(i, N+1) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> B[i];
  }
  LL ans = 0;
  REP(i, N) {
    if (A[i] < B[i]) {
      B[i] -= A[i];
      ans += A[i];
      if (A[i+1] < B[i]) {
        ans += A[i+1];
        A[i+1] = 0;
      } else {
        A[i+1] -= B[i];
        ans += B[i];
      }
    } else {
      ans += B[i];
    }
  }
  OUT(ans);

  return 0;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	string s;
	cin >> s;

	char l = s[0];
	char r = s[s.size()-1];

	int turn=1;
	for (int i = 1; i < s.size()-1; i++) {
		if (s[i]==l||s[i]==r) {
			continue;
		}
		if (s[i-1]==s[i+1]) {
			continue;
		} else {
			s[i] = s[i-1];
			turn++;
		}
	}
	if (turn%2==0) {
		cout << "First" << "\n";
	} else {
		cout << "Second" << "\n";
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int P[N];
    for (int i = 0; i < N; ++i) cin >> P[i];
    int min=N+1;
    int count=0;
    for(int i=0;i<N;++i){
        if (P[i]<min){
            count++;
            min=P[i];
            if(min==1){
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	string h;
	int y,m,d;
	while(cin >> h) {
		if(h=="#") break;
		cin >> y >> m >> d;
		if( (y==31 and m>=5) or y>=32 ){
			cout << "? " << y-30 << " " << m << " " << d << endl;
		}else {
			cout << h << " " << y << " " << m << " " << d << endl;
		}
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>

using namespace std;

int logs[200005];

int main(){
    int n, k; cin>>n>>k;
    int maxl = 0;
    for(int i = 0; i < n; i++){
        cin>>logs[i];
        maxl = max(maxl, logs[i]);
    }
    long long l = 1, r = maxl, mid = (l + r) / 2;
    while(l != r){
        int res = 0;
        for(int i = 0; i < n; i++){
            if(logs[i] > mid){
                res += logs[i] / mid;
            }
        }
        if(res > k){
            l = mid + 1;
        }
        else{
            r = mid;
        }
        mid = (l + r) / 2;
    }
    cout<<l<<endl;
}


Measured memory_bytes: 4336