akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "cmath"
using namespace std;
int main()
{
	int a[100][100], b[100][100];
	long long c[100][100] = {};
	int n, m, l;
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int j = 0; j < m; j++)
	{
		for (int k = 0; k < l; k++)
		{
			cin >> b[j][k];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int k = 0; k < l; k++)
			{
				c[i][k] += a[i][j] * b[j][k];
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cout << c[i][j];
			if (j == l - 1)
			{
				cout << endl;
			}
			else
			{
				cout << " ";
			}
		}
	}
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  cout<<(n-1)/2;
 

  return 0;
}

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

struct Node
{
    int num;
    int next[300];
};
Node t[10000];
int top=1;

int n,m;
char s[100];
int ans=0;

void insert(char *s,int num)
{
    int now=1;
    for (int i=0; s[i]!='\0'; i++)
    {
        if (t[now].next[s[i]]==0)
            t[now].next[s[i]]=++top;
        now=t[now].next[s[i]];
    }
    t[now].num+=num;
}
    

int main()
{
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        scanf("%s",s);
        insert(s,1);
    }
    cin>>m;
    for (int i=0; i<m; ++i)
    {
        scanf("%s",s);
        insert(s,-1);
    }
    for (int i=1; i<=top; ++i)
        ans=max(ans,t[i].num);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
const int N=110000;
int a[N],n,T;
int main(){
	scanf("%d%d",&n,&T);
	rep(i,1,n)scanf("%d",&a[i]);
	int mi=(1e9)+10;
	int diff=0;
	int cnt=0;
	rep(i,1,n){
		if(a[i]-mi==diff)++cnt;
		else if(a[i]-mi>diff){diff=a[i]-mi;cnt=1;}
		mi=min(mi,a[i]);
	}
	printf("%d\n",cnt);
	return 0;
}





Measured memory_bytes: 640
while True:
    m,f,r=map(int,input().split())

    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f>=65:
        print("B")
    elif m+f>=50:
        print("C")
    elif m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	long long k,n;
	cin >> k >> n;
	vector<long long> a(n,0),b(n,0);
	for(long long i=0;i<n;i++){
		cin >> a[i];
		if(i>0){
			b[i-1]=a[i]-a[i-1];	
		}
		if(i==n-1){
			b[i]=a[0]+(k-a[i]);
		}
	}
	sort(b.begin(),b.end());
	cout << k-b.back() << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
comp(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int
main(int argc, const char *argv[])
{
  int n, m, a[100010];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);

  int sum[100010];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = (sum[i - 1] + a[i - 1]) % m;
  }

  qsort(sum, n + 1, sizeof(int), comp);

  int k = 0; ll cnt, ans = 0;
  sum[n + 1] = -1;
  while (k <= n) {
    cnt = 0;
    while (sum[k] == sum[k + 1]) {
      k++; cnt++;
    } cnt++; k++;
    ans += cnt * (cnt - 1) / (ll)2;
  }

  printf("%lld\n", ans);

  return 0;
}
    
  


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

int w, h;
int sima[51][51];
int move_X[9] = {-1,-1,-1,0,0,0,1,1,1};
int move_Y[9] = {-1,0,1,-1,0,1,-1,0,1};

void dfs(int y, int x){
    
    // 現在の位置を海に変える
    sima[y][x] = 0;
    
    for(int i = 0; i < 9; i++){
        int next_X = x + move_X[i];
        int next_Y = y + move_Y[i];
        
        if(sima[next_Y][next_X] == 1 && next_X >= 0 && next_Y >= 0 && next_X < w && next_Y < h)
            dfs(next_Y, next_X);
    }
    
    return ;
    
}

