akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
	int N,M;
	cin >> N >> M;
	int a[50],b[50],c[50],d[50];
	for(int i=0; i<N; i++) cin >> a[i] >> b[i];
	for(int i=0; i<M; i++) cin >> c[i] >> d[i];

	for(int i=0; i<N; i++){
		int ans = 0;
		int m = INT_MAX;
		for(int j=0; j<M; j++){
			if(abs(a[i]-c[j])+abs(b[i]-d[j]) < m){
				ans = j;
				m = abs(a[i]-c[j])+abs(b[i]-d[j]);
			}
		}
		cout << ans+1 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int a; cin >> a;
  print(a+a*a+a*a*a);
}


Measured memory_bytes: 3524
const main = (input) => {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b <= 2*c:
    ans = a*x+b*y
else:
    z = min(x,y)
    z1 = max(x,y)
    ans1 = 2*c*z1
    ans2 = 2*c*z + (z1-z) * (a if x>y else b)
    ans = min(ans1,ans2)
print(ans)

Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin >> a;
  if (a[0] ==a[1]) {
    cout << "Bad";
  } else if (a[1] == a[2]) {
    cout << "Bad";
  } else if (a[2] == a[3]) {
    cout << "Bad";
  } else {
    cout << "Good ";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/


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

int main() {
    int x,y;
    cin >> x >> y;
    if((4*x-y)%2 == 0){
        if ((0<=(4*x-y)/2) and ((4*x-y)/2 <= x)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(void){
    int n, k;
    char s[100001];
    scanf("%d %d", &n, &k);
    scanf("%s", &s);
    int s0 = s[0];
    int count = 1;
    int  t[100001];
    int t_c = 0;
    for(int i = 1;i < n;i++){
        if(s[i] == s0){
            count++;
        }else{
            t[t_c] = count;
            count = 1;
            t_c++;
            s0 = s[i];
        }
    }
    t[t_c] = count;
    t[t_c+1] = 0;
    
    int max = 0;
    if(k >= (t_c+2)/2){
        for(int j = 0;j <= t_c;j++){
            max = max + t[j];
        }
        printf("%d\n", max);
    }else{
        if(s[0] == '0'){
            for(int j = 0;j < k;j++){
                max = max + t[j*2+0] + t[j*2+1];
            }
            for(int i = 1;i*2+k*2-1 <= t_c+1;i++){
                int isum = t[i*2-1];
                for(int j = 0;j < k;j++){
                    isum = isum + t[i*2+j*2+0] + t[i*2+j*2+1];
                }
                if(max < isum){
                    max = isum;
                }
            }
            printf("%d\n", max);
        }else{
            max = max + t[0];
            for(int j = 0;j < k;j++){
                max = max + t[j*2+2] + t[j*2+1];
            }
            for(int i = 1;i*2+k*2 <= t_c+1;i++){
                int isum = t[i*2];
                for(int j = 0;j < k;j++){
                    isum = isum + t[i*2+j*2+2] + t[i*2+j*2+1];
                }
                if(max < isum){
                    max = isum;
                }
            }
            printf("%d\n", max);
        }
    }
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        string input;
        int m = 0;
        int h = 0;
        var list = new LinkedList<char>();
        var result =new List<string>();
            
        do
        {
            input = Console.ReadLine();

            if (input == "-")
            {
                break;
            }
                   
            m = int.Parse(Console.ReadLine());

            
            foreach(var c in input)
            {
                list.AddLast(c);
            }


            for(int i = 0; i < m; i++)
            {
                h = int.Parse(Console.ReadLine());

                for(int j = 0; j < h; j++)
                {
                    var node = list.First;                   
                    list.Remove(node);
                    list.AddLast(node);
                }              
            }
            

            result.Add(String.Join("",list));
            list.Clear();
            
        } while (true);

        foreach(var s in result)
        {
            Console.WriteLine(s);
        }
              
    }
}


Measured memory_bytes: 18412
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <numeric>

typedef long long ll;
#define INF 1 << 29
#define LLINF 1LL << 60
#define EPS 1e-6
#define ALL(c) (c).begin(), (c).end()
#define CNT(c,x) count(ALL(c),x)
#define dump(x)  cerr << #x << " = " << (x) << endl;
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

using namespace std;

ll v[100010];
ll dp[100010][2];

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

  ll sum = 0;
  ll mv = LLINF;
  int minus = 0;
  for (int i = 0; i < N; i++){
    ll x;
    cin >> x;
    sum += abs(x);
    if (x < 0LL) minus++;
    mv = min(mv, abs(x));
  }
  if(minus % 2) sum -= (mv * 2LL);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
list_A = [1]*N
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for j in range(d):
        if list_A[l[j]-1]  == 1:
            list_A[l[j]-1]  = 0

print(list_A.count(1))        

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

int a[100001], b[100001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int A, B, M; cin >> A >> B >> M;
    int mn_a = 987654231, mn_b = 987654321;
    for (int i = 1; i <= A; i++) {
        cin >> a[i];
        mn_a = min(mn_a, a[i]);
    }
    for (int i = 1; i <= B; i++) {
        cin >> b[i];
        mn_b = min(mn_b, b[i]);
    }

    int ans = mn_a + mn_b;
    for (int i = 0; i < M; i++) {
        int x, y, c; cin >> x >> y >> c;
        ans = min(ans, a[x] + b[y] - c);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

int main() {
	long long n, k;
	cin >> n >> k;
	long long ma = n, mi = 0;
	long long ans = 0;
	for (int i = 1; i <= n+1; i++) {
		if (i >= k) ans = mod(ans + ma - mi + 1);
		ma = mod(ma + n - i);
		mi = mod(mi + i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#define mod 1000000007
using namespace std;
int n,k;
string str[1002];
int dp[1002][1002];
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0' || ch>'9')f|=(ch=='-'),ch=getchar();
	while(ch>='0' && ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x=f? -x:x;return ;
}
int main()
{
	read(n),read(k);
	for(int i=1;i<=n;i++)
		cin>>str[i];
	for(int i=1;i<=k;i++)
	{
		if(str[1][i-1]=='#')
			break;
		dp[1][i]=1;
	}
	for(int i=2;i<=n;i++)
	{
		if(str[i][0]=='#')
			break;
		dp[i][1]=1;
	}
	for(int i=2;i<=n;i++)
		for(int j=2;j<=k;j++)
			if(str[i][j-1]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
	printf("%d",dp[n][k]);
	return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};
int n,d,ans=0;
int a[20][20];

void judge(int i,int j)
{
    int x=0;
    for(int k=0;k<d;k++)
    {
        x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
    }
    if(x==1)
    {
        ans++;
        return ;
    }
    int k;
    for(k=2;k*k<x;k++)
    {

    }
    if(k*k==x)
        ans++;
}

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    cin>>n>>d;
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
    {
        cin>>a[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            judge(i,j);
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(void){
    // Your code here!
    int N;
    string S;
    set<string> st;
    cin >> N >> S;
    auto calc = calcNext(S);
    for(int i = 0; i <= 9; i++){
        int order1 = calc[0][i];
        if(order1 >= N) continue;
        
        for(int j = 0; j <= 9; j++){
            int order2 = calc[order1 + 1][j];
            if(order2 >= N) continue;
            
            
            for(int k = 0; k <= 9; k++){
                int order3 = calc[order2 + 1][k];
                if(order3 >= N) continue;
                
                string tmp = "";
                tmp += S[order1];
                tmp += S[order2];
                tmp += S[order3];
                st.insert(tmp);
            }
        }
    }
    
    cout << st.size() << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int n, a, ac, m;
bitset<2000005> bt;
int main(){
	bt[0] = true;
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		ac += a;
		bt |= bt << a;
	}
	rep(i,ac/2+1) if(bt[i]) m = i;
	printf("%d\n", ac - m);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
#define pb push_back
#define F first
#define S second
using namespace std;

int main(void) {
	boost;
	ll n;
	cin >>n;
	vector<ll> f(n+1,0);
	for(int i=1;i<n;i++){
		for(int j=1;j<n;j++){
			for(int k=1;k<n;k++){
				ll ans=i*i+j*j+k*k+i*j+i*k+j*k;
				if(ans > n){
					break;
				}else{
					f[ans]++;
				}
			}
		}
	}for(int i=1;i<=n;i++){
		cout<<f[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3612
n,a,b = map(int,input().split())
ans = 0

def k(N):
    sum = 0
    while N>0:
        sum += N%10
        N = N//10
    return sum

for i in range(1,n+1):
    if a<=k(i)<=b:
        ans +=i
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 200005;
int a[MAXN],t[MAXN],n;
inline bool check(int limit)
{
	for(int i=1;i<=n*2-1;++i)
		t[i]=(a[i]>=limit);
	int l=-1,r=-1,lpos=-0x3f3f3f3f,rpos=0x3f3f3f3f;
	for(int i=n+1;i<=n*2-1;++i)
		if(t[i]==t[i-1]){r=t[i],rpos=i-1;break;}
	for(int i=n-1;i>0;--i)
		if(t[i]==t[i+1]){l=t[i],lpos=i+1;break;}
	if(l==-1 && r==-1)
		if(n&1)return t[n];
		else return t[n]^1;
	else return (rpos-n>n-lpos?l:r);
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2-1;++i)
		scanf("%d",a+i);
	int l=1,r=n*2-1,mid,ans=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))l=mid+1,ans=mid;
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		Integer q = sc.nextInt();
		for(int i=0; i<q; i++) {
			String func = sc.next();
			if(func.equals("replace")) {
				Integer arg1 = sc.nextInt();
				Integer arg2 = sc.nextInt();
				String arg3 = sc.next();
				str = replace(str, arg3, arg1, arg2);
			} else if(func.equals("reverse")) {
				Integer arg1 = sc.nextInt();
				Integer arg2 = sc.nextInt();
				str = reverse(str, arg1, arg2);
			} else if(func.equals("print")) {
				Integer arg1 = sc.nextInt();
				Integer arg2 = sc.nextInt();
				print(str, arg1, arg2);
			}
		}

		sc.close();

	}

	private static void print(String str, Integer start, Integer end) {
		System.out.println(str.substring(start, end+1));
	}

	private static String reverse(String str, Integer start, Integer end) {
		StringBuffer sb = new StringBuffer(str);
		String reversingStr = sb.substring(start, end+1);
		StringBuffer sb2 = new StringBuffer(reversingStr);
		String reversedStr = sb2.reverse().toString();
		String resultStr = sb.replace(start, end+1, reversedStr).toString();
		return resultStr;
	}

	private static String replace(String str, String replaceStr, Integer start, Integer end) {
		StringBuffer sb = new StringBuffer(str);
		sb.replace(start, end+1, replaceStr);
		String ret = sb.toString();
		return ret;
	}


}



Measured memory_bytes: 29768
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define int long long

/* 
ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}



int nCrModPFermat(int n, int r, int p)
{
   if (r==0)
      return 1;
    int fac[n+1];
    fac[0] = 1;
    for (int i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;
 
    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}
*/
/*struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
 
*/
 
/*vector<bool> sieve(100007,true);
 
void help(){
     sieve[0] = false;
     sieve[1] = false;
 
     for(int i=2;i*i<100007;++i){
        if(sieve[i]){
            for(int j=i*i;j<100007;j+=i)
                sieve[j] = false;
 
        }
     }
 
}*/
/*
ll expo(ll a,ll b){ll r=1;a=a%mod;while(b){if(b%2)r=(r*a)%mod;a=(a*a)%mod;b=b/2;}
return r;}
 
 
 */
 int n,s;
 const int mod = 1000000007;
  const int N = 200009;
  int arr[N];
  int sum ; 
  bool check(int mid)
  {
      
     int v[n];
     

      fo(i,n)
        v[i] = arr[i] + (i+1)*mid; 

      sort(v,v+n);
     int sum = 0;
      for(int i=0;i<mid;++i)
        sum+= v[i];
      
     return sum>s;
  }
  
  

    int32_t main() {
     fastIO
     
     int n;
     cin>>n;

     n-=1;

     int ans = (n*(n+1))/2;
     cout<<ans;
    
    
     return 0;
      }
// always test the corner cases ALWAYS;

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

int main(){
    ll n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> que;
    rep(i, 0, n) {
        double v;
        cin >> v;
        que.push(v);
    }
    rep(i, 0, n-1){
        auto q1 = que.top();
        que.pop();
        auto q2 = que.top();
        que.pop();
        que.push((q1 + q2) / 2);
    }
    printf("%.12lf\n", que.top());
    return 0;
}

Measured memory_bytes: 3804
// 046-b

#include <iostream>
using namespace std;

int main(void){
    int n, k, ans;

    cin >> n >> k;

    ans = k;
    for(int i = 1; i < n; i ++) {
        ans *= (k - 1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

int main(){
    string s;cin>>s;
    string t;cin>>t;
    bool flag=false;
    for(int i=s.length()-t.length();i>=0;i--){
        bool match=true;
        REP(j,t.length()){
            if(s[i+j]!='?' and s[i+j]!=t[j]){
                match=false;
                break;
            }
        }
        if(match==true){
            REP(j,t.length()){
                s[i+j]=t[j];
            }
            flag=true;
            break;
        }
    }
    if(flag==true){
        REP(i,s.length()){
            if(s[i]=='?'){
                cout<<"a";
            }else{
                cout<<s[i];
            }
        }
        cout<<"\n";
    }else{
        cout<<"UNRESTORABLE\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[200005], y[100005], z[100005];
ll k;

vector<ll> G[500005];

void solve(){
    map<ll, ll> mp;
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i];

    }
    mp[x[0] + 1] = 1;
    ll ans = 0;
    for(ll i=1;i<n;i++){
        ans += mp[i+1-x[i]];
        mp[x[i]+i+1]++;
    }
    p(ans);
    return;
}

int main(){

    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 39676
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  map<int,int> m;
  rep(i,N){
    ini(x);
    m[x] ^= 1;
  }
  int ans = 0;
  each(x , m) ans += x.se;
  out(ans);
}

Measured memory_bytes: 4992
#include <stdio.h>

int main () {
	int ang, akk = -1;
	char word[255];
	scanf ("%d", &ang);
	scanf ("%s", word);
	int x = ang / 2;
	if (ang % 2 == 0) {
		for (int i = 0; i < x; i++) {
			if (word[i] != word[x+i]) {
				akk = 1;
				break;
			} else {
				akk = 0;
			}		
		}
	} else printf ("No");
	
	if (akk == 0) {
		printf ("Yes");
	} else if (akk == 1) {
		printf ("No");
	}
	return 0;
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string x;
  cin>>n>>x;
  int m=0;
  for(int i=0;i<n;i++)
    m+=(int)(x.at(i)-'0');
  int rp=0;
  int rm=0;
  for(int i=0;i<n;i++){
    rp=(rp*2+(int)(x.at(i)-'0'))%(m+1);
    if(m>1)
      rm=(rm*2+(int)(x.at(i)-'0'))%(m-1);
  }
  vector<int> c(n,0);
  int pp=1;
  int pm=1;
  for(int i=n-1;i>=0;i--){
    if(m==1&&x.at(i)=='1')
      continue;
    int ci=1;
    int b=(x.at(i)=='0'?(rp+pp)%(m+1):(rm-pm+m-1)%(m-1));
    while(b>0){
      ci++;
      int a=b;
      int pc=0;
      while(a>0){
        pc+=a%2;
        a/=2;
      }
      b%=pc;
    }
    c.at(i)=ci;
    pp=pp*2%(m+1);
    if(m>1)
      pm=pm*2%(m-1);
  }
  for(int i=0;i<n;i++)
    cout<<c.at(i)<<endl;
}

Measured memory_bytes: 4440
(N,) = [int(x) for x in input().split()]

MOD = 10 ** 9 + 7

if N <= 1:
    print(0)
    exit()
else:
    total = pow(10, N, MOD)
    noZeroes = pow(9, N, MOD)
    noNines = pow(9, N, MOD)
    noZeroOrNines = pow(8, N, MOD)
    print((total - noZeroes - noNines + noZeroOrNines) % MOD)


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

int main() {
    int n;
    cin >> n;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        st.insert(a);
    }

    int ans = st.size();
    if ((n - ans) % 2 == 1)
        ans--;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8140
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define pb(s) push_back(s)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  ll N;
  cin >>N;
  
  vl vec(N+1);
  rep(i,N) {
cin >>vec.at(i);
  }
  vec.at(N)=INF;
  ll count=0;
  ll a=1;
  rep(i,N) {
    if(vec.at(i)==vec.at(i+1)) {
      a++;
    }
    else if(vec.at(i)!=vec.at(i+1)) {
      count +=floor((a)/2);
      a=1;
    }
    
  }
  
  cout<<count<<endl;
}
  
  
 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	x := io.NextInt()
	if x == 0 {
		io.Println(1)
	} else {
		io.Println(0)
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let a = get!();
    let b = get!();
    let c = get!();
    
    use std::cmp::min;
    let ans = c - min(a - b, c);
    println!("{}", ans);
}

Measured memory_bytes: 4352
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()

ym = True
my = True

tmp = ''
for i in range(2):
    tmp += s[i]
tmp = int(tmp)
if tmp < 1 or 12 < tmp:
    my = False

tmp = ''
for i in range(2):
    tmp += s[i+2]
tmp = int(tmp)
if tmp < 1 or 12 < tmp:
    ym = False

if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll dp[510][510];

int main(){
    int n,m,Q;
    cin >> n >> m >> Q;
    rep(i,510){
        rep(j,510){
            dp[i][j]=0;
        }
    }
    rep(i,m){
        int l,r;
        cin >> l >> r;
        dp[l][r]++;
    }
    rep(i,510){
        rep(j,509){
            dp[i][j+1]+=dp[i][j];
        }
    }
    rep(i,Q){
        int p,q;
        cin >> p >> q;
        ll res = 0;
        for(int j=p;j<=q;j++){
            res += dp[j][q]-dp[j][p-1];
        }
        cout << res << endl;
    }


    return 0;
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int k,x;cin>>k>>x;
  if(500*k>=x)puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
template <typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;
    F f;
    T unit;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(int newn,F f,T t):f(f),unit(t){
        init(newn);
    }
    SegmentTree(const vector<T> &v,F f,T t):f(f),unit(t){
        int n_ = v.size();
        init(n_);
        for(int i=0;i<n_;i++)dat[n+i]=v[i];
        for(int i=n-1;i;i--){
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
        }
    }
 
    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.assign(n<<1,unit);
    }
    
    void update(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    T query(int a,int b){
        T vl=unit,vr=unit;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
            if(l&1)vl=f(vl,dat[l++]);
            if(r&1)vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }
 
};
 
ll n,q;
SegmentTree<ll>seg[26];
 
int main(void){
    string s;
    cin>>n>>s>>q;
    auto f = [](ll l,ll r){return l+r;};
    for(int i=0;i<26;i++)seg[i] = SegmentTree<ll>(n,f,0);
    for(int i=0;i<s.length();i++){
        seg[s[i]-'a'].update(i,1);
    }
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            ll index;
            char c;
            cin>>index>>c;
            ll x = c-'a';
            ll y = s[index-1]-'a';
            seg[y].update(index-1,0);
            seg[x].update(index-1,1);
            s[index-1]=c;
        }
        else{
            ll l,r;
            cin>>l>>r;
            ll ans = 0;
            for(int i=0;i<26;i++){
                ll cnt = seg[i].query(l-1,r);
                //cout<<cnt<<endl;
                if(cnt>0)ans++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 214020
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        String s = nt();
        int mid = s.length() >> 1;
        if(s.substring(0, mid).equals(s.substring(mid+1, s.length())))
            pl("Yes");
        else
            pl("No");
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 22740
import fractions

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

left = [0] * N
right = [0] * N

left[0] = A[0]
for i in range(1,N):
    left[i] = fractions.gcd(left[i-1],A[i])

right[N-1] = A[N-1]
for j in range(N-2,0,-1):
    right[j] = fractions.gcd(A[j],right[j+1])

can = [0] * N
can[0] = right[1]
for k in range(1,N-1):
    can[k] = fractions.gcd(left[k-1],right[k+1])
can[N-1] = left[N-2]

print(max(can))

Measured memory_bytes: 16124
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int a,b;
  cin>>a>>b;
  bool res =false;
  rep(i,10001){
    if((int)(i*0.08) ==a && (int)(i*0.10) ==b){
      cout << i<<endl;
      res =true;
      break;
    }
  }
  if(!res) {
    cout<<-1<<endl;
  }
  
}




Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int x;
	cin>>x;
	for(int i=0;;i++){
		if(i*(i+1)/2>=x){
			cout<<i;
			return 0;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (int)(n);i++)
typedef long long ll;
using namespace std;
int main(){
  int n = 0;
  cin >> n;
  map<string ,int> m;
  rep(i,n){
    string s;
    cin >> s; 
    sort(s.begin(),s.end());
    m[s]++;
  }
  ll total = 0;
  for(auto& mp : m){ 
    int s = mp.second;
    total += (ll)s*(s-1) / 2;
  }
  cout << total << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define int long long
#define INF 1<<25
using namespace std;

int N,W;
int ans;
int v[1010],w[1010];
int mem[10100][10100];

int dfs(int n,int h){
    if(n==0){
        ans=0;
    }
    else if(mem[n][h]!=0)ans=mem[n][h];
    else if(w[n]>h)ans=dfs(n-1,h);
    else ans=max(dfs(n-1,h),dfs(n-1,h-w[n])+v[n]);
    return mem[n][h]=ans;
}

signed main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++){
        cin>>v[i]>>w[i];
    }
    cout<<dfs(N,W)<<endl;
}

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

import re

n = int(raw_input())
a = re.split('\s', raw_input())

ans = [0]*n

if (n % 2 == 0):
        first = n / 2 - 1
        second = n / 2
        for i in range(n):
                if (i % 2 == 0):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
else:   
        first = (n - 1) / 2
        second = (n - 1) / 2 + 1
        for i in range(n):
                if (i % 2 == 1):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
ans = map(str, ans)
print " ".join(ans)


Measured memory_bytes: 25436
#include <iostream>
#include <vector>
#include <string>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

const int n = 110000;
int main(){
  int x;
  cin >> x;
  vector<bool> era(n, true);
  int z = 1;
  while(z < n){
    z++;
    if (!era[z]) continue;
    for(int i = z*2; i < n; i+=z){
      era[i] = false;
    }
  }
  
  while(1){
    if (era[x]){
      cout << x << endl;
      break;
    }
    x++;
  }
  
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 2e5+10;
int a[maxn];
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		int t;
		memset(a,0,sizeof(a));
		int flag = 0;
		for(int i = 0 ; i < n ; i ++)
		{
			scanf("%d",&t);
			if(!a[t])
			{
				flag++;
			}
			a[t]++;
		}
		if(flag<=m) puts("0");
		else 
		{
			int ans = 0;
			sort(a,a+n+1);
			/*for(int i = 0 ;i <= n ;i++)
			{
				printf("%d ",a[i]);
			}*/
			for(int i = 0 ; i <= n;i++)
			{
				if(a[i])
				{
					flag--;
					ans+=a[i];
				}
				if(flag <= m)
				{
					printf("%d\n",ans);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
	int n;
    cin >> n;
    vector<string> S(n);
    rep(i,n) cin >> S[i];

    map<string, int> poll;
    rep(i,n){
        if(poll.count(S[i])){
            poll[S[i]]++;
        }else{
            poll[S[i]] = 1;
        }
    }

    int max = 0;
    vector<string> win;
    for(auto x : poll){
        auto k = x.first;
        auto v = x.second;
        if(v > max){
            max = v;
            win = {k};
        }else if(v == max){
            win.push_back(k);
        }
    }

    sort(win.begin(), win.end());
    for(auto x : win){
        cout << x << endl;
    }

	return 0;
}

Measured memory_bytes: 28404
#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, d;
  cin >> a >> b >> c >> d;
  
  int e,f;
  if (a%d==0) e = a/d;
  else e = a/d + 1;
  
  if (c%b==0) f = c/b;
  else f = c/b + 1;
  
  if (e >= f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <string>
#define maxn 41
using namespace std;
string str;
int s1[maxn], s2[maxn], s3[maxn];
long long f[maxn][maxn];
int main(){
	int n;
	cin >> n;
	cin >> str;
	long long ans = 0;
	for (int s = 0; s < 1 << n; ++ s){
		int m1 = 0;
		for (int i = 0; i < n; ++ i)
			if (s & (1 << i))
				s1[++ m1] = str[i];
		int m2 = 0;
		for (int i = 0; i < n; ++ i)
			if ((s & (1 << i)) == 0)
				s2[++ m2] = str[i];
		int m3 = 0;
		for (int i = 2 * n - 1; i >= n; -- i)
			s3[++ m3] = str[i];
		memset(f, 0, sizeof(f));
		for (int i = 0; i <= m1; ++ i)
			for (int j = 0; j <= m2; ++ j){
				if (i == 0 && j == 0)
					f[i][j] = 1;
				if (i && s3[i + j] == s1[i])
					f[i][j] += f[i - 1][j];
				if (j && s3[i + j] == s2[j])
					f[i][j] += f[i][j - 1];
			}
		ans += f[m1][m2];
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bitset>
#include<cstdint>
#include<string>
#include<iostream>
#include <vector>
#include<numeric>

int main() {
	using uint32 = std::uint_fast32_t;
	using int32 = std::int_fast32_t;
	constexpr uint32 SIZ = 17000;
	std::string s;
	int32 x, y;
	std::cin >> s >> x >> y;
	const uint32 len = s.length();
	std::vector<uint32> a, b;
	uint32 it = 0;
	while (it < len) {
		if (s[it] == 'F')
			--x, ++it;
		else
			break;
	}
	for (bool f = 1;it < len;++it) {
		if (s[it] == 'T') {
			f ^= 1;
			f ? a.push_back(0) : b.push_back(0);
		}
		else {
			f ? ++a.back() : ++b.back();
		}
	}
	std::bitset<SIZ> dpx, dpy;
	x += std::accumulate(a.begin(), a.end(), 0);
	y += std::accumulate(b.begin(), b.end(), 0);
	if (x < 0 || y < 0) {
		std::cout << "No" << std::endl;
		return 0;
	}
	dpx.set(0);
	for (const auto d : a)
		dpx |= dpx << (d << 1);
	dpy.set(0);
	for (const auto d : b)
		dpy |= dpy << (d << 1);
	std::cout << (dpx[x] && dpy[y] ? "Yes" : "No") << std::endl;
	return 0;
}

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


void solve(long long A, long long B, long long C, long long D){
    if(A >= B){
        if(C >= D) cout << B + D << endl;
        else cout << B + C << endl;
    }else{
        if(C >= D) cout << A + D << endl;
        else cout << A + C << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    int A, B;
    in >> A, B;

    out << std::max({A + B, A - B, A * B});

    return 0;
}


Measured memory_bytes: 256