akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int R;
int S;
int P;
char T[100000+2];
int sz;
int arr[100000];
int main(){
  int st;
  int res = 0;
  rd(N);
  rd(K);
  rd(R);
  rd(S);
  rd(P);
  rd(T);
  for(st=(0);st<(K);st++){
    int i;
    sz = 0;
    for(i=(st);i<(N);i+=(K)){
      if(T[i]=='r'){
        arr[sz++] = 2;
      }
      if(T[i]=='p'){
        arr[sz++] = 1;
      }
      if(T[i]=='s'){
        arr[sz++] = 0;
      }
    }
    for(i=(0);i<(sz);i++){
      if(i && arr[i]==arr[i-1]){
        arr[i] = -1;
        continue;
      }
      if(arr[i]==0){
        res += R;
      }
      if(arr[i]==1){
        res += S;
      }
      if(arr[i]==2){
        res += P;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// int N, K, R, S, P;
// char T[1d5+2];
// 
// int sz, arr[1d5];
// 
// {
//   int res = 0;
//   rd(N,K,R,S,P,T);
//   rep(st,K){
//     sz = 0;
//     rep(i,st,N,K){
//       if(T[i]=='r') arr[sz++] = 2;
//       if(T[i]=='p') arr[sz++] = 1;
//       if(T[i]=='s') arr[sz++] = 0;
//     }
//     rep(i,sz){
//       if(i && arr[i]==arr[i-1]) arr[i] = -1, continue;
//       if(arr[i]==0) res += R;
//       if(arr[i]==1) res += S;
//       if(arr[i]==2) res += P;
//     }
//   }
//   wt(res);
// }


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  queue<string> Q;
  vector<int64_t> L(0); 
  for(int i=0; i<9; i++){
    char x = '1' + i;
    string S = "";
    S += x;
    Q.push(S);
    int64_t l = stoll(S);
    L.push_back(l);
  }
  for(int i=0; i<10; i++){
    int q = Q.size();
    int cnt = 0;
    while(cnt < q){
      string T = Q.front();
      Q.pop();
      char c = T.at(T.size()-1);
      if(c != '0'){
        string U = T;
        char d = c - 1;
        U += d;
        Q.push(U);
        int64_t l = stoll(U);
        L.push_back(l);
      }
      if(c != '9'){
        string U = T;
        char d = c + 1;
        U += d;
        Q.push(U);
        int64_t l = stoll(U);
        L.push_back(l);
      }
      string U = T + c;
      Q.push(U);
      int64_t l = stoll(U);
      L.push_back(l);
      cnt++;
    }
  }
  sort(L.begin(),L.end());
  cout << L.at(K-1) << endl;
}

Measured memory_bytes: 34924
#include <stdio.h>
#include <string.h>

int main(void){
	char S[101] = {'\0'};
	char T[101] = {'\0'};
	char temp[101] = {'\0'};
	int i;
	int j;
	int flag = 0;
	
	scanf("%100s", &S);
	scanf("%100s", &T);
	
	for(i = 0; i < strlen(S); i++){
		for(j = 0; j < strlen(S); j++){
			temp[j] = S[(j+i)%strlen(S)];
		}
		if(strcmp(temp, T) == 0){
			flag = 1;
			break;
		}
	}

	if(flag == 1){
		puts("Yes");
	}
	else{
		puts("No");
	}
	
	return 0;
}

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

using ll = long long;

#define fi first
#define se second

struct T {
  int x, y, id;
  T() {}
  T(int x, int y, int id) : x(x), y(y), id(id) {}
};

ll R, C;
int n, as, bs, cs, ds;
T p, q;
vector<T> a, b, c, d, v;
map<int, bool> mp;

bool cmp_a(const T& t1, const T& t2) {
  return t1.y < t2.y;
}
bool cmp_b(const T& t1, const T& t2) {
  return t1.y > t2.y;
}
bool cmp_c(const T& t1, const T& t2) {
  return t1.x > t2.x;
}
bool cmp_d(const T& t1, const T& t2) {
  return t1.x < t2.x;
}

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

  cin >> R >> C >> n;

  for (int i = 0; i < n; ++i) {
    cin >> p.x >> p.y >> q.x >> q.y;

    if ((p.x == 0 || p.x == R || p.y == 0 || p.y == C) && (q.x == 0 || q.x == R || q.y == 0 || q.y == C)) {
      if (p.x == 0) {
        a.push_back({p.x, p.y, i});
        as++;
      }
      else if (p.x == R) {
        b.push_back({p.x, p.y, i});
        bs++;
      }
      else if (p.y == 0) {
        c.push_back({p.x, p.y, i});
        cs++;
      }
      else if (p.y == C) {
        d.push_back({p.x, p.y, i});
        ds++;
      }
      if (q.x == 0) {
        a.push_back({q.x, q.y, i});
        as++;
      }
      else if (q.x == R) {
        b.push_back({q.x, q.y, i});
        bs++;
      }
      else if (q.y == 0) {
        c.push_back({q.x, q.y, i});
        cs++;
      }
      else if (q.y == C) {
        d.push_back({q.x, q.y, i});
        ds++;
      }
    }
  }

  sort(a.begin(), a.end(), cmp_a);
  sort(b.begin(), b.end(), cmp_b);
  sort(c.begin(), c.end(), cmp_c);
  sort(d.begin(), d.end(), cmp_d);

  for (int i = 0; i < as; ++i) v.push_back(a[i]);
  for (int i = 0; i < ds; ++i) v.push_back(d[i]);
  for (int i = 0; i < bs; ++i) v.push_back(b[i]);
  for (int i = 0; i < cs; ++i) v.push_back(c[i]);

  n = as + bs + cs + ds;
  stack<int> st;

  for (int i = 0; i < n; ++i) {
    if (!mp[v[i].id]) {
      st.push(v[i].id);
      mp[v[i].id] = true;
    }
    else {
      if (!st.empty()) {
        if (st.top() == v[i].id) {
          st.pop();
          mp[v[i].id] = false;
        }
        else {
          cout << "NO\n";
          return 0;
        }
      }
      else {
        cerr << "ERROR" << endl;
        return 0;
      }
    }
  }

  cout << "YES\n";

  return 0;
}

Measured memory_bytes: 10248
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const int maxn = 4e2 + 5;
const int mod = 1e9 + 7;
const int logn = log2(maxn) + 1;
int sum[maxn][maxn];
int a[maxn] , b[maxn];
int n , c;
int f[maxn][maxn];

int Pow(int x , int y){
    if(y == 0)return 1;
    int r = Pow(x , y / 2);
    if(y & 1)return (ll)r * r % mod * x % mod;
    return (ll)r * r % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n >> c;
    for(int i = 0 ; i <= 400 ; ++i){
        for(int j = 1 ; j <= 400 ; ++j){
            sum[i][j] = sum[i][j - 1] + Pow(j , i);
            if(sum[i][j] >= mod)sum[i][j] -= mod;
        }
    }
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
    }
    for(int i = 1 ; i <= n ; ++i){
        cin >> b[i];
    }
    f[0][0] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= c ; ++j){
            for(int t = 0 ; t <= j ; ++t){
                f[i][j] += (ll)f[i - 1][t] * (sum[j - t][b[i]] - sum[j - t][a[i] - 1] + mod) % mod;
                if(f[i][j] >= mod)f[i][j] -= mod;
            }
        }
    }
    cout << f[n][c];
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
using namespace std;
int main(){
	for(int i=1;i<10;i++){
		for(int l=1;l<10;l++){
			cout<<i<<'x'<<l<<"="<<i*l<<endl;
			
			
			
		}
		
		
		
	}
}


