akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
5
6 9 12 10 8

2 3  4  5 1
3 4  5  1 2
1 2  3  4 5
ん？
総数 45=12345*3
3回やるとか
とれない時は操作しちゃだめ
特定箇所を複数回もありうる

5
6 9 12 10  8
9 9  9  9  9
3 0 -3  1 -1

5
4 5  1  2 3
3 3  3  3 3
1 2 -2 -1

打ち消しできればOKとか？

1234
1234
1234
1234

 4  8 12 16
10 10 10 10

1423
1423

 2  8  4  6
 5  5  5  5
-3 +3 -1 +1
そうでもないな
全探索するのが楽なんだが間に合うわけが無い
N^2くらい？かなり近いっちゃちかい

12345
12345
12345

3 6 9 12 15

51234
7 5 8 11 14
45123
+33-222
+222-33
+1111-4
変数N個の連立方程式なん

5
6 9 12 10 8

x1x2x3x4x5

x1*5+x2*4+x3*3+x4*2+x5*1=6
x1*1+x2*5+...           =9

e=6 -5a-4b-3c-2d
a=9 -   5b-4c-3d-2e
b=12-2a   -5c-4d-3e
c=10-3a-2b   -5d-4e
d=8 -4a-3b-2c-  -5e
みたすくみあわせを全通り探す？そんなんあるかな
最大40000回くらい
全部10^9=40000*40000/2くらい？
総和
みつけたとして、確認するのに？N？
確認不要の方法･･･
全部総和10^9
nC2=10^9
rt2*10^9
10^4*root20
44000
これみたすのってそんななかったりするかな
5=3
113
122

ああ、差をとるのか
それで初期値ひいておいて、回数分Nを足す

5
6 9 12 10 8

3 3 -2 -2 -2
あれ、どこかたすと
4 -1 -1 -1 -1
これを3回やる
あらかじめ3をひいておいて、+5をする
0 0 -5 -5 -5

これで、3，4，5を1回ずつとわかる
負なのいやだな


5
6 9 12 10 8

-3 -3 2 2 2
+3
 0  0 5 5 5
