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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int n,m;
  cin >> n >> m;
  int per_min , per_max ;
  cin >> per_min >> per_max;
  forn(i,m-1){
    int x , y;
    cin >> x >> y;
    per_min = max (x,per_min);
    per_max = min (y,per_max);
  }
  int c = per_max-per_min+1 ;
  cout << (c>0 ? c : 0) << endl;
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;
typedef pair<int,pii> iii;

int H, W;
string S[1010];
queue<iii> Q;
int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};

int main()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++)cin >> S[i];


    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++)
    {
        if(S[i][j] == '#')
        {
            Q.push(mk(0, mk(i, j)));
            S[i][j] = '.';
        }
    }

    int ans = 0;
    while(Q.size())
    {
        iii now = Q.front();
        Q.pop();

        if(now.se.fi < 0 || now.se.fi >= H || now.se.se < 0 || now.se.se >= W)continue;
        if(S[now.se.fi][now.se.se] == '#')continue;

        ans = now.fi;
        S[now.se.fi][now.se.se] = '#';

        for(int i = 0; i < 4; i++)Q.push(mk(now.fi + 1, mk(now.se.fi + dx[i], now.se.se + dy[i])));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 49736
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1004;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
//Lordvishnu@almighty
char ch[maxn][maxn];
int vis[maxn][maxn];
int dp[maxn][maxn],n,m,sx,sy,ex,ey;
int dx1[]={-1,1,0,0};
int dy1[]={0,0,-1,1};
int dx[]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
int dy[]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
bool is_valid(int x,int y)
{
	if(x<=0||y<=0||y>m||x>n||ch[x][y]=='#')
		return 0;
	return 1;
}
void solve()
{
	int i,j,k;
	deque<pair<int,int>>q;
	q.push_front({sx,sy});
	dp[sx][sy]=0;
	//vis[sx][sy]=1;
	while(!q.empty())
	{
		int curx=q.front().ff;
		int cury=q.front().ss;
		q.pop_front();
        for(int i=0;i<4;i++)
        {
        	int next_x=curx+dx1[i];
        	int next_y=cury+dy1[i];
        	if(is_valid(next_x,next_y))
        	{
        		//vis[x][y]++;
        		if(dp[next_x][next_y]>dp[curx][cury]){
        			vis[next_x][next_y]++;
        		   dp[next_x][next_y]=dp[curx][cury];
        	    	q.push_front({next_x,next_y});
        	}
        	}

        }
        for(i=curx-2;i<=curx+2;i++)
        {
        	for(j=cury-2;j<=cury+2;j++){
        	int next_x=i;
        	int next_y=j;
        	if(is_valid(next_x,next_y))
        	{
        		
        		if(dp[next_x][next_y]>1+dp[curx][cury])
        		{
        			vis[next_x][next_y]++;
        		dp[next_x][next_y]=1+dp[curx][cury];
        		q.push_back({next_x,next_y});
        	  }
        		
        	}
        }
        	
        }


	}

}
int main()
{
	
	fastio;
	ll int i,j,k;
	cin>>n>>m;
	cin>>sx>>sy>>ex>>ey;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++){
			cin>>ch[i][j];
			//dp[i][j]=inf;
		}
	}
  for(i=1;i<=n;i++)
  {
  	for(j=1;j<=m;j++)
  		dp[i][j]=inf;
  }

	solve();
  if(dp[ex][ey]==inf)
  {
  	cout<<-1;
  }
  else
  	cout<<dp[ex][ey];
     
     
	

}
//Lordvishnu@almighty

Measured memory_bytes: 12532
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, int b) {
	return a.pow(b);
}


int n;
vector<vector<int>> edg;
vector<int> cnt;
vector<Mint> ev;

int func(int pos, int prev = -1) {
	int ret = 1;
	for (int e : edg[pos]) {
		if (e == prev) continue;
		ret += func(e, pos);
	}
	return cnt[pos] = ret;
}