Measured memory_bytes: 3000
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

struct BIT{
  BIT(int n):_n(n+1),v(n+1,0),s(n+1,0){}

  void add(int i, int a){
    i++; //1 index
    v[i]+=a;
    for(int k=i;k<=_n;k+=(k&-k))s[k]+=a;
  }

  lint sum(int i){
    i++; //1 index
    lint r=0;
    for(int k=i;k>0;k-=(k&-k))r+=s[k];
    return r;
  }

  private:
  int _n;
  vector<lint> v,s;
};

int main(){
  int N,Q;
  cin>>N>>Q;
  int c[N];
  REP(i,N)cin>>c[i];
  pair<int,int> d[Q];
  multiset<pair<pair<int,int>,int> > m;
  REP(i,Q){
    int l,r;
    cin>>l>>r;
    l--;r--;
    d[i]=make_pair(r,l);
    m.insert(make_pair(d[i],i));
  }
  int ans[Q];
  BIT b(N);
  int p=-1;
  map<int,int> cm;
  for(auto e:m){
    int r=e.first.first;
    int l=e.first.second;
    while(p<r){
      p++;
      if(cm.find(c[p])!=cm.end()){
        b.add(cm[c[p]],-1);
      }
      cm[c[p]]=p;
      b.add(cm[c[p]],1);
    }
    // cerr<<"@"<<p<<endl;
    // for(auto ce:cm)cerr<<ce.first<<" "<<ce.second<<endl;
    // REP(i,N)cerr<<b.v[i+1]<<" ";
    // cerr<<endl;
    ans[e.second]=b.sum(r)-(l>0?b.sum(l-1):0);
  }
  for(auto e:ans)cout<<e<<endl;
  return 0;
}


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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    //xの倍数を数え始めるスタート地点とゴール地点を決めて数を引く
    long long ai = a / x;
    long long bi = b / x;
    long long start, goal;
    //aがxで割り切れる場合はai、割り切れない場合はai+1から数え始める
    if (ai * x == a) start = ai;
    else start = ai + 1;
    //bがxで割り切れるかどうかに関わらずbiはゴール地点となる
    goal = bi;
    cout << goal - start + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
       int n,m;
       cin>>n>>m;
       int a;
       for(int i=0;i<m;i++){
            cin>>a;
            n-=a;
       }
       if(n<0)cout<<-1<<endl;
       else cout<<n<<endl;



      }

        


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
point = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
for i in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
def dfs(s,parent):
    for i in graph[s]:
        if i == parent:
            continue
        point[i] += point[s]
        dfs(i,s)
