akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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; }

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

//---------------------------------------------------------------
// ＷＡが消えない・・・
//---------------------------------------------------------------

int H, W;
string S[400];

int par[400 * 400];	    // 親を指す
int64 b[400 * 400];	    // 黒の数
int64 w[400 * 400];	    // 白の数

int root(int x) {
    if(par[x] == x)     return x;
    else                return par[x] = root(par[x]);
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y)  return;
    par[x] = y;
}


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

	cin >> H >> W;
	REP(i, 0, H)	cin >> S[i];
	
	REP(i, 0, H) {
	   REP(j, 0, W) {
	       par[i*W + j] = i * W + j;
	   }
	}
	
	REP(i, 0, H) {
		REP(j, 0, W) {
			if(i < (H - 1) && S[i][j] != S[i+1][j])		unite(i * W + j, (i+1) * W + j);
			if(j < (W - 1) && S[i][j] != S[i][j+1])		unite(i * W + j, i * W + j + 1);
		}
	}
	int k;
	REP(i, 0, H) {
	    REP(j, 0, W) {
	    	k = i * W + j;
	    	if(S[i][j] == '#')	{
		        b[ root(par[k]) ]++; 
//		        cout << "b[" << root(par[k]) << "] = " << b[ root(par[k]) ] << endl;
		    } else {
		        w[ root(par[k]) ]++; 
//		        cout << "w[" << root(par[k]) << "] = " << w[ root(par[k]) ] << endl;
		    }
	    }
	}
	int64 ans = 0;
	REP(i, 0, H) {
	    REP(j, 0, W) {
	    	k = i * W + j;
	        if((b[k] + w[k]) > 1) {
	            ans += (b[k] * w[k]);
//    	        cout << "b = " << b[k] << "   w = " << w[k] << " -->  ans = " << ans << endl;
	        } 
	    }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
int main() {
	int N, P, t, a = 0, b = 0;
	ll c = 0;
	cin >> N >> P;
	vector<int> A(N);
	rep(i, 0, N)cin >> t, (t % 2 ? b : a)++;
	vector<vector<long long int> > v(b + 1, vector<long long int>(b + 1, 0));
	comb(v);
	t = P;
	while (t <= b) {
		c += v[b][t];
		t += 2;
	}
	printf("%lld\n", (ll)pow(2, a) * c);
	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int A, B;
  cin >> A >> B;
  FOR(i, 1, 4){
    if(i == A || i == B){
      continue;
    }
    else{
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/*	                           
							 * * 
						   *     * 
						 *	       * 
					   *	         * 
                     *     _ooOoo_     * 
                   *      o8888888o      * 
                 *        88" . "88        * 
                *         (| -_- |)         * 
               *       *  0\  =  /0  *       * 
               *       *__0/`---'\0__*       * 
               *     .'  \\|     |//  `.     * 
                *   /  \\|||  :  |||//  \   * 
                 * /  _||||| -:- |||||-  \ * 
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   佛祖保佑       永无BUG
                        author：Richie 
*/

#include<stdio.h>
#include<string.h>	
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define LOCAL
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q)) 
#define ll long long
#define N 500001
#define mod 998244353

int cmp(const void *a,const void *b);
void print_array(int *a,int n);
void read_array(int *a,int n);
void init();
ll fast(ll x);
ll exgcd(ll a,ll b,ll *x,ll *y);
ll getInv(int a);
ll gcd(ll a,ll b);

int p[5005];
int c[5005]; 
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    ll ans=-100000000000000;
    read_array(p,n);
    read_array(c,n); 
    
    FOR(i,1,n){
    	int next=p[i];
    	int l=1;
    	ll max=c[next];
    	ans=max(ans,max);
    	while(l<k&&next!=i){
    		next=p[next];
    		max+=c[next];
    		ans=max(ans,max);
    		l++;
		}
		if(l<k&&max>=0){
			max*=(k-l)/l;
	    	int t=k%l+l;
	    	while(t>0){
		        next=p[next];
		        max+=c[next];
		        ans=max(ans,max);       
		        t--;
			}
		}
	}
    printf("%lld\n",ans);
	return 0;
}



ll gcd(ll a,ll b){
	int t;
	while(b!=0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}

ll fast(ll x){									//逆元 费马小定理/欧拉定理 适用范围：一般在mod是个素数的时候用
	int y=mod-2;
	ll res=1;
	while(y){
		if(y&1)res=res*x%mod;
		x=x*x%mod; 
		y>>=1;
	}
	return res;
}

ll exgcd(ll a,ll b,ll *x,ll *y)					//扩展欧几里得算法 
{
    if(b==0)
    {
        *x=1,*y=0;
        return a;
    }
    ll ret=exgcd(b,a%b,y,x);
    *y-=a/b*(*x);
    return ret;
}
ll getInv(int a)								//求a在mod下的逆元，不存在逆元返回-1 
{
    ll x,y;
    ll d=exgcd(a,mod,&x,&y);
    return d==1?(x%mod+mod)%mod:-1;
}

void init(void){
	#ifdef LOCAL
		freopen("P2678_2.in","r",stdin);
		freopen("data.txt","w",stdout);
	#endif
}

int cmp(const void *a,const void *b){
	return *(int*)a-*(int*)b;					//升序排列 
} 

void print_array(int *a,int n){
	FOR(i,1,n){
		if(i!=n)printf("%d ",a[i]);
		else printf("%d",a[i]);
	}
} 

void read_array(int *a,int n){
	FOR(i,1,n)scanf("%d",&a[i]);
}




Measured memory_bytes: 1776
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
const double INF = 1e10;
const double EPS = 1e-10;

int main(){
    int n,m;
    double l;
    cin >> n >> m >> l;
    vector<double> p(n), t(n), v(n);
    for(int i=0; i<n; i++){
        cin >> p[i] >> t[i] >> v[i];
        p[i] /= 100.0;
    }

    vector<vector<double> > c(m+1, vector<double>(m+1, 0));
    for(int i=0; i<=m; i++) c[i][0] = 1;
    for(int i=1; i<=m; i++){
        for(int j=1; j<=i; j++){
            c[i][j] = c[i-1][j-1] +c[i-1][j];
        }
    }

    vector<vector<double> > prob(n, vector<double>(m+1)), time(n, vector<double>(m+1));
    for(int i=0; i<n; i++){
        double ttime = l/v[i];
        for(int j=0; j<=m; j++){
            prob[i][j] = pow(p[i], j) *pow(1-p[i], m-j) *c[m][j];
            time[i][j] = ttime;
            ttime += t[i];
        }
    }
    vector<vector<double> > accumprob = prob;
    for(int i=0; i<n; i++){
        for(int j=m-1; j>=0; j--){
            accumprob[i][j] += accumprob[i][j+1];
        }
    }

    cout << fixed;
    cout << setprecision(10);
    for(int i=0; i<n; i++){
        double subans = 0;
        for(int j=0; j<=m; j++){
            double pr = prob[i][j];
            for(int k=0; k<n; k++){
                if(i==k) continue;
                double subpr = 0;
                for(int s=0; s<=m; s++){
                    if(time[k][s] > time[i][j] +EPS){
                        subpr = accumprob[k][s];
                        break;
                    }
                }
                pr *= subpr;
            }
            subans += pr;
        }
        cout << subans << endl;
    }
    return 0;
}


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

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

int main()
{
    vector<int> abc(100);
    rep(i, 3){
        int tmp = 0;
        cin >> tmp;
        abc.at(tmp - 1)++;
    }

    int ans = 0;
    rep(i, 100){
        if(abc.at(i) != 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Integer>> list = new ArrayList<List<Integer>>(n);
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			int k = Integer.parseInt(sa[0]);
			List<Integer> list2 = new ArrayList<Integer>(k);
			for (int j = 1; j <= k; j++) {
				list2.add(Integer.parseInt(sa[j]));
			}
			list.add(list2);
		}
		br.close();

		int[] parent = new int[m + 1];
		for (int i = 0; i < parent.length; i++) {
			parent[i] = i;
		}

		Set<Integer> lang = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			List<Integer> list2 = list.get(i);
			lang.add(list2.get(0));
			for (int j = 1; j < list2.size(); j++) {
				union(parent, list2.get(0), list2.get(j));
				lang.add(list2.get(j));
			}
		}

		int a = lang.iterator().next();
		for (int i : lang) {
			if (find(parent, a) != find(parent, i)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

	static void union(int[] parent, int x, int y) {
		int px = find(parent, x);
		int py = find(parent, y);
		if (px != py) {
			parent[px] = py;
		}
	}

	static int find(int[] parent, int x) {
		if (parent[x] == x) {
			return x;
		}
		parent[x] = find(parent, parent[x]);
		return parent[x];
	}
}


Measured memory_bytes: 52248
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	int a, b, n;
    	cin >> a >> b >> n;
    	
    	cout << a * min(b - 1, n) / b << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 3800
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
int main() {
    int h1, h2, m1, m2, hs, ms;
    cin >> h1 >> m1 >> h2 >> m2;
    int k;
    cin >> k;
    hs=k/60;
    ms=k%60;
    hs=h2-hs;
    ms=m2-ms;
    if(ms<0){
      ms=60+ms;
      hs--;
    }
    //cout << hs << ' ' << ms << endl;
    hs-=h1;
    ms-=m1;
    if(ms<0){
      ms=60+ms;
      hs--;
    }
    cout << hs*60+ms << endl;
    }

Measured memory_bytes: 3592
#横にn個入力
n, m, q = map(int, input().split())
#行列
s = []
for i in range(m):#h:高さ
    s.append([int(m) for m in input().split()] + [i])
# 行列
t = []
for i in range(q):  # h:高さ
    t.append([int(m) for m in input().split()])

LR = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for v in range(m):
     LR[s[v][0]][s[v][1]] += 1

for j in range(1, n + 1):
    for i in range(1, n + 1):#Lについての累積和
        LR[i][j] += LR[i - 1][j]
for i in range(1, n + 1):
    for j in range(1, n + 1):#Rについての累積和，2次元累積和にする
        LR[i][j] += LR[i][j - 1]

for k in range(q):
    tmp = 0
    #for j in range(t[k][0], t[k][1] + 1):#Rについてみていく
        #tmp += LR[t[k][1]][j] - LR[t[k][0] - 1][j]
    tmp += (LR[t[k][1]][t[k][1]] - LR[t[k][1]][t[k][0] - 1]) - (LR[t[k][0] - 1][t[k][1]] - LR[t[k][0] - 1][t[k][0] - 1])

    print(tmp)

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

using namespace std;
typedef long long ll;

int main() {
    string s;

    cin >>  s;
    if(s == "Sunny") cout << "Cloudy";
    if(s == "Cloudy") cout << "Rainy";
    if(s == "Rainy") cout << "Sunny";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

from functools import lru_cache
@lru_cache(maxsize=2**12)
def solve(i, m):
    if m == 0:
        return True
    if i == n:
        return False
    return solve(i+1, m) or solve(i+1, m-a[i])
for i in m:
    if solve(0, i):
        print("yes")
    else:
        print("no")


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

int main() {
  long k;
  string s,ans="";
  cin >> k >> s;
  if(s.size()<=k){
    ans=s;
  } else {
    for(long i=0;i<k;i++) ans=ans+s[i];
    ans=ans+"...";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

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

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}

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

int main(){
    int a,b;
    cin >>a>>b;
    int d = a/b;
    int r = a%b;
    double f = double(a)/double(b);

    printf("%d %d %.6lf", d, r, f);
return 0;
}


Measured memory_bytes: 3208
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <sstream>
using namespace std;

#define LL long long
int num[4], ans[4] = {1, 4, 7, 9};

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &num[0]) != EOF) {
        for(int i = 1; i < 4; ++i) {
            scanf("%d", &num[i]);
        }
        sort(num, num + 4);
        bool flag = true;
        for(int i = 0; i < 4; ++i) {
            if(num[i] != ans[i]) {
                flag = false;
            }
        }
        printf("%s\n", flag? "YES": "NO");
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[4],b[2];
  for(int i=0;i<4;i++){
    cin>>a[i];
  }
  sort(a,a+4);
  for(int i=0;i<2;i++){
    cin>>b[i];
  }
  sort(b,b+2);
  cout<<a[3]+a[2]+a[1]+b[1]<<endl;
  return 0;
}

Measured memory_bytes: 3136
S = input() + 'R'
s1 = 'R'
s2 = 'L'
c = 0
RL = []
for i in range(len(S)-1):
    if S[i] == s1:
        c += 1
        if S[i+1] == s2:
            RL.append(c)
            s1, s2 = s2, s1
            c = 0

for i in range(0, len(RL)-1, 2):
    if RL[i]%2 == 0 and RL[i+1]%2 == 0:
        for _ in range(RL[i]-1):
            print(0, end=' ')
        print(RL[i]//2+RL[i+1]//2, end=' ')
        print(RL[i]//2+RL[i+1]//2, end=' ')
        for _ in range(RL[i+1]-1):
            print(0, end=' ')
    
    if RL[i]%2 == 1 and RL[i+1]%2 == 1:
        for _ in range(RL[i]-1):
            print(0, end=' ')
        print(RL[i]//2+1+RL[i+1]//2, end=' ')
        print(RL[i]//2+RL[i+1]//2+1, end=' ')
        for _ in range(RL[i+1]-1):
            print(0, end=' ')
            
    if RL[i]%2 == 1 and RL[i+1]%2 == 0:
        for _ in range(RL[i]-1):
            print(0, end=' ')
        print(RL[i]//2+1+RL[i+1]//2, end=' ')
        print(RL[i]//2+RL[i+1]//2, end=' ')
        for _ in range(RL[i+1]-1):
            print(0, end=' ')
           
    if RL[i]%2 == 0 and RL[i+1]%2 == 1:
        for _ in range(RL[i]-1):
            print(0, end=' ')
        print(RL[i]//2+RL[i+1]//2, end=' ')
        print(RL[i]//2+RL[i+1]//2+1, end=' ')
        for _ in range(RL[i+1]-1):
            print(0, end=' ')
                       
print('')

Measured memory_bytes: 73820
#include <iostream>
using namespace std;
int main(){
    int n, b, f, r, v, house[4][3][10] = {}, i, k, s, u, flag = 0 ,flag_1 = 0;
    cin >> n;
    for (i = 0; i < n; i ++ ){
        cin >> b >> f >> r >> v; 
        b -= 1; f -= 1; r -= 1;
        house [b][f][r] += v;
    }
    for (k = 0; k < 4; k ++){
        flag += 1;
        for (s = 0; s < 3; s++){
            for (u = 0; u < 10 ; u++){ 
                flag_1 += 1;
                cout <<" "<< house[k][s][u] ;
            }
            cout << endl;
        }
        if (flag <= 3){
            cout <<"####################" << endl;
            }
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define MAXN 200200
#define ll long long
using namespace std;
 
 
int main(){
    int a,b;
 
    cin>>a>>b;
 
    int res=-1;

    for(int i=2; i<=1200; i++){
        if((i*8)/100 == a && (i/10) == b){
            res = i;
            break;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, ans, max;
    int p[200000], a[200000];
    cin >> n;

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

    ans = 1;
    max = 1;
    for (int i = 1; i < n; i++)
    {
        if (a[i] > a[i - 1])
        {
            ans++;
            if (ans > max)
                max = ans;
        }
        else
            ans = 1;
    }

    cout << n - max << endl;

    return 0;
}

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

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


int main(){
  int N;
  cin>>N;
  ll ans=0;
  map<int,int> mp;

  rep(i,N){
    ll a;
    cin>>a;
    ans += mp[i-a];
    mp[i+a]++;
  }
  cout<<ans;
}


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

typedef long long ll;

string S;

ll digit(ll i) { return S[i] - '0'; }
bool month(ll n) { return 1 <= n && n <= 12; }
int main() {
  cin >> S;
  bool yymm = month(digit(2) * 10 + digit(3));
  bool mmyy = month(digit(0) * 10 + digit(1));
  cout << (yymm && !mmyy
               ? "YYMM"
               : mmyy && !yymm ? "MMYY" : yymm && mmyy ? "AMBIGUOUS" : "NA")
       << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%s", $a);
    fscanf(STDIN, "%s", $b);
    $len_a = strlen($a);
    $len_b = strlen($b);
    if($len_a > $len_b){
        echo "GREATER\n";
        exit;
    }else if($len_a < $len_b){
        echo "LESS\n";
        exit;
    }else{
        for($i = 0; $i < $len_a; $i++){
            $x = (int)$a[$i];
            $y = (int)$b[$i];
            if($x > $y){
                echo "GREATER\n";
                exit;
            }else if($x < $y){
                echo "LESS\n";
                exit;
            }
        }
        echo "EQUAL\n";
    }
?>


Measured memory_bytes: 3828
class Node:

    def __init__(self, _id):
        self.id = _id
        self.left = None
        self.right = None
        self.parent = None

    def add_left(self, node):
        node.parent = self
        self.left = node

    def add_right(self, node):
        node.parent = self
        self.right = node

    @property
    def parent_id(self):
        if self.parent is None:
            return -1
        else:
            return self.parent.id

    @property
    def deg(self):
        count = 0
        if self.right is not None:
            count += 1
        if self.left is not None:
            count += 1
        return count

    @property
    def sibling_id(self):
        if self.parent is None or self.parent.deg == 1:
            return -1
        else:
            if self.parent.left == self:
                return self.parent.right.id if self.parent.right is not None else -1
            else:
                return self.parent.left.id if self.parent.left is not None else -1

    @property
    def node_type(self):
        if self.parent is None:
            return 'root'
        if self.left is None and self.right is None:
            return 'leaf'
        return 'internal node'

    @property
    def height(self):
        if self.left is None:
            left = -1
        else:
            left = self.left.height
        if self.right is None:
            right = -1
        else:
            right = self.right.height
        return max(left, right) + 1

    @property
    def depth(self):
        if self.parent is None:
            return 0
        else:
            return self.parent.depth + 1

    def __eq__(self, other):
        return self.id == other.id

    def __repr__(self):
        return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
            self.id, self.parent_id, self.sibling_id, self.deg, self.depth, self.height, self.node_type)


def pre_parse(node, lst):
    if node is None:
        return
    lst.append(str(node.id))
    pre_parse(node.left, lst)
    pre_parse(node.right, lst)


def in_parse(node, lst):
    if node is None:
        return
    in_parse(node.left, lst)
    lst.append(str(node.id))
    in_parse(node.right, lst)


def post_parse(node, lst):
    if node is None:
        return
    post_parse(node.left, lst)
    post_parse(node.right, lst)
    lst.append(str(node.id))


def main():
    n = int(input())
    nodes = [Node(i) for i in range(n)]
    for _ in range(n):
        ID, left, right = map(int, input().split(' '))
        if left != -1:
            nodes[ID].add_left(nodes[left])
        if right != -1:
            nodes[ID].add_right(nodes[right])
    root = None
    for node in nodes:
        if node.depth == 0:
            root = node
    lst = []
    pre_parse(root, lst)
    print('Preorder')
    print(' ' + ' '.join(lst))
    lst = []
    in_parse(root, lst)
    print('Inorder')
    print(' ' + ' '.join(lst))
    lst = []
    post_parse(root, lst)
    print('Postorder')
    print(' ' + ' '.join(lst))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
        
        
int main() {
        ll n,a,b;
        cin >> n >> a >>b;
        ll c =  n/(a+b);
        ll p = n%(a+b);
        ll ans = c*a;
        if( p <= a) ans += p;
        else ans += a;
        cout << ans << endl;
        
        return 0;
}




Measured memory_bytes: 256
n,m = map(int,input().split())

ac = 0
wa = 0

challengable = [True] * n
wa_cnt = [0] * n

for _ in range(m):
    num, res = input().split()
    num = int(num)

    if not challengable[num-1]:
        continue

    if res == "AC":
        ac += 1
        challengable[num-1]=False
        wa += wa_cnt[num-1]
    else:
        wa_cnt[num-1]+=1

print(ac,wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define out(a) cout<<fixed<<setprecision((a))
int main(){
	int a,b;
	char x;
	while(1){
	    cin >> a >> x >> b;
	    if(x=='?')break;
	    if(x=='+')cout << a+b << endl;
	    if(x=='-')cout << a-b << endl;
	    if(x=='*')cout << a*b << endl;
	    if(x=='/')cout << a/b << endl;
	}
}


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

using namespace std;

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

#define ff first
#define ss second

const int INF = 4e6+10;
const int maxn = 2e5+10;

vector<int> g[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;++i){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector<int> d(n+1,INF),ans(n+1);
	d[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(auto &u:g[x]){
			if(d[x]+1 < d[u]){
				d[u] = d[x]+1;
				ans[u] = x;
				q.push(u);
			}
		}
	}
	bool ok = true;
	for(int i=1;i<=n;++i){
		//cout << "d[i] = " << d[i] << '\n';
		if(d[i]==INF)
			ok = false;
	}
	if(!ok){
		cout << "No\n";
	}
	else{
		cout << "Yes\n";
		for(int i=2;i<=n;++i){
			cout << ans[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 13032
function main()
    N = parse(Int64, readline())
    input = []
    ac  = 0
    wa  = 0
    tle = 0
    re  = 0
    for i in 1:N
        x = readline()
        if x == "AC"
            ac += 1
        end
        if x == "WA"
            wa += 1
        end
        if x == "TLE"
            tle += 1
        end
        if x == "RE"
            re += 1
        end
    end
    
    println("AC x $(ac)")
    println("WA x $(wa)")
    println("TLE x $(tle)")
    println("RE x $(re)")

end

main()


Measured memory_bytes: 158888
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int A[200010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),ans=0;
	for(int i=1;i<=n;++i)A[i]=gi();
	int s1=0,s2=0;
	for(int i=1;i<n;++i)s1+=A[i]<A[i+1],s2+=A[i]>A[i+1];
	ans=std::min(s1,s2)+1;
	std::vector<pr>vi={{0,0}};
	for(int i=1;i<=n+1;++i){
		//for(pr s:vi)printf("%d %d\n",s.fi,s.se);
		//puts("");
		if(i>n)break;
		int d=A[i]-A[i-1];
		auto ok=[&](int x){return 0<=x&&x<=A[i];};
		std::vector<pr>nv;
		for(pr s:vi){
			if(ok(s.fi))nv.push_back({s.fi,s.se+(d>0)});
			if(d&&ok(s.fi+d))nv.push_back({s.fi+d,s.se+(d<0)});
			nv.push_back({0,s.se+(0<s.fi)+(0<s.fi+d)});
		}
		int mn=2e9;for(pr s:nv)cnk(mn,s.se);
		vi.clear();
		std::sort(all(nv));
		for(int i=mn;i<=mn+2;++i){
			int p=-1;
			for(pr s:nv)if(s.se==i){p=s.fi;break;}
			if(~p&&(vi.empty()||p<vi.back().fi))vi.push_back({p,i});
		}
	}
	for(pr s:vi)cnk(ans,vi[0].se+!!vi[0].fi);
	printf("%d\n",ans);
	return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
G = list2d(N, N, 0)
for i in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    G[a][b] = G[b][a] = 1

# dp[S][i] := 訪問済の頂点集合をSとして、最後に頂点iにいる場合の通り数
dp = list2d(1<<N, N, 0)
# 最初は頂点1にいる状態から
dp[1][0] = 1
for S in range(1, 1<<N):
    for i in range(N):
        # iが遷移元に含まれていない
        if not S & 1<<i:
            continue
        for j in range(N):
            # jが遷移元に含まれている(ので遷移先にはできない)
            if S & 1<<j:
                continue
            # 辺の張られた頂点間であれば遷移させる
            if G[i][j]:
                dp[S|1<<j][j] += dp[S][i]
# 全頂点訪問できた通り数を合計する
ans = sum(dp[(1<<N)-1])
print(ans)


Measured memory_bytes: 3188
M,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
ANS = 0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for j in range(M-K+1):
    ANS += (L[K-1+j] - L[M-K-j])*cmb(K-1+j,K-1,mod)

print(ANS % mod)

Measured memory_bytes: 19920
from sys import stdin


def input():
    return stdin.readline().strip()


def main():
    N, M, Q = map(int, input().split())
    a, b, c, d = [0] * Q, [0] * Q, [0] * Q, [0] * Q
    for i in range(Q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
        a[i] -= 1
        b[i] -= 1

    def dfs(seq, N, M):
        if len(seq) == N:
            score = 0
            for i in range(Q):
                if seq[b[i]] - seq[a[i]] == c[i]:
                    score += d[i]
            return score

        score = 0
        start = seq[-1] if seq else 1
        for n in range(start, M + 1):
            score = max(score, dfs(seq.copy() + [n], N, M))

        return score

    print(dfs([], N, M))


if __name__ == "__main__":
    main()


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

int main(){
    using namespace std;
    enum event_t{
        enemy,
        bomb_end
    };
    unsigned long N, D, A;
    cin >> N >> D >> A;
    priority_queue<pair<pair<unsigned long, event_t>, unsigned long>> pq;
    for(unsigned long i{0}, X, H; i < N; ++i){
        cin >> X >> H;
        pq.emplace(pair<unsigned long, event_t>{2 * X + 1000000000, enemy}, H);
    }
    unsigned long ans{0}, now{0};
    while(!pq.empty()){
        auto t = pq.top();
        pq.pop();
        if(t.first.second == enemy){
            if(t.second > now * A){
                pq.emplace(pair<unsigned long, event_t>{t.first.first - min(t.first.first, D * 4 + 1), bomb_end}, (t.second - (now - 1) * A - 1) / A);
                ans += (t.second - (now - 1) * A - 1) / A;
                now += (t.second - (now - 1) * A - 1) / A;
            }
        }else now -= t.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
const int N = 1e6;
ll a[N][27];
void update(ll x, ll id, ll val)
{
    for(; x < N; x += (x & -x))
        a[x][id] += val;
}
ll  query(ll x, ll id)
{
    ll ans = 0;
    for(; x; x -= x & (-x))
        ans += a[x][id];
    return ans;
}

void solve()
{
    ll i, j, n, m, k, x, y, z;
    cin >> n;
    string s;
    char c;
    cin >> s;
    rep(i, n)
    {
        update(i + 1, s[i] - 'a', 1);
    }
    ll q;
    cin >> q;
    while(q--)
    {
        cin >> x >> y ;
        if(x == 1)
        {
            cin >> c;
            if(s[y - 1] != c)
            {
                update(y, s[y - 1] - 'a', -1);
                s[y - 1] = c;
                update(y, s[y - 1] - 'a', 1);
            }

        }
        else
        {
            cin >> z;
            ll ans = 0;

            rep(i, 26)
            {
                if(query(z, i) - query(y-1, i))
                    ans++;
            }
            cout << ans << endl;

        }
    }






}


int main()
{



    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //    cin >> t;
    while(t--)
    {
        solve();
        cout << endl;
    }

}




Measured memory_bytes: 111516
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int cnt = 0;
      for(int i = 0;i < h;i++){
      	char[] c = sc.next().toCharArray();
        for(int j = 0;j < w;j++)if(c[j]=='#')cnt++;
      }
      if(cnt==h+w-1)System.out.println("Possible");
      else System.out.println("Impossible");
    }
}

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;

void a();void b();void c();void d();void e();void f();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    a();
    // b();
    // c();
    // d();
    // e();
    // f();
    return 0;
}
// Write Here

void a(){
    int n;
    cin >> n;
    int amt = 0;
    while(amt < n)amt += 1000;
    cout << amt - n << '\n';
}

void b(){

}

void c(){

}

void d(){

}

void e(){

}

void f(){

}

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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<long> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    long ans = 0;
    vector<int> vst(n);
    for (int d = 1; d <= (n - 1) / 2; d++)
    {
        long res = 0;
        fill(vst.begin(), vst.end(), 0);
        for (int l = 0; l + d < n; l += d)
        {
            if (vst[l])
                break;
            res += as[l];
            vst[l] = 1;
            int r = n - 1 - l;
            if (vst[r])
                break;
            res += as[r];
            vst[r] = 1;
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    cerr << "\"努力不足ですね！\"" << endl;
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

vector<string> tot;

void dfs(string cur, int des, int ln){
	if(tot.size() == 100000) return;
	if(des == ln){
		tot.pb(cur);
		return;
	}
	if(cur[cur.size() - 1] > '0'){
		string cur1 = cur;
		char add = cur[cur.size() - 1];
		add--;
		cur1 += add;
		dfs(cur1, des, ln + 1);
	}
	string cur1 = cur;
	char add = cur[cur.size() - 1];
	cur1 += add;
	dfs(cur1, des, ln + 1);
	if(cur[cur.size() - 1] < '9'){
		string cur1 = cur;
		char add = cur[cur.size() - 1];
		add++;
		cur1 += add;
		dfs(cur1, des, ln + 1);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int k;
	cin >> k;
	if(k < 10){
		cout << k << endl; //digits
		return 0;
	}
	rep(i, 9) tot.pb(to_string(i + 1));
	repn(len, 2, 11){
		//the length of the string
		for(char st = '1'; st <= '9'; st++){
			string go = "";
			go += st;
			dfs(go, len, 1);
		}
	}
	cout << tot[k - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
    int x,y;
    cin >> x >> y;
    if(y %2!=0){
        cout << "No" << endl;
        return 0;
    }

    if((y>=2*x)&&(y<=4*x)){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;


}

Measured memory_bytes: 3644
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		System.out.printf("%d %d %f\n", a/b, a%b, (double)a/(double)b);
		scanner.close();
	}
}

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

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct Edge
{
	int s, t, cost;
	Edge(int s,int t,int cost):s(s),t(t),cost(cost){}
	Edge():Edge(-1,-1,-1){}
};

vector<Edge> G[100000];
int d[100000];
int V, E;

void shortest_path(int s)
{
	rep(i, 0, V)d[i] = INF;
	d[s] = 0;

	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(mp(0, s));

	while (!pq.empty())
	{
		pii p = pq.top(); pq.pop();
		if (d[p.second] < p.first)
		{
			continue;
		}
		for (auto& e : G[p.second])
		{
			if (d[e.t] > d[e.s] + e.cost)
			{
				d[e.t] = d[e.s] + e.cost;
				pq.push(mp(d[e.t], e.t));
			}
		}
	}
}

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

	int start;
	cin >> V >> E >> start;
	rep(i, 0, E)
	{
		int s, t, c;
		cin >> s >> t >> c;
		G[s].push_back(Edge(s, t, c));
		//G[t].push_back(Edge(t, s, c));
	}

	shortest_path(start);

	rep(i, 0, V)
	{
		printf(d[i] == INF ? "INF\n" : "%d\n", d[i]);
	}
	
	return 0;
}


Measured memory_bytes: 15468
def solve():
    N, M = map(int, input().split())
    A = [list(input()) for i in range(N)]
    B = [list(input()) for i in range(M)]

    i = 0
    j = 0
    snipped = []
    while i + M <= N:
        for di in range(M):
            snipped.append(A[i+di][j:M+j])
        if B == snipped:
            print('Yes')
            break

        snipped = []
        j += 1
        if j + M > N:
            i += 1
            j = 0
    else:
        print('No')

    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 39408
fun main(args: Array<String>) = abc159b()

fun abc159b() {
    val s = readLine()!!
    val n2 = s.length / 2

    val answer = if (s == s.reversed() &&
        s.take(n2) == s.take(n2).reversed() &&
        s.takeLast(n2) == s.takeLast(n2).reversed()
    ) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 33784
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,n,p1,p2,a[200000],b[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	p1=(n-1)/2;
	p2=p1;
	b[p1]=a[0];
	p1++;	p2--;
	for(i=1;i<n;i++)	{
		if(i%2==1)	{
			b[p1]=a[i];	p1++;
		}
		else {
			b[p2]=a[i];	p2--;
		}
	}
	if(n%2==1)	{
		printf("%d",b[0]);
		for(i=1;i<n;i++)	{
			printf(" %d",b[i]);
		}
		printf("\n");
	}
	else {
		printf("%d",b[n-1]);
		for(i=n-2;i>=0;i--)	{
			printf(" %d",b[i]);
		}
		printf("\n");
	}
	
	return 0;
}
		


Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for(int i=0; i<n; ++i){
        int x, l;
        cin >> x >> l;
        v[i].first = x + l;
        v[i].second = x - l;
    }

    sort(v.begin(), v.end());
    int ans = n;
    int k = 0;
    for(int i=1; i<n; ++i){
        if(v[i].second < v[k].first)
            -- ans;
        else
            k = i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using PP = pair<int, int>;
const int mod = 1000000007;

int n;
vector<PP> cons[300]; 
long DP[301][300][300];

bool ok(int i, int j, int k) {
  for (PP con : cons[i - 1]) {
    int l = con.first;
    int c = con.second;
    if (c == 1) {
      if (l < j) return false;
    } else if (c == 2) {
      if (l < k) return false;
      if (l >= j) return false;
    } else {
      if (l >= k) return false;
    }
  }
  return true;
}

long sub() {
  DP[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        if (!ok(i, j, k)) continue;
        DP[i + 1][j][k] = (DP[i + 1][j][k] + DP[i][j][k]) % mod;
        DP[i + 1][i][k] = (DP[i + 1][i][k] + DP[i][j][k]) % mod;
        DP[i + 1][i][j] = (DP[i + 1][i][j] + DP[i][j][k]) % mod;
      }
    }
  }
  
  long sum = 0;
  for (int j = 0; j < n; ++j) {
    for (int k = 0; k < n; ++k) {
      if (!ok(n, j, k)) continue;
      sum = (sum + DP[n][j][k]) % mod;
    }
  }
  return sum;
}

int main() {
  int m;
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int l, r, c;
    cin >> l >> r >> c;
    --l;
    --r;
    cons[r].push_back(PP(l, c));
  }
  
  cout << sub() << endl;
}

Measured memory_bytes: 211200
class item:
    def __init__(self,v,w):
        self.v = v
        self.w = w

n,W = map(int,input().split())
items = [None]*n
for i in range(n):
    v,w = map(int,input().split())
    items[i] = item(v,w)
    
dp = [[None]*(W+1) for _ in range(n+1)]
dp[0] = [0]*(W+1)

for i in range(1,n+1):
    for w in range(W+1):
        max_value = dp[i-1][w]
        if w-items[i-1].w>=0:
            max_value = max(max_value,dp[i-1][w-items[i-1].w]+items[i-1].v)
        dp[i][w] = max_value
        
print(dp[n][W])



Measured memory_bytes: 25516
/*betaでやろう*/
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = 1e15;
const ll NEGA=-INF*10000; 


ll ans = 0;
int cnt=0;

ll a[200000];
int used[1001];
ll dp[1001][1001];
ll sumx,sumy,sumz;
ll sx,sy,sz;
int main() 
{
 
 int n;
 cin>>n;
 rep(i,n) cin>>a[i];
 rep(i,n) {
     a[i]-=(i+1);
 }
 
 sort(a,a+n);
 if(n==1) {
     cout<<0<<endl;
     return 0;
 }
ans=INF;
int t=-1;
for(int i=1;i<n;++i){
  if(a[i-1]<0&&a[i]>=0) t=i;
}
 if(t!=-1){
  for(int b=max(0,t-400);b<min(n,t+400);++b)
  { 
  ll sc=0;
   rep(i,n) sc+=abs(a[i]-a[b]);
   ans=min(ans,sc);
  }
 }
for(int b=max(0,n/2-700);b<min(n,n/2+700);++b){
  ll sc=0;
  rep(i,n) sc+=abs(a[i]-a[b]);
  ans=min(ans,sc);
 }
 cout<<ans<<endl;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int a, b;
	cin >> a >> b;

	int ans = a - 2 * b;
	if (ans < 0) ans = 0;
	col(ans);

	return 0;
}

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

int main() {
	int n; cin >> n;
	long long luca0 = 2,luca1 = 1,luca;
	for (int i = 0; i < n - 1; i++) {
		luca = luca1;
		luca1 += luca0;
		luca0 = luca;
	}
	cout << luca1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			
			HashMap<Integer, Long> salesmen = new HashMap<>();
			ArrayList<Integer> ids = new ArrayList<>();
			
			for(int i = 0; i < n; i++){
				int id = sc.nextInt();
				long each = sc.nextLong();
				long num = sc.nextLong();
				
				if(!ids.contains(id)) ids.add(id);
				salesmen.computeIfPresent(id, (K, O) -> O + each * num);
				salesmen.putIfAbsent(id, each * num);
			}
			
			if(ids.stream()
					.filter(ID -> salesmen.get(ID) >= 1_000_000L)
					.peek(System.out::println)
					.count() == 0) System.out.println("NA");
		}
		sc.close();
		
	}
}

Measured memory_bytes: 38124
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);++i)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vi A(N);
	rp(i,N)cin>>A[i];
	sort(all(A));
	ote(A[N-1]-A[0]);
}


Measured memory_bytes: 256