akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main(){
  int n,k;
  cin >> n >> k;
  ll t;
  ll ansg; cin >> ansg;
  ll mx=ansg;
  rep(i,n-1){
    cin >> t;
    mx = max(mx,t);
    ansg = gcd(t,ansg);
  }
  if(k%ansg==0 && k <=mx){ 
    cout << "POSSIBLE" << endl; 
  } else {
    cout << "IMPOSSIBLE" << endl; 
  }
  return 0;
}


Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati
 *  Institute : Pandit Deendayal Petroleum University
 *  Problem : Assembly Line Scheduling
 *  Time complexity : O(n)
 *  Space complexity : O(n)
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, w, i, j;
    cin>>n>>w;
    vector<int> weight(n), value(n);
    for(i=0;i<n;++i)
    {
        cin>>weight[i]>>value[i];
    }
    vector<vector<long long>> dp(n+1,vector<long long>(w+1,0));
    for(i=0;i<n+1;++i)
    {
        for(j=0;j<w+1;++j)
        {
            if(i == 0 || w == 0)
                dp[i][j] = 0;
            else if(j < weight[i-1])
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i-1]]+value[i-1]);
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 80256
a, b = map(int, input().split())

if a <= 0 <= b:
    print('Zero')
elif 0 < a < b:
    print('Positive')