void func2(int pos, int prev = -1, int prevv = 0) {
	int s = 0;
	for (int e : edg[pos]) {
		if (e == prev) s += prevv;
		else s += cnt[e];
	}
	for (int e : edg[pos]) {
		if (e == prev) {
			ev[pos] += Mint(1) / pow(Mint(2), s - prevv);
		}
		else {
			ev[pos] += Mint(1) / pow(Mint(2), s - cnt[e]);
		}
	}
	ev[pos] -= Mint(edg[pos].size() - 1) / pow(Mint(2), s);
	ev[pos] = (Mint(1) - ev[pos]) / Mint(2);

	for (int e : edg[pos]) {
		if (e == prev) continue;
		func2(e, pos, s + 1 - cnt[e]);
	}
}

int main() {
	cin >> n;
	edg.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		edg[a].push_back(b);
		edg[b].push_back(a);
	}
	cnt.resize(n);
	ev.resize(n);
	func(0);
	func2(0);
	Mint ans = 0;
	for (int i = 0; i < n; i++) {
		ans += ev[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    string S;
    cin >> S;
    string S_R = S;
    reverse(S_R.begin(), S_R.end());
    if (S != S_R) {
        cout << "No" << endl;
        return 0;
    }
    int N = S.size();
    string S_B = S.substr(0, (N - 1)/2);
    string S_A = S.substr((N + 1)/2, (N - 1)/2);

    string S_B_R = S_B;
    reverse(S_B_R.begin(), S_B_R.end());
    if (S_B != S_B_R) {
        cout << "No" << endl;
        return 0;
    }

    string S_A_R = S_A;
    reverse(S_A_R.begin(), S_A_R.end());
    if (S_A != S_A_R) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
    char s[3];
    char tmp[3];
    int i,j;
    cin >> s;
    while(s[i]!=0){
        i++;
    }
    if(i==3){
        for(i=0;i<3;i++){
            tmp[i]=s[i];
        }
        s[0]=tmp[2];
        s[1]=tmp[1];
        s[2]=tmp[0];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    P p[200005];
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    sort(p, p + n);
    int l;
    if(n % 2) l = p[n / 2].first;
    else l = p[n / 2 - 1].first + p[n / 2].first;
    for(int i = 0; i < n; i++){
        p[i] = P(p[i].second, p[i].first);
    }
    sort(p, p + n);
    int r;
    if(n % 2) r = p[n / 2].first;
    else r = p[n / 2 - 1].first + p[n / 2].first;
    cout << r - l + 1 << endl;
}


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

int main() {
    int N; cin >> N;

    for (int i = 0; i <= N; i += 4) {
        if ((N - i) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }

int f[9] = { 0 };

int main() {
	int N, A;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A);
		if (1 <= A&&A <= 399) { f[0] = 1; }
		if (400 <= A&&A <= 799) { f[1] = 1; }
		if (800 <= A&&A <= 1199) { f[2] = 1; }
		if (1200 <= A&&A <= 1599) { f[3] = 1; }
		if (1600 <= A&&A <= 1999) { f[4] = 1; }
		if (2000 <= A&&A <= 2399) { f[5] = 1; }
		if (2400 <= A&&A <= 2799) { f[6] = 1; }
		if (2800 <= A&&A <= 3199) { f[7] = 1; }
		if (3200 <= A&&A <= 4800) { f[8]++; }
	}
	int sum = 0;
	int s = 0, b = 0, p = 0;
	for (int i = 0; i < 8; i++) {
		if (f[i] == 1) {
			sum++;
		}
	}
	if (sum == 0) {
		s = 1;
	}
	else {
		s = sum;
	}

	b = sum + f[8];

	printf("%d %d\n", s, b);


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  int H[N + 5];

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

  int maxtimes = 0;
  int i = 0;
  while (i < N - maxtimes) {
    int j = i + 1;
    while (H[j] <= H[j - 1] && j < N) {
      j++;
    }

    maxtimes = std::max(maxtimes, j - i - 1);
    i++;
  }

  cout << maxtimes;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			if (n == 0) break;
			int w = 2 * n;
			int f[] = new int[w + 1];
			for (int i = 2; i <= w; i++) {
				f[i] = i;
			}
			for (int i = 2; i <= Math.sqrt(w); i++) {
				for(int j = i + i; j <= w; j += i) {
					f[j] = 0;
				}
			}
			int count = 0;
			for (int i = n + 1; i <= 2 * n; i++) {
				if (f[i] != 0)
					count++;
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 58776
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    bool data[N][M]; F0R(i, N) {
        F0R(j, M) {
            char C; cin >> C; data[i][j] = C == '.';
        }
    }

    int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
    int ans = 0;
    F0R(ix, N) {
        F0R(iy, M) {
            if (!data[ix][iy]) continue;
            int dist[N][M]; F0R(i, N) F0R(j, M) dist[i][j] = -1;
            dist[ix][iy] = 0;
            queue<pi> q; q.push({ix, iy});
            while (!q.empty()) {
                pi cur = q.front(); q.pop();
                int x = cur.f, y = cur.s;
                
                F0R(i, 4) {
                    int nX = cur.f + dx[i], nY = cur.s + dy[i];
                    if (nX < 0 || nX >= N || nY < 0 || nY >= M) continue;
                    if (!data[nX][nY]) continue;
                    if (dist[nX][nY] != -1) continue;
                    dist[nX][nY] = dist[x][y] + 1;
                    q.push({nX, nY});
                    ans = max(ans, dist[nX][nY]);
                }
            }
        }
    }

    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  for(i=0;i<n;i++){
    cin>>buf;
    chmin(res2,buf);
    chmax(res1,buf);
  }
  cout<<res1-res2<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================
ll half(int n) {
    return pow(2, n+1) - 1;
}

ll sol(int n, ll eat) {
    ll h = half(n);
    if (n == 0) return 1;
    else if (eat == 1) return 0;
    else if (eat == 2*h-1) return sol(n, eat-1);
    else if (eat == h) return pow(2, n);
    else if (eat > h) return sol(n, h) + sol(n-1, eat-h);
    else return sol(n-1, eat-1);
}

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N; ll X;
    cin >> N >> X;
    cout << sol(N, X) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <numeric>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int n;
	cin >> n;
	VI l(n);
	REP(i, n)cin >> l[i];

	ll sum = 0;
	REPC(x, l) {
		sum += (x-1);
	}

	cout << sum << endl;
}

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

#define VER 1
#define HOL 2

using namespace std;

typedef long long ll;

int main(void) {
    
    int n;
    vector<int> v;
    string s1, s2;
    
    cin >> n >> s1 >> s2;
    
    for (int i = 0; i < n; ++i) {
        
        if (i + 1 == n || s1[i] != s1[i + 1]) {
            
            v.push_back(VER);
            
        } else {
            
            v.push_back(HOL);
            
            ++i;
            
        }
        
    }
    
    ll ans;
    int pre;
    
    if (v[0] == VER) {
        
        ans = 3;
        
        pre = VER;
        
    } else {
        
        ans = 6;
        
        pre = HOL;
        
    }
    
    for (int i = 1; i < v.size(); ++i) {
        
        if (pre == VER) {
            
            ans = (ans * 2) % 1000000007;
            
            if (v[i] == HOL) {
                
                pre = HOL;
                
            }
            
        } else {
            
            if (v[i] == VER) {
                
                pre = VER;
                
            } else {
                
                ans = (ans * 3) % 1000000007;
                
            }
            
        }
        
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}



























Measured memory_bytes: 256
from collections import Counter
n,k = map(int,input().split())
a_ls = list(map(int, input().split()))
c = Counter(a_ls)
value_ls = list(c.values())
value_ls.sort(reverse=True)
ans = 0
for i in range(k, len(value_ls)):
    ans += value_ls[i]
print(ans)


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int mx = max(a, max(b, c));
  int sum = a + b + c;
  if ((3 * mx) % 2 != sum % 2) mx++;
  int ans = (3 * mx - sum) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3504
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define pqi                priority_queue<ll>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
#define inf                1e18L+1
using namespace std;
#define N  100005
ll dp[2][N];
ll n,w;
ll v[101],c[101];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    cin>>n>>w;
    rep(i,0,n)
    cin>>c[i]>>v[i];
    ll sum_value=0;
    rep(i,0,n)sum_value+=v[i];
    rep(i,1,sum_value+1)
    dp[0][i]=inf;
    rep(i,1,n+1)
    {
    	ll t1=i%2;
    	rep(j,0,sum_value+1)
    	{
    		dp[t1][j]=inf;
    	}
    	rep(j,0,sum_value+1)
    	{
    		dp[t1][j]=min(dp[!t1][j],dp[t1][j]);
    		if(j>=v[i-1])
    		{
    			dp[t1][j]=min(dp[t1][j],dp[!t1][j-v[i-1]]+c[i-1]);
    		}
    		//else dp[t][j]=dp[!t][j];    	
    	}
    }
    ll t1=n%2;
    ll ans=0;
    rep(i,1,sum_value+1)
    if(dp[t1][i]<=w)
    	ans=i;
    cout<<ans;
}
    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    readLine()
    val S = readLine()!!
    var open = 0
    val sb = StringBuilder()
    for (i in 0..S.length - 1) {
        when(S[i]) {
            '(' -> {
                open++
            }
            ')' -> {
                if (open > 0) {
                    open--
                } else {
                    sb.insert(0, '(')
                }
            }
        }
        sb.append(S[i])
    }
    while (open > 0) {
        open--
        sb.append(')')
    }
    println(sb)
}

Measured memory_bytes: 31308
n,k = map(int,input().split())
N = list(range(1,n+1))
A = set()
count = 0
for i in range(k):
  d = int(input())
  Ad = list(map(int,input().split()))
  for j in range(d):
    A.add(Ad[j])

for i in range(n):
  if N[i] in A:
    count += 1

print(n-count)

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

using namespace std;

int main() {
  int n, m, x;

  cin >> n >> m >> x;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> c(n);

  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
    for (int j = 0; j < m; j++) {
      cin >> a.at(i).at(j);
    }
  }

  int ans = 10e8;

  for (int bit = 0; bit < (1 << n); bit++) {
    int flag = 1;
    vector<int> tmp(m, 0);
    int money = 0;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < m; j++) {
          tmp.at(j) += a.at(i).at(j);
        }
        money += c.at(i);
      }
    }
    for (int t = 0; t < m; t++) {
      if (tmp.at(t) < x) flag = 0;
    }
    if (flag) ans = min(ans, money);
  }
  if (ans == 10e8) {
    cout << -1;
    return 0;
  } else {
    cout << ans;
    return 0;
  }
}