int main(void){
    
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) return 0;
    
        // 島と海の入力
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> sima[i][j];
            }
        }
        
        // 島の個数
        int ans = 0;
        
        // 島の個数を調べる
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(sima[i][j] == 1){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        
        cout << ans << endl;
        
    }
    
    return 0;
    
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    for(int i=0; i<n; ++i)
        cin >> b[i];

    int ans = 0;
    for(int i=0; i<29; ++i){
        int x = 1 << i;
        vector<int> v(n);
        for(int j=0; j<n; ++j)
            v[j] = b[j] % (x << 1);
        sort(v.begin(), v.end());

        int cnt = 0;
        for(int j=0; j<n; ++j){
            int c = a[j] % (x << 1);
            vector<int> y = {x, x << 1, (x << 1) | x};
            vector<int> index(3);
            for(int k=0; k<3; ++k)
                index[k] = lower_bound(v.begin(), v.end(), y[k] - c) - v.begin();
            cnt += (index[1] - index[0]) + (n - index[2]);
        }
        if(cnt % 2 != 0)
            ans ^= x;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];

    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];
        --b[i];
    }

    rep(i, n){
        rep(j, n){
            if(i == j)
                dist[i][j] = 0;
            else
                dist[i][j] = INF;
        }
    }

    rep(i, m){
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[a[i]][b[i]], c[i]);
    }


    rep(k, n){
        rep(i, n){
            rep(j, n){
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }

    int ans = m;
    rep(i, m){
        bool shortest = false;
        rep(j, n){
            if(dist[j][a[i]] + c[i] == dist[j][b[i]])
                shortest = true;
        }
        if(shortest)
            --ans;
    }


    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
D = {i: 0 for i in range(1, M+1)}
for i in range(N):
  L = list(map(int, input().split()))
  for j in range(1, L[0]+1):
    D[L[j]] += 1
cnt = 0
for i in D:
  if D[i] == N:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	char str[N];int a[N],dp[N][2];
	void main()
	{
		scanf("%s",str+1);int n=strlen(str+1);fo(i,1,n) a[n-i+1]=str[i]-'0';
		//int ans=0;fo(i,1,N-1) if(a[i]<=5) ans+=a[i]; else a[i+1]++,ans+=10-a[i];write(ans);
		mem(dp,0x3f);dp[n+1][0]=0,dp[n+1][1]=1;
		fd(i,n,1)
		{
			{
				chmin(dp[i][0],dp[i+1][0]+a[i]);
				chmin(dp[i][1],dp[i+1][0]+a[i]+1);
			}//lst=0
			{
				chmin(dp[i][0],dp[i+1][1]+10-a[i]);
				chmin(dp[i][1],dp[i+1][1]+10-a[i]-1);
			}//lst=1
		}
		fd(i,n+1,1) fo(lst,0,1) debug("dp(%d,%d)=%d\n",i,lst,dp[i][lst]);write(dp[1][0]);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 22784
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            while(true){
            	
            	int s1 =scan.nextInt();
            	int s2 =scan.nextInt();
            	if((s1|s2)==0)break;
            	int c =0;
            	int max =s1+s2;
            	for(int i=1;i<5;i++){
            	s1 = scan.nextInt();
            	s2 = scan.nextInt();
            	if(Math.max(max, s1+s2)>max){
            		max = s1+s2;
            		c = i;
            	}
            	}
            	System.out.println((char)('A'+c)+" "+max);
            }
        }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> r(N),l(N);
    long long Count = 0;
    for(int i = 0; i < N; i++){
        cin >> l[i] >> r[i];
        Count += r[i] - l[i] + 1;
    }
    cout << Count << endl;
}


Measured memory_bytes: 256
// WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

ll pow3(ll a, ll b, ll m)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    ll n, m, k;
    cin >> n >> m >> k;
    ll inf = 998244353;
    ll N = 200001;
    ll val[k + 1] = {0};
    ll f[N], ivf[N];
    f[0] = 1;
    for(ll i = 1; i < N; i++)
        f[i] = (i * f[i - 1]) % inf;
    for(ll i = 0; i < N; i++)
        ivf[i] = pow3(f[i], inf - 2, inf);
    ll ans = 0;
    for(ll i = n - k; i <= n; i++)
    {
        ll temp = f[n - 1];
        temp = (temp * ivf[i - 1]) % inf;
        temp = (temp * ivf[n - i]) % inf;
        temp = (temp * m) % inf;
        ll temp2 = pow3(m - 1, i - 1, inf);
        temp = (temp * temp2) % inf;
        ans = (ans + temp) % inf;
    }
    cout << ans << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++)
    {
    	solve();
    }
    return 0;
}

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