dfs(0,-1)
print(*point)

Measured memory_bytes: 230960
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    vector<char> p(4);
    int bad = 0;

    for(int i = 0;i < 4;i++) cin >> p[i];

    for(int i = 0;i < 3;i++){
        if(p[i] == p[i+1])  bad = 1;
    }

    if(bad == 1) cout << "Bad" << endl;
    else    cout <<"Good" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class Main{
	public static void main(final String[] args){
		final Scanner sc = new Scanner(System.in);
		// �����̓���
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		final int h[] = new int[n];
		final ArrayList<Integer> highest = new ArrayList<>();
		final ArrayList<Integer> sameh = new ArrayList<>();
		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
		}
		for(int i = 0; i < m; i++){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int ah = h[a-1];
			final int bh = h[b-1];
            if(ah > bh){
			    highest.add(b);
			}else if(ah < bh) {
				highest.add(a);
			}else{
				sameh.add(a);
				sameh.add(b);
			}
		}
		highest.addAll(sameh);
		final List<Integer> result = new ArrayList<Integer>(new HashSet<>(highest));
		System.out.println(n - result.size());
	}
}


Measured memory_bytes: 61252
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var dict = new Dictionary<string, int>();

            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().ToCharArray();
                Array.Sort(tmp);
                var s = string.Join("", tmp);
                if (dict.ContainsKey(s))
                    dict[s]++;
                else
                    dict[s] = 1;
            }

            var total = 0L;
            foreach (var d in dict)
            {
                if (d.Value >= 2)
                {
                    for (var i = 1; i <= d.Value - 1; i++)
                        total += i;
                    //total += Enumerable.Range(1, d.Value - 1).Sum();
                }
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 27576
#include <iostream>

using namespace std;

int main(){
    // Your code here!
    //値の取得と初期化
    int i,j,k;
    int a;
    int n,m,l;
    cin>>n>>m>>l;
    int A[n+1][m+1];
    int B[m+1][l+1];
    for(i=0; i<n+1; i++){
        for(j=0; j<m+1; j++){
            A[i][j]=0;
        }
    }
    for(i=0; i<m+1; i++){
        for(j=0; j<l+1; j++){
            B[i][j]=0;
        }
    }
    
    
    //A~Bに代入
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            cin>>a;
            A[i][j]=a;
        }
    }
    for(i=1; i<=m; i++){
        for(j=1; j<=l; j++){
            cin>>a;
            B[i][j]=a;
        }
    }
    
    for(i=1; i<=n; i++){
        for(j=1; j<=l; j++){
            long long sum=0;
            for(k=1; k<=m; k++){
                sum+=A[i][k]*B[k][j];
            }
            if(j!=l){
                cout<<sum<<" ";
            }
            else{
                cout<<sum<<endl;
            }
        }
    }    
    
    return 0;
}