Measured memory_bytes: 3636
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

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


	cout << (a+b)*h/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
   
int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    ll n , b;
    int a = 0;
    cin >> n;
    b = n;
    while( n >= 10 ) {
        a += n % 10;
        n /= 10;
    }
    a += n;
    if( b % a == 0 ) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 3572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll eratosthenes(ll x){
    vbo isprime(x+1,true);
    isprime[0]=false;
    isprime[1]=false;
    ll p=0;
    for(ll i=2;i<=x;i++){
        if(isprime[i]){
            p++;
            for(ll j=2*i;j<=x;j+=i)isprime[j]=false;
        }
    }
    return p;
}

int main(){
    queue<int> q;
    int n;
    while(cin>>n)q.push(eratosthenes(n));
    while(q.size()){
        cout<<q.front()<<endl;
        q.pop();
    }
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>

class Solver {
public:
    void solve();
};

void Solver::solve() {
    int H, W, sh, sw;
    std::cin >> H >> W >> sh >> sw;
    std::cout << (H - sh) * (W - sw) << std::endl;
}


int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

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

int main(){
    int a , b;
    scanf( "%d%d" , &a , &b );
    if( a > b ) swap( a , b );

    if( a == 1 ){
        if( b == 2 ) puts( "3" );
        else puts( "2" );
    }
    else puts( "1" );
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
           

            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');

                int x = int.Parse(s[0]);
                int y = int.Parse(s[1]);

                if (x == 0 && y == 0)
                    break;
               
                if (x > y) 
                {
                    Console.WriteLine(y+" "+x);

                }
            else 
                {
                    Console.WriteLine(x+" "+y);
                }
            

            }
        }
    }
}

