akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int s;
    cin >> s;
    vector<mint> dp(s+1);
    dp[0] = 1;
    for(int i = 3; i <= s; i++){
        rep(j, i-2){
            dp[i] += dp[j];
        }
    }
    cout << dp[s] << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,ans=1;
    cin>>n;
    vector<long long int >v(n);
    int f=1;
    int z=0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]==0)
        {
            z++;

        }
    }
    if(z>0)
    {
        cout<<0<<endl;
    }
    else
    {
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        if(v[i]<=1000000000000000000/ans)
        {
            ans=ans*v[i];
        }
        else
        {
            cout<<-1;
            f=0;
            break;
        }
    }
    if(f==1)
        cout<<ans;
    }
}

Measured memory_bytes: 3988
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  vvi c(h, vi(w, 0));
  int cnt = 0;
  rep (i, n) {
    rep (j, a[i]) {
      int h_ = cnt / w;
      int w_ = cnt % w;
      if (h_ % 2 == 1) {
        w_ = w-1 - w_;
      }
      c[h_][w_] = i+1;
      cnt += 1;
    }
  }
  rep (i, h) {
    rep (j, w) {
      printf("%d ", c[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

const int MAX = 4e3 + 5;
ll fact[MAX], invf[MAX];
ll nCr(ll n, ll r){if(n<r||n<0||r<0)return 0; return mul(fact[n],mul(invf[n - r],invf[r]));}
void preprocess()
{
	fact[0] = 1;
	invf[0] = 1;
	for(ll i = 1; i < MAX; i++){
		fact[i] = mul(fact[i - 1], i);
		invf[i] = power(fact[i], MOD - 2);
	}
}

int main()
{
	boost;
	preprocess();
	ll s, i;
	
	cin >> s;
	ll ans = 0;
	for(i = 1; i <= s; i++) {
		ll x = s - i * 3;
		if(x < 0) break;
		
		ll curr = nCr(x + i - 1, x);
		ans = add(ans, curr);
	}
	cout << ans;
}


Measured memory_bytes: 3688
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 15084
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(b>0){
	b--;
      }
      else{
	a++;
      }
    }
    else{
      if(a>0){
	a--;
      }
      else{
	b++;
      }
    }
  }
  cout<<s.size()-(a+b)<<endl;
  return(0);
}


Measured memory_bytes: 512
mod = 998244353


N, M, K = map(int, input().split())


invs = {}


def inv(n):
    if n not in invs:
        invs[n] = pow(n, mod-2, mod)
    return invs[n]


fact = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = fact[i-1]*i
    fact[i] %= mod


def comb(n, r):
    ret = fact[n]*inv(fact[r])*inv(fact[n-r])
    return ret % mod


ans = 0
for i in range(K+1):
    now = M*pow(M-1, N-1-i, mod)*comb(N-1, i)
    now %= mod
    ans += now
    ans %= mod

print(ans)


Measured memory_bytes: 37712
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const int iinf = 1e9+6;
const ll linf = 1e18;
//const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

struct Zalgo{
  // v[i] には s と s[i..-1] の最長共通接頭辞長が入る
  void solve(vector<int>& v, string& s){
    int l = s.size(), i = 1, j = 0, k;
    v.resize(l);
    if(l < 1) return;
    v[0] = l;
    while (i < l) {
      while (i+j < l && s[j] == s[i+j]) ++j;
      v[i] = j;
      if (j == 0) { ++i; continue;}
      k = 1;
      while (i+k < l && k+v[k] < j) v[i+k] = v[k], ++k;
      i += k; j -= k;
    }
  }
} z;
string s;
vi v[2];
vector<bool> vz[2];
int ans;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int l = sz(s);
  FOR(i, 0, 2){
    z.solve(v[i], s);
    vz[i].assign(l+1, true);
    FOR(j, 1, l/2+1)if(vz[i][j])for(int k=2*j; k<=l; k+=j){
      if(v[i][k-j] < j) break;
      vz[i][k] = false;
    }
    reverse(rng(s));
  }
  if(vz[0][l]){
    cout << 1 << endl << 1 << endl;
    return 0;
  }
  FOR(i, 0, l+1) if(vz[0][i]&&vz[1][l-i]) ans++;
  if(ans){
    cout << 2 << endl << ans << endl;
  }else{
    cout << l << endl << 1 << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    int min = numeric_limits<int>::max();
    int count = 0;

    rep (i, n) {
        if(p.at(i) <= min) {
            count++;
            min = p.at(i);
        }
    }
    cout << count << endl;
}

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

int main()
{
	int K, X;

	cin >> K >> X;

	if (500 * K >= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;
use std::cmp;

fn main() {
    input! {
        r: usize,
        c: usize,
        k: usize,
        items: [(Usize1, Usize1, isize); k],
    }

    let mut dp = vec![vec![vec![0; 4]; c]; r];
    let mut item_array = vec![vec![0; c]; r];

    for &item in &items {
        item_array[item.0][item.1] = item.2;
    } 

    if item_array[0][0] != 0 {
        dp[0][0][1] = item_array[0][0];
    }

    for i in 0..r {
        for j in 0..c {
            for k in 0..4 {
                if item_array[i][j] != 0 {
                    if i > 0 {
                        dp[i][j][1] = cmp::max(dp[i][j][1], dp[i-1][j][k] + item_array[i][j]);
                        dp[i][j][0] = cmp::max(dp[i][j][0], dp[i-1][j][k]);
                    }
                    if j > 0 {
                        if k < 3 {
                            dp[i][j][k+1] = cmp::max(dp[i][j][k+1], dp[i][j-1][k] + item_array[i][j]);
                        }
                        dp[i][j][k] = cmp::max(dp[i][j][k], dp[i][j-1][k]);
                    }
                } else {
                    if i > 0 {
                        dp[i][j][0] = cmp::max(dp[i][j][0], dp[i-1][j][k]);
                    }
                    if j > 0 {
                        dp[i][j][k] = cmp::max(dp[i][j][k], dp[i][j-1][k]);
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for &value in &dp[r-1][c-1] {
        ans = cmp::max(ans, value);
    }

    println!("{}", ans);
}


Measured memory_bytes: 713056
#include <bits/stdc++.h>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
  string name;
  cin >> name;
  if (name[2] == name[3] && name[4] == name[5]){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int a[10005];
bool check(int x,int y,int c){
    if(x==y||x==c||y==c) return false;
    vector<int> p;
    p.push_back(x);p.push_back(y);p.push_back(c);
    sort(p.begin(),p.end());
    if(p[0]+p[1]<=p[2]) return false;
    else return true;
}
int main(){
    int n,num=0;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                if(check(a[i],a[j],a[k])) num++;
            }
        }
    }
    cout<<num<<endl;
}

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

int n;
int a[20];
int b[20];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += max(0, a[i] - b[i]);
  }
  cout << sum << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int a,b,c,k;cin>>a>>b>>c>>k;
  int left=k;
  int ans=0;
  ans+=min(a,left);
  left-=min(a,left);
  if(left>b)
  {
    left-=b;
    ans-=min(c,left);
  }
  cout<<ans<<endl;
}

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

int main()
{
    int s;
    cin >> s;
    int th = s/1000;
    int hun = s/100 - th*10;
    int ten = s/10 - th*100 - hun*10;
    int o = s - th*1000 - hun*100 - ten*10;
    if(th == hun || hun == ten || ten == o ){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <math.h>
#include <map>
#include <queue>

#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define vec vector

using namespace std;
using ll = long long;
using P = pair<int, int>;

// D: WAがあるらしい
int main() {
  int n, k;
  cin >> n >> k;
  vec<int> p(n);
  rep(i, n) cin >> p[i];
  rep(i, n) p[i]++;
  int mx = 0;
  int s = 0;
  queue<int> q;
  rep(i, n) {
    s += p[i];
    q.push(p[i]);
    if (q.size() > k) {
      s -= q.front(); q.pop();
    }
    if (q.size() == k) {
      mx = max(mx, s);
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int C = scan.nextInt();
        int[] B = new int[M];
        for (int i = 0; i < M; i++) {
            B[i] = scan.nextInt();
        }
        int answer = 0;
        for (int i = 0; i < N; i++) {
            int[] A = new int[M];
            for (int j = 0; j < M; j++) {
                A[j] = scan.nextInt();
            }
            int sum = 0;
            for (int j = 0; j < M; j++) {
                sum += A[j]*B[j];
            }
            sum += C;
            if (sum > 0) {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const double pi = 3.141592653589793;
#define MOD 1000000007
#define INF 10000000000000


signed main(){
  int ans=1;
  int n,m;
  cin>>m>>n;
  while(n>0){
    if(n&1) ans=m*ans%MOD;
    m=m*m%MOD;
    n>>=1;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int n,sum=0;
	cin >> n;
	vector<int>v(n);
	vector<int>c(n);
	vector<int>s(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		s[i] = v[i] - c[i];
		//cout << s[i] << endl;
	}
	sort(s.begin(), s.end());
	reverse(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		if (s[i] >= 0) {
			sum += s[i];
		}
		else {
			break;
		}
	}
	cout << sum << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i,H) cin >> S[i];
    vector<vector<int>> cum(H+1, vector<int>(W+1));
    REP(i,H) REP(j,W){
        cum[i+1][j+1] = cum[i][j+1] + cum[i+1][j] - cum[i][j] + (S[i][j] == '1');
    }
    int ans = INF;
    REP(i, 1<<(H-1)){
        vector<int> h;
        REP(j,H-1) if((i >> j) & 1) h.push_back(j+1);
        h.push_back(H);
        int cnt = (int)h.size() - 1;
        int preW = 0;
        bool ok = true;
        for(int j=1;j<=W;j++){
            int preH = 0;
            int tmp = 0;
            for(auto x : h){
                chmax(tmp, cum[x][j] - cum[preH][j] - cum[x][preW] + cum[preH][preW]);
                preH = x;
            }
            if(tmp > K){
                if(j == 1){
                    ok = false;
                    break;
                }
                preW = j - 1;
                j--;
                cnt++;
            }
        }
        int tmp = 0;
        int preH = 0;
        for(auto x : h){
            chmax(tmp, cum[x][W] - cum[preH][W] - cum[x][preW] + cum[preH][preW]);
            // if(i == 3) cout << x << " " << preW << " " << tmp << endl;
            preH = x;
        }
        // if(i == 3) cout << tmp << endl;
        if(tmp > K) ok = false;

        if(ok){
            chmin(ans, cnt);
            //cout << i << " " << cnt << endl;
        }
    }
    cout << ans << endl;
}

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

int main(void){ 
    int A = 0; //1-100
    int B = 0; //1-100
    int price = 1;

    cin >> A >> B;
    
    //消費税のMAXが100円なので、MAXでも100/0.08で1250円
    //1250円までサーチしてOK/NG判定すれば良い
    for(int price=1; price<1251; price++)
    {
        if( int(price*0.08) == A && int(price*0.10) == B)
        {
            cout << price << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

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

typedef long long ll;

// see: https://drken1215.hatenablog.com/entry/2020/06/21/224900
int main() {
  int N;
  cin >> N;

  vector<int> counts(1000000, 0);

  ll sum = 0;

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    // 数をメモっとく
    counts[tmp]++;
    sum += tmp;
  }

  int Q;
  cin >> Q;

  for (int i = 0; i < Q; i++) {
    ll b, c;
    cin >> b >> c;

    sum += (c - b) * counts[b]; // 移動させる分、sum を差分更新
    counts[c] += counts[b];  // カウントを移動
    counts[b] = 0;           // 移動させたカウント削除
    cout << sum << endl;
  }
}

Measured memory_bytes: 7168
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == '1')cout << 9;
		else cout << 1;
	}
	cout << endl;
}

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

  int x = N;
  int sum = 0;
  
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
void main(){
	int a, b;
	readf("%d %d\n", &a, &b);
	(a*b-(a+b)+1).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int X; cin>>X;
	cout<<8-(X-400)/200<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3592
MOD = 1_000_000_007
N,K = gets.split(' ').map(&:to_i)
trees = {}
(1..N).each do |i|
  trees[i] = []
end
(N-1).times do
  a,b = gets.split(' ').map(&:to_i)
  trees[a].push(b)
  trees[b].push(a)
end

nodes = []
visited = {1 => true}
# root
ans = K
# 1層目
count = K-1
trees[1].each do |id|
  ans *= count
  ans % MOD
  nodes.push(trees[id])
  visited[id] = true
  count -= 1
end
# 2層目
nodes.each do |tree|
  count = K-2
  tree.each do |id|
    next if visited[id]
    ans *= count
    ans %= MOD
    nodes.push(trees[id])
    visited[id] = true
    count -= 1
  end
end
p ans

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
    // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ll x,y;cin>>x>>y;
    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll t =(x+y) / 3;

    ll move_y = y-t;
    ll move_x = x-t;
    //cout << "y:"<< move_y << " x:"<<move_x<<endl;
    if(move_y < 0 || move_x < 0){
        cout << 0 << endl;
        return 0;
    }
    combination c(x+y);
    mint ans = c(move_x+move_y,move_x);
    cout << ans.x << endl;


    return 0;
}

Measured memory_bytes: 31488
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define mod 1000000007

void solve() {
	int n;cin>>n;
	string s; cin >> s;

	string a="",b="";

	for(int i=0;i<n/2;++i) {
		a+=s[i];
	}
	for(int i=n/2;i<n;++i) {
		b+=s[i];
	}

	if(a==b){
		cout << "Yes\n";
	}
	else cout << "No\n";
}


int main() {
	ios_base::sync_with_stdio(false);

	 solve();
	return 0;
} 


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
using namespace std;
typedef struct{
  char sign;
  int num;
}card;
int n;
card l[50005], r[50005];
int partition(card qarr[], int p, int t) {
  int x = qarr[t].num, change = p;
  card tmp;
  for (int i = p; i<t; ++i) {
    if (qarr[i].num <= x) {
      tmp = qarr[i];
      qarr[i] = qarr[change];
      qarr[change] = tmp;
      ++change;
    }
  }
  tmp=qarr[t];
  qarr[t]=qarr[change];
  qarr[change]=tmp;
  return change;
}
void quicksort(card qarr[], int p, int t) {
  if (p<t) {
    int q = partition(qarr, p, t);
    quicksort(qarr, p, q - 1);
    quicksort(qarr, q + 1, t);
  }
}
void merge(card marr[], int left, int mid, int right) {
  int x = mid - left, y = right - mid;
  for (int i = 0; i<x; ++i) l[i] = marr[left + i];
  for (int i = 0; i<y; ++i) r[i] = marr[mid + i];
  l[x].num = r[y].num = 1000000001;
  x = y = 0;
  for (int i = left; i<right; ++i) {
    if (l[x].num <= r[y].num) marr[i] = l[x++];
    else marr[i] = r[y++];
  }
}
void mergesort(card marr[], int left, int right) {
  if (left + 1<right) {
    int mid = (right + left) / 2;
    mergesort(marr, left, mid);
    mergesort(marr, mid, right);
    merge(marr, left, mid, right);
  }
}
int main() {
  card marr[100000], qarr[100000];
  scanf("%d", &n);
  for (int i = 0; i<n; ++i) {
    scanf("\n%c %d", &qarr[i].sign, &qarr[i].num);
    marr[i] = qarr[i];
  }
  quicksort(qarr, 0, n - 1);
  mergesort(marr, 0, n);
  int flag = 1;
  for (int i = 0; i<n; ++i)
    if (marr[i].sign != qarr[i].sign) flag = 0;
  if (flag) printf("Stable\n");
  else printf("Not stable\n");
  for (int i = 0; i<n; ++i) printf("%c %d\n", qarr[i].sign, qarr[i].num);
  return 0;
}


Measured memory_bytes: 5528
let n = Scanf.scanf "%d" (fun x -> x)
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
let calc c = a
  |> Array.map (fun v -> (v - c) * (v - c))
  |> Array.fold_left (+) 0
let () = Array.init 210 (fun v -> calc (v-105))
  |> Array.fold_left min 10101010101010
  |> Printf.printf "%d\n"

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

int main() {
  int N;
  cin >> N;
  int COUNT = 0;
  vector<int> B(N-1);
    cin >> B.at(0);
   COUNT +=B.at(0);
  
    for (int i = 1; i < N-1; i++) {
    cin >> B.at(i);
    COUNT += min( B.at(i),B.at(i-1) );
    }
  COUNT += B.at(N-2);
  cout << COUNT << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> T, long long M, std::vector<long long> P, std::vector<long long> X){
    LL sum = accumulate(ALL(T), 0LL);

    REP(i, M) {
        cout << (sum - T[P[i]-1] + X[i]) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final dice d = new dice();
        for(int i = 0; i<6; i++)
            d.face[i] = Integer.parseInt(sc.next());
        final int n = Integer.parseInt(sc.next());
        for(int i = 0; i<n; i++){
            final int top = Integer.parseInt(sc.next());
            final int front = Integer.parseInt(sc.next());
            d.rotateto(top, front);
            out.println(d.face[2]);
        }
        out.flush();
    }
}

class dice{
    public int face[] = new int[6];
    private static final String dir = "EEENWWWSEEENWWWSEEENWWWS";
    public void rotate(char dir){
        int temp;
        switch(dir){
        case 'N':
            temp = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = temp;
            break;
        case 'E':
            temp = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = temp;
            break;
        case 'W':
            temp = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = temp;
            break;
        case 'S':
            temp = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = temp;
            break;
        }
    }
    public boolean rotateto(final int top, final int front){
        for(int i = 0; i<24; i++){
            if(face[0]==top&&face[1]==front) return true;
            rotate(dir.charAt(i));
        }
        return false;
    }
};

Measured memory_bytes: 26204
<?php
$input_val_count = intval(fgets(STDIN));
$input_array = explode(" ", fgets(STDIN));
$devide_count = array();
foreach($input_array as $input_val) {
    $count = 0;
    $input_val = intval($input_val);
    while($input_val % 2 == 0) {
        $input_val = $input_val / 2;
        $count += 1;
    }
    array_push($devide_count, $count);
}
print min($devide_count);
?>

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int d, A;
    vector<int> ansA(N);
    for (int i = 0; i < N; i++)
    {
        ansA[i] = 1;
    }
    
    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> A;
            ansA[A-1] = 0;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += ansA[i];
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n, m, a, b;
	cin >> n >> m;
	vector<int> vec(n, 0);

	for(int i = 0; i < m; i++) {
		cin >> a >> b;
		vec.at(a - 1)++;
		vec.at(b - 1)++;
	}
	for(int i = 0; i < n; i++) {
		cout << vec.at(i) << endl;
	}
}

Measured memory_bytes: 256
card = Hash.new
card["a"] = gets.strip
card["b"] = gets.strip
card["c"] = gets.strip

turn = "a"
while 0 < card[turn].length
  next_turn  = card[turn][0]
  card[turn] = card[turn][1 .. -1]
  turn       = next_turn
end

puts turn.upcase


Measured memory_bytes: 1788
lst = (
    list(int(x) for x in input().split())
    + list(int(x) for x in input().split())
    + list(int(x) for x in input().split())
)

N = int(input())
lst2 = [int(input()) for _ in range(N)]
for i, n in enumerate(lst):
    if lst2.count(n) > 0:
        lst[i] = 0

if (
    sum(lst[:3]) == 0
    or sum(lst[3:6]) == 0
    or sum(lst[6:]) == 0
    or lst[0] + lst[3] + lst[6] == 0
    or lst[1] + lst[4] + lst[7] == 0
    or lst[2] + lst[5] + lst[8] == 0
    or lst[0] + lst[4] + lst[8] == 0
    or lst[2] + lst[4] + lst[6] == 0
):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cstring>

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

using namespace std;

const int MOD = 100000;
int dp[101][101][3][3];
int main(){
	int w, h;
	while(cin >> w >> h, w|h){
		memset(dp, 0, sizeof(dp));
		dp[0][0][0][0] = 1;
		rep(i, h){
			rep(j, w){
				rep(l, 3){
					rep(m, 3){
						if(l != 2 || m != 1) (dp[i][j+1][1][l] += dp[i][j][l][m]) %= MOD; 
						if(l != 1 || m != 2) (dp[i+1][j][2][l] += dp[i][j][l][m]) %= MOD;
					}
				}
			}
		}
	
		int ans = 0;
		rep(i, 3) rep(j, 3) ans += dp[h-1][w-1][i][j];
		cout << ans%MOD << endl;
	}

	return 0;
}

Measured memory_bytes: 1524
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    unsigned n;
    cin >> n;
    cout << bitset<32>(n) << endl;
    cout << bitset<32>(~n) << endl;
    cout << bitset<32>(n << 1) << endl;
    cout << bitset<32>(n >> 1) << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3132
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			
			for(int i=1;i<=n;i++) {
				double x = Math.floor(i*1.08);
				if(x==n) {
					System.out.println(i);
					return;
				}
			}
			
			System.out.println(":(");
		}
	}


Measured memory_bytes: 35852
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(std::string s){
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == ',')s[i] = ' ';
  }
  cout << s << endl;
}

// Generated by 1.1.6 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(){
    std::string s;
    std::cin >> s;
    solve(s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int r;
cin >> r;

cout << r*r << endl;

return 0;

}


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

int main(){
    int n,l;
    cin >> n >>l;
    vector<string>s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        cout << s[i];
    }
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, K;

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

  printf( "%d\n", N-K+1 );

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};


int main()
{
   int n;
   cin >> n;
   vector <int> vec(n);
   int max1 = 0;
   ll ans = 0;
   for(int i = 0; i < n; i++){
       cin >> vec[i];
       ans += 1LL*(vec[i]-1);
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int pow = sc.nextInt();
        
        double num = 1;
        
        for(int i=1; i<=pow; i++){
            num = num * i % (Math.pow(10, 9) + 7);
        }
        
        int ans = (int)num; 
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> pii;
typedef unsigned long ul;

int main() {
    int N;
    string S;
    cin >> N >> S;
    char alpha[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
                    'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
                    'W', 'X', 'Y', 'Z'};
    int tam = S.length();
    string ans;
    for (int i = 0; i < tam; ++i) {
        S[i] = alpha[(S[i] - 'A' + N) % 26];
    }
    cout << S << '\n';
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A_g = [i for i in A if i % 2 == 0]
A_k = [i for i in A if i % 2 == 1]

if len(A_k) % 2 == 1:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 14112
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define ll long long 
#define pii pair<int,int>
#define fi first
#define se second
#define bg begin
cs int RLEN=(1<<20)|3;
inline char gc(){
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline ll readll(){
	char ch=gc();
	ll res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;	
}
inline int readstring(char *s){
	char ch=gc();int l=0;
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++l]=ch,ch=gc();
	return l;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();return ch;
}
template<typename tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<typename tp>inline void chemn(tp &a,tp b){a<b?a=b:0;}
cs int mod=1e9+7;
inline int add(int a,int b){return (a+b>=mod)?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b>=mod)?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
cs int N=55;
int c[N][N],n,f[N][N];
inline void init_c(){
	for(int i=1;i<N;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)
		c[i][j]=add(c[i-1][j],c[i-1][j-1]);
	}
}
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	init_c();
	n=read();
	f[1][0]=f[1][1]=n;
	for(int i=1;i<n;i++)
	for(int j=0;j<=i;j++)
	for(int k=max(1,j);i+k<=n;k++)if(!((k-j)&1)){
		int v=(k-j)>>1;
		for(int l=0;l<=k;l++)
		Add(f[i+k][abs(v-l)],mul(c[n-i][k],mul(c[k][l],f[i][j])));
	}cout<<f[n][0]<<'\n';return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    
    n = ini()
    tmp = ina()
    num,index = 0,0
    for i in range(n):
        if(abs(tmp[i])>num):
            num,index = abs(tmp[i]),i
    print(2*n-2)
    if(tmp[index]<=0):
        for i in range(n):
            if(i!=index):
                print(index+1,i+1)
        for i in range(n,1,-1):
            print(i,i-1)
    else:
        for i in range(n):
            if(i!=index):
                print(index+1,i+1)
        for i in range(1,n):
            print(i,i+1)


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()


Measured memory_bytes: 27200
package main

import (
    "fmt"
    "strings"
)

func scanInput() (n int, pre []int, in []int) {
    fmt.Scanf("%d", &n)
    pre = make([]int, n)
    in = make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &pre[i])
    }
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &in[i])
    }
    return
}

func printSlice(slice []int) {
    fmt.Println(strings.Trim(strings.Join(strings.Fields(fmt.Sprint(slice)), " "), "[]"))
}

func main() {
    n, pre, in := scanInput()
    post := make([]int, 0, n)
    parent := 0

    walk(0, len(pre)-1, &parent, pre, in, &post)

    printSlice(post)
}

func walk(left, right int, parent *int, pre, in []int, post *[]int) {
    if left > right {
        return
    }

    dlm := pre[*parent]
    *parent++

    var idx int
    for i, v := range in {
        if v == dlm {
            idx = i
            break
        }
    }

    walk(left, idx-1, parent, pre, in, post)
    walk(idx+1, right, parent, pre, in, post)

    *post = append(*post, dlm)
}



Measured memory_bytes: 1232
ac = 0
wa = 0
tle = 0
re = 0

input_list = Array.new

while line = gets
  input_list << line.chomp! # 改行を削除
end
input_list.each do |input|
  case input
    when "AC"
    	ac +=1
    when "WA"
    	wa +=1
    when "TLE"
    	tle +=1
    when "RE"
    	re +=1
  	else
  end
end
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 20180
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>

using namespace std;

int n,m,x[101010]={0},y[101010]={0},z[101010]={0};
vector<int>e[101010];
int color[101010]={0};

signed main(){
    cin>>n>>m;
    

    for(int i=0;i<m;++i){
        cin>>x[i]>>y[i]>>z[i];
        e[x[i]].push_back(y[i]);
        e[y[i]].push_back(x[i]);
    }

    int num=0;
    for(int i=1;i<=n;++i){
        if(color[i]==0){
            num++;
            color[i]=1;
            stack<int>st;
            st.push(i);
            while(!st.empty()){
                int u=st.top();
                st.pop();
                for(int j=0;j<e[u].size();++j){
                    if(color[e[u][j]]==0){
                        st.push(e[u][j]);
                        color[e[u][j]]=1;
                    }
                }
            }
        }
    }

    cout<<num<<endl;

    return 0;
}

Measured memory_bytes: 8184
use proconio::input;

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

    let mut dp = vec![0; s + 1];
    dp[0] = 1;
    let mo = 10usize.pow(9) + 7;

    for i in 0..=s {
        let mut sub = 3;
        while i >= sub {
            dp[i] += dp[i - sub];
            dp[i] %= mo;
            sub += 1;
        }
    }

    println!("{}", dp[s])
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  vector<bool> b(1000);
  vector<vector<int>> c(n,vector<int>(10));
  c[0][s[0]-'0']=1;
  for(int i=1;i<n;i++){
    for(int j=0;j<10;j++){
      if(j==s[i]-'0'){
        c[i][j]=c[i-1][j]+1;
      }
      else{
        c[i][j]=c[i-1][j];
      }
    }
  }
  for(int i=1;i<n-1;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        if(c[i-1][j]>=1&&c[n-1][k]-c[i][k]>=1){
          int t=s[i]-'0';
          b[j*100+t*10+k]=true;
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<1000;i++){
    if(b[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 1e5
#define PI 3.141592653589793
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int i, j, k;
    int N;
    vector<int> L;
    cin >> N;
    rep(i, N)
    {
        int a;
        cin >> a;
        L.push_back(a);
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for (i = 0; i < N; i++)
    {
        for (j = i + 1; j < N; j++)
        {
            auto it = lower_bound(L.begin(), L.end(), L[i] + L[j]);
            int count = it - L.begin() - j - 1;
            int mae = ans;
            ans += it - L.begin() - j - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256