akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> A(N,vector<int>(M));
    rep(i,N){
        rep(j,M){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    set<int> s;
    rep(i,M){
        s.insert(i);
    }
    int ans=N;
    vector<int> count(M);
    while(!s.empty()){
        rep(i,M){
            count[i]=0;
        }
        rep(i,N){
            rep(j,M){
                if (s.count(A[i][j])){
                    count[A[i][j]]++;
                    break;
                }
            }
        }
        int MAX=0,next;
        rep(i,M){
            if (chmax(MAX,count[i])){
                next=i;
            }
        }
        chmin(ans,MAX);
        s.erase(next);
    }
    cout << ans << endl;
}

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

int main(void){
  int n,k; cin >> n;
  string str; cin >> str;
  cin >> k;
  //cout << str[1] << endl;

  char replace = str[k-1];
  string ret = "";
  for( string::iterator itr=str.begin(); itr!=str.end(); ++itr){
    if ( *itr != replace) ret += '*';
    else ret += *itr;
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

//ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 44444

ll t[MAX], v[MAX];
ld x, ans2;
ld vm[MAX];
ld n, sum, temp;

int main(void) {
  cin >> n;

  FOR(i, 0, n) {
	cin >> t[i];
	t[i] *= 2;
	sum += t[i];
  }

  FOR(i, 0, n) cin >> v[i];

  FOR(i, 0, sum / 2) {
	vm[i] = (ld)i / 2;
  }

  FOR(i, sum / 2, sum) {
	vm[i] = (sum - (ld)i) / 2;
  }

  temp = 1;
  FOR(i, 0, n) {
	FOR(j, 0, temp) {
	  if (vm[j] > v[i] + ((ld)temp - 1 - j) / 2) vm[j] = v[i] + ((ld)temp - 1 - j) / 2;
	}
	FOR(j, temp, t[i] + temp) {
	  if (vm[j] > v[i]) vm[j] = v[i];
	}
	temp += t[i];
	FOR(j, temp, sum) {
	  if (vm[j] > vm[j - 1]) vm[j] = vm[j - 1] + 0.5;
	}
  }

  FOR(i, 0, sum) {
	x = (vm[i + 1] - vm[i]) / 4;
	ans2 += vm[i] / 2 + x;
  }

  //FOR(i, 0, sum + 1) cout << (ld)i / 2 << " " << vm[i] << endl;
  
  cout.precision(20);
  cout << fixed << ans2 << endl;
  
  return 0;
}


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

int main(){
	int R0,W0,C,R,x;
	while(1){
		cin>>R0>>W0>>C>>R;
		if(R0==0&&W0==0&&C==0&&R==0) break;
		x=0;
		while(1){
			if((R0+R*x)/W0>=C) break;
			x++;
		}
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 2996
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(b-1>c)cout<<int(a*(1.*c/b));
	else cout<<int(a*(1.*(b-1)/b));
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >>k;
    vector<ll> h;
    ll in[n];
    ll max=0;
    for(int i=0;i<n;i++){
        cin >> in[i];
        h.push_back(in[i]);
        max+=in[i];
    }

    if(k>=n){
        cout << '0' << endl;
    }else{
        sort(h.begin(),h.end(),greater<ll>());
        for(int i=0;i<k;i++){
            max=max-h[i];
        }
        cout << max << endl;
    }
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> res(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		string S;
		cin >> S;
		int last = -1;
		for (int j = 0; j < W; j++) {
			if (S[j] == 'c') last = j;
			if (last < 0) {
				res[i][j] = -1;
			}
			else {
				res[i][j] = j - last;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << res[i][j] << " \n"[j + 1 == W];
		}
	}
	return 0;
}



Measured memory_bytes: 3196
import java.util.*;
 
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
 
		int num = sc.nextInt();
		int money = sc.nextInt();
 
		for(int x=0;x<money/10000+1;x++){
			
			for(int y=0;y<(money-10000*x)/5000+1;y++){
 
				
				int rval = money - (x*10000 + y*5000);
				
				int m = rval/1000;
				
				if((x + y + m) == num){
					answer(x,y,m);
					return;
				}
			}
		}
		answer(-1);
 		
	}
 
	private static void answer(int n){
		System.out.println("-1 -1 -1");
	}
 
	private static void answer(int a,int b,int c){
		System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, m;
    cin >> n >> m;

    ll c = m / n;
    for(ll i = c; i > 1; i--)
    {
        if(m % i == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
import math
K=int(input())
N=0
k=K*K
d1=[0]*int(k)
i=0
j=0
for b in range(K):
    for c in range(K):
        d1[i]=math.gcd((c+1),(b+1))
        i+=1
for a in range(K):
    for x in d1:
        N+=math.gcd(x,(a+1))
print(N)

Measured memory_bytes: 9324
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	int sum = 0;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		sum ^= a[i];
	}
	rep(i, n) cout << (sum ^ a[i]) << ' ';
	cout << '\n';
}

Measured memory_bytes: 3988
s = input()
n = len(s)

ans = 0
for i in range(2**(n-1)) :
    wa = 0
    kou = s[0]
    for j in range(n-1):
        if i>>j & 1 :
            wa += int(kou)
            kou = s[j+1]
        else :
            kou += s[j+1]
        if j == n-2 :
            wa += int(kou)
    ans += wa
if n == 1 :
    print(int(s))
else :
    print(ans)


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

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
	int n;
	int count=0;
	cin>>n;
	int cp=n;
	for(int i=0;i<n;i++){
		int tmp=GetDigit(cp);
		if(tmp%2==1){
			count++;
		}
		cp--;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char S[105][105];
int xx[]={0,-1,0,1};
int yy[]={-1,0,1,0};
int N,M;
void dfs(int x,int y,char temp_c){
    int i,j,temp_x,temp_y;
    S[x][y]='.';
    for(i=0;i<4;i++)
    for(j=0;j<4;j++){
        temp_x=x+xx[i];
        temp_y=y+yy[i];
        if(S[temp_x][temp_y]!=temp_c||temp_x<0||temp_x>=N||temp_y<0||temp_y>=M)
        continue;
        dfs(temp_x,temp_y,temp_c);
    }
}
int main(){
    int i,j,sum;
    while(cin>>N>>M&&(N||M)){
        sum=0;
        for(i=0;i<N;i++)
        for(j=0;j<M;j++)
        cin>>S[i][j];
        for(i=0;i<N;i++)
        for(j=0;j<M;j++)
        if(S[i][j]!='.'){
        dfs(i,j,S[i][j]);
        sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int A, B; cin >> A >> B;
  cout << max(0, A - 2 * B) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int n,a[101],counter = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        for(int j = (n-1); j > i; --j){
            if(a[j-1]>a[j]){
                swap(a[j-1], a[j]);
                counter++;
            }
        }
    }
    for(int i = 0; i < n; ++i){
        cout << a[i];
        if(i == (n-1))cout << endl;
        else cout << " ";
    }
    cout << counter << endl;
}


Measured memory_bytes: 3088
#include<stdio.h>   //B - Kagami Mochi

int main(){

    int n;
    scanf("%d",&n);

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

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(ricecake[i]==ricecake[j]){
                ricecake[j]=0;
            }
        }
    }
    int unique_count=0;
    for(int i=0;i<n;i++){
        if(ricecake[i]>0){
            unique_count++;
        }
    }
    printf("%d\n",unique_count);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010


int main(){
  int n;
  int a[SIZE];

  scanf("%d",&n);

  for(int i=0;i<3*n;i++){
    scanf("%d",a+i);
  }

  ll sum_f[SIZE], sum_b[SIZE];

  priority_queue<int> pq;
  ll c_sum = 0;
  
  for(int i=0;i<3*n;i++){
    pq.push(-a[i]);
    c_sum += a[i];
    
    if(pq.size() < n){
      sum_f[i] = -LLINF;
      continue;
    }

    if(pq.size() > n){
      c_sum -= -pq.top();
      pq.pop();
    }

    sum_f[i] = c_sum;
  }

  priority_queue<int> pq2;
  ll c_sum2 = 0;
  
  for(int i=3*n-1;i>=0;i--){
    pq2.push(a[i]);
    c_sum2 += a[i];
    
    if(pq2.size() < n){
      sum_b[i] = LLINF;
      continue;
    }

    if(pq2.size() > n){
      c_sum2 -= pq2.top();
      pq2.pop();
    }

    sum_b[i] = c_sum2;
  }

  ll ans = -LLINF;
  
  for(int i=0;i<3*n-1;i++){
    ans = max(ans, sum_f[i] - sum_b[i+1]);
  }

  printf("%lld\n",ans);
  
  
  return 0;
}


Measured memory_bytes: 7160
#include<cstdio>
#include<cstring>	
char s[15],t[15];
int main(){
	scanf("%s",s);
	getchar();
	scanf("%s",t);
	int length=strlen(s);
	t[length]={'\0'};
	if(strcmp(s,t)==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const long LMIN=-1l<<63;
struct TAG{long* array;int size,head,tail,count;};
typedef struct TAG* DEQUE;
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Max(const long x,const long y){return x<y?y:x;}
static inline void* xmalloc(size_t size){void* p=malloc(size);if(p==NULL){exit(EXIT_FAILURE);}return p;}
static inline DEQUE CREATE(void)
{
  const int size=10000;
  struct TAG* deque=(DEQUE)xmalloc(sizeof(struct TAG));
  deque->array=(long*)xmalloc(sizeof(long)*size);
  deque->size=size;deque->head=deque->tail=deque->count=0;return deque;
}
static inline void DELETE(DEQUE deque){free(deque->array);free(deque);}
static inline int PREV(DEQUE deque,int index){return(!index)?deque->size-1:index-1;}
static inline int NEXT(DEQUE deque,int index){return(index+1)%deque->size;}
static inline void PUSH(DEQUE deque,long val,int back)
{
  //front=0,back=1;
  if(deque->count==deque->size){exit(EXIT_FAILURE);}
  if(back)deque->tail=NEXT(deque,deque->tail);else deque->head=PREV(deque,deque->head);
  deque->array[(back)?deque->tail:deque->head]=val;deque->count++;
  if(deque->count==1){if(back)deque->head=deque->tail;else deque->tail=deque->head;}
}
static inline long POP(DEQUE deque,int back)
{
  if(!deque->count){exit(EXIT_FAILURE);}
  long val=deque->array[(back)?deque->tail:deque->head];
  if(back)deque->tail=PREV(deque,deque->tail);else deque->head=NEXT(deque,deque->head);
  deque->count--;return val;
}
int main(void)
{
  int N=IN(),K=IN(),C[5000],P[5000],vis[5000]={0};long score=LMIN,vector[15000];
  rep(i,N){P[i]=IN()-1;}rep(i,N){C[i]=IN();score=Max(score,C[i]);}if(score<0){return OUT(score),0;}
  rep(i,N)
  {
    if(vis[i]){continue;}
    int len=0,now=K,sz=0,x=P[i];long high=LMIN,temp=0,y=1l*C[x];vis[i]=1;
    vector[sz++]=0,vector[sz++]=y;
    while(!vis[x]){vis[x]=1;x=P[x];y+=1l*C[x];vector[sz++]=1l*C[x];}
    if(y>0)
    {
      temp+=1l*Max(1l*now/(sz-1l)-1l,0l)*y;
      if(now>sz-1){now%=sz-1;now+=1l*sz-1l;}
    }
    len=sz;
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,sz-2){vector[j+2]+=1l*vector[j+1];}
    DEQUE dq=CREATE();PUSH(dq,0,0);
    rep(j,sz-1)
    {
      while(dq->count&&vector[dq->array[dq->head]]>vector[j+1]){POP(dq,0);}
      PUSH(dq,j+1,0);
      while(dq->count&&j+1-dq->array[dq->tail]>now){POP(dq,1);}
      if((j+1)!=dq->array[dq->tail]){high=1l*Max(1l*high,1l*vector[j+1]-1l*vector[dq->array[dq->tail]]);}
    }
    temp+=1l*high;score=1l*Max(score,temp);DELETE(dq);
  }
  return OUT(score),0;
}

Measured memory_bytes: 2160
n,m,k=map(int,input().split())
a=list(map(int,input().split()))#n
b=list(map(int,input().split()))#m

c=0

sa=0#s[:aa]
sb=0#s[:bb]
aa=0#0~n
bb=0#0~m

for i in range(m):
    sb+=b[i]
    if sb>k:
        sb-=b[i]
        bb=i
        break
    if i==m-1:
        bb=m



for i in range(n+1):
    aa=i
    if aa!=0:
        sa+=a[aa-1]
    if sa>k:
        break
    if sa+sb<=k:
        c=max(c,aa+bb)
    else:
        while sa+sb>k:
            sb-=b[bb-1]
            bb-=1
        c=max(c,aa+bb)


print(c)

Measured memory_bytes: 40752
n= int(input())
mini = 1000
ans = 0
for i in range(n):
    s = int(input())
    ans += s
    if s % 10 != 0 and mini > s:
        mini = s
if ans % 10 == 0:
    if mini != 1000:
        print(ans - mini)
    else:
        print(0)
else:
    print(ans)

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

using std::pair;
using std::vector;


struct vertex {
	long long x, y;
	int idx;
};
struct edge {
	int a, b;
	long long cost;
};
long long abss(long long a) {
	if (a < 0)return -a;
	return a;
}
long long cost(vertex a, vertex b) {
	return std::min(abss(a.x - b.x), abss(a.y - b.y));
}
struct disjoint_set {
	vector<int> tree;
	disjoint_set(int n) {
		tree.resize(n, -1);
	}
	int find(int idx) {
		if (tree[idx] == -1)return idx;
		return tree[idx] = find(tree[idx]);
	}
	void Union(int a, int b) {
		int A = find(a);
		int B = find(b);
		if (A == B)return;
		tree[B] = A;
	}
};
int main() {
	int n;
	scanf("%d", &n);
	vector<vertex> P;
	for (int i = 0; i < n; i++) {
		long long x, y;
		scanf("%lld%lld", &x, &y);
		P.push_back({ x,y,i });
	}

	vector<edge> E;
	const int offset = 10;
	std::sort(P.begin(), P.end(), [&](const vertex& a, const vertex& b) {
		return a.x < b.x;
	});
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n && j - i <= offset; j++) {
			E.push_back({ P[i].idx,P[j].idx,cost(P[i],P[j]) });
			E.push_back({ P[j].idx,P[i].idx,cost(P[i],P[j]) });
		}
	}
	std::sort(P.begin(), P.end(), [&](const vertex& a, const vertex& b) {
		return a.y < b.y;
	});
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n && j - i <= offset; j++) {
			E.push_back({ P[i].idx,P[j].idx,cost(P[i],P[j]) });
			E.push_back({ P[j].idx,P[i].idx,cost(P[i],P[j]) });
		}
	}
	disjoint_set set(n);
	std::sort(E.begin(), E.end(), [&](const edge& a, const edge& b) {
		return a.cost < b.cost;
	});
	long long ans = 0;
	for (edge& e : E) {
		if (set.find(e.a) != set.find(e.b)) {
			ans += e.cost;
			set.Union(e.a, e.b);
		}
	}
	printf("%lld", ans);
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5, lgsz = 30;
bool vis[lgsz + 5][nsz + 5];
int n, a[nsz + 5], b[nsz + 5], t[nsz + 5], s[2 * nsz + 5];
vector< pair<int, int> > ans;

void inline z_init(string &s, vector<int> &z) {
	int len = (int) s.size();
	z = vector<int>(len, 0);
	for (int i = 1, l = 0, r = 0; i < len; ++i) {
		if (i <= r)  z[i] = min(r - i + 1, z[i - l]);
		for (; i + z[i] < len && s[z[i]] == s[i + z[i]]; ++z[i]);
		if (i + z[i] - 1 > r)  l = i, r = i + z[i] - 1;
	}
}

void inline solve(int k) {
	string dat;
	loop (i, n) {
		t[i] = a[i] >> k & 1;
	}
	loop (i, n) {
		s[i] = b[i] >> k & 1;
		s[i + n] = s[i];
	}
	loop (i, n) {
		dat += t[i] ^ 48;
	}
	dat += '#';
	loop (i, 2 * n) {
		dat += s[i] ^ 48;
	}
	vector<int> z;
	z_init(dat, z);
	circ (i, n, 2 * n) {
		vis[k][(n + 1 - i + n) % n] |= z[i] == n;
	}
	dat = "";
	loop (i, n) {
		dat += t[i] ^ 1 ^ 48;
	}
	dat += '#';
	loop (i, 2 * n) {
		dat += s[i] ^ 48;
	}
	z_init(dat, z);
	circ (i, n, 2 * n) {
		vis[k][(n + 1 - i + n) % n] |= z[i] == n;
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	loop (i, n) {
		cin >> a[i];
	}
	loop (i, n) {
		cin >> b[i];
	}
	loop (k, lgsz) {
		solve(k);
	}
	loop (i, n) {
		bool f = 1;
		loop (k, lgsz) {
			if (!vis[k][i]) {
				f = 0;
				break;
			}
		}
		if (f) {
			cout << i << ' ' << (a[i] ^ b[0]) << ln;
		}
	}
}


Measured memory_bytes: 16840
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int mod = 1000000007;

bool used[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    for(int i = 0; i < n; ++i){
        cin >> t[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    
    for(int i = 0; i < n; ++i){
        if(i == 0){
            if(t[i] > a[i]){
                cout << 0 << endl;
                return 0;
            }
            
            used[i] = true;
            continue;
        }
        
        if(t[i] > t[i-1]){
            if(t[i] > a[i]){
                cout << 0 << endl;
                return 0;
            }
            
            used[i] = true;
        }
    }
        
    for(int i = n-1; i >= 0; --i){
        if(i == n-1){
            if(a[i] > t[i]){
                cout << 0 << endl;
                return 0;
            }
            
            used[i] = true;
            continue;
        }
        
        if(a[i] > a[i+1]){
            if(a[i] > t[i]){
                cout << 0 << endl;
                return 0;
            }
            
            used[i] = true;
        }
    }
    
    ll res = 1;
    for(int i = 0; i < n; ++i){
        if(used[i])     continue;
        
        res = (res * min(t[i], a[i])) % mod;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> count(k+1,0);
    for (ll i = k; i >= 1; i--){
        ll res = RepeatSquaring(k/i,n,MOD);
        ll s = 2*i;
        while(s <= k){
            res += MOD;
            res -= count[s];
            res %= MOD;
            s += i;
        }
        count[i] = res;
    }
    ll ans = 0;
    rep(i,1,k+1){
        ans += count[i]*i;
        ans %= MOD;
    }
    PRINT(ans);
}


Measured memory_bytes: 3960
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define pi 2*acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5;
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
#define mod 10e9
int main()
{
    ll s,w;
    cin>>s>>w;
    s-=w;
    if(s>0)
        cout<<"safe";
    else
        cout<<"unsafe";
    cout<<endl;
}


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline

n , q = map(int, input().split())

tree = {}
for i in range(n-1):
    a, b = map(int, input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]

op = [0] * (n+1)
for i in range(q):
    p, x = map(int, input().split())
    op[p] += x

for root, reaf in tree.items():
    for i in reaf:
        op[i] += op[root]

print(*op[1:])


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

int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  REP(i,n){
    cin>>h[i];
  }
  int cnt=0;
  REP(i,n){
    if(h[i]>=k){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


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

map< pair<int, int>, int> H;
int h, w, n;
long long ans[10];

int main()
{
	scanf("%d %d %d", &h, &w, &n);
	ans[0] = (long long)(h - 2) * (w - 2);
	for(int i = 1; i <= n; ++i)
	{
		int x, y; scanf("%d %d", &x, &y);
		for(int dx = x; dx <= x + 2; ++dx)
			for(int dy = y; dy <= y + 2; ++dy)
				if(dx >= 3 && dx <= h && dy >= 3 && dy <= w)
				{
					ans[H[make_pair(dx, dy)]]--;
					ans[++H[make_pair(dx, dy)]]++;
				}
	}
	for(int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);
	return 0;
}

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

using namespace std;
int main() {
	int h, n;
	cin >> h >> n;
	vector<int>a(n);
	int w = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		w += a[i];
	}
	if (w >= h)cout << "Yes" << endl;
	else cout << "No";
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

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

long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

long long lcm(long long a,long long b){
	long long g=gcd(a,b);
	return a/g*b;
}

int prime[1000020]={};//100000以下の素数:9592個
int Er_N=1000010;
void Er(){//Eratosthenes  1:PRIME  0:NOT PRIME
	for(int i = 2; i < Er_N; i++){
		prime[i] = 1;
	}
	int limit_Er_roop=sqrt(Er_N);
	for(int i = 2; i < limit_Er_roop; i++){
		if(prime[i]){
			for(int j = 0; i * (j + 2) < Er_N; j++){
				prime[i *(j + 2)] = 0;
			}
		}
	}
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL a,b;
	cin>>a>>b;
	Er();
	a=gcd(a,b);
	if(a<=1){
		cout<<1<<endl;
		return 0;
	}
	int ans=1;
	auto aa=divisor(a);
	FOR(i,2,Er_N){
		int d=i;
		if(prime[i]!=1)continue;
		if(a%i==0){
			ans++;
			while(a%i==0){
				a/=i;
			}
		}
	}
	if(a>=1000000)ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4224
import math
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

ans = 0
for i in range(N-1):
    for k in range(i+1, N):
        distance = 0
        for z in range(D):
            distance += (X[i][z] - X[k][z]) ** 2
        if math.ceil(distance**0.5) == math.floor(distance**0.5):
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<char,char> P;

struct state{
	P p1, p2;
	state(P p1_, P p2_){ p1 = p1_; p2 = p2_; }
};
int w, h;
int dx1[4] = {0,-1,1,0};
int dy1[4] = {-1,0,0,1};
int dx2[4] = {0,1,-1,0};
int dy2[4] = {-1,0,0,1};
bool flag[51][51][51][51];
char L[51][51];
char R[51][51];

void init(){
	for(int i=0 ; i < 51 ; i++ ){
		for(int j=0 ; j < 51 ; j++ ){
			for(int k=0 ; k < 51 ; k++ ){
				for(int l=0 ; l < 51 ; l++ ){
					flag[i][j][k][l] = false;
				}
			}
		}
	}
}

// デバッグ用
void debug(){
	cout << "[Left]" << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			cout << L[y][x];
		}
		cout << endl;
	}
	cout << endl;
	cout << "[right]" << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			cout << R[y][x];
		}
		cout << endl;
	}
	cout << endl;
}

// R[y][x] == 'R' となる (x,y) を返す
P R_search(){
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( R[y][x] == 'R' ){
				R[y][x] = '.';
				return P(x,y);
			}
		}
	}
	return P(0,0);
}

// L[y][x] == 'L' となる (x,y) を返す
P L_search(){
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( L[y][x] == 'L' ){
				L[y][x] = '.';
				return P(x,y);
			}
		}
	}
	return P(0,0);
}

bool bfs(){
	P ls = L_search();
	P rs = R_search();
	
	queue< pair<P,P> > q;
	pair<P,P> s( ls , rs );
	q.push( s );
	
	while( !q.empty() && q.size() < 1000000 ){
		pair<P,P> now = q.front(); q.pop();
		int x1 = now.first.first;
		int y1 = now.first.second;
		int x2 = now.second.first;
		int y2 = now.second.second;
		
		if( L[y1][x1] == '%' && R[y2][x2] == '%' ){
			return true;
		}else if( L[y1][x1] == '%' && R[y2][x2] != '%' ){
			continue;
		}else if( L[y1][x1] != '%' && R[y2][x2] == '%' ){
			continue;
		}
		flag[y1][x1][y2][x2] = true;
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx1 = x1 + dx1[i];
			int my1 = y1 + dy1[i];
			if( mx1 < 0 || my1 < 0 || mx1 >= w || my1 >= h || L[my1][mx1] == '#' ){
				mx1 = x1;
				my1 = y1;
			}
			int mx2 = x2 + dx2[i];
			int my2 = y2 + dy2[i];
			if( mx2 < 0 || my2 < 0 || mx2 >= w || my2 >= h || R[my2][mx2] == '#' ){
				mx2 = x2;
				my2 = y2;
			}
			P p1(mx1,my1);
			P p2(mx2,my2);
			pair<P,P> next(p1,p2);
			if( !flag[my1][mx1][my2][mx2] ){
				q.push( next );
				flag[my1][mx1][my2][mx2] = true;
			}
		}
	}
	return false;
}

int main(){
	while( cin >> w >> h, w || h ){
		init();
		
		for(int y=0 ; y < h ; y++ ){
			string l, r;
			cin >> l >> r;
			for(int x=0 ; x < w ; x++ ){
				L[y][x] = l[x];
				R[y][x] = r[x];
			}
		}
		// debug();
		bool ans = bfs();
		if( ans )
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 7756
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin>>S;
	int k;
	cin>>k;
	for(int i=0;i<S.size();i++){
		if(('z'-S[i]+1)%26>k)continue;
		k-=('z'-S[i]+1)%26;
		S[i]='a';
	}
	k%=26;
	S[S.size()-1]=(S[S.size()-1]-'a'+k)%26+'a';
	cout<<S<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int64_t N,M;
    cin >> N >> M;
    vector<vector<int64_t>> vec(N,vector<int64_t> (2));
    for(int64_t i = 0;i < N;i++) {
        cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    }
    sort(vec.begin(),vec.end());
    int64_t money = 0;
    int64_t i = 0;
    while(M > 0) {
        if(M > vec.at(i).at(1)){
            money += vec.at(i).at(0) * vec.at(i).at(1);
            M -= vec.at(i).at(1);
        }else{
            money += vec.at(i).at(0) * M;
            M = 0;
        }
        i++;
    }
    cout << money << endl;
}


Measured memory_bytes: 5760
/**
 *    author: Behradm
 *    Created: 27.05.2020 15:19:25
 *    In the Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy";
	else if (s == "Cloudy")
		cout << "Rainy";
	else
		cout << "Sunny";
	return 0;
}




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


void solve(long long N, std::vector<long long> A){
  A.erase(unique(A.begin(), A.end()), A.end());

  long long ans = 1;

  for(long long i = 1; i < (A.size()-1); i++){
    if(A[i-1] < A[i] && A[i] > A[i+1] ||
       A[i-1] > A[i] && A[i] < A[i+1]) {
      ans++;
      i++;
    }
  }

  cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <queue>
using namespace std;
int x[4]={-1,0,1,0},y[4]={0,-1,0,1};
int h,w;
char a[1009][1009];
int d[1009][1009];
queue<pair<int,int>> q;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            d[i][j]=-1;
            if(a[i][j]=='#'){
                q.push(make_pair(i,j));
                d[i][j]=0;
            }
        }
    }
    int ans=0;
    while(q.size()){
        pair<int,int> now=q.front(); q.pop();
        for(int i=0;i<4;i++){
            int nx=now.first+x[i],ny=now.second+y[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&d[nx][ny]==-1){
                d[nx][ny]=d[now.first][now.second]+1;
                q.push(make_pair(nx,ny));
                ans=d[nx][ny];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
    int sum=0;
    for(int i=0;i<5;i++)
    {
        sum+=a[i]/10;
        a[i]%=10;
    }
    sum*=10;
    sort(a,a+5);
    int flag=0;
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
            continue;
        else if(flag==0)
        {
            flag=1;
            sum+=a[i];
        }
        else
            sum+=10;
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define INF 2<<29

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b) swap(a,b);
  if(a-b>1){
    printf("%d\n",a*2-1);
  }else{
    printf("%d\n",a+b);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

const int NUM = std::pow(10, 5);

int main(){
    int n;
    long long k;
    std::cin >> n >> k;

    std::vector<long long> counts(NUM, 0);
    for(int i = 0; i < n; ++i){
        int a, b;
        std::cin >> a >> b;
        counts.at(a - 1) += b;
    }

    int i = 0;
    long long sum = 0;
    while(sum < k){
        sum += counts.at(i++);
    }

    std::cout << i << std::endl;

    return 0;
}

Measured memory_bytes: 1532
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, H, W;
  cin >> N >> H >> W;

  int ans = (N - H + 1) * (N - W + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define fl(i,n)             for(int i=0;i<n;i++)
#define fit(it,x)           for(auto it=x.begin();it!=x.end();it++)
#define fll(j,n)            for(int j=n-1;j>=0;j--)
#define pb                  push_back
#define mp                  make_pair
#define f                   first
#define s                   second
#define all(x)              x.begin(),x.end()
typedef vector<int>         vi;
typedef vector<double>      vd;
typedef vector<char>        vc;
typedef vector<string>      vs;
typedef map<int, int>       mii;
typedef map<string, int>    msi;
typedef pair<int, int>      pii;
typedef long long ll;
const int mod = 1000000007;
int sum = 0, max = 0, min = 0;
void solve() {
    char c; cin >> c;
    if (c >= 'A' && c <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin >> test_case;
    while (test_case--) {
        solve();
        cout << endl;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,k;
    string s;
    cin >> n >> k >> s;
    rep(i,s.size()){
        cout << (i==k-1?(char)(s[i]+32):s[i]);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    X, A, B = map(int, input().split())

    da = abs(X-A)
    db = abs(X-B)

    if da < db:
        print("A")
    elif da > db:
        print("B")
    else:
        assert False

if __name__ == "__main__": main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    from math import ceil

    s = list(input())
    ans = [0 for _ in range(len(s))]

    # KeyInsight
    # 1. RLとなる部分に子どもたちが集まる
    # 2. 試行回数が偶数、かつ、最初の位置から偶奇が入れ替わることはない
    # See:
    # https://www.youtube.com/watch?v=lyHk98daDJo
    for i in range(2):
        count = 0

        # Rのみカウント
        for index, si in enumerate(s):
            if si == 'R':
                count += 1
            else:
                # R側の個数は切り上げ、L側の個数は切り捨て
                ans[index] += count // 2
                ans[index - 1] += ceil(count / 2)
                count = 0

        # 実装を楽にするため、入力と結果を反転させている&LRを入れ替え
        s = s[::-1]
        ans = ans[::-1]

        for index, si in enumerate(s):
            if si == 'L':
                s[index] = 'R'
            else:
                s[index] = 'L'

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11648
import Control.Applicative

fill a t ai ti = head [ (a',t') | x<-[ start..]
                                , let a'=x*ai
                                      t'=x*ti
                                , a'>=a
                                , t'>=t
                                ]
              where start = max (a`div`ai) (t`div`ti)

solve [] (a,t) = a+t
solve ([ai,ti]:ats) (a,t) = solve ats $ fill a t ai ti

main = do
  _ <- read <$> getLine :: IO Int
  ats <- map (map read.words).lines <$> getContents :: IO [[Integer]]
  print $ solve ats (1,1)


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    ll n,m;
    std::cin >> n >> m;
    //奇数回の個数
    if(n==1 && m==1) std::cout << 1 << "\n";
    else if(n==1) std::cout << m-2 << "\n";
    else if(m==1) std::cout << n-2 << "\n";
    else std::cout << (n-2)*(m-2) << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

using namespace std;

int p[100001];
int main(){
    int n;
    cin>>n;
    long long r = 0;
    for(int i = 0;i<n;i++){
        int a = 0;
        int b = 0;
        cin>>a>>b;
        p[i] = -(a+b);
        r -=b;
    }
    sort(p,p+n);
    for(int j = 0;j<n;j+=2)
        r-=p[j];
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

int main() {
	int x;
	cin>>x;
	int ans=(x/500)*1000;
	x%=500;
	ans+=(x/5)*5;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
a = Array.new(4){ Array.new(13, false) }
n = gets.to_i
table1 = {"S" => 0, "H" => 1, "C" => 2, "D" =>3}
table2 = ["S", "H", "C", "D"]
while line = gets do
  m, r = line.split
  a[table1[m]][r.to_i - 1] = true
end

0.upto(3) do |i|
  0.upto(12) do |j|
    if a[i][j] == false then puts "#{table2[i]} #{j + 1}" end
  end
end

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

int main()
{
  string x;
  int num, length;
  cin>>length>>num;
  cin>>x;
  int charvalue = int(x[num-1]);
  charvalue+=32;
  x[num-1] = charvalue;
  for (int i = 0; i < length; i++){
      cout<<x[i];
  }
  
}

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

using namespace std;

typedef long long ll;

const int N=100010;

int n,q,t;
ll b[N],Q[N],a[N],c[N];

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

inline void read(int &x){
  char c=nc(); x=0;
  for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}

inline void read(ll &x){
  char c=nc(); x=0;
  for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
}

inline void work(ll x,ll y){
  int p=upper_bound(Q,Q+1+t,x)-Q-1;
  if(!p) a[1]+=y,a[x+1]-=y;
  else c[p]+=y*(x/Q[p]),work(x%Q[p],y);
}

int main(){
  read(n); read(q);
  if(q==0){
    for(int i=1;i<=n;i++) printf("%d\n",1); return 0;
  }
  for(int i=1;i<=q;i++) read(b[i]);
  Q[++t]=b[q];
  for(int i=q-1;i;i--){
    if(b[i]>=Q[t]) continue;
    Q[++t]=b[i];
  }
  if(n<Q[t]) Q[++t]=n; reverse(Q+1,Q+1+t);
  c[t]=1;
  for(int i=t;i>1;i--)
    c[i-1]+=c[i]*(Q[i]/Q[i-1]),work(Q[i]%Q[i-1],c[i]);
  for(int i=1;i<=n;i++) a[i]+=a[i-1];
  for(int i=1;i<=Q[1];i++) a[i]+=c[1];
  for(int i=1;i<=n;i++) printf("%lld\n",a[i]);
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#define ARYMAX 5
int main(){
    int ary[ARYMAX];
    int k;
    for(int i=0;i<ARYMAX;i++)scanf("%d",&ary[i]);
    scanf("%d",&k);
    int gt=0;
    for(int i=0;i<ARYMAX;i++){
        for(int l=i+1;l<ARYMAX;l++){
            if(ary[l]-ary[i]>k){
                gt++;
                break;
            }
        }
        if(gt!=0)break;
    }
    if(gt==0){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	a = [0] * n
	for i in range(n):
		a[i] = int(input().strip())
	l = [0] *(n+1)
	r = [0] *(n+1)
	for i in range(0, n):
		l[i+1] = max(l[i], a[i])
	for i in reversed(range(1, n)):
		r[i-1] = max(r[i], a[i])
	for i in range(n):
		print(max(l[i], r[i]))

if __name__ == '__main__':
	main()


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

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

    if (K == 0) {
        rep(i, N) {
            if (i) cout << " ";
            cout << S-1;
        }
        cout << endl;
        return 0;
    }

    if (N >= K) {
        rep(i, K) {
            if (i) cout << " ";
            cout << S;
        }
        rep(i, N-K) {
            cout << " ";
            if (S == 1) {
                cout << 1000000;
            }else {
                cout << S-1;
            }
        }
        cout << endl;
    }
    else {

        int tmp = 2;
        cout << S << " ";
        rep(i, (K-2)/2) {
            cout << 0 << " ";
            tmp++;
        }
        cout << S << " ";

        if (K%2) {
            cout << 0 << " ";
            tmp++;
        }
        rep(i, N-tmp) {
            if (i) cout << " ";
            if (S == 1) {
                cout << 1000000;
            }else {
                cout << S-1;
            }
        }
        cout << endl;



    }
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

#define fi first
#define se second
#define long long long

using namespace std;

int main()
{
    //    freopen("input.in", "r", stdin);
    int n; cin >> n;
    set<int> st;
    while(n--)
    {
        int x; cin >> x;
        st.insert(x);
    }
    cout << st.size() << "\n";
}



Measured memory_bytes: 256