*/
int main(){
  ll N,S=0,NN=0,k=0; cin>>N;
  NN=(N*(N+1))/2;
  vector<ll> A(N,0),B(N,0);
  for(ll i=0; i<N; i++) cin>>A[i];
  for(ll i=0; i<N; i++) S+=A[i];
  if(S%NN>0){
    cout<<"NO"<<endl;
    return 0;
  }
  k=S/NN;
  for(ll i=0; i<N; i++){
    ll n=(i<N-1)?i+1:0;
    B[i]=A[i]-A[n]+k;
  }
//for(ll i=0; i<N; i++) cout<<B[i]<<" ";
  for(ll i=0; i<N; i++){
    if(B[i]%N>0 || B[i]<0){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

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

int table[252][252];

int mass[252];

int main() {

    int rmax,n;

    while(1){

        scanf(" %d",&rmax);

        if(rmax == 0){
            break;
        }

        scanf(" %d",&n);

        for(int i=0;i<=n+1;i++){
            for(int j=0;j<=n+1;j++){
                table[i][j] = 0;
            }
        }

        mass[0] = 0;
        mass[n+1] = 0;


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

        for(int i=0;i<=n;i++){
            for(int j=1;j<=rmax;j++){
                if(i+j+mass[i+j]>n+1){
                    table[i][n+1] = 1;
                }
                else if(i+j+mass[i+j] < 0){
                    table[i][0] = 1;
                }
                else{
                    table[i][i+j+mass[i+j]] = 1;
                }
            }
        }

        /*for(int i=0;i<=n+1;i++){
            for(int j=0;j<=n+1;j++){
                cout << table[i][j] << " ";
            }
            cout << endl;
        }cout << endl;*/

        for(int k=0;k<=n+1;k++){
            for(int i=0;i<=n+1;i++){
                for(int j=0;j<=n+1;j++){
                    if(table[k][j] == 1 && table[i][k] == 1) {
                        table[i][j] = 1;
                    }
                }
            }
        }

        /*for(int i=0;i<=n+1;i++){
            for(int j=0;j<=n+1;j++){
                cout << table[i][j] << " ";
            }
            cout << endl;
        }cout << endl;*/

        bool check = true;

        for(int i=0;i<=n;i++){
            if(table[0][i] == 1 && table[i][n+1] == 0){
                check = false;
                printf("NG\n");
                break;
            }
        }

        if(check){
            printf("OK\n");
        }

        /*for(int i=0;i<=n+1;i++){
            for(int j=0;j<=n+1;j++){
                cout << table[i][j] << " ";
            }
            cout << endl;
        }*/



    }



    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.second == b.second){
        return a.first < b.first;
    }
    return a.second < b.second;
}
int main()
{
    fio;
    ll a, b, c;
    cin >> a >> b >> c;
    ll k = a / (b + c);\
    ll kk = a % (b + c);
    if(kk == 0){
        cout << b * k << endl;
    }
    else{
        if(kk > b){
            cout << (b * k) + b << endl;
        }
        else cout << (b * k) + kk << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,n,p;
    cin>>x>>n;
    std::deque<int> deq;
    std::map<int, int> map;
    if (n!=0) {
        for (int i=0;i<n;i++) {
            cin>>p;
            deq.emplace_back(p);
            map.emplace(p,1);
        }
        sort(deq.begin(),deq.end());
        auto itr=lower_bound(deq.begin(),deq.end(),x);
        if (itr!=deq.end()) {
            for (int i=1;i<=100;i++) {
                if (map[*itr-i]==0) {
                    cout<<*itr-i<<endl;
                    return 0;
                } else if (map[*itr+i]==0) {
                    cout<<*itr+i<<endl;
                    return 0;
                }
            }
        } else {
            for (int i=0;i<=100;i++) {
                if (map[x-i]==0) {
                    cout<<x-i<<endl;
                    return 0;
                } else if (map[x+i]==0) {
                    cout<<x+i<<endl;
                    return 0;
                }
            }
        }
    } else {
        cout<<x<<endl;
    }
}

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

int main(void)
{
	double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
	
	while (cin>>ax1>>ay1>>ax2>>ay2>>bx1>>by1>>bx2>>by2){
		if (ax1 <= bx2 && bx1 <= ax2 && ay1 <= by2 && by1 <= ay2){
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int64_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int64_t ans = 0;
    
    if (A + B <= 2 * C) {
        ans = X * A + Y * B;
    } else if (X > Y) {
        if (A <= 2 * C) ans = 2 * Y * C + (X - Y) * A;
        else ans = 2 * X * C;
    } else {
        if (B <= 2 * C) ans = 2 * X * C + (Y - X) * B;
        else ans = 2 * Y * C;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll func(ll a){
    ll cnt = 0;
    while(a != 0){
        bitset<20> B = a;
        ll S = B.count();
        a = a % S;
        cnt++;
    }
    return cnt;
}


int main(){
    ll N; cin >> N;
    string S; cin >> S;
    ll BS = 0;
    for(auto ch : S) if(ch == '1') BS++;
    ll MULS = 0;
    ll MULR = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == '1') {
            MULS += modpow(2, N-i-1, BS+1);
            MULS %= (BS+1);
            if(1 < BS) {
                MULR += modpow(2, N-i-1, BS-1);
                MULR %= (BS-1);
            }
        }
    }
    for(int i = 0; i < N; i++){
        ll MUL;
        if(S[i] == '1'){
            if(BS == 1) {cout << 0 << endl; continue; }
            if(1 < BS)MUL = MULR - modpow(2, N-i-1, BS-1);
            if(1 < BS)MUL = (MUL + BS-1) % (BS-1);
        }
        else{
            MUL = MULS + modpow(2, N-i-1, BS+1);
            MUL = (MUL + BS+1) % (BS+1);
        }
        cout << func(MUL)+1 << endl;
    }


} 


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int level[200005];
int v[200005];
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> g[200005];
	while(m--){
		int a,b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(level,-1,sizeof(level));
	level[1] = 0;
	queue<int> q;
	q.push(1);

	while(q.size()){
		int u=q.front();
		q.pop();
		if(!v[u]){
			v[u] = true;
			for(int i=0;i<g[u].size();++i){
				int r = g[u][i];
				if(!v[r]){
					q.push(r);
					level[r] = level[u] +1;
				}
			}
		}
	}
	if(level[n]==2)cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
}

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

int n,m,q,a[50],b[50],c[50],d[50],ans;
int p[10];

void dfs(int len,int pre){
    if(len==n){
        int sum=0;
        for(int i=0;i<q;i++) if(p[b[i]-1]-p[a[i]-1]==c[i]) sum+=d[i];
        ans=max(ans,sum);
        return;
    }
    for(int i=pre;i<=m;i++){
        p[len]=i;
        dfs(len+1,i);
    }
}

main()
{
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(0,1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3572
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 81;

const int sz = 160 * 80 * 2 + 100;

int n, m;
int a[MAXN][MAXN];
bitset<sz> dp[MAXN][MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int x;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> x;
            a[i][j] -= x;
            a[i][j] = abs(a[i][j]);
        }
    }
    int z = 160 * 80 + 1;
    dp[0][0][z - a[0][0]] = 1;
    dp[0][0][z + a[0][0]] = 1;
    for (int i = 1; i < n; i++) {
        dp[i][0] = ((dp[i - 1][0] << a[i][0]) | (dp[i - 1][0] >> a[i][0]));
    }
    for (int i = 1; i < m; i++) {
        dp[0][i] = ((dp[0][i - 1] << a[0][i]) | (dp[0][i - 1] >> a[0][i]));
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            dp[i][j] = (dp[i - 1][j] << a[i][j]);
            dp[i][j] |= (dp[i - 1][j] >> a[i][j]);
            dp[i][j] |= (dp[i][j - 1] << a[i][j]);
            dp[i][j] |= (dp[i][j - 1] >> a[i][j]);
        }
    }
    int ans = 1e9;
    for (int i = 0; i < sz; i++) {
        if (dp[n - 1][m - 1][i]) ans = min(ans, max(i - z, z - i));
    }
    cout << ans;
}
/*

*/


Measured memory_bytes: 20864
#include<iostream>
#include<stack>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
    stack<int> S1; 
    stack<pair<int,int>> S2; 
    char ch; 
    int sum=0;

    for (int i=0;cin>>ch;i++){
        if(cin.eof())break;
        if(ch == '\\')S1.push(i);
        else if(ch == '/' && S1.size()>0){
            int j=S1.top(); S1.pop();
            sum += i-j;
            int a = i-j;
            while(S2.size() > 0 && S2.top().first>j){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }   

    cout << sum << endl;
    vector<int> ans;
    int sz = S2.size();
    //for (int i=0;i<sz;i++){
    while(S2.size()>0){
        ans.push_back(S2.top().second); S2.pop();
    }   

    reverse(ans.begin(),ans.end());
    cout << ans.size();
    for (int i=0;i<ans.size();i++){
        cout << " " << ans[i];
    }   
    cout << endl;
    return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

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

	int score = 0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] == S[i]) score++;
	}

	int ans = min(score + 2 * K, N - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#define USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

string S, T;
bool pos;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> S >> T;
	
	pos = true;
	if ((ll)S.length() + 1 != (ll)T.length()) pos = false;
	for (ll i = 0; i < (ll)S.length(); i++) {
		if (S[i] != T[i]) pos = false;
	}
	
	if (pos) cout << "Yes";
	else cout << "No";
	
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

    while (in.hasNext()) {
      int X = in.nextInt();
      int A = in.nextInt();

      if (X < A) {
        System.out.println(0);
      } else {
        System.out.println(10);
      }
    }
  }
}

Measured memory_bytes: 24020
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define mp make_pair

const int N = 100000;
long long s[N], ans[N];
vector<int> g[N];
int sz[N];
int n;
map<pair<int, int>, int> edge_i;
map<int, pair<int, int>> i_edge;

void dfs(int u, int prev) {
        sz[u] = 1;
        for (auto v : g[u]) if (v != prev) {
                dfs(v, u);
                sz[u] += sz[v];
                long long diff = (n - sz[v]) - sz[v];
                long long res = (diff == 0 ? 0 : (s[v] - s[u]) / diff);
                ans[edge_i[mp(min(u, v), max(u, v))]] = res;
        }
};

void dfs2(int u, int prev, long long &res) {
        for (auto v : g[u]) if (v != prev) {
                dfs2(v, u, res);
                res += sz[v] * ans[edge_i[mp(min(u, v), max(u, v))]];
        }
};

int main() {
        scanf("%d", &n);
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
                edge_i[mp(min(a, b), max(a, b))] = i;
                i_edge[i] = mp(min(a, b), max(a, b));
        }
        for (int i = 0; i < n; i ++) scanf("%lld", &s[i]);
        dfs(0, -1);
        for (int i = 0; i < n - 1; i ++) if (ans[i] == 0) {
                int u, v;
                tie(u, v) = i_edge[i];
                long long res = 0;
                dfs2(0, -1, res);
                ans[i] = (s[0] - res) / (n / 2);
                break;
        }
        for (int i = 0; i < n - 1; i ++) printf("%lld\n", ans[i]);
        return 0;
}


Measured memory_bytes: 33280
#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int n;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

// 座標は 2n+2 個ある
void coordinate_compress(vector<int> &xl, vector<int> &xr, int &t) {
  vector<int> xc(2 * n + 2);
  for (int i = 0; i < n; i++) {
    xc[i]     = xl[i];
    xc[i + n] = xr[i];
  }
  xc[2 * n] = 0;
  xc[2 * n + 1] = t;

  sort(xc.begin(), xc.end());
  // 重複を削除
  xc.erase( unique(xc.begin(), xc.end()), xc.end() );

  map<int,int> zip;
  for (int i = 0; i < xc.size(); i++) {
    zip[xc[i]] = i;
  }

  for (int i = 0; i < n; i++) {
    xl[i] = zip[ xl[i] ];
    xr[i] = zip[ xr[i] ];
  }
  t = zip.size() - 1;
}

int main() {
  // ifstream cin("../test.txt");
  while (true) {
    int w,h;
    cin >> w >> h >> n;

    if (!(w|h)) break;

    vector<int> xl, yl, xr, yr;
    xl = vector<int>(n);
    xr = vector<int>(n);
    yl = vector<int>(n);
    yr = vector<int>(n);
    for (int i = 0; i < n; i++) {
      cin >> xl[i] >> yl[i] >> xr[i] >> yr[i];
    }

    // 座標圧縮
    coordinate_compress(xl, xr, w);
    coordinate_compress(yl, yr, h);


    // 表示　テープの座標
    // for (int i = 0; i < n; i++) {
    //   cout << w << " " << h << endl;
    //   cout << xl[i] << " " << yl[i] << " " << xr[i] << " " << yr[i] << endl;
    // }

    // テープを貼る
    // 格子は左下の座標を基準にする
    vector< vector<int> > m (w, vector<int>(h+1));
    for (int i = 0; i < w; i++) {
      for (int j = 0; j <= h; j++) {
        m[i][j] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int x = xl[i]; x < xr[i]; x++) {
        m[x][yl[i]] += 1;
        m[x][yr[i]] -= 1;
        if (xl[i] >= w || xr[i] > w || yl[i] >= h || yr[i] > h)
          cout << "warning" << endl;
      }
    }

    for (int y = 1; y < h; y++) {
      for (int x = 0; x < w; x++) {
        m[x][y] += m[x][y-1];
      }
    }

    // 色を幅優先で塗る
    int cnt_clr = 0;
    queue< pair<int, int> > qu;
    for (int x = 0; x < w; x++) {
      for (int y = 0; y < h; y++) {
        if (m[x][y] <= 0) { // テープがなければ色塗り開始
          cnt_clr++;
          qu.push(make_pair(x,y));
          while (!qu.empty()) {
            pair<int, int> p = qu.front();
            qu.pop();
            for (int i = 0; i < 4; i++) {
              int nx = p.first  + dx[i];
              int ny = p.second + dy[i];
              if (nx >= 0 && nx < w && ny >= 0 && ny < h && m[nx][ny] <= 0) {
                m[nx][ny] = 1;
                qu.push(make_pair(nx,ny));
              }
            }
          }
        }
      }
    }

    // 出力
    cout << cnt_clr << endl;
  }
}

Measured memory_bytes: 2392
// Problem : L - Deque
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_l
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 3005;
#ifndef LOCAL
#define cerr if(0)cout
#endif

ll dp[MAXN][MAXN];
ll A[MAXN];

int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,1,n)cin>>A[i];
	DEC(i,n,1) {
		FOR(j,i,n) {
			if(i==j)dp[i][j]=A[i];
			else dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1]);
		}
	}
	cout << dp[1][n];
}