Measured memory_bytes: 3128
import math
n,m = map(int, input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(math.factorial(n)*math.factorial(m)*2%(10**9+7))
else:
    print(math.factorial(n)*math.factorial(m)%(10**9+7))


Measured memory_bytes: 55152
a=[int(input()) for i in range(5)]
k=int(input())
ans=0
for i in range(4):
  for j in range(i+1,5):
    if a[j]-a[i]>k:
      ans=":("
      break
if ans==0:
  print("Yay!")
else:
  print(ans)

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

using namespace std;

int main(void){
	int N;
	int K;
	int ans = 0;
	int x,y;
	while(scanf("%d", &N) != EOF){
		scanf("%d", &K);
		
		for(int i = 0; i < K; i++){
			scanf("%d %d", & x, &y);
			
			if(x <= N/2 && y <= N/2){
				ans = min(x,y) % 3;
			}else if(x > N/2 && y <= N/2){
				ans = min(N-x+1,y)%3;
			}else if(x <= N/2 && y > N/2){
				ans = min(x,N-y+1)%3;
			}else {
				ans = min(N-x+1,N-y+1) % 3;
			}
			
			printf("%d\n",ans==0?3:ans);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n,m,v,p;
  cin>>n>>m>>v>>p;
  vector<ll> a(n);
  rep(i,n){cin>>a[i];}
  sort(all(a));
  ll l=n-p;
  ll q=l,t=q/2;
  bool ans=false;
  if(v-t-p<=0){if(a[t]+m>=a[n-p]){ans=true;l=t;}}
  if(v-t-p>0){ll k=0,s;
              for(ll j=t+1;j<=n-p;j++){k+=a[j];}
              k+=m*(v-t-p);
              if(k%(n-p-t)==0){s=max(a[n-p],k/(n-p-t));}
              else{s=max(a[n-p],k/(n-p-t)+1);}
              if(a[t]+m>=s){ans=true;l=t;}}
  if(ans){for(ll i=t;i>=0;--i){
    if(v-i-p<=0){if(a[i]+m>=a[n-p]){l=i;}}
    if(v-i-p>0){ll k=0,s;
                for(ll j=i+1;j<=n-p;j++){k+=a[j];}
                k+=m*(v-i-p);
                if(k%(n-p-i)==0){s=max(a[n-p],k/(n-p-i));}
                else{s=max(a[n-p],k/(n-p-i)+1);}
                if(a[i]+m>=s){l=i;}}}}
  else{l=q;
  for(ll i=n-p-1;i>t;--i){
    if(v-i-p<=0){if(a[i]+m>=a[n-p]){l=i;}}
    if(v-i-p>0){ll k=0,s;
                for(ll j=i+1;j<=n-p;j++){k+=a[j];}
                k+=m*(v-i-p);
                if(k%(n-p-i)==0){s=max(a[n-p],k/(n-p-i));}
                else{s=max(a[n-p],k/(n-p-i)+1);}
                if(a[i]+m>=s){l=i;}}}}
    cout<<n-l<<endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,c;

int main(void){
    scanf("%d%d%d",&a,&b,&c);
    printf("%s\n",a==b&&b==c?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto& e : v) {
    cin >> e;
    e--;
  }
  vecbool start(n, false);
  vecbool goal(n, false);
  // start[0] = goal[0] = true;
  REP(i, n) {
    if (v[i] == 0) {
      start[v[i]] = true;
      goal[v[i]] = true;
    } else if (!start[v[i]] && goal[v[i] - 1]) {
      goal[v[i] - 1] = false;
      goal[v[i]] = true;
    } else if (!goal[v[i]]) {
      start[v[i]] = true;
      goal[v[i]] = true;
    }
  }
  // REP(i, n) { cout << i + 1 << " " << start[i] << " " << goal[i] << endl; }
  int tmp = 0;
  int l;
  l = 0;
  for (int i = 0; i < n; i++) {
    if (start[i]) {
      tmp = max(i - l + 1, tmp);
      l = i;
    }
  }
  tmp = max(n - l + 1, tmp);
  // cout << tmp << endl;
  cout << n - tmp + 1 << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



// 二項係数ライブラリ---------------------------------------------------------------------------------------//
const ll MAX_COM = 1000007;
ll fac[MAX_COM], finv[MAX_COM], inv[MAX_COM];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1ll;
    finv[0] = finv[1] = 1ll;
    inv[1] = 1ll;
    for (int i = 2; i < MAX_COM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] % MOD * finv[k] % MOD * finv[n - k] % MOD;
}

// Nが大きいときの二項係数計算
// N = 10^9, k = 2*10^5まで使える
const ll MAX_COM_NB = 200010;
vector<ll> COM_NB(MAX_COM_NB);
void COM_NBinit(int N) {
    // COMinit();
    COM_NB[0] = 1ll;
    rp(i, 1, MAX_COM_NB) {
        COM_NB[i] = COM_NB[i-1] * (N+1-i) % MOD * inv[i] % MOD;
    }
}

// 二項係数ライブラリここまで-----------------------------------------------------------------------------------//


int main() {
    COMinit();
    ll s; cin >> s;
    ll res = 0;
    rp(i, 1, (s/3)+1) {
        ll m = s-3*i;
        // printf("%lld %d %lld\n", m, i, COM(m+i-1, m));
        res += COM(m+i-1, m);
        res %= MOD;
    }
    cout << res << endl;

}


Measured memory_bytes: 28192
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W, A, B = map(int, input().split())

for _ in range(B):
    print("1"*A+"0"*(W-A))

for _ in range(H-B):
    print("0"*A+"1"*(W-A))



Measured memory_bytes: 13388
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  for (char c = 'a'; c <= 'z'; c++){
    if (find(s.begin(), s.end(), c) == s.end()){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
N,K = gets.split.map(&:to_i)
v = gets.split.map(&:to_i)
T = [K, N].min
res = 0

(T+1).times do |a|
  ((T-a)+1).times do |b|
    h = v[0,a]+v[(N-b),b]    
    h.sort!
    sum = h.inject(&:+) || 0
    [K-a-b, h.length].min.times do |i|
      break if h[i] >= 0
      sum -= h[i]
    end
    res = sum if sum > res
  end
end

puts res


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, 0);
  vector<vll> check(1, vll(n, 0));
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      check.emplace_back(check[i - w[memo]]);
      check[i][memo] = 1;
    }
    else check.emplace_back(check[i - 1]);
  }
  cout << dp[ww] << endl;
}

Measured memory_bytes: 83120
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int pogepoge; cin>>pogepoge;
    rep(hogehogehoge,pogepoge){
        int n;cin>>n;
        vi v(n+1,0);rep(i,n)cin>>v[i];
        pii ans=pii(0,0);
        rep(i,n-1){
            if(v[i]<v[i+1])ans.first=max(ans.first,v[i+1]-v[i]);
            else ans.second=max(ans.second,v[i]-v[i+1]);
        }
        cout<<ans.first<<" "<<ans.second<<endl;
    }
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           ll ans=0;
           rep(a,1,n){
             ans+=((n-1)/a);
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int limit = 50;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];
int N, M;

void dfs(int v)
{
    visited[v] = true;
    for (int i = 0; i < N; i++)
    {
        if(graph[v][i] == false) continue;
        if(visited[i] == true) continue;
        dfs(i);
    }
    
}

int main(void)
{
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    int count = 0;
    for (int i = 0; i < M; i++)
    {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for (int j = 0; j < N; j++)
        {
            visited[j] = false;
        }
        dfs(0);

        bool bridge = false;
        for (int j = 0; j < N; j++)
        {
            if(visited[j] == false) bridge = true;
        }
        if(bridge) count += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define INF 1000000001


int s[5010][5010];

int main(){

	int n,m,x1,y1,x2,y2,x3,y3;
	vector<int>x,y,X,Y;

	cin >> n >> m;

	rep(i,n){

	cin >> x1 >> y1;

	x.push_back(x1);
	y.push_back(y1);

	}

	X=x; Y=y;

	x.push_back(-INF); x.push_back(INF);
	y.push_back(-INF); y.push_back(INF);

	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());



	rep(i,n){

	int dx=lower_bound(x.begin(),x.end(),X[i])-x.begin();
	int dy=lower_bound(y.begin(),y.end(),Y[i])-y.begin();

	s[dy][dx]++;

	}

	REP(i,1,n) REP(j,1,n) s[i][j]+=s[i][j-1]+s[i-1][j]-s[i-1][j-1];


	rep(i,m){

	cin >> x2 >> y2 >> x3 >> y3;

	int dx2=lower_bound(x.begin(),x.end(),x2)-x.begin();
	int dy2=lower_bound(y.begin(),y.end(),y2)-y.begin();
	int dx3=upper_bound(x.begin(),x.end(),x3)-x.begin()-1;
	int dy3=upper_bound(y.begin(),y.end(),y3)-y.begin()-1;


    cout << s[dy3][dx3]-s[dy2-1][dx3]-s[dy3][dx2-1]+s[dy2-1][dx2-1] << endl;


	}

	return 0;
}

Measured memory_bytes: 99172
<?php
fscanf(STDIN, "%s", $s);
$rs = strrev($s);
if ($s != $rs) {echo 'No';return;}
$n = strlen($s);
$h = substr($s, 0, ($n-1)/2);
$rhs = strrev($h);
if ($h != $rhs) {echo 'No';return;}
$t = substr($s, ($n+3)/2 - 1, $n - 1);
$rts = strrev($t);
if ($t != $rts) {echo 'No';return;}
echo 'Yes';

Measured memory_bytes: 4728
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, k;

void init() {
  //enableFileIO();

  n = read();
  k = read();
}

int main() {
  init();

  printf("%d\n", int(ceil((n - 1) * 1.0 / (k - 1))));
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define f0(s,a,b) for(lli s=a;s<b;s++)
#define f1(s,a,b) for(lli s=a;s<=b;s++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define T 100
#define print(x) cout<< #x <<"=" <<x<<"\n";


int main()
{
     fast
     lli n;
     cin>>n;
     lli sum=0;
     for(lli i=1;i<=n;i++)
     {
          if(i%3==0&&i%5==0)
          {
               continue;
          }
          else if(i%3==0)
          {
               continue;
          }
          else if(i%5==0)
          {
               continue;
          }
          else
          {
               sum+=i;
          }
          
          
     }
     cout<<sum;

     
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
//vectordefine
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
//queuedefine
#define qint queue<int>
#define qtr queue<string>
#define qc queue<char>
//pairdefine
#define pint pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pis pair<int,str>
#define psi pair<str,int>
#define pcc pair<char,char>
#define pss pair<str,str>
#define mp make_pair
//mapdefine
#define mint map<int,int>
#define mic map<int,char>
#define mci map<char,int>
#define mis map<int,str>
#define msi map<str,int>
#define pb() push_back()
#define all(x) x.begin(),x.end()
#define elif else if
//function
str shizuku(char,char);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};
//main
signed main(){
    int pow,N,M,X,count=0,count2=0,Deg;
    double Dis;
    int alph='A'-'a';
    char op,C;
    str S,T;
    cin>>N>>M;
    if(N*2>M)cout<<M/2;
    else{
      count+=N;
      M-=N*2;
      count+=M/4;
      cout<<count<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	int i;
	cin>>s;
	if(s.length()%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	char ch[s.length()];
	for(i=0;i<s.length();i++)ch[i]=s[i];
	sort(ch,ch+s.length());
	for(i=0;i<s.length();i+=2){
		if(ch[i]!=ch[i+1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
"use strict";

function Main(input) {
    var input=input.split(" ");
    for(var i=0;i<input.length;i++)
        input[i]=parseInt(input[i],10);
    if(input[0] < input[1] && input[1] < input[2])
        console.log("Yes");
    else
        console.log("No");
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15508
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();
      String S = sc.next();
      int count = 1;//1つは絶対スライムがあるから
      
      //char[] slime = S.toCharArray();
      
      //初めにスライムの2番目と1番目を比べる
      for(int i =1; i<N; i++){
      		if(S.charAt(i)!=S.charAt(i-1)){
              	count +=1;//被っていなかったら
            }
      }
       System.out.println(count);
    }
}

Measured memory_bytes: 39684
from collections import defaultdict, Counter
N, M = map(int, input().split())
#X = list(map(int, input().split()))
C = Counter(map(int, input().split()))
D = defaultdict(int)
E = defaultdict(int)
for k, v in C.items():
    D[k%M] += v
    E[k%M] += v//2

ans = D[0] // 2

for i in range(1, M):
    j = M - i
    if i < j:
        x = min(D[i], D[j])
        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])
        ans += x + y
    elif i == j:
        ans += D[i] //2
    else:
        break

print(ans)

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

#define ll long long
#define EPS (ll)1e-9
#define N (ll)(2*1e5)
#define M (ll)(1e9+7)

using namespace std;

bitset<100010> trap;
ll dp[N];

ll solve(ll n) {
    dp[0] = 1;
    dp[1] = trap[1] ? 0 : 1;

    for(ll i = 2; i <= n; i++) {
        if(trap[i])
            dp[i] = 0;
        else 
            dp[i] = (dp[i-1] + dp[i-2])%M;
    }
    return dp[n]%M;
}


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

    ll n, m, pos;

    cin >> n >> m;

    for(ll i = 0; i < m; i++) {
        cin >> pos;
        trap[pos] = true;
    }
    cout << solve(n) << endl;
    
    return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc059/tasks/abc059_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string A, B;
    cin >> A >> B;
    if (A.size() > B.size())
    {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (A.size() < B.size())
    {
        cout << "LESS" << endl;
        return 0;
    }
    else
    {
        REP(i, A.size())
        {
            if (A[i] > B[i])
            {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (A[i] < B[i])
            {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }
    
    return 0;
}


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

int main() {
  int N;
  cin >>N;
  string S;
  cin >> S;
  vector<char>A(N);
  for(int i=0; i<N; i++)A.at(i)=S.at(i);
  int s=S.size();
  string rS=S;
  reverse(rS.begin(), rS.end());
  
  int count =0;
  if(rS.find("R")!=string::npos && rS.find("W")!=string::npos){
  for(int i=0; i<N; i++){
    int end = rS.find("R");
    int begin = S.find("W");
    if(end+begin<=s-2){
      rS.replace(end, 1, "W");
      rS.replace(s-begin, 1, "R");
      S.replace(begin, 1, "R");
      S.replace(s-end, 1, "W");
      count ++;
    }
    else break;
  }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 4180
def solve(string):
    n, m, *a = map(int, string.split())
    needs = {i + 1: n for i, n in enumerate(map(int, "2 5 5 4 5 6 3 7 6".split()))}
    if 2 in a and (3 in a or 5 in a):
        a.remove(2)
    if 3 in a and 5 in a:
        a.remove(3)
    if 6 in a and 9 in a:
        a.remove(6)
    b = sorted(a, key=lambda x: needs[x])
    index = 0
    base = str(b[0]) * (n // needs[b[0]])
    n %= needs[b[0]]
    while n > 0:
        use = [_b for _b in b if needs[_b] <= needs[b[0]] + n]
        if len(use) == 1:
            base = base[:-1]
            n += needs[b[0]]
            continue
        flag = max(use) == b[0]
        tmp_n = use[-1] if flag else max(use)
        tmp_c = n // (needs[tmp_n] - needs[b[0]])
        if flag:
            base = base[:-tmp_c] + str(tmp_n) * tmp_c
        else:
            base = base[:index] + str(tmp_n) * tmp_c + base[index + tmp_c:]
            index += tmp_c
        n -= (needs[tmp_n] - needs[b[0]]) * tmp_c
    return base


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Measured memory_bytes: 3064
n = input()
a = list(n)
k = int(input())
n = len(a)
for i in range(n):
    a[i] = int(a[i])
dp = [[[0 for i in range(2)] for i in range(k+2)]for i  in range(n)]
dp[0][0][0] = 1
dp[0][1][0] = a[0]-1
dp[0][1][1] = 1
for i in range(n-1):
    for j in range(k+1):
        if a[i+1] == 0:
            dp[i+1][j][1] += dp[i][j][1]
            dp[i+1][j][0] += dp[i][j][0]
            dp[i+1][j+1][0] += dp[i][j][0]*9
        else:
            dp[i+1][j][0] += dp[i][j][0]+dp[i][j][1]
            dp[i+1][j+1][0] += dp[i][j][1]*(a[i+1]-1)+dp[i][j][0]*9
            dp[i+1][j+1][1] += dp[i][j][1]
print(dp[n-1][k][0]+dp[n-1][k][1])

Measured memory_bytes: 63076
// Vicfred
// https://atcoder.jp/contests/abc147/tasks/abc147_b
// string manipulation
import std.stdio;
import std.string;

void main() {
    string s = readln.strip;
    const long n = s.length;

    int answer = 0;
    for(int i = 0; i < n; i++)
        if(s[i] != s[n-i-1])
            answer += 1;
    writefln("%d", answer/2);
}



Measured memory_bytes: 2812
//  LINK ZADATKA: http://abc073.contest.atcoder.jp/tasks/abc073_a

#include <cstdio>


int main(){
	int n;
	scanf("%d", &n);
	
	if(n % 10 == 9 || n / 10 == 9) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()


int__ main() {
	fast;
	string s; cin >> s;

	for(char x:s) if(x=='7') {cout << "Yes"; return 0;}

	cout << "No";
}


Measured memory_bytes: 3656
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let arr: Vec<usize> = sc.vec(n);

    let mut acc = 0;
    for a in &arr {
        acc = acc ^ a;
    }

    for a in &arr {
        print!("{} ", acc ^ a);
    }
    println!();
}


Measured memory_bytes: 4140
#include <stdio.h>
 
#define MAX 100000
 
int max(int a, int b){
  if(a>b) return a;
  return b;
}
 
int main(){
  int n;
  int a[MAX], b[MAX], c[MAX], dp[3][MAX];
  int ans;
  scanf("%d", &n);
  for(int i=0; i<n; i++) {
  	scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  dp[0][0] = a[0];
  dp[1][0] = b[0];
  dp[2][0] = c[0];
  for(int i=1; i<n; i++) {
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
    dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
  }
  ans = max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);
  printf("%d", ans);
}

Measured memory_bytes: 2560
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get_line();
    if s == "AAA" || s == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main(){
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;

}



Measured memory_bytes: 3628
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    int AA[2]={};
    REP(i,SZ(s)){
        AA[s[i]-'0']++;
    }
    W(min(AA[0],AA[1])*2);
    return 0;
}


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

int gcd(int a, int b){
    int r;
    while (b > 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    int x, y;
    cin >> x >> y;
    if (x < y) swap(x,y);
    cout << gcd(x,y) << endl;
}




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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll n,w;
ll arr[200][2];
ll dp[100010][110];
ll solve(ll rem,ll i){
	if(rem<0 || i>=n){
		return -1e11;
	}
	if(rem==0){
		return 0;
	}
	if(i==n-1){
		if(rem>=arr[i][0]){
			return arr[i][1];
		}
		else{
			return 0;
		}
	}
	if(dp[rem][i]!=-1){
		return dp[rem][i];
	}
	ll ans=max(arr[i][1]+solve(rem-arr[i][0],i+1),solve(rem,i+1));
	dp[rem][i]=ans;
	return dp[rem][i];
}
int main(){
	fast;
	cin>>n>>w;
	for(ll i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(w,0)<<endl;
	return 0;
}

Measured memory_bytes: 86272
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define loop(i,start, stop) for(int i = start; i < (stop); i++)
using namespace std;

int main(){
  
  string S,T;
  cin >> S >> T;

  loop(i,0,S.size()){
    if (S[i] != T[i]) {no return 0;}
  }

  yes

  return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
	private static int count = 0;

	/**
	 * バブルソートをするプログラム
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] value = new int[num];
		for (int i = 0; i < num; i++) {
			value[i] = scan.nextInt();
		}

		int[] sort = bubbleSort(value, num);
		for (int j = 0; j < num; j++) {
			if (j == num - 1) {
				System.out.print(sort[j]);
			} else {
				System.out.print(sort[j] + " ");
			}
		}
		System.out.println("");
		System.out.println(count); // ソート回数

		scan.close();
	}

	/**
	 * バブルソート
	 * 
	 * @param sortArray
	 *            ソートする配列
	 * @param num
	 *            ソートする個数
	 * @return 昇順にソートされた配列
	 */
	public static int[] bubbleSort(int[] sortArray, int num) {
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int j = num - 1; j >= 1; j--) {
				if (sortArray[j] < sortArray[j - 1]) {
					int tmp;
					tmp = sortArray[j];
					sortArray[j] = sortArray[j - 1];
					sortArray[j - 1] = tmp;
					flag = true;
					counter();
				}
			}
		}
		return sortArray;
	}

	public static void counter() {

		count++;
	}
}



Measured memory_bytes: 26364