elif a <= b < 0:
    a *= -1
    b *= -1
    if (b - a) % 2 == 0:
        print('Negative')
    else:
        print('Positive')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  int s, t;

  for (int i = 1; i <= n; i++){

    s = 0;
    t = i;

    while(true){
      s += t % 10;
      t =  t / 10;
      if (t == 0){
        break;
      }
    }

    if ((a <= s) && (s <= b)){
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static InputReader in;
    public static PrintWriter out;
    public static void main(String[] args) {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        String s = in.next();
        int[] sumE = new int[n];
        for (int i = 0; i < n; i++) {
            sumE[i] = (s.charAt(i) == 'E' ? 1 : 0);
            if (i > 0) sumE[i] += sumE[i - 1];
        }
        int ans = n;
        for (int i = 0; i < n; i++) {
            int cur = 0;
            if (i - 1 >= 0) cur += i - sumE[i - 1];
            if (i + 1 < n) cur += sumE[n - 1] - sumE[i];
            ans = Math.min(ans, cur);
        }
        out.println(ans);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() {
            return Long.parseLong(next());
        }
        public Double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 28544
#include <iostream>

using namespace std;

int main() {
	int a[3];
	int buf;

	cin >> a[0] >> a[1] >> a[2];
	
	
	for(int j = 0; j < 2; j++){
		for (int i = 0; i < 2; i++) {
			if (a[i] < a[i + 1]) {
				buf = a[i];
				a[i] = a[i + 1];
				a[i + 1] = buf;
			}
		}
	}

	cout << a[0] * 10 + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())

a = y - 2 * x
b = 4 * x - y

if a < 0:
  print('No')
elif a % 2 != 0:
  print('No')
elif b < 0:
  print('No')
elif b % 2 != 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9184
import sys
input = sys.stdin.readline
import collections

n = int(input().rstrip())
a = [a for a in input().split()]

b = collections.deque([], maxlen=n)
for i in range(n):
    b.append(a[i]) if i % 2 == 0 else b.appendleft(a[i])
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Measured memory_bytes: 22708
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  string str;
  cin >> str;
  n %= 26;

  for (int i = 0; i < str.length(); i++) {
    str[i] = (char)(((str[i] - 'A' + n)%26)+'A');
  }

  cout << str << endl;
  
  return 0;
}


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

int main() {
    int n;
    while (cin >> n) {
        int a, b, c;
        cin >> a >> b >> c;
        vector<int> ds(n);
        for (int i = 0; i < n; i++) {
            cin >> ds[i];
        }
        sort(ds.begin(), ds.end(), greater<int>());
        for (int i = 0; i < n; i++) {
            if ((double) c / a < (double) (c + ds[i]) / (a + b)) {
                c += ds[i];
                a += b;
            } else {
                break;
            }
        }
        cout << c / a << endl;
    }
}

Measured memory_bytes: 1216
s = input()

def dfs(i,f,ans):
  
  if i == len(s)-1:
    
    if ans == 7:
      print(f + '=7')
      exit()
    
  else:
    dfs(i+1, f + '+' + s[i+1], ans+int(s[i+1]))
    dfs(i+1, f + '-' + s[i+1], ans-int(s[i+1]))
      
dfs(0,s[0], int(s[0]))

Measured memory_bytes: 3064
let rec f i xs =
    match xs with
        |[] -> "Yes"
        |'U'::x -> f (i+1) x
        |'D'::x -> f (i+1) x
        |'R'::x -> if i%2=1 then f (i+1) x else "No"
        |'L'::x -> if i%2=0 then f (i+1) x else "No"
        |_ -> "No"
stdin.ReadLine() |> Seq.toList |> f 1 |> stdout.WriteLine

Measured memory_bytes: 11220
#include<stdio.h>
int main(void)
{
  int A,B,C,D,x;
  x=scanf("%d %d %d %d",&A,&B,&C,&D);
  while(x)
  {
    C-=B;if(C<=0)return printf("Yes"),0;
    A-=D;if((A<=0))return printf("No"),0;
  }
}

Measured memory_bytes: 1724
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int mod = 1e6 + 3;
int f[mod];
int pow(int a,int b,int mod) {
	int ans = 1;
	while (b) {
		if (b & 1) {
			ans = (1ll * ans * a) % mod;
		}
		b /= 2;
		a = (1ll * a * a) % mod;
	}
	return ans;
}
int main(void) {
	f[0] = 1;
	for (int i = 1;i < mod;++i)
		f[i] = (1ll * f[i - 1] * i) % mod;
	int Q;
	cin>>Q;
	while (Q --) {
		int x,d,n;
		cin>>x>>d>>n;
		if (!d || !x) {
			cout << pow(x,n,mod) << '\n';
		} else {
			int cnt = 1ll * x * pow(d,mod - 2,mod) % mod;
			int l = cnt,r = cnt + n - 1;
			if (r >= mod) {
				cout << "0\n";
			} else {
				int ans;
				ans = (1ll * f[r] * pow(f[l],mod - 2,mod)) % mod;
				ans = (1ll * ans * pow(d,n - 1,mod)) % mod;
				ans = (1ll * ans * x) % mod;
				cout << ans << '\n';
			}
		}
	} 
    return 0;
}

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

int main(){
    long long n;
    long long sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        long long tmp;
        cin >> tmp;
        sum += tmp;
    }
    cout << sum - n << endl;
    return 0;
}

Measured memory_bytes: 256
// 20:34 -
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if (a*b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int l[] = new int[n];
        int d[] = new int[n + 1];
        d[0] = 0;
        int x = stdIn.nextInt();
        for (int i = 0; i < l.length; i++) {
            l[i] = stdIn.nextInt();
        }
        int c = 1;
        for (int i = 0; i < l.length; i++) {
            d[i + 1] = d[i] + l[i];
            if (d[i + 1] > x)
                break;
            c++;
        }
        System.out.println(c);

    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

pair<int, int> crack(int n) {
    int st = sqrt(n);
    int fac = n / st;
    while (n % st) {
        st += 1;
        fac = n / st;
    }

    return make_pair(st, fac);
}

inline ll qpow(ll a, int n) {
    ll ans = 1;
    for(; n; n >>= 1) {
        if(n & 1) ans *= 1ll * a;
        a *= a;
    }
    return ans;
}
// ================================================ //

int a, b;

int main() {
    //freopen("input.txt", "r", stdin);

    cin >> a >> b;

    bool ans = false;
    _rep(x, 0, a) {
        int y = a - x;
        if(2*x + 4*(y) == b) {
            ans = true;
            break;
        }
    }

    ans ? printf("Yes\n") : printf("No\n");
}

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

int main() {
  int n;
  long long ans;
  long long a0=0,a1=0;
  long long s=0;

  cin >> n;

  int a[n];
  long long lsum=0,rsum=0;

  for(int i=0;i<n;i++) {
    cin >> a[i];
    s += a[i];
  }

  float sl = (float)s/2;

  for(int i=0;i<n;i++) {
    if(lsum<sl){
      lsum += a[i];
    }
    else {
      rsum += a[i];
    }
  }

  //cout << lsum << " " << rsum << endl;

  a0 = lsum - rsum;

  lsum=0;rsum=0;

  for(int i=n-1;i>=0;i--) {
    if(rsum<sl){
      rsum += a[i];
    }
    else {
      lsum += a[i];
    }
  }

  //cout << lsum << " " << rsum << endl;

  a1 = rsum - lsum;

  ans = min(a0,a1);

  //cout << a0 << " " << a1 << endl;

  cout << ans << endl;
}


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

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

  int N = X / 100 + 1;

  for (int onigiri = 0; onigiri <= N; ++onigiri) {
    for (int sandwich = 0; sandwich <= N; ++sandwich) {
      for (int cookie = 0; cookie <= N; ++cookie) {
        for (int cake = 0; cake <= N; ++cake) {
          for (int candy = 0; candy <= N; ++candy) {
            for (int pc = 0; pc <= N; ++pc) {
              int sum = 100 * onigiri + 101 * sandwich + 102 * cookie +
                        103 * cake + 104 * candy + 105 * pc;
              if (sum == X) {
                cout << 1 << endl;
                return 0;
              }
            }
          }
        }
      }
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 256
import heapq
import sys
input=sys.stdin.readline

N,Q=map(int,input().split())
H=[]
for i in range(N):
    s,t,x=map(int,input().split())
    H.append([s-x,t-x,x])
H.sort()
#print(H)
P=0
q=[]
heapq.heapify(q)
for i in range(Q):
    n=int(input())
    #print("A",len(q))
    if P<N:
        while H[P][0]<=n:
            heapq.heappush(q,[H[P][2],H[P][0],H[P][1]])
            P+=1
            if P==N:
                break
    #print("B",i,len(q))
    if len(q)>0:
        while q[0][2]<=n:
            heapq.heappop(q)
            if len(q)==0:
                break
    if len(q)==0:
        print(-1)
    else:
        print(q[0][0])

Measured memory_bytes: 64520
N = int(input())
g = {i: [] for i in range(N)}
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
c = list(map(int, input().split()))
c.sort()
print(sum(c[:-1]))
nums = [0] * N
stack = [0]
while stack:
    d = stack.pop()
    nums[d] = c.pop()
    for node in g[d]:
        if nums[node] == 0:
            stack.append(node)
print(' '.join(map(str, nums)))

Measured memory_bytes: 6520
#include<stdio.h>
int main (void){
    int N_num;
    int K_num;
    int dp[258][3][2]={{{0}}};
    int i,j,k,l;
    int date,kind;
    int ans=0;
    scanf("%d%d",&N_num,&K_num);
    for(i=0;i<N_num;i++){
        for(j=0;j<3;j++){
            for(k=0;k<2;k++){
                dp[i][j][k]=0;
            }
        }
    }
    for(i=0;i<3;i++)dp[0][i][0]=1;
 
    for(i=0;i<K_num;i++){
        scanf("%d%d",&date,&kind);
        for(j=0;j<3;j++){
            if(j!=kind-1){
                for(k=0;k<2;k++){
                    dp[date-1][j][k]=-1;
                }
            }
        }
    }
    for(i=0;i<N_num;i++){
        for(j=0;j<3;j++){
            if(dp[i][j][0]!=-1){
                for(k=0;k<2;k++){
                    switch(k){
                    case 0:
                        for(l=0;l<3;l++){
                            if(j==l){
                                if(dp[i+1][l][1]!=-1){
                                    dp[i+1][l][1]+=dp[i][j][0];
                                    dp[i+1][l][1]%=10000;
                                }
                            }else{
                                if(dp[i+1][l][0]!=-1){
                                    dp[i+1][l][0]+=dp[i][j][0];
                                    dp[i+1][l][0]%=10000;
                                }
                            }
                        }
                        break;
                    case 1:
                        for(l=0;l<3;l++){
                            if(j==l){
                            }else{
                                if(dp[i+1][l][0]!=-1){
                                    dp[i+1][l][0]+=dp[i][j][1];
                                    dp[i+1][l][0]%=10000;
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
    /*for(j=0;j<3;j++){
        printf("###");
        for(i=0;i<N_num;i++){
            for(k=0;k<2;k++){
                printf("%3d",dp[i][j][k]);
            }
            printf(" ");
        }
        puts("");
    }*/
    for(i=0;i<3;i++){
        for(j=0;j<2;j++){
            if(dp[N_num-1][i][j]!=-1){
                ans+=dp[N_num-1][i][j];
                ans%=10000;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 604
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = 0
for i in range(N):
    if i >= K:
        ans += Y
    else:
        ans += X
print(ans)


Measured memory_bytes: 38768
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N
for i in range(M):
    if left<List[i][0]:
        left = List[i][0]
    if List[i][1]<right:
        right = List[i][1]

if right<left:
    print(0)
else:
    print(right-left+1)

Measured memory_bytes: 27344
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n;
char s[3][105];
int main(){
  cin>>n;
  REP(i,3) scanf("%s",s[i]);

  int res=0;
  REP(i,n){
    set<char> S;
    REP(j,3) S.insert(s[j][i]);
    res+=S.size()-1;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
    den=reduce(lambda x,y:x*y%mod,range(1,r+1))
    return num*pow(den,mod-2,mod)%mod
def main():
    n,a,b=map(int,input().split())
    mod=10**9+7
    print((pow(2,n,mod)-1-mod_comb4(n,a)-mod_comb4(n,b))%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();
const long double EPS =1e-9;

int main(){
    long double l;
    cin >> l;
  
   long double res=pow(l/3.0,3);
  std::cout << std::fixed;
	std::cout << std::setprecision(10) <<res<<endl;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    rep(i,N-1) if(S[i] != S[i+1]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c ;
  cin >> c;
  if(c =='a' || c == 'i'|| c =='u' || c == 'e' ||c =='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define w(x) int x; cin>>x; while(x--)
#define mo 998244353
#define d arr0.size()
#define ba back()
using namespace std;
ll p=748683265;
int main(){
	ll r;
  	cin>>r;
  	double l=2*(3.141592653589793238462);
  	double z=l*r;
  	cout<<fixed<<setprecision(21)<<z<<endl;
  return 0;
}

Measured memory_bytes: 3784
#include <cstring>
#include <algorithm>
#include <cstdio>

const int N = 200010;
int _w;

int n, m, a[N], ans;
int cnt[N], vis[N];

void ins( int x ) {
	++cnt[x];
	int y = x - cnt[x] + 1;
	if( y > 0 ) {
		++vis[y];
		ans -= vis[y] == 1;
	}
}

void del( int x ) {
	int y = x - cnt[x] + 1;
	--cnt[x];
	if( y > 0 ) {
		--vis[y];
		ans += !vis[y];
	}
}

void prelude() {
	ans = n;
	for( int i = 1; i <= n; ++i )
		ins( a[i] );
}

void modify( int x, int y ) {
	del( a[x] );
	a[x] = y;
	ins( a[x] );
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	prelude();
	while( m-- ) {
		int x, y;
		_w = scanf( "%d%d", &x, &y );
		modify(x, y);
		printf( "%d\n", ans );
	}
	return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[200005],b[200005];
	int n, t, sum;
	while(cin >> n >> t)
	{
		for(int i = 0; i < n; i++)
			cin >> a[i];
		sum = 0;
		for(int i = 1; i < n; i++)
			sum += min(a[i] - a[i - 1], t);
		printf("%d\n", sum + t);
	}
}


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

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

    for (int i = 0; i < s.length(); i++)
    {
        s[i] = ((s[i] - 'A' + n) % 26) + 'A';
    }

    cout << s << endl;
}

Measured memory_bytes: 3616
K, X = map(int, input().split())

blacks = {}
blacks[X] = True
for i in range(K):
    if -1000000 <= i and i <= 1000000:
        blacks[X - i] = True
        blacks[X + i] = True

blacks_list = list(blacks.keys())
print(' '.join([str(x) for x in sorted(blacks_list)]))

Measured memory_bytes: 3060
import java.util.*;

class Main{
    public static void main(String args[]){
        int count = 0;
        String ans[] = {"Good","Bad"};
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char a[] = new char[str.length()];
        for(int i = 0;i < str.length();i++){
            a[i] = str.charAt(i);
        }if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]){
            count++;
        }
        System.out.print(ans[count]);
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    string c1, c2, c3;
    cin >> c1 >> c2 >> c3;
    print(c1[0] << c2[1] << c3[2]);
}

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

using namespace std;

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

    vector<int> A(N);
    for(int i=0; i<N; i++)cin >> A.at(i);

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

    int Amax = A.back();
    vector<int> dp(Amax+1, 0);
    for(int a : A){
        if(dp.at(a) == -1){
            dp.at(a) = 2;
            continue;
        }else if(dp.at(a) != 0){
            continue;
        }
        dp.at(a) = -1;
        for(int i = 2*a; i<=Amax; i+=a){
            dp.at(i)++;
        }
    }

    int res = 0;
    for(int a : A)
        if(dp.at(a) == -1)res++;
    cout << res << endl;
}

Measured memory_bytes: 7880
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;
                                                          
template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

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

const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);                                
    string s, t;
    cin >> s >> t;
    vector<vector<int>> l(sz(s) + 1, vector<int>(sz(t) + 1));
    for (int i = 1; i <= sz(s); i++)
        for (int j = 1; j <= sz(t); j++) {
            if (s[i - 1] == t[j - 1]) 
                l[i][j] = l[i - 1][j - 1] + 1;
            else
                l[i][j] = max(l[i - 1][j], l[i][j - 1]);
        }
    string ans = "";
    int i = sz(s), j = sz(t);
    while (i && j) {
        if (s[i - 1] == t[j - 1]) {
            ans += s[i - 1];
            i--, j--;
        } else if (l[i - 1][j] > l[i][j - 1]) {
            i--;
        } else
            j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return false;                                                       
}


Measured memory_bytes: 35584
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n = n_in()
x = s_in()

popcnt = sum(i == '1' for i in x)

def mod_add(a, b):
  return (a+b)%MOD

def mod_sub(a, b):
  return (a+MOD-b)%MOD

def mod_mul(a, b):
  return a*b%MOD

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = (1,0,a)
    w = (0,1,b)
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return (w[0],w[1])

def mod_inv(a):
    x,_  = extgcd(a, MOD)
    return (MOD+x%MOD)%MOD

def mod_div(a, b):
    return a*mod_inv(b)%MOD

def mod_pow(a, b):
    res = 1
    while b > 0:
        if b & 1:
            res = res * a % MOD
        a = a * a % MOD
        b >>= 1
    return res

memo = {}

MOD = popcnt+1
memo[MOD] = []
for i in range(n):
    memo[MOD].append(mod_pow(2, i))
    

if popcnt-1 > 0:
    MOD = popcnt-1
    memo[MOD] = []
    for i in range(n):
        memo[MOD].append(mod_pow(2, i))

base_1 = 0
base_2 = 0
for i in range(n):
    if x[i] == '1':
        MOD = popcnt+1
        base_1 = mod_add(base_1, memo[MOD][n-i-1])

    
        if popcnt-1 > 0:
            MOD = popcnt-1
            base_2 = mod_add(base_2, memo[MOD][n-i-1])


for i in range(n):
    cnt = 0
    if x[i] == '0':        
        MOD = popcnt + 1
        current = mod_add(base_1, memo[MOD][n-i-1])
        cnt += 1
        while current > 0:
            MOD = sum(c=='1' for c in bin(current)[2:])
            current = current%MOD
            cnt += 1
    else:
        MOD = popcnt - 1
        if MOD == 0:
            print(0)
            continue
        current = mod_sub(base_2, memo[MOD][n-i-1])
        cnt += 1
        while current > 0:
            MOD = sum(c=='1' for c in bin(current)[2:])
            current = current%MOD
            cnt += 1

    print(cnt)


Measured memory_bytes: 103012
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
   
 
   cin >> n;
  
   
  
   if(n==7||n==5||n==3){
     cout << "YES" << endl;
   }else{
     cout << "NO" << endl;
   }
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>

using namespace std;

int
main ( )
{
  int k = 0, u = 0, p = 0, c = 0;

  for ( ; ; )
  {
    const int ch = getchar ( );

    if ( ch == '\n' ) break ;
    switch ( ch )
    {
      case 'K': ++k; break ;
      case 'U': ++u; break ;
      case 'P': ++p; break ;
      case 'C': ++c; break ;
    }
  }
  printf ( "%d\n", min ( min ( k, u ), min ( p, c ) ) );

  return ( 0 );
}

Measured memory_bytes: 0
/**
 *      ABC 93 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/29
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, K; cin >> A >> B >> K;
    if (A + K - 1 < B - K + 1){
        for (int i = 0; i < K; ++i) {
            cout << A + i << '\n';
        }
        for (int i = 0; i < K; ++i) {
            cout << B - K + 1 + i << '\n';
        }
    }
    else {
        for (int i = 0; i < B - A + 1; ++i) {
            cout << A + i << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 256
<?php
$current = array();
$prev = array();

while($line = trim(fgets(STDIN))) {
	list($ind, $date) = explode(',', $line);
	if (isset($prev[$ind])) {
		$prev[$ind]++;
	} else {
		$prev[$ind] = 1;
	}
}

while($line = trim(fgets(STDIN))) {
	list($ind, $date) = explode(',', $line);
	if (isset($current[$ind])) {
		$current[$ind]++;
	} else {
		$current[$ind] = 1;
	}
}

ksort($current);

foreach ($current as $ind => $cnt) {
	if (isset($prev[$ind])) {
		printf("%d %d\n", $ind, $cnt + $prev[$ind]);
	}
}

Measured memory_bytes: 6628
#include<stdio.h>
void bubbleSort(int* ,int);
int main(){
  int array[100];
  int N,i;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&array[i]);
  bubbleSort(array,N);
  return 0;
}
void bubbleSort(int *A,int N){
  int j;
  int flag=1,count=0;
  int keep;
  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	keep=A[j];
	A[j]=A[j-1];
	A[j-1]=keep;
	flag=1;
	count++;
      }
    }
  }
  for(j=0;j<N-1;j++)
    printf("%d ",A[j]);
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> v(5);
    rep(i,5) cin >> v[i];
    rep(i,5) {
        if(v[i]==0) cout << i+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
 
int main()
{
    int a,b,c;
    int t;
    scanf("%d %d %d",&a,&b,&c);
    while(!(a<=b&&b<=c)){
        if(a>b){
            t=a;
            a=b;
            b=t;
        }
        if(b>c){
            t=b;
            b=c;
            c=t;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int n;cin >> n;
  int ans=0;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int l=0;l<n;l++){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main() {
    string a,b;
    cin >> a >> b;
    if (a+b[b.size()-1] == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(1, n).filter(i -> {
				int digitSum = digitSum(i);
				return (digitSum >= a) && (digitSum <= b);
			}).sum());
		}
	}

	/**
	 * @param number
	 * @return numberの10進数の各桁の合計
	 */
	private static int digitSum(int number) {
		int result = 0;
		while (number > 0) {
			result += number % 10;
			number /= 10;
		}
		return result;
	}
}


Measured memory_bytes: 36008
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long pow(long a, long n, long mod) {
		long ret = 1;
		for (; n > 0; n >>= 1, a = a * a % mod) {
			if (n % 2 == 1) {
				ret = ret * a % mod;
			}
		}
		return ret;
	}

	long inv(long a, long mod) {
		return pow(a, mod - 2, mod);
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		long[] a = new long[p];
		for (int i = 0; i < p; ++i) {
			a[i] = sc.nextLong();
		}
		long[] fac = new long[p];
		long[] ifac = new long[p];
		{
			fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
			for (int i = 2; i < fac.length; ++i) {
				fac[i] = i * fac[i - 1] % p;
				ifac[i] = inv(fac[i], p);
			}
		}
		long[] c = new long[p];
		for (int i = 0; i < p; ++i) {
			long res = 0;
			for (int j = 0; j < i; ++j) {
				res = res + c[j] * fac[i] % p * ifac[i - j] % p;
				res %= p;
			}
			c[i] = (a[i] - res + p) % p * inv(fac[i], p) % p;
		}

		long[] b = new long[p];
		long[][] coe = new long[2][p];
		coe[0][0] = 1;
		for (int i = 0; i < p; ++i) {
			for (int j = 0; j < p; ++j) {
				b[j] = (b[j] + coe[i % 2][j] * c[i] % p) % p;
			}
			for (int j = 0; j < p; ++j) {
				coe[(i + 1) % 2][j] = 0;
			}
			for (int j = 0; j + 1 < p; ++j) {
				coe[(i + 1) % 2][j + 1] = coe[i % 2][j];
			}

			for (int j = 0; j + 1 < p; ++j) {
				coe[(i + 1) % 2][j] += coe[i % 2][j] * (p - i) % p;
				coe[(i + 1) % 2][j] %= p;
			}
		}
		for (int i = 0; i < p; ++i) {
			System.out.print(b[i] + (i == p - 1 ? "\n" : " "));
		}

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 27076
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
#define MOD 1000000007
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
int power(int x,int y){ int res = 1; while(y>0){   if(y&1) res = (res*x)%MOD;
        y >>= 1; x = (x*x)%MOD; } return res; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

bool check(int mid,int x,int y){
    int ret = 0;
    for(int i=max(mid/2-10,1LL);i<=min(mid/2+10,mid);i++){
        int a = i,b = mid-i+1;
        if(a >= x) a++;
        if(b >= y) b++;
        ret = max(ret,a*b);
    }
    return ret < x*y;
}

void solve(){
    int q; cin>>q;

    while(q--){
        int x,y; cin>>x>>y;

        int s = 1,e = 3e9;
        int ans = 0;

        while(s <= e){
            int mid = (s+e)>>1;
            if(check(mid,x,y)) ans = mid,s = mid+1;
            else e = mid-1;
        }

        cout<<ans<<endl;
    }
}
 
signed main(){

    FastRead; 


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] N = S.split("");
        int cnt = 0;
        for (int i=0; i<N.length; i++) {
            if (i > 0 && N[i-1].equals(N[i])) {
                if (N[i-1].equals("0"))
                    N[i] = "1";
                else
                    N[i] = "0";
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 33760
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

void solve() {
    string s;
    cin >>s;
    if (s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) printf("Yes");
    else printf("No");
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
std::vector<int>g[200005];
int parent[200005];
//count as root, not as the smallest index...

long long dfs(int u,int n){
    long long res = 0;
    if(parent[u]<u) res += (long long)(u-parent[u])*(long long)(n-u+1);
    else res += (long long)(u)*(long long)(parent[u]-u);
    for(int i = 0; i < (int)g[u].size(); i++){
        int v = g[u][i];
        if(parent[v]==0 && v!=1){
            parent[v] = u;
            res += dfs(v,n);
        }
    }
    //printf("u = %d, parent = %d, res = %lld\n",u,parent[u],res);
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    printf("%lld\n",dfs(1,n));
    return 0;
}


Measured memory_bytes: 27472
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
void solve()
{
ll n,k;
cin>>n>>k;
vector<ll> a(n),v(n,-1);
for (int i = 0; i < n; i++)
{
    cin>>a[i];
    a[i]--;
}
int cur=0;
ll cnt=0;
while (true)
{
 if(v[cur]!=-1||cnt==k)
 break;
v[cur]=cnt;
cur=a[cur];
cnt++;
}
if (k>cnt)
{
    k=k-v[cur];
    cnt-=v[cur];
    k=k%cnt;
    for (int i = 0; i < k; i++)
    {
        cur=a[cur];
    }
}
cout<<cur+1<<endl;
}
int main()
{
     
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 6356
def djkstra(a,in_connect_list,v):
    out_shortest_list = [10**15 for i in range(v)]
    out_shortest_list[a] = 0
    searching_list = [a]
    
    while searching_list != []:
        new_search_list = []
        for i in searching_list:
            for c in in_connect_list[i]: 
                if out_shortest_list[c] == 10**15:
                    out_shortest_list[c] = 1 + out_shortest_list[i]
                    new_search_list.append(c)
        searching_list = new_search_list
    return out_shortest_list

n, u, v = [ int(v) for v in input().split() ]
u -= 1
v -= 1
connnect = [ [] for i in range(n) ]
for i in range(n-1):
    a, b = [ int(v) for v in input().split() ]
    a -= 1
    b -= 1
    connnect[a].append(b)
    connnect[b].append(a)

takahashi_time = djkstra(u, connnect, n)
aoki_time = djkstra(v, connnect, n)

ans_time = [ aoki_time[i]  for i in range(n) if aoki_time[i] >= takahashi_time[i] ]

print(max(0, max(ans_time)-1))


Measured memory_bytes: 69996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    ArrayList<Date> date=new ArrayList<>();
	    while(true){
		String str=reader.readLine();
		if(str.equals("#")){
		    break;
		}
		String s[]=str.split(" ");
		String gen=s[0];
		int y=Integer.parseInt(s[1]);
		int m=Integer.parseInt(s[2]);
		int d=Integer.parseInt(s[3]);

		date.add(new Date(gen,y,m,d));
	    }
	    for(int i=0;i<date.size();i++){
		System.out.println(date.get(i).gen+" "+date.get(i).y+" "+date.get(i).m+" "+date.get(i).d);
	    }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    static class Date{
	String gen;
	int y;
	int m;
	int d;
	public Date(String gen,int y,int m,int d){
	    this.gen=gen;
	    this.y=y;
	    this.m=m;
	    this.d=d;
	    init();
	}
	void init(){
	    if(y>31||(y==31&&m>4)){
		gen="?";
		y=y-30;
	    }
	}
    }
}



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

int main(){
    string s;
    cin >> s;
    int a = s.at(0)-'0'; int b = s.at(1)-'0'; int c = s.at(2)-'0'; int d = s.at(3)-'0';
    for (int zentansaku = 1; zentansaku < (1 << 4); zentansaku++){
        bitset<4>bit(zentansaku);
        if (bit.test(1)){
            b *= -1;
        }
        if (bit.test(2)){
            c *= -1;
        }
        if (bit.test(3)){
            d *= -1;
        }
        if (a+b+c+d == 7){
            cout << a;
            if (b >= 0) cout << "+";
            cout << b;
            if (c >= 0) cout << "+";
            cout << c;
            if (d >= 0) cout << "+";
            cout << d << "=7" << "\n";
            return 0;
        }
    }
}

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

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)

int main() {
	ll n, p;
	ll ans = 0;
	cin >> n >> p;
	string s;
	cin >> s;

	if (p == 2 || p == 5) {
		rep(i, n) {
			if ((s[i] - '0') % p == 0)ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}
	else {
		vector<ll> sum(n + 1);
		vector<ll> c(p);
		ll buf = 1;
		for (int i = n - 1; i >= 0; i--) {
			sum[i] = (sum[i + 1] + (s[i] - '0') * buf % p) % p;
			buf *= 10;
			buf %= p;
		}
		for (int i = n; i >= 0; i--) {
			ans += c[sum[i]];
			c[sum[i]]++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};

vector<int> read(int n, int k){
	vector<int> vec(n);
	for(int i = 0; i < k; ++i) cin >> vec[i];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = k; i < n; ++i)
		vec[i] = (a * 1ll * vec[i - 2] + b * 1ll * vec[i - 1] + c) % d;
	return vec;
}

void solve(){

	int n;
	cin >> n;
	cout << ( n ^ 1) << "\n";
	return;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        double x1,y1,x2,y2,x3,y3,x4,y4;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if((y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s;
    cin >> s;
    int kaisuu[26] = {};
    REP(i,4){
        kaisuu[int(s[i] - 'A')] ++;
    }
    int cnt = 0;
    REP(i,26){
        if(kaisuu[i] == 2) cnt ++;
    }
    if(cnt == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
// Poor
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;

int main ()
{
    int A,B,C;
    cin >> A >> B >>C;
    int cnt = 0;
    if (A == B ) {
        cnt++;
    }
    if (B == C) {
        cnt++;
    }
    if (A == C) {
        cnt++;
    }
    if (cnt == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 888