Measured memory_bytes: 70144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    set<char> st;
    rep(i, s.size()) st.insert(s[i]);
    cout << (st.size() == s.size() ? "yes" : "no") << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  int i,counter=0;
  for(i=0;i<N;i++){
    cin >> A[i];
  }
  int flag = 1;
  while(flag == 1){
    for(i=0;i<N;i++){
      if( A[i]%2 == 0 && i == N-1){
         counter++;
      }else if( A[i]%2 == 0){
         A[i] /= 2;
      }else if( A[i]%2 != 0){
         flag = 0;
         break;
      }
    }
  }
  cout << counter << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int a[10000];

bool is_prime(int n){
    if(n<=1){return false;}
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    
    int ans=0;
    for(int i=0;i<n;i++){
        if(is_prime(a[i])){
            ans++;;
        }
    }
    cout<<ans<<endl;
   
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
ll N;
ll ans=0;
vec d;
const ll MAXN=1000010;
bool arrived[MAXN];

void Solve(ll i){
    if(arrived[d[i]]) return;
    if(i==N-1) ans++;
    else if(d[i]!=d[i+1]) ans++;
   // cout<<"arrived"<<endl;
    for(ll j=1; j*d[i]<MAXN; j++) arrived[d[i]*j]=true;
    return;
}
int main(){
    char x; cin>>x;
    ll a=x-'a';
    if(0<=a && a<26) cout<<'a'<<endl;
    else cout<<'A'<<endl;

}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for(int i = 0;i < H;i++) {
                    for(int j = 0;j < W;j++) {
                        if(i==0||j==0||i==H-1||j==W-1){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                    }
                    System.out.print("\n");
                }
                System.out.print("\n");
            }
        }
    }
}