#define pb push_back
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e6 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, p;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> p;
		if(p%2 == 1) return cout << "first", 0;
	}
	cout << "second";
	return 0;
}


/*
4096 4096 4096
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const ll MAX = 2e5+2;
ll res;
pair<ll,ll> a[MAX];
map<ll,ll> ml,mr;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].first;
        a[i].second = i;
    }
    for(ll i=0;i<n;i++)
    {
        ml[a[i].first + a[i].second]++;
        if(mr[a[i].first + a[i].second] > 0)
        {
            res+=mr[a[i].first + a[i].second];
        }
        mr[a[i].second - a[i].first]++;
        if(ml[a[i].second - a[i].first] > 0)
        {
            res+=ml[a[i].second - a[i].first];
        }
    }
    cout<<res<<endl;
    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C);
    REP(i, A) cin >> P[i];
    REP(i, B) cin >> Q[i];
    REP(i, C) cin >> R[i];
    sort(all(P), greater<ll>());
    sort(all(Q), greater<ll>());
    vector<ll> W;
    REP(i, X) W.pb(P[i]);
    REP(i, Y) W.pb(Q[i]);
    REP(i, C) W.pb(R[i]);
    sort(all(W), greater<ll>());
   	ll ans = 0;
   	REP(i, X + Y) {
    	ans += W[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8816
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n%2==0) cout<<n<<endl;
	else cout<<n*2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	ll sum = 0;
	REP(i, n)
	{
		int a; cin >> a;
		sum += a;
	}
	cout << sum - n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	ll L, R;
	cin >> L >> R;
	if (R - L >= 2040)print(0);
	else {
		ll mini = 2200*2200;
		for (ll i = L; i <= R; i++) {
			for (ll j = i+1; j <= R; j++) {
				if (mini > ((i*j) % 2019))mini = (i * j) % 2019;
			}
		}
		print(mini);
	}

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let n = read_one::<usize>();
    let s = read_one::<String>();
    let s = s.chars()
        .map(|c| match c {
            'E' => 1,
            'W' => 0,
            _   => 2,
        }).collect::<Vec<usize>>();

    let mut sum_r = s.iter().sum::<usize>();
    let mut sum_l = 0;
    let mut sum = sum_r + sum_l;
    for i in 0..n {
        match s[i] {
            0 => {
                sum_l += 1;
            },
            1 => {
                sum_r -= 1;
            }
            _ => {},
        }
        if sum_l + sum_r < sum { sum = sum_l + sum_r; }
    }
    println!("{}", sum);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 10104
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
using namespace std;

ll i,j,k;
const ll MOD = 1000000000 + 7;

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

int main(){
    string s;
    cin>>s;
    string ans="ABC";

    if(s=="ABC"){
        ans="ARC";
    }
    cout<<ans<<'\n';

    return 0;
}



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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200200;
const int MOD = 1000 * 1000 * 1000 + 7;

VI g[MAX];

int Lev[MAX];

void _dfs(int x, int d)
{
	Lev[d]++;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		_dfs(to, d+1);
	}
}

vector<pair<LL, LL> > A[MAX];
int sz;

bool cmp(int a, int b)
{
	return SZ(A[a]) > SZ(A[b]);
}

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD-2);
}

int dfs(int x)
{
	VI v;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		v.PB(dfs(to));
	}

	if (v.empty())
	{
		v.PB(sz);
		sz++;
	}

	sort(ALL(v), cmp);

	int sz = 0;
	if (SZ(v) > 1) sz = SZ(A[v[1]]);

	FOR (i, 0, sz)
	{
		LL sum = 0;

		LL tot_0 = 1;
		LL tot = 1;
		FOR (j, 0, SZ(v))
		{
			if (SZ(A[v[j]]) <= i) break;

			tot_0 = (tot_0 * A[v[j]][SZ(A[v[j]]) - i - 1].second) % MOD;

			tot = (tot * (A[v[j]][SZ(A[v[j]]) - i - 1].first + A[v[j]][SZ(A[v[j]]) - i - 1].second)) % MOD;
		}

		// cout<<"!! "<<i<<": "<<tot_0<<' '<<tot<<endl;

		FOR (j, 0, SZ(v))
		{
			if (SZ(A[v[j]]) <= i) break;

			LL cur = (tot_0 * inv(A[v[j]][SZ(A[v[j]]) - i - 1].second)) % MOD;

			cur *= A[v[j]][SZ(A[v[j]]) - i - 1].first;
			cur %= MOD;

			// cout<<"@ "<<cur<<endl;

			sum += cur;
		}

		// cout<<"% "<<sum<<' '<<tot<<endl;

		A[v[0]][SZ(A[v[0]]) - i - 1].first = sum;
		A[v[0]][SZ(A[v[0]]) - i - 1].second = (tot - sum);

		A[v[0]][SZ(A[v[0]]) - i - 1].first %= MOD;
		A[v[0]][SZ(A[v[0]]) - i - 1].second %= MOD;
		A[v[0]][SZ(A[v[0]]) - i - 1].second += MOD;
		A[v[0]][SZ(A[v[0]]) - i - 1].second %= MOD;
	}

	A[v[0]].PB(MP(1, 1));

	// cout<<x<<": ";
	// FOR (i, 0, SZ(A[v[0]]))
	// {
	// 	cout<<A[v[0]][i].first<<' '<<A[v[0]][i].second<<endl;
	// }
	// cout<<endl;

	return v[0];
}

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

	int n;
	scanf("%d", &n);
	n++;
	FOR (i, 1, n)
	{
		int p;
		scanf("%d", &p);
		g[p].PB(i);
	}

	_dfs(0, 0);
	int ind = dfs(0);

	vector<pair<LL, LL> >& v = A[ind];

	// FOR (i, 0, SZ(v))
	// {
	// 	cout<<v[i].first<<' '<<v[i].second<<endl;
	// }

	reverse(ALL(v));

	LL res = 0;

	FOR (i, 0, SZ(v))
	{
		LL cur = v[i].first;
		int rest = n - Lev[i];

		cur *= bpow(2, rest);
		res = (res + cur) % MOD;
	}

	cout<<res<<endl;


}


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

using namespace std;

using int64 = long long;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

int DiameterOfTree(const vector<vector<Edge>>& graph) {
  function<tuple<int, int>(int, int)> dfs =
      [&](int v, int p) -> tuple<int, int> {
    auto r = make_tuple(v, 0);
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      int arg, value;
      tie(arg, value) = dfs(e.to, v);
      value += 1;
      if (get<1>(r) < value) {
        r = make_tuple(arg, value);
      }
    }
    return r;
  };
  int v;
  tie(v, ignore) = dfs(0, -1);
  int d;
  tie(ignore, d) = dfs(v, -1);
  return d;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedGraph(n, n - 1, true);
  int d = DiameterOfTree(graph);

  if (d % 3 == 1) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 310010
#define offset 30010
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<map<int,int> ,int> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
vector<int> grafo[tam];
ii rango[tam];
int sumh[tam],condsum[tam];
int padre[tam];
bool marcado[tam];
const int INF=1e9;
int dfs0(int num,int pa)
{
    int hijo;
    int tot=0;
    padre[num]=pa;
    forr(i,0,grafo[num].size())
    {
        hijo=grafo[num][i];
        if (hijo==pa)continue;
        tot+=dfs0(hijo,num);
    }
    condsum[num]=sumh[num]=tot;
    //cout<<num<<' '<<pa<<","<<tot<<endl;
    if (rango[num].fi!=-INF)
        tot++;
    return tot;
}
int ans[tam];
void dfs1(int num,int pa)
{
    int hijo,tuiz,tuder;
    forr(i,0,grafo[num].size())
    {
        hijo=grafo[num][i];
        if (hijo==pa)continue;
        tuiz=rango[hijo].fi,tuder=rango[hijo].se;
        if (ans[num]-1>=tuiz&& ans[num]-1<=tuder)
            ans[hijo]=ans[num]-1;
        else
            ans[hijo]=ans[num]+1;
        dfs1(hijo,num);
    }
}
int main()
{
    forr(i,0,tam){
        rango[i]=mp(-INF,INF);
        marcado[i]=0;
    }
    ios::sync_with_stdio(false);cin.tie(0);
    int n,u,v;
    cin>>n;
    forr(i,0,n-1)
    {
        cin>>u>>v;
        grafo[u].pb(v);
        grafo[v].pb(u);
    }
    int k,valor;
    cin>>k;
    forr(i,0,k)
    {
        cin>>v>>valor;
        rango[v]=ii(valor,valor);
        marcado[v]=1;
    }
    dfs0(1,0);
    queue<int> cola;
    forr(i,1,n+1)
    {
        if (sumh[i]==0&& marcado[i])
            cola.push(i);
    }
    int tuiz,tuder,miiz,mider;
    bool invalid=false;
    while(!cola.empty())
    {
        int num=cola.front();cola.pop();
        int auxpa=padre[num];
        condsum[auxpa]-=sumh[num]+marcado[num];
        tuiz=rango[auxpa].fi,tuder=rango[auxpa].se;
        miiz=rango[num].fi,mider=rango[num].se;
        //cout<<num<<" "<<miiz<<" "<<mider<<" "<<condsum[auxpa]<<" "<<auxpa<<endl;
        if (tuiz==-INF)
        {
            rango[auxpa]=mp(miiz-1,mider+1);
        }
        else
        {
            if (abs(tuiz%2)!=abs((miiz-1)%2))
            {
                invalid=1;break;
            }
            else{
                miiz--;mider++;
                if (mider<tuiz || miiz>tuder){invalid=1;break;}
                rango[auxpa]=mp(max(miiz,tuiz),min(mider,tuder));
            }
        }
        if (num!=1 && condsum[auxpa]==0)
        {
            cola.push(auxpa);
        }
    }
    //checkpoint
    if (invalid==false){
        if (rango[1].fi!=-INF)
        ans[1]=rango[1].fi;
        else    
        ans[1]=0;
        dfs1(1,1);
        cout<<"Yes\n";
        forr(i,1,n+1)
        cout<<ans[i]<<"\n";
        //cout<<endl;
    }
    else
    {
        cout<<"No\n";
    }

}

Measured memory_bytes: 28160
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int K;
    cin >> K;

    for(int i=0;i<s.size();i++){
        if(s[i]!=s[K-1]){
            s[i] = '*';
        }
    }
    cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

int n;

vi dijkstra(int node, vvi &adj) {
	vi dist(n, inf);
	dist[node] = 0;
	priority_queue<ii> q;
	q.push({-dist[node], node});
	while(!q.empty()) {
		int node = q.top().ss; q.pop();
		for(int i : adj[node]) {
			if(dist[node] + 1 < dist[i]) {
				dist[i] = dist[node] + 1;
				q.push({-dist[i], i});
			}
		}
	}
	
	return dist;
}

void solve() {
	cin >> n;
	
	vvi adj(n);
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		
		adj[u].pub(v);
		adj[v].pub(u);
	}
	
	vi dist1 = dijkstra(0, adj);
	int maxi = 0;
	for(int i = 0; i < n; i++) {
		if(dist1[maxi] < dist1[i]) maxi = i;
	}
	
	vi dist2 = dijkstra(maxi, adj);
	int mx = 0;
	for(int i = 0; i < n; i++) mx = max(mx, dist2[i]);
	
	int longest = mx;
	if(longest % 3 != 1) cout << "First" << endl;
	else cout << "Second" << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    set<int>S;
    for (int X = 0; X < M; X++) {
        int L, R;
        cin >> L >> R;
        G[L-1].push_back(R-1);
        G[R-1].push_back(L-1);
        S.insert(L-1);
        S.insert(R-1);
    }
    vector<int> V(N, -1);queue<int> Q;
    V[0] = 0;
    Q.push(0);
    if(S.size()<N){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        for (;!Q.empty();) {
            int W = Q.front();
            Q.pop(); 
            for (int p : G[W]) {
                if (V[p] != -1){
                    continue;
                }
                V[p] = W;
                Q.push(p);
            }
        }
        for (int X = 0; X < N; X++) {
            if(X!=0){
                cout << V[X]+1 << endl;
            }
        }
    }
}

Measured memory_bytes: 14828
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
def yaku(m):
    ans = []
    i = 1
    while i*i <= m:
        if m % i == 0:
            j = m // i
            ans.append(i)
        i += 1
    ans = sorted(ans)
    return ans
a = yaku(n)
#print(a)
ans = float('inf')
for v in a:
    ans = min(ans, (v-1)+(n//v)-1)
print(ans)


Measured memory_bytes: 10428
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!

int a[60];
int main(){
	int n;
	ri(n);
	FOR(i,0,n) ri(a[i]);
	int posm=0,posM=0;
	FOR(i,1,n){
		if(a[posm]>a[i]) posm=i;
		if(a[posM]<a[i]) posM=i;
	}
	printf("%d\n",2*n-1);
	if(abs(a[posm])<abs(a[posM])){
		FOR(i,0,n) printf("%d %d\n",posM+1,i+1);
		FOR(i,1,n) printf("%d %d\n",i,i+1);
	}else{
	    FOR(i,0,n) printf("%d %d\n",posm+1,i+1);
		FORR(i,n-1,0) printf("%d %d\n",i+1,i);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    string W;
    map<string, int> m;
    cin >> N;
    char before = '-';
    int ng = -1;
    REP(i, N) {
        cin >> W;
        if (W[0] != before) ng++;
        before = W[W.length() - 1];
        m[W]++;
    }
    bool ok = ng == 0;
    for (auto p : m) {
        if (p.second > 1) ok &= false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb push_back

const int N = 2e6 + 7;
ll n,m,k,ans[N],cur,ar[N];
ll sum,a[N],b[N],c,d;
vector<ll> v[N];
map <ll,ll> mp;

void dfs(ll x,ll sum){
	sum += mp[x];
	ans[x] = sum;
	fori(i,0,v[x].size())
		dfs(v[x][i],sum);
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);

	// freopen("../in.txt","r",stdin);
	// freopen("../out.txt","w",stdout);
	ll q;
	cin >> n >> q;
	fori(i,0,n - 1){
		cin >> c >> d;
		v[c].pb(d);
	}
	fori(i,0,q){
		cin >> a[i] >> b[i];
		mp[a[i]] += b[i];
	}
	dfs(1,0);
	fori(i,1,n + 1)
		cout << ans[i] << ' ';
	
}

Measured memory_bytes: 94080
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

dp = [[10001] * W for _ in range(H)]
if s[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0
moves = [[1, 0],[0, 1]]

for y in range(H):
    for x in range(W):
        for m in moves:
            ny, nx = y+m[0], x+m[1]
            if ny >= H or nx >= W:
                continue
            add = 0
            # .から#に突入する時だけカウントが増える
            if s[y][x] == '.' and s[ny][nx] == '#':
                add = 1
            dp[ny][nx] = min(dp[ny][nx], dp[y][x] + add)
print(dp[-1][-1])


Measured memory_bytes: 3188
a, b, c = gets.split(" ").map(&:to_i)
k = gets.to_i

res = [[a, b, c]]
k.times do |i|
  res = res.flat_map{|r| [[r[0] * 2, r[1], r[2]], [r[0], r[1] * 2, r[2]], [r[0], r[1], r[2] * 2]]}
end

res.map do |r|
    if r[0] < r[1] && r[1] < r[2] then
      puts "Yes"
      return
    end
end

puts "No"


Measured memory_bytes: 14296
import sys
def 解():
    iN = int(input())
    aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    iT = aD[0][0]
    iA = aD[0][1]
    for a in aD[1:]:
        iTn = a[0]
        iAn = a[1]
        if iT <= iTn and iA <= iAn:
            iT = iTn
            iA = iAn
        else:
            iD = iT/iA
            iDn = iTn/iAn
            if iD > 1 > iDn or iD < 1 < iDn:
                if iDn < 1:
                    iG = iT//iTn
                    if iT % iTn !=0 :
                        iG += 1
                else:
                    iG = iA//iAn
                    if iA % iAn !=0 :
                        iG += 1
                iA = iAn * iG
                iT = iTn * iG
            else :
                if iA/iAn > iT/iTn:
                    iG = iA//iAn
                    if iA % iAn !=0 :
                        iG += 1
                else:
                    iG = iT//iTn
                    if iT % iTn !=0 :
                        iG += 1
                iA = iAn * iG
                iT = iTn * iG
    return iA+iT
print(解())


Measured memory_bytes: 3192
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = n - sum(a)
    if ans < 0:
        print(-1)
    else:
        print(ans)

main()

Measured memory_bytes: 9880
#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;

int main() {
	ll n, x, d; cin >> n >> x >> d;
	if (d == 0) {
		if (x == 0) cout << 1 << endl;
		else cout << n + 1 << endl;
		return 0;
	}
	if (d < 0) {
		x = -x;
		d = -d;
	}
	map<ll, vector<pair<ll, ll>>> r;
	r[0].emplace_back(0, d);
	ll left = 0, right = 0;
	for (int i = 0; i < n; i++) {
		left += i;
		right += n - i - 1;
		r[(i + 1)*x % d].emplace_back((i + 1)*x + d*left, (i + 1)*x + d*(right + 1));
	}
	for (auto &p : r) {
		auto &v = p.second;
		sort(v.begin(), v.end(), [&](auto &a, auto &b) {
			return a.second < b.second;
		});
	}
	for (auto &p : r) {
		auto &v = p.second;
		for (int j = (int)v.size() - 2; j >= 0; j--) {
			if (v[j].second > v[j + 1].first) {
				v[j].second = v[j + 1].first;
				if (v[j].first > v[j].second) {
					v[j].first = v[j].second;
				}
			}
		}
	}
	ll ans = 0;
	for (auto &p : r) {
		cerr << p.first << endl;
		auto &v = p.second;
		for (int j = 0; j < (int)v.size(); j++) {
			if (v[j].first >= v[j].second) continue;
			ans += (v[j].second - v[j].first) / d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22144
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
    print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
    print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int m,n,a,b,p[100010],ans=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		p[a-1]=(p[a-1]?max(p[a-1],a-b):a-b);
	}
	b=0;
	for(int i=0;i<n;i++){
		if(!p[i]) continue;
		//cout<<p[i]<<' '<<b<<endl;
		if(b<=i){
			ans++;
			b=i-p[i];
		}
		else b=min(b,i-p[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans;
  if(n==1 && m==1)ans=1;
  if(n>=3 && m>=3)ans=(n-2)*(m-2);
  if(n==2 || m==2)ans=0;
  if(n==1 && m>=3)ans=m-2;
  if(n>=3 && m==1)ans=n-2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a[1001];
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) { break; }
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && a[i] + a[j] <= m && a[i] + a[j] > ans) {
                    ans = a[i] + a[j];
                }
            }
        }
        if (ans == -1) { cout << "NONE" << endl; }
        else { cout << ans << endl; }
    }
    return 0;
}


Measured memory_bytes: 3080
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	nextReader = newScanner()
	k, n := nextInt(), nextInt()
	as := nextInts(n)
	sort.Ints(as)

	l := 0
	for i := 0; i < n; i++ {
		var d int
		if i == n-1 {
			d = k - as[i] + as[0]
		} else {
			d = as[i+1] - as[i]
		}
		if l < d {
			l = d
		}
	}
	fmt.Println(k - l)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,sum=0;
  cin>>n>>k;
  int p[n];
  for(int i=0;i<n;i++)
  cin>>p[i];
  sort(p,p+n);
  for(int i=0;i<k;i++)
  sum=sum+p[i];
  cout<<sum;
  
}

Measured memory_bytes: 3620
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
const int N = 4e3 + 10;
int cnt[N][3];
void solve() {
	int n;
	string s;
	cin >> n >> s;
	s = '(' + s;
	unordered_map<char, int> hash;
	hash['R'] = 0;
	hash['G'] = 1;
	hash['B'] = 2;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cnt[i][j] = cnt[i - 1][j];
		}
		cnt[i][hash[s[i]]]++;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (s[i] != s[j]) {
				if ((hash[s[i]] == 0 and hash[s[j]] == 1) or (hash[s[i]] == 1 and hash[s[j]] == 0)) {
					ans = ans + cnt[n][2] - cnt[j][2];
					if (2 * j - i <= n and hash[s[2 * j - i]] == 2)
						ans--;
				}
				if ((hash[s[i]] == 0 and hash[s[j]] == 2) or (hash[s[i]] == 2 and hash[s[j]] == 0)) {
					ans = ans + cnt[n][1] - cnt[j][1];
					if (2 * j - i <= n and hash[s[2 * j - i]] == 1)
						ans--;
				}
				if ((hash[s[i]] == 1 and hash[s[j]] == 2) or (hash[s[i]] == 2 and hash[s[j]] == 1)) {
					ans = ans + cnt[n][0] - cnt[j][0];
					if (2 * j - i <= n and hash[s[2 * j - i]] == 0)
						ans--;
				}
			}
		}
	}
	cout << ans << endl;
}
int32_t main() {
	BOLT;
	int t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>


using namespace std;


int main()
{
	int A, B, C,D;
	cin >> A >> B >> C;
	D = A;
	if (A == 1) {
		cout << "YES" << endl;
		exit(0);
	}
	else if (A % 2 == 0&&B%2==0&&C%2==1) {
		cout << "NO" << endl;
		exit(0);
	}
	for (int i = 0; i < 100000000; i++) {
		if (D%B == C) {
			D = 1;
			break;
		}
		else {
			D += A;
		}
	}
	if (D == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int n, dp[1024][1024];
char f[1024][1024];

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) scanf("%s", f[i]);
        int ans = 0;
        rep (i, n) rep (j, n) {
            dp[i][j] = 0;
            if (f[i][j] == '.') {
                dp[i][j] = 1;
                if (i && j) {
                    const int a = min(dp[i-1][j-1],
                            min(dp[i][j-1], dp[i-1][j]));
                    dp[i][j] = a+1;
                }
            }
            ans = max(ans, dp[i][j]);
        }
        printf("%d\n", ans);
    }
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    map<string, int> mp[n+1];
    int p;
    string s;
    for (int i = 0; i < m; i++) {
        cin >> p >> s;
        if (s == "WA" && mp[p].count("AC") == 1) {
            continue;
        }
        mp[p][s]++;
    }

    int correct = 0;
    int penalty = 0;
    for (int i = 1; i < n+1; i++) {
        if (mp[i].count("AC") == 1) {
            correct++;
            if (mp[i].count("WA") == 1) penalty += mp[i]["WA"];
        }
    }

    cout << correct << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <bitset>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <deque>
using namespace std;
#define res(i, n) for(int (i)=0;(i)<(n);(i)++)
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 3001
#define INF (1 << 30)
#define MAXX 16002
#define MAXY 16002
#define MAXN 100010
#define MAXM 100001
#define MAXK 100001
#define MAXV 201
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
struct edge {
    int to, cost;
};

int N;

string reverse(string s){
    string res = "";
    for(int i = s.length() - 1;i >= 0;i--){
        res += s[i];
    }
    return res;
}

string solve(int i){
    string res = "";
    while(i / -2){
        if(i > 0){
            res += (i % -2) + 48;
            i /= -2;
        }else{
            if(i % -2 < 0){
                res += (i % -2) + 50;
                i /= -2;
                i++;
            }else{
                res += 48;
                i /= -2;
            }
        }
    }
    if(i == 1){
        res += "1";
    }else if(i == -1){
        res += "11";
    }else{
        res += "0";
    }

    return reverse(res);
}

int main(){
    cin >> N;
    cout << solve(N) << endl;
    return 0;
}

Measured memory_bytes: 256