Measured memory_bytes: 5784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int min = 0;
        int n = Integer.parseInt(input.readLine());
        StringTokenizer  tokenizer = new StringTokenizer(input.readLine());
        int [] value = new int[n];
        for (int i = 0; i < n; i++) {
            value[i] = Integer.parseInt(tokenizer.nextToken());
        }
        boolean state = true;
        while (state){
            for (int i = 0; i < n && state; i++) {
                if ((value[i] & 1) == 0){
                    value[i]  /=2;
                }else{
                    state = false;
                }
            }
            if (state)
             min++;
        }
        System.out.println(min);
    }

    static int log(int x, int base) {
        return (int)(Math.log(x) / Math.log(base));
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <bits/stdc++.h>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

 
int main(void){
    
    string str;
    int cnt;
    
    cin >> str;
    cin >> cnt;
 
    REP(i,str.size()){

        int t = 'z' - str[i] + 1;

 
        if(str[i] != 'a' && t <= cnt){
            str[i] = 'a';
            cnt -= t;
        }
    }
 
    if(cnt != 0){
        char c = (str[str.size()-1] + cnt % 26);
        str[str.size()-1] = c;
    }
    
    cout << str << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
    int N, ans=1;
    int min_h = -1;
    cin >> N;
    int H[N];
    for(int i=0;i < N;i++){
        cin >> H[i];
    }
    for(int i=0;i < N-1;i++){
        if(H[i]-1 > H[i+1]){
            ans = 0;
            goto END;
        } else if(H[i]-1 == H[i+1]){
            if(H[i]-1 < min_h){
                ans = 0;
                goto END;
            }
            H[i] -= 1;
        } else {
            if(min_h < H[i]){
                H[i] -=1 ;
            }
        }
        min_h = H[i];
    }
END:
    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main() {
	string S;
	cin>>S;
	string S0="CODEFESTIVAL2016";
	int cnt=0;
	rep(i,S.size()){
		if(S[i]!=S0[i])cnt++;
	}
	cout<<cnt<<endl;
}

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

const int N=200100;
typedef long long ll;
ll Sa[N],tag[N*4];
int a[N],b[N],K,c[N],cnt,n;
int L[N],R[N];
void reduce(int&x){x+=x>>31&K;}

int q1,q2;ll q3;
void bt(int o,int l,int r){
	tag[o]=-1;
	if(l==r){
		tag[o]=c[l];
		return;
	}
	int mid=(l+r)/2;
	bt(o*2,l,mid);bt(o*2+1,mid+1,r);
}

void push_down(int o){
	if(tag[o]!=-1){
		tag[o*2]=tag[o*2+1]=tag[o];
		tag[o]=-1;
	}
}

void mdf(int o,int l,int r){
	if(q1<=l&&r<=q2){
		tag[o]=q3;
		return;
	}
	int mid=(l+r)/2;push_down(o);
	if(q1<=mid)mdf(o*2,l,mid);
	if(q2>mid)mdf(o*2+1,mid+1,r);
}

void modify(int l,int r,ll x){
	if(l>r)return;
	q1=l;q2=r;q3=x;
	mdf(1,1,cnt);
}

void query(int o,int l,int r){
	if(l==r||tag[o]!=-1){q3=tag[o];return;}
	int mid=(l+r)/2;
	if(q1<=mid)query(o*2,l,mid);
	else query(o*2+1,mid+1,r);
}

ll get_val(int x){
	q1=q2=x;q3=0;
	query(1,1,cnt);
	return q3-c[x];
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;++i){
		cin>>a[i]>>b[i];a[i]*=2;
		Sa[i]=Sa[i-1]+a[i];
		if(b[i]==1&&a[i]>K){
			cout<<-1<<'\n';
			return 0;
		}
		if(b[i]==1){
			reduce(L[i]=-Sa[i-1]%K);
			reduce(R[i]=-Sa[i]%K);	
		}else L[i]=0,R[i]=K-1;
		c[++cnt]=L[i];c[++cnt]=R[i];
	}
	sort(c+1,c+cnt+1);cnt=unique(c+1,c+cnt+1)-c-1;
	bt(1,1,cnt);
	for(int i=n;i;--i){
		int l=lower_bound(c+1,c+cnt+1,L[i])-c,
			r=lower_bound(c+1,c+cnt+1,R[i])-c;
		ll res=get_val(l);
		if(l>r)modify(r+1,l,res+L[i]);
		else modify(1,l-1,res+L[i]),modify(r+1,cnt,res+L[i]+K);
	}
	ll ans=LLONG_MAX;
	for(int i=1;i<=cnt;++i)ans=min(ans,get_val(i));
	cout<<(ans+Sa[n])<<'\n';
	return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
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;
}
//小文字=大文字+32
int main() {
	ll N;
	cin >> N;
	if (N <= 1) {
		cout << 0;
		return 0;
	}
	ll res09 = 1;
	ll res0 = 1;
	ll res = 1;
	rep(i, N) {
		res09 *= 10;
		res0 *= 9;
		res *= 8;
		res09 %= mod;
		res0 %= mod;
		res %= mod;
	}
	ll ans= res09 - 2 * res0 + res;
	while(ans<0) {
		ans += mod;

	}
	cout << ans % mod;

}

Measured memory_bytes: 3648
using System;
class S
{
static void Main()
{
int a=int.Parse(Console.ReadLine());
int n=int.Parse(Console.ReadLine());
int saisho=int.Parse(Console.ReadLine());
int saigo=int.Parse(Console.ReadLine());
int en=0;
for(int i=1;i<=a;i++)
{
if(i<=n){en+=saisho;}
else{en+=saigo;}
}
Console.WriteLine(en);
}
}

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


int main()
{
	int a, b, c, d, e, f, ans = 0, res = 0, fg = 0;
	
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; j * b * 100 + i * a * 100 <= f; j++) {
			if (i == 0 && j == 0) continue;
			int tmp = a * i + b * j;
			tmp *= e;
			for (int k = 0; k <= f; k++) {
				for (int p = 0; p <= f; p++) {
					if (tmp / e * 100 + c * k + d * p <= f && c * k + d * p <= tmp) {
						fg = 1;
						int p1 = tmp / e * 100 + c * k + d * p;
						int p2 = c * k + d * p;
						if (ans == 0 || p2 * ans > p1 * res) {
							ans = p1, res = p2;
						}
						
					} 
 				}
			}
		}
	}
	printf("%d %d\n", ans, res);
}


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

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

typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<int> cp(A);
    sort(cp.begin(), cp.end(), greater<int>());
    for(int i=0;i<N;i++){
        int j=0;
        if(A[i]!=cp[j]){
            cout<<cp[j]<<endl;
        }else{
            cout<<cp[j+1]<<endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int l = 0;
  string ls = "", rs = "";
  REP(i, N) {
    if (S[i] == '(')
      l++;
    else
      l--;
    if (l < 0) {
      ls += "(";
      l++;
    }
  }
  REP(i, l) rs += ")";
  cout << ls + S + rs << endl;
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;
    ll siz=S.size();
    ll X=0;
    ll counter=0;
    for(ll i=0;i<siz-1;i++){
        if(S.at(i)==S.at(i+1)){counter++;
        }
        else{
            X+=(counter+1)/2;
            counter=0;
        }
    ;}
    X+=(counter+1)/2;
    if(counter==siz-1){
        cout<<(siz*K)/2;
    }
    else if(S.at(0)!=S.at(siz-1)){
        cout<<X*K<<endl;
    }
    else if(S.at(0)==S.at(siz-1)){
        ll counterf=0;
       for(int i=0;i<siz;i++){if(S.at(i)==S.at(i+1)){counterf++;
        }
        else{break;}
       ;}
       ll Y=X*K-((counter+1)/2)*(K-1)-((counterf+1)/2)*(K-1)+(counter+counterf+2)/2*(K-1);
       cout<<Y<<endl;
       
    }
    
    return 0;
}  


Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll n ;
	cin>> n ;
	ll arr[n+1];
	map<ll,ll> a , b ;
	for(ll i=1;i<=n ;i++){
		cin>>arr[i];
		a[i+arr[i]]++;
		b[i-arr[i]]++;
	}
	ll ans=0;
	for(auto x : a){
		if(b.count(x.f)>0){
			ll num= x.s*b[x.f];
			ans+=num;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 28312
n,m=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort_by {|a| -a}
bs=gets.split.map(&:to_i).sort_by {|b| -b}


if as.uniq != as || bs.uniq != bs
  p 0
  exit 0
end

i = 0
j = 0
t = n*m
count = 0
ret = 1
while 0 < t
  i += 1 while i < as.length && t < as[i]
  j += 1 while j < bs.length && t < bs[j]

  if as[i] == t && bs[j] == t
    # nop
  elsif as[i] == t
    ret *= j
  elsif bs[j] == t
    ret *= i
  else
    pat = i*j - count
    if pat <= 0
      p 0
      exit 0
    end
    ret *= pat
  end

  ret %= 1_000_000_007
  count += 1
  t -= 1
end

p ret

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define sqr(x) ((x) * (x))
using namespace std;
int n;
pair<int, int> coord[10];
double dist[10][10], sum;
int perm[10];

int fact(int n)
{
	int ret = 1;
	for (int i = 2; i <= n; i++) {
		ret *= i;
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> coord[i].first >> coord[i].second;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			dist[i][j] = dist[j][i] = sqrt(sqr(coord[i].first - coord[j].first) + sqr(coord[i].second - coord[j].second));			
		}
	}
	for (int i = 1; i <= n; i++) {
		perm[i] = i;
	}
	do {
		for (int i = 1; i < n; i++) {
			sum += dist[perm[i]][perm[i + 1]];
		}
	} while (next_permutation(perm + 1, perm + 1 + n));
	cout << setprecision(8) << sum / fact(n);
	return 0;
}

Measured memory_bytes: 256
/*
@author James Fisher
@date
@version
*/

import java.util.Scanner;

public class Main {

    private int max(int a, int b){
        return (a > b)? a : b;
    }

    private int lcs(char[] X, char[] Y, int m, int n){
/*        if (m == n)
            return 0;
        if(X[m-1] == Y[n-1])
            return 1 + lcs(X, Y, m-1, n-1);
        else
            return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));*/


        int L[][] = new int[m + 1][n + 1];
        for(int i = 0; i <= m; i++){
            for(int j = 0; j <= n; j++){
                if(i == 0 || j == 0)
                    L[i][j] = 0;
                else if(X[i - 1] == Y[j - 1]){
                    L[i][j] = L[i - 1][j - 1] + 1;
                } else {
                    L[i][j] = max(L[i - 1][j], L[i][j-1]);
                }
            }
        }
        return L[m][n];
    }

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

        int runLength = sc.nextInt();

        for(int i = 0; i < runLength; i++){
            String input1 = sc.next();
            String input2 = sc.next();

            char[] X = input1.toCharArray();
            char[] Y = input2.toCharArray();
            int m = input1.length();
            int n = input2.length();

            System.out.println(lcs.lcs(X, Y, m, n));
        }

    }
}



Measured memory_bytes: 64504
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
 
int main()
{
 
    char  s[4];
    int cnt=0;
  int i;
 // 整数の入力
    scanf("%s", s);
//    printf("%s\n",s);

  for(i=0;i < 3 ;i++ ){
//    printf("%c\n",s[i]);
    if(49 == s[i]){ 
     cnt = cnt + 1;
//     printf("%d\n",cnt);
              }
  }
     printf("%d\n", cnt);
 
    return 0;
}

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

int main() {
  
  int X; cin >> X;
  
  for (int i = X; 0 < i; i--) {
    for (int j = 1; j < 32; j++) {
      for (int k = 2; k < 10; k++) {
        if (i == pow(j, k)) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
  
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())

d = defaultdict(int)
for i in range(1, n+1):
    j = 2
    while i > 1:
        if i % j == 0:
            d[j] += 1
            i = i // j
        else:
            j += 1

x = {75: 0, 25: 0, 15: 0, 5: 0, 3: 0}
for y in x:
    for v in d.values():
        if v + 1 >= y:
            x[y] += 1

ans = 0
ans += x[75]
ans += x[15] * (x[5] - 1) if x[5] >= 1 else 0
ans += x[25] * (x[3] - 1) if x[3] >= 1 else 0
ans += (x[5] * (x[5] - 1) // 2) * (x[3] - 2) if x[3] >= 2 else 0
print(ans)


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<int> b(1000000,-1);

    for(int i = 0;i < n;i ++){
        if(i % 2 == 0){
            cin >> b.at(500000+(i/2));
        }else{
            cin >> b.at(500000-(i/2)-1);
        }
    }

    if(n % 2 == 0){
        for(int i = 0;i < 1000000;i ++){
            if(b.at(i) == -1){
                continue;
            }else{
                cout << b.at(i) << " ";
            }
        }
    }

    if(n % 2 == 1){
        for(int i = 1000000-1;i >= 0;i --){
            if(b.at(i) == -1){
                continue;
            }else{
                cout << b.at(i) << " ";
            }
        }
    }

    cout << endl;
}

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

int main() {
	long long int n,x,t;
	cin>>n>>x>>t;
	long long int ans=0;
	if(n%x==0){
		ans=(n/x)*t;
	}
	else{
		ans=((n/x)+1)*t;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N, K = map(int, input().split())
A = list(map(int, input().split()))

s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]
# pprint(s)

prev = s[K]
for i in range(K+1, N+1):
    # print(f'i = {i}')
    # print(f's[i] = {s[i]}, s[i-K] = {s[i-K]}')
    score = s[i] - s[i-K]
    # print(f'score = {score}')
    if prev < score:
        print('Yes')
    else:
        print('No')
    prev = score


Measured memory_bytes: 95996
//DayofTakahashi.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
        int b=sc.nextInt();
        
        int ans=0;
        for(int i=0; i<a; i++){
            ans++;
        }
        if(b<a){
            System.out.println(ans-1);
        }
        else{
            System.out.println(ans);
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s;
	cin >> s;
	int temp = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')temp++;
	}

	cout << temp * 100 + 700 << endl;

	return 0;
}

Measured memory_bytes: 256
S=list(input())
N=len(S)

C0=[]
C1=[]

for n in range(N):
  if S[n]=='0':
    C0.append(n)
  elif S[n]=='1':
    C1.append(n)

C_Num=[len(C0),len(C1)]
print(2*min(C_Num))

Measured memory_bytes: 7872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,t=0,k,m=1e9+7;
int main ()
{
    cin>>n>>k;
    for(int i=k;i<=n+1;i++)
    {
        t+=(n-i+1)*i+1;
        t%=m;
    }
    cout<<t;
}


Measured memory_bytes: 3632