Measured memory_bytes: 35376
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def calc(nn, a,b,c,d):
    global dp

    if nn in dp :
        return dp[nn]
    if nn == 0:
        return 0
    
    ncost = []
    # /2
    if nn%2 == 0:
        tcost = calc(nn//2, a,b,c,d)
        ncost.append(tcost + min((nn//2)*d , a))
    else:
        tcost = calc((nn-1)//2, a,b,c,d)
        ncost.append(tcost + min(((nn-1)//2)*d + d , a+d))

        tcost = calc((nn+1)//2, a,b,c,d)
        ncost.append(tcost + min(((nn+1)//2)*d + d , a+d))

    # /3
    if nn%3 == 0:
        tcost = calc(nn//3, a,b,c,d)
        ncost.append(tcost + min((nn//3)*2*d , b))
    else:
        m = nn%3
        tcost = calc((nn-m)//3,  a,b,c,d)
        ncost.append(tcost + min(((nn-m)//3)*2*d + d*m , b+d*m) )
        tcost = calc((nn+(3-m))//3, a,b,c,d)
        ncost.append(tcost + min((nn+(3-m))//3*2*d + d*(3-m) , b+d*(3-m)))

    # /5
    if nn%5 == 0:
        tcost = calc(nn//5, a,b,c,d)
        ncost.append(tcost + min((nn//5)*4*d , c))
    else:
        m = nn%5
        tcost = calc((nn-m)//5 , a,b,c,d)
        ncost.append(tcost +  min(((nn-m)//5)*4*d + d*m , c+d*m))
        tcost = calc((nn+(5-m))//5, a,b,c,d)
        ncost.append(tcost +  min((nn+(5-m))//5*4*d + d*(5-m) , c+d*(5-m)))

    mincost = min(ncost) 
    dp[nn] = mincost
    return mincost

t = ii()
ans = []
for i in range(t):
    n,a,b,c,d = mi()
    dp = {}
    dp[1] = d
    ansi = calc(n,a,b,c,d)
    ans.append(ansi)

for i in range(t):
    print(ans[i])


Measured memory_bytes: 11148
#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b) {
    int c = 0;
    if(b > a) {
        int tmp = b;
        b = a;
        a = tmp;
    }
    while(1) {
        c = a % b;
        if(c == 0) break;
        a = b;
        b = c;
    }
    return b;
}

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    while(A.size() > 1) {
        int a = gcd(*A.begin(), *(A.begin() + 1));
        A.erase(A.begin());
        A[0] = a;
    }
    cout << A[0] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    ll n, a;
    ll ans = 1;
    int flag = 1;
    scanf("%lld", &n);
    rep(i, n)
    {
        ll pre = ans;
        scanf("%lld", &a);
        if (a != 0)
            if (pre < LLONG_MAX / a)
                ans *= a;
            else
                flag = 0;
        else if (pre != 0)
            if (a < LLONG_MAX / pre)
                ans *= a;
            else
                flag = 0;
        else
            ans *= a;
    }

    if (ans == 0)
    {
        puts("0");
        return 0;
    }

    if (ans > 1000000000000000000 || flag == 0)
        ans = -1;

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

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define N 100
#define INFTY (1<<21)
#define WH 0
#define GR 1
#define BL 2
using namespace std;

vector<int> color(N),d(N),p(N);
vector<vector<int>> M(N,vector<int>(N));
int n;

void dijkstra(){
	for(int i=0;i<n;i++){
		color.at(i) = WH;
		d.at(i) = INFTY;
	}
	d.at(0) = 0;
	color.at(0) = GR;
	
	while(1){
		int mincost = INFTY;
		int u = -1;
		for(int i=0;i<n;i++){
			if(color.at(i) != BL && d.at(i) < mincost){
				mincost = d.at(i);
				u = i;
			}
		}
		if(u == -1) break;
		
		color.at(u) = BL;
		
		for(int v=0;v<n;v++){
			if(color.at(v) != BL && M.at(u).at(v) != INFTY){
				if(d.at(u) + M.at(u).at(v) < d.at(v)){
					d.at(v) = d.at(u) + M.at(u).at(v);
					p.at(v) = u;
					color.at(v) = GR;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		cout << i << " ";
		if(d.at(i) == INFTY) cout << -1 << endl;
		else cout << d.at(i) << endl;
	}
	
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			M.at(i).at(j) = INFTY;
		}
	}
	int k,c,u,v;
	for(int i=0;i<n;i++){
		cin >> u >> k;
		for(int j=0;j<k;j++){
			cin >> v >> c;
			M.at(u).at(v) = c;
		}
	}
	dijkstra();
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ptr = 0;
		int[] prime = new int[10001];
		boolean[] check = new boolean[10001];
		check[0] = false;
		check[1] = false;
		check[2] = true;
		check[3] = true;
		prime[ptr++] = 2;
		prime[ptr++] = 3;
		for(int i = 5; i <= 10000; i += 2){
			boolean wflag = false;
			for(int j = 1; prime[j] * prime[j] <= i; j++){
				if(i % prime[j] == 0){
					wflag = true;
					break;
				}
			}
			if(!wflag){
				prime[ptr++] = i;
				check[i] = true;
			}
		}
		while(sc.hasNext()){
			int n = sc.nextInt();
			int ans = 0;
			for(int i = 1; i <= n; i++){
				if(check[i] && check[n - i + 1])
					ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 24072
n = int(input())
ls = list(map(int, input().split()))
# 二分探索で探す?
# あるkがあったとして,nCkが最大になるkはnが最大のときである.
# したがって,ソートした後にひとつずつ考えればよい.
ls = sorted(ls, key=lambda x: -x)

ans = [ls[0], ls[1]]
dif = ans[0] - ans[1] if ans[1] > ans[0] // 2 else ans[1]
for i in range(2, n):
    if ls[i] > ans[0] // 2:
        tmpdif = ans[0] - ls[i]
    else:
        tmpdif = ls[i]
    if tmpdif > dif:
        dif = tmpdif
        ans[1] = ls[i]
print(str(ans[0]) + " " + str(ans[1]))


Measured memory_bytes: 64748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(ll i=1;i<=n;i++) 
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
    for(ll i=1;i<=m;i++) 
	{
		cin>>b[i];
		b[i]+=b[i-1];
	}
    for(ll i=0;i<=n;i++) 
		if(k>=a[i]) 
			ans=max(ans,upper_bound(b+1,b+1+m,k-a[i])-b-1+i);
    cout<<ans;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=(ll)1e9+7;

int main(){
  ll n,k,a;
  cin>>n>>k;
  vector<ll> p,z,m;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>=0)p.push_back(a);
    if(a<0)m.push_back(a);
  }
  ll ps=p.size(),ms=m.size();
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(m.begin(),m.end());
  ll kk=k,pmax=0,mmax=0,pmin=ps-1,mmin=ms-1;
  while(k>1){
    k-=2;
    if(pmax+1<ps && mmax+1<ms && p[pmax]*p[pmax+1]>=m[mmax]*m[mmax+1]){pmax+=1;k++;}
    else if(pmax+1<ps && mmax+1<ms && p[pmax]*p[pmax+1]<m[mmax]*m[mmax+1])mmax+=2;
    else if(pmax+1>=ps && mmax+1<ms)mmax+=2;
    else if(pmax+1<ps && mmax+1>=ms)pmax+=2;
    else{mmax++;pmax++;}
  }
  while(kk>1){
    kk-=2;
    if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]>=m[mmin]*m[mmin-1])mmin-=2;
    else if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]<m[mmin]*m[mmin-1]){pmin-=1;kk++;}
    else if(pmin-1<0 && mmin-1>=0)mmin-=2;
    else if(pmin-1>=0 && mmin-1<0)pmin-=2;
    else{mmin--;pmin--;}
  }
  ll ans=1;
//  cout<<k<<" "<<pmax<<" "<<mmax<<" "<<pmin<<" "<<mmin<<endl;
  if(k==0 || (k==1 && pmax<ps)){
    if(k==1 && pmax<ps)pmax++;
    for(int i=0;i<pmax;i++){
      ans*=p[i];ans%=MOD;
    }
    for(int i=0;i<mmax;i++){
      ans*=m[i];ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
  }
  else if(k==1 && pmax==ps){
    mmin--;
    for(int i=ps-1;i>pmin;i--){
      ans*=p[i];ans%=MOD;
    }
    for(int i=ms-1;i>mmin;i--){
      ans*=m[i];ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
  }
}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int ans_H = 0;
        int ans_W = 0;
        for (int i = 1; i <= H; i++) {
            for (int j = 0; j < W; j++) {
                String s = scan.next();
                if ("snuke".equals(s)) {
                    ans_H = i;
                    ans_W = j;
                    break;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        sb.append((char)((int)'A'+ans_W));
        sb.append(ans_H);
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=101;
long long arr[N];
int a[N],b[N];
vector<double> slope;
bool bo[N];
int main()
{


/*

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

    cin>>a[i]>>b[i];
bo[i]=true;


}
int counter=0;
for(int i=0;i<n;i++){

if(bo[i]==false)continue;
    double res=(b[i]-y)*(a[i]-x);


    for(int j=0;j<n;j++){

        if(i!=j ) {

            if(res==((b[j]-y)*(a[j]-x))) {bo[j]==false; bo[i]=false; }


            }



        }
        counter++;

    }




cout<<counter;

*/

/*
vector<long long>vc;

long long n;
cin>>n;

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

    if(n%i==0)vc.push_back(i);
}
long long res=10e13;

for(long long int i=0;i<vc.size();i++){

    res=min(res,abs(vc[i]-1+(n/vc[i])-1));

}

cout<<res;
*/



int n;
cin>>n;
int t=n;
n--;
long long int mini=10e5;
for(int i=0;i<n;i++)cin>>arr[i];
long long res=arr[n-1]+arr[0];
for(int i=0;i<n-1;i++){res+=min(arr[i],arr[i+1]);
//cout<<arr[i]<<" ";}
}
cout<<res;


}


Measured memory_bytes: 256
let op x = match x with
    "+" -> (+)
  | "-" -> (-)
  | "*" -> ( * )
  | "/" -> (/)
  | _ -> (fun x -> fun x -> x);;

let rec read () =
  let f x y z = match (x,y,z) with
    (_,"?",_) -> ()
    | (x,y,z) -> Printf.printf "%d\n" ((op y) x z);read ()
  in
  Scanf.scanf "%d %s %d\n" f;;

 let () = read ();;

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int h, w, n;
   cin >> h >> w >> n;

   h = max(h, w);
   if (n % h == 0)
   {
      cout << n / h << '\n';
   }
   else
      cout << n / h + 1 << '\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int[] benefit = new int[n];
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			benefit[i] = Math.max(0, x - min);
			min = Math.min(min, x);
		}
		Arrays.sort(benefit);
		int prev = benefit[n - 1];
		int count = 1;
		for (int i = n - 2; i >= 0; i--) {
			if (prev == benefit[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 52584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=1LL<<60;

ll dfs(ll x,vl &dp,vvl &graph){
    if(dp[x]!=-1){return dp[x];}
    ll Max=-INF;
    for(ll i=0;i<graph[x].size();i++){
        Max=max(Max,dfs(graph[x][i],dp,graph))
    ;}
    if(Max==-INF){return dp[x]=0;}
    return dp[x]=Max+1;
}

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> x(M,0);
    vector<ll> y(M,0);
    vector<vector<ll>> graph(N+1, vector<ll>(0));
    for(ll i=0;i<M;i++){
        cin>>x[i]>>y[i];
        graph[x[i]].emplace_back(y[i]);
    ;}
    vector<ll> dp(N+1,-1);
    for(ll i=0;i<N;i++){
        dfs(i+1,dp,graph);
    ;}
    ll ans=-INF;
    for(ll i=0;i<N;i++){
        ans=max(ans,dp[i+1]);
    ;}
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int R, C, K;   cin >> R >> C >> K;
    vector<vector<long long> > vec(R, vector<long long>(C, 0));
    for (int i = 0; i < K; i++) {
        int r, c;   long long v;    cin >> r >> c >> v;
        vec[r-1][c-1] = v;
    }

    vector<vector<vector<long long > > > dp(R, vector<vector<long long > >(C, vector<long long> (4, 0)));
    if (vec[0][0]) {
        dp[0][0][1] = vec[0][0];
    }

    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < 4; k++) {
                if (i+1 < R) {
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                    if (vec[i+1][j])
                        dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + vec[i+1][j]);
                }
                if (j+1 < C) {
                    dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                    if (vec[i][j+1] && k < 3)
                        dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + vec[i][j+1]);
                }
            }
        }
    }

    long long ans = 0;
    for (int i = 0; i <= 3; i++)
        ans = max(ans, dp[R-1][C-1][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 706580
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{    
  int N;
  cin >> N;
  int ans = 1;
  for (int i = 0; i < 10; i++)
  {
    if (ans*2 > N){
      break;
    }
    ans *= 2;
  }
  cout << ans << endl;
  
} 


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li];
int cev;
//~ char dp[li];
string s;
vector<int> v;

int main(void){
	fio();
	cin>>n>>s;
	for(int i=0;i<=25;i++){
		dp[i]=(i+n)%26;
		//~ dp[i]='a'+(dp[i]%'z');
	}
	for(int i=0;i<(int)s.size();i++){
		cout<<(char)(dp[s[i]-'A']+'A');
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
map<string ,int>t;
int32_t main()
{
    IOS
    string k;
    cin>>k;
    string have="";
    int key=0;
    fa(i,k)
    {
        string now="";
        now+=i;
        if(key)
        {
            have+=i;
            key=0;
            ans++;
            continue;
        }
        if(now==have)
        {
            key=1;
        }else{
            ans++;
            have="";
            have+=i;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    string S;
    int x;
    cin >> S;

    x=S.size();

    if(S.at(x-1) == 's'){
        cout << S + "es" << endl; 
    }
    else
    {
        cout << S + "s" << endl;
    }
    

}


Measured memory_bytes: 3596
#include<stdio.h>
typedef long long ll;
ll x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	ll sum=0;
	ll k=x;
	while(k<=y)
	{
		sum++;
		k*=2;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
ans = [0 for _ in range(n+1)]
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      s = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if s <= n:
        ans[s] += 1
for i in range(1,n+1):
  print(ans[i])

Measured memory_bytes: 69508
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int N; cin>>N;
    long long int L[N];L[0]=2;L[1]=1;
    for(int i=2;i<=N;i++){
        L[i]=L[i-1]+L[i-2];
    }
    cout<<L[N];
    return 0;
}

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

int main()
{
	int A, B;
	cin >> A >> B;
	if(A == B) cout << "Draw" << endl;
	else{
		if(A == 1) cout << "Alice" << endl;
		else if(B == 1) cout << "Bob" << endl;
		else{
			if(A > B) cout << "Alice" << endl;
			else cout << "Bob" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int bingo[3][3], b[10];
int lines[3] = {3, 3, 3};
int cols[3] = {3, 3, 3};
int dp = 3;
int ds = 3;
int N;

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

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> bingo[i][j];
		}
	}

	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> b[i];
	}

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < N; k++){

				if(bingo[i][j] == b[k]){
					lines[i]--;
					cols[j]--;

					if(i == j){
						dp--;
					}

					if(i+j == 2){
						ds--;
					}

					break;
				}
			}
		}
	}

	for(int i = 0; i < 3; i++){
		if(lines[i] == 0){
			cout << "Yes\n";
			return 0;
		}

		if(cols[i] == 0){
			cout << "Yes\n";
			return 0;
		}

	}

	if(dp == 0 or ds == 0){
		cout << "Yes\n";
		return 0;
	}

	cout << "No\n";

	return 0;		
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i;
	float c,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%2!=0)
		cnt++;
	}
	c=cnt/n;
	printf("%f",c);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<class V, int NV> struct LazySegTreeMin { // [L,R)
    vector<V> dat, lazy; LazySegTreeMin() { dat.resize(NV * 2, def); lazy.resize(NV * 2, ldef); }
    void update(int a, int b, V v, int k, int l, int r) { push(k, l, r); if (r <= a || b <= l) return;
        if (a <= l && r <= b) { setLazy(k, v); push(k, l, r); } else {
        update(a, b, v, k * 2 + 1, l, (l + r) / 2); update(a, b, v, k * 2 + 2, (l + r) / 2, r);
        dat[k] = comp(dat[k * 2 + 1], dat[k * 2 + 2]);}}
    V get(int a, int b, int k, int l, int r) { push(k, l, r); if (r <= a || b <= l) return def;
        if (a <= l && r <= b) return dat[k]; auto x = get(a, b, k * 2 + 1, l, (l + r) / 2);
        auto y = get(a, b, k * 2 + 2, (l + r) / 2, r); return comp(x, y);}
    void update(int a, int b, V v) { update(a, b, v, 0, 0, NV); }
    V get(int a, int b) { return get(a, b, 0, 0, NV); }
    // ---- Template ---------------------------------------------------------------------------------
	// 区間min代入,区間min
	const V def = inf, ldef = inf;
	V comp(V l, V r) { return min(l, r); }
	void setLazy(int i, V v) { lazy[i] = min(lazy[i], v); }
	void push(int k, int l, int r) {
		if (lazy[k] != ldef) {
			// modify------------------------------
			dat[k] = min(dat[k], lazy[k]);
			// ------------------------------------
			if (r - l > 1) { setLazy(k * 2 + 1, lazy[k]); setLazy(k * 2 + 2, lazy[k]); }
			lazy[k] = ldef;
		}
	}
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, A[201010], L[201010], R[201010];
LazySegTreeMin<int, 1 << 18> U;
ll dp[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, M) cin >> L[i] >> R[i];

	rep(i, 0, M) U.update(L[i], R[i] + 1, L[i]);

	rep(i, 1, N + 1) {
		int u = U.get(i, i + 1);

		if (u == inf) chmax(dp[i], dp[i - 1] + A[i - 1]);
		else chmax(dp[i], dp[u - 1] + A[i - 1]);

		chmax(dp[i], dp[i - 1]);
	}

	cout << dp[N] << endl;
}



Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;

string num;

int main(){

  cin >> num;
  bool allNineFlag = true;
  FOR(i,1,num.size()){
    if(num[i] != '9') allNineFlag = false;
  }
  int ans = 0;
  if(allNineFlag){
    rep(i,num.size()){
      ans += (num[i]-'0');
    }
  }else{
    rep(i,num.size()){
      if(i == 0){
        ans += (num[i]-'0');
        ans --;
      }else{
        ans += 9;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256