akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

class Dijkstra{
public:
	vector<vector<P> > G;
	vector<int> d;
	
	void init(int n){
		d.resize(n);
		G.resize(n);
	}
	void add_edge(int s, int t, int cost){
		G[s].push_back(P(t, cost));
	}
	
	void dijkstra(int s){
		priority_queue<P, vector<P>, greater<P> > q;
		fill(d.begin(), d.end(), INF);
		d[s] = 0;
		q.push(P(0, s));
		while(!q.empty()){
			P p = q.top();q.pop();
			int v = p.second;
			if(d[p.second] < p.first)continue;
			rep(i,G[v].size()){
				int to = G[v][i].first, cost = G[v][i].second;
				if(d[to] <= d[v]+cost)continue;
				d[to] = d[v]+cost;
				q.push(P(d[to], to));
			}
		}
	}
};

vector<P> G[200000];
vector<int> d[2], dp[2];
Dijkstra dij[2];
P a[400000];
map<P, int> mp;
int f[200000], dis;
const int mod = 1e9+7;

void bfs(int s, int idx){
	fill(f, f+200000, 0);
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, s));
	dp[idx][s] = 1;
	while(!q.empty()){
		P p = q.top();q.pop();
		rep(i,G[p.se].size()){
			int to = G[p.se][i].fi, cost = G[p.se][i].se;
			if(d[idx][p.se]+d[!idx][to]+cost == dis){
				mp[P(p.se, to)] = mp[P(to, p.se)] = 1;
				ADD(dp[idx][to], dp[idx][p.se]);
				if(f[to] == 0)q.push(P(d[idx][to], to));
				f[to] = 1;
			}
		}
	}
}

int mul(int x, int y){
	int xx = (x*x)%mod, yy = (y*y)%mod;
	return (xx*yy)%mod;
}

signed main(){
	int n, m, s, t;
	scanf("%lld%lld%lld%lld", &n, &m, &s, &t);s--;t--;
	rep(i,2)dij[i].init(n+2);
	rep(i,2)dp[i].resize(n+2);
	rep(i,m){
		int u, v, c;
		scanf("%lld%lld%lld", &u, &v, &c);u--;v--;
		rep(j,2)dij[j].add_edge(u, v, c);
		rep(j,2)dij[j].add_edge(v, u, c);
		G[u].push_back(P(v, c));
		G[v].push_back(P(u, c));
		a[i] = P(u, v);
	}
	dij[0].dijkstra(s);
	dij[1].dijkstra(t);
	rep(i,2)d[i] = dij[i].d;
	dis = d[0][t];
	bfs(s, 0);bfs(t, 1);
	
	int ans = (dp[0][t]*dp[0][t])%mod;
	rep(i,n){
		if(2*d[0][i] == dis)ans = (ans+mod-mul(dp[0][i], dp[1][i]))%mod;
	}
	rep(i,m){
		int u = a[i].fi, v = a[i].se;
		if(2*d[0][u] < dis and 2*d[0][v] > dis and mp[P(u, v)] == 1)
		ans = (ans+mod-mul(dp[0][u], dp[1][v]))%mod;
		swap(u, v);
		if(2*d[0][u] < dis and 2*d[0][v] > dis and mp[P(u, v)] == 1)
		ans = (ans+mod-mul(dp[0][u], dp[1][v]))%mod;
	}
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 74176
//答え見た
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, x = 0, y = 0, ans = 0;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  if(n == 1){
    cout << 0 << "\n";
    return 0;
  }
    
  for(int i = 0; i < n - 1; i++){
    if(s.at(i) == s.at(i + 1))
      ans++;
  }
  
  if(s.at(0) == 'L')
    y++;
  
  if(s.at(n - 1) == 'R')
    y++;
  
  for(int i = 1; i < n - 1; i++){
    if(s.at(i) == 'R')
      if(s.at(i + 1) == 'L')
        x++;
  }
  
  for(int i = 0; i < k; i++){
    if(x > 0){
      ans += 2;
      x--;
    }
    else if (y > 0){
      ans++;
      y--;
    }
  }
  
  if(ans >= n)
    cout << n - 1 << "\n";
  else
    cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))

xor=0
for i in a:
    xor ^= i

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=xor #各猫の排他的論理和

ans=[]
for i in a:
    x=i^sum_xor
    ans.append(x)

print(" ".join(map(str, ans)))

Measured memory_bytes: 124388
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

int bai[] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};

int memo[10][7];

int dfs(vi &a, vi &isOdd, int sum, int n = 0){
	if(memo[sum%10][n] != -1) return memo[sum%10][n];
	//cout << "sum:" << sum << " n:" << n << endl;
	if(n == isOdd.size()) return !(sum%10);

	int res = 0;
	rep(i, a.size()){
		int num = a[i];
		if(isOdd[n]) num = bai[num];
		//cout << "use " << a[i] << " as " << num << endl;
		res += dfs(a, isOdd, sum+num, n+1);
	}

	return memo[sum%10][n] = res;
}

int main(){
	int n, m;
	string id;
	cin >> n >> id >> m;
	vector<int> a(m);
	rep(i, m) cin >> a[i];
	vector<int> isOdd; // 0-indexed で奇数なら2倍

	reverse(all(id));
	int sum = 0;
	rep(i, id.size()){
		if(id[i] == '*'){
			isOdd.push_back(i%2);
		}else{
			int num = id[i]-'0';
			if(i%2) num = bai[num];
			sum += num;
		}
	}

	memset(memo, -1, sizeof(memo));

	cout << dfs(a, isOdd, sum, 0)  << endl;

	return 0;
}

Measured memory_bytes: 1356
#include <stdio.h>

int main()
{
    int n, a, sogra_desce=0;
    int i = 0;
    
    scanf("%d", &n);
    
    while (i<n) {
        scanf("%d", &a);
        
        if (a%2==0) {   
            if (a % 3 != 0 && a % 5 != 0) {
                sogra_desce=1;
                break;
            }
        }
        ++i;
    }
    if (sogra_desce) {
        printf("DENIED");
    }
    else {
        printf("APPROVED");
    }
    return 0;
}

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

using namespace std;

int W, H;
vector<vector<bool>> field;

void dfs(vector<vector<bool>>& visited, int h, int w){
    if(visited[h][w]) return;
    visited[h][w]=true;
    int dx[3]={-1, 0, 1};
    int dy[3]={-1, 0, 1};
    for(int yi=0; yi<3; ++yi){
        for(int xi=0; xi<3; ++xi){
            if(field[h+dy[yi]][w+dx[xi]]) dfs(visited, h+dy[yi], w+dx[xi]);
        }
    }
}

int solve(){
    vector<vector<bool>> visited(H+2, vector<bool>(W+2));
    int ans=0;
    for(int h=1; h<=H; ++h){
        for(int w=1; w<=W; ++w){
            if(!field[h][w]) continue;
            if(visited[h][w]) continue;
            dfs(visited, h, w);
            ++ans;
        }
    }
    return ans;
}

int main(){
    while(true){
        cin >> W >> H;
        if(W==0 && H==0) break;
        field=vector<vector<bool>>(H+2, vector<bool>(W+2));
        for(int h=1; h<=H; ++h){
            for(int w=1; w<=W; ++w){
                char c; cin >> c;
                field[h][w]=c=='1';
            }
        }
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3324
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 5014;
int p[SIZE];
LL dp[SIZE];
int main(){
    int N,A,B; R(N,A,B);
    FOR(i,1,N)R(p[i]);
    p[N+1]=N+1;
    FOR(i,1,N+1){
        dp[i]=1e18;
        LL now=0;
        for(int j=i-1;j>0;j--){
            if(p[j]<p[i]){
                dp[i]=min(dp[i],dp[j]+now);
                now+=B;
            }
            else now+=A;
        }
        dp[i]=min(dp[i],now);
    }
    W(dp[N+1]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

ll N, res;

ll calc(ll num1, ll num2, ll times) {
    if (times > N) {
        return 0;
    }
    res = num1 + num2;
    times++;
    calc(num2, res, times);
} 
int main() {
    ll L0, L1, times;
    cin >> N;
    L0 = 2;
    L1 = 1;
    times = 2; 
    calc(L0, L1, times);
    if (N == 0) {
        res = L0;
    } else if (N == 1) {
        res = L1;
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::cin>> a;
    std::vector< int64_t > list( a );
    b = 0;
    
    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    std::vector< int64_t > dist;
    dist.push_back( abs( list[0] ) );
    b += abs( list[0] );
    
    for( int i = 1; i < a; i++ )
    {
        b += abs( list[i-1] - list[i] );
        dist.push_back( abs( list[i-1] - list[i] ) );
    }

    b += abs( list.back() );
    dist.push_back( abs( list.back() ) );
    for( int i = 0; i < a; i++ )
    {
        c = b;
        c -= dist[i];
        c -= dist[i+1];
        //std::cout<< dist[i]  << " " << dist[i+1] <<"\n";

        if( i == 0 )
        {
            c += abs( list[i+1] );
        }
        else if( i == a - 1 )
        {
            c += abs( list[i-1] );
        }
        else
        {
            c += abs( list[i-1] - list[i+1] ); 
        }

        std::cout<< c <<"\n";
    }
}


Measured memory_bytes: 2932
#include <stdio.h>

int main(){
  int a,b,c;
  int i = 0;
  
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  int n;
  n = b / a;
  if(n < c)
    printf("%d",n);
  else
    printf("%d",c);
return 0;  
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans, X, T = 0;

ll calcDist(int t){
    return t*(t+1)/2;
}

void solve(){
    while(calcDist(T) < X){
        T++;
    }
    cout << T << endl;
}

int main(){
    cin >> X;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll MOD = 1000000007ll;
ll bn(ll a, ll n)
{
	ll r = 1;
	for(;n>0;n>>=1ll)
	{
		if(n & 1)
			r = (r * a)  % MOD;
		a = (a * a) % MOD;
	}
	return r;
}

ll a[N], f[N];

ll cnk(ll n, ll k)
{
	if(k > n || n == 0 || k == 0)
		return 0;
	if(n == k)
		return 1;
	if(k == 1)
		return n;
	ll q = (f[k] * f[n - k]) % MOD;
	return (f[n] * bn(q, MOD - 2)) % MOD;
}

int main()
{
	int n, k;
	cin >> n >> k;
	f[0] = 1;
	for(ll i = 1; i <= n; i ++)
		f[i] = (f[i - 1] * i) % MOD;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	ll res = 0, ans = 0;
	sort (a + 1, a + n + 1);
	for(int i = 1; i <= n; i ++)
	{
      ll foo = (cnk(i - 1, k - 1) * a[i])%MOD;
      ll hoo = (cnk(n - i, k - 1) * a[i])%MOD;
		ans = (ans + foo) % MOD;
		res = (res + hoo) % MOD;
	}
	cout << (ans - res + MOD) % MOD;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    long ans = 0;
    long cur = 0;
    int t = -1;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
        while((cur + a[i]) != (cur ^ a[i])){
            t++;
            cur -= a[t];
        }
        ans += i - t;
        cur += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication29
{
    class Program
    {
        static void Main()
        {
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            while (true)
            {
                Array.Sort(A);
                if (A[1] % A[0] == 0) break;
                int B = A[0];
                A[0] = A[1] - A[0];
                A[1] = B;
            }
            Console.WriteLine(A[0]);
        }
    }
}

Measured memory_bytes: 9708
#include <cstdio>
#include <cstring>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <set>
#include <stack>
#include <queue>

using namespace std;                

#define rep(i,a,b) for(int i = a; i < b; i++)
#define mp make_pair
#define pb push_back

typedef long long lld;
typedef long double llf;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(void){
    
    int a,b,out,tmp;
    cin>>a>>b;
    
    out = 0;
    tmp = a+b;
    out = max(out,tmp);
    tmp = 2*a-1;
    out = max(out,tmp);
    tmp = 2*b-1;
    out = max(out,tmp);
    cout<<out;
    return 0;	
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int N,ad,dp[1002][7];//dp[day n][state]
long long int ans=0;
char c;
int main()
{
	cin>>N;cin>>c;
	for(int i=0;i<7;i++)dp[1][i]=0;
	if(c=='J')dp[1][0]=dp[1][3]=dp[1][4]=dp[1][6]=1;
	else if(c=='O')dp[1][3]=dp[1][6]=1;
	else if(c=='I')dp[1][4]=dp[1][6]=1;	
	for(int i=2;i<=N;i++){
		cin>>c;
		dp[i][0]=(dp[i-1][0]+dp[i-1][3]+dp[i-1][4]+dp[i-1][6])%10007;
		dp[i][1]=(dp[i-1][1]+dp[i-1][3]+dp[i-1][5]+dp[i-1][6])%10007;
		dp[i][2]=(dp[i-1][2]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6])%10007;
		dp[i][3]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6])%10007;
		dp[i][4]=(dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6])%10007;
		dp[i][5]=(dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6])%10007;
		dp[i][6]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6])%10007;
		if(c=='J')dp[i][1]=dp[i][2]=dp[i][5]=0;
		else if(c=='O')dp[i][0]=dp[i][2]=dp[i][4]=0;
		else if(c=='I')dp[i][0]=dp[i][1]=dp[i][3]=0;
	}
	for(int i=0;i<7;i++)ans+=dp[N][i];
	cout<<ans%10007<<endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a == b) {
    if (b == c) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  } else {
    if (b == c) {
      cout << 2 << endl;
    } else {
      if (a == c) {
        cout << 2 << endl;
      } else {
        cout << 3 << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
int a[5];

void input(){
   rep(i,5){
       cin>>a[i];
       if(a[i]==0)
        cout<<i+1<<endl;
   }
}

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

    return 0;
}


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

using namespace std;
const float EPS=1e-9;
int q;
struct point
{
    double x,y;
};
point vt(point a,point b)
{
    point vt;
    vt.x=b.x-a.x;
    vt.y=b.y-a.y;
    return vt;
}
double tichcheo(point a,point b)
{
    return a.x*b.y-b.x*a.y;
}
double scalar(point a,point b)
{
    return (b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y);
}
double tichcham(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
int main()
{
    point p1,p0;
    cin>>p0.x>>p0.y>>p1.x>>p1.y;
    cin>>q;
    while (q--)
    {
        point p2;
        cin>>p2.x>>p2.y;
        point p01=vt(p0,p1);
        point p02=vt(p0,p2);
        if (tichcheo(p01,p02)>0) cout<<"COUNTER_CLOCKWISE"<<endl;
        else if (tichcheo(p01,p02)<0) cout<<"CLOCKWISE"<<endl;
        else
        {
            double sc01=scalar(p0,p1);
            double sc02=scalar(p0,p2);
            if (((p2.x==p0.x)&&(p2.y==p0.y))||((p2.x==p1.x)&&(p2.y==p1.y))) cout<<"ON_SEGMENT"<<endl;
            else
            if (fabs(tichcham(p01,p02)+sqrt(sc01*sc02))<EPS) cout<<"ONLINE_BACK"<<endl;
            else
            {
                if (sc01<sc02) cout<<"ONLINE_FRONT"<<endl;
                else cout<<"ON_SEGMENT"<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3216
H, N = map(int, input().split())
AB = list(list(map(int, input().split())) for _ in range(N))

def main2(H, N, AB):
    inf = 2**31 -1
    dp = [inf] * (H + max(a for a, _ in AB))
    dp[0] = 0
    for i in range(1, len(dp)):
        dp[i] = min(dp[i-a]+b for a,b in AB)
    print(min(dp[H:]))

main2(H,N,AB)

Measured memory_bytes: 3832
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
#input = sys.stdin.readline

import copy

N=int(input())
Amoto=list(map(int,input().split()))
lst=[]
A=copy.copy(Amoto)
_min=A[0]
minidx=0
for i in range(1,N):
    if _min>A[i]:
        _min=A[i]
        minidx=i
if _min<0:
    for i in range(N)[::-1]:
        while _min<A[i] and len(lst)<=2*N+1:
            A[i]+=_min
            lst.append([minidx+1,i+1])
        minidx=i
        _min=A[i]

    if  len(lst)<=2*N:
        print(len(lst))
        for i in lst:
            print(" ".join([str(x) for x in i ]))
        exit()
A=copy.copy(Amoto)
_max=A[0]
maxidx=0
lst=[]
for i in range(1,N):
    if _max<A[i]:
        _max=A[i]
        maxidx=i
if _max>0:
    for i in range(N):
        while _max>A[i] and len(lst)<=2*N+1:
            A[i]+=_max
            lst.append([maxidx+1,i+1])
        maxidx=i
        _max=A[i]
    if  len(lst)<=2*N:
        print(len(lst))
        for i in lst:
            print(" ".join([str(x) for x in i ]))
        exit()
else:
    print(0)


Measured memory_bytes: 38640
//agc016_b.cpp
//Thu May 14 21:40:27 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n+1];
	fill(a,a+n+1,0);
	int first;
	for (int i=0;i<n;i++){
		int x;
		cin >> x;
		if (i==0){
			first = x;
		}
		a[x]++;
	}

	int pos1 = first;
	int pos2 = first+1;

	if (a[pos1]+a[pos1-1]==n &&
		a[pos1-1]>=max(2*pos1-n,0)){
		int max = 0;
		if (pos1==n){
			max = pos1;
		}else {
			max = pos1-1;
		}
		if (a[pos1-1]<=max){
			cout << "Yes" << endl;
			return 0;
		}
	}

	if (a[pos2]+a[pos2-1]==n &&
		a[pos2-1]>=max(2*pos2-n,0)){
		int max = 0;
		if (pos2==n){
			max = pos2;
		}else {
			max = pos2-1;
		}
		if (a[pos2-1]<=max){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 640
// AOJ 0534: Chain
// 2017.10.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char a[10002]; int n;
int f[6] = { 0, 1, 2, 3, 1, 2 };

int no(int p, int c)
{
	int i, j, k, cnt;

	for (i = p-1; i >= 0 && a[i] == c; i--);
	i++;
	for (j = p+1; j < n && a[j] == c; j++);
	j--;
	if ((k = j - i + 1) < 4) return 0;
	cnt = k;

	while (i > 0 && j < n-1 && a[i-1] == a[j+1]) {
		c = a[--i];
		for (; i >= 0 && a[i] == c; i--);
		i++;
		for (j++; j < n && a[j] == c; j++);
		j--;
		k = j - i + 1 - cnt;
		if (k < 4) break;
		cnt += k;
	}
	return cnt;
}

int main()
{
	int i, j, x, max; 
	char buf[10];

	while (fgets(buf, 8, stdin) && *buf != '0') {
		n = atoi(buf);
		for (i = 0; i < n; i++) fgets(buf, 8, stdin), a[i] = *buf & 0xf;
		for (max = 0, i = 0; i < n; i++) for (j = 1; j <= 2; j++) {
			x = no(i, f[a[i]+j]);
			if (x > max) { max = x; if (max == n) goto done; }
		}
done:	printf("%d\n", n - max);
	}
	return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll n;

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

void solve(){
    string s; cin>>s;
    reverse(s.begin(), s.end());
    n = s.size();
    vector<ll> arr(n);
 
    for(ll i = 0; i < n; i++)
        arr[i] = ( (s[i] - '0') * modexp(10, i, 2019) ) % 2019;

    vector<ll> pref(n);

    pref[0] = arr[0];
    for(ll i = 1; i < n; i++)
        pref[i]= (pref[i-1] + arr[i]) % 2019;

    // for(auto i : arr)
    //     cout << i << space;
    // cout << endl;
    // for(auto i : pref)
    //     cout << i << space;
    // cout << endl;

    unordered_map<ll,ll> m;

    ll ans = 0;

    for(ll i = 0; i < n; i++){
        if(pref[i] == 0)
            ans++;
        ans += m[pref[i]];
        m[pref[i]]++;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6628
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
}

Measured memory_bytes: 43740
from collections import deque
n, m = map(int, input().split())
ary = []
a = []
b = []
ary = [0 for i in range(n)]
chk = [False for i in range(n)]
d = {}
for i in range(m):
	aa, bb = map(int, input().split())
	if aa not in d:
		d[aa] = []
	d[aa].append(bb)
	if bb not in d:
		d[bb] = []
	d[bb].append(aa)

visited = [-1 for i in range(n)]
visited[0] = 0
queue = deque([1])
while queue:
	c = queue.popleft()
	for i in d[c]:
		if visited[i-1] != -1:
			continue
		visited[i-1] = c
		queue.append(i)
for i in visited:
	if i == -1:
		print ("No")
		exit()
print ("Yes")
for i in visited[1:]:
	print (i)

Measured memory_bytes: 40676
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int n,m=100000;
bool b[210000];
UG es(210000);
int l,r;

void dfs(int k){
  if(b[k]) return;
  if(k<m) l++;
  else r++;

  b[k]=true;
  for(int e:es[k]){
    dfs(e);
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    x--;y--;
    es[x].PB(y+m);
    es[y+m].PB(x);
  }


  int ans=0;
  rep(i,m){
    if(b[i]) continue;
    l=0,r=0;
    dfs(i);
    ans+=l*r;
  }


  cout<<ans-n<<endl;


}

Measured memory_bytes: 10496
#include<iostream>
using  namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    if(n%2==0){//偶数
        for(int i=0;i<n;i++){
            if(i%2!=0)b[n/2-(i/2+1)]=a[i];
            else b[n/2+i/2]=a[i];
        }
    }
    else{//奇数
        for(int i=0;i<n;i++){
            if(i%2!=0)b[n/2+(i/2+1)]=a[i];
            else b[n/2-i/2]=a[i];
        }
    }

    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }
}

Measured memory_bytes: 3712
def main():
    S = input()
    for bit in range(1 << 3):
        calc_v = int(S[0])
        ans = [S[0]]
        for i in range(3):
            if bit & (1 << i):
                calc_v += int(S[i+1])
                ans.append("+")
                ans.append(S[i+1])
            else:
                calc_v -= int(S[i+1])
                ans.append("-")
                ans.append(S[i+1])
        if calc_v == 7:
            return print("".join(ans)+"=7")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n;
	cin >> n;
	vll d(2);
	ll cnt = 0;
	rep(i, 0, n) {
		cin >> d[0] >> d[1];
		if (d[0] == d[1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		if (cnt >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
NTEST = 26

D=int(input())

C=list(map(int,input().split()))

SL=list()
SL.append([0 for i in range(NTEST)])
for d in range(D):
    S=list(map(int,input().split()))
    SL.append(S)

tests=list()
tests.append(0)
for d in range(D):
    tests.append(int(input()))

def calcSat(test_applied):
    lastDay = [0 for i in range(NTEST)]

    sat = 0
    for d in range(1,D+1):
        tst = test_applied[d] - 1
        lastDay[tst] = d
        sat += SL[d][tst]
        for itst in range(NTEST):
            sat -= C[itst] * (d-lastDay[itst])
    return sat

satList = list()
satList.append(0)
lastDay = [[0 for i in range(NTEST)]]

def calcSat_with_memo(test_applied):

    total_sat = 0
    for d in range(1,D+1):
        lastDay.append(list(lastDay[d-1]))
        sat = 0
        tst = test_applied[d] - 1
        lastDay[d][tst] = d
        sat += SL[d][tst]
        for itst in range(NTEST):
            sat -= C[itst] * (d-lastDay[d][itst])
        satList.append(sat)
        total_sat += sat

    return total_sat

def recalcSat_with_memo(total_sat_before, tday, t_from, t_to, test_applied):

    d_total_sat = 0

    lastDay[tday][t_from -1]=lastDay[tday-1][t_from -1]
    d_sat=0
    d_sat += (SL[tday][t_to -1]-SL[tday][t_from -1])
    d_sat += C[t_to -1]*(tday - lastDay[tday][t_to -1])
    d_sat -= C[t_from -1]*(tday - lastDay[tday][t_from -1])

    lastDay[tday][t_to -1]=tday

    satList[tday]+= d_sat
    d_total_sat  += d_sat

    old_last = tday
    new_last = lastDay[tday][t_from -1]
    for d in range(tday+1,D+1):
        if test_applied[d] == t_from :
            break
        d_sat = C[t_from -1]*(- old_last + new_last)
        lastDay[d][t_from -1] = new_last
        satList[d]+= d_sat
        d_total_sat += d_sat

    old_last = lastDay[tday-1][t_to -1]
    new_last = tday
    for d in range(tday+1,D+1):
        if test_applied[d] == t_to :
            break
        d_sat = C[t_to -1]*(- old_last + new_last)
        lastDay[d][t_to -1] = new_last
        satList[d]+= d_sat
        d_total_sat += d_sat
            
    return d_total_sat


# sat = calcSat(tests)
# print(sat)

sat = calcSat_with_memo(tests)
# print(sat)


# -------------------
M=int(input())

ans = list()

for m in range(M):
    d, new_tst = list(map(int, input().split()))

    d_sat = recalcSat_with_memo(sat, d, tests[d], new_tst, tests)

    tests[d] = new_tst
    sat += d_sat
    ans.append(sat)

for m in range(M):
    print(ans[m])



Measured memory_bytes: 13596
/*input

*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n;
	cout<<n/3;
}

Measured memory_bytes: 256
s = input()
n = len(s)
k = 'keyence'
a = 0
b = 6

for i in range(n):
    if k[a] == s[i]:
        a += 1
    else:
        break
    if a == 7:
        break

for i in range(n)[::-1]:
    if k[b] == s[i]:
        b -= 1
    else:
        break
    if b == -1:
        break
    
b = 7 - b - 1
if a + b >= 7:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9040
#include <stdio.h>
int main(void){
    int n,g,choko,i,a[100];
    scanf("%d%d%d",&n,&g,&choko);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        choko+=g/a[i];
        if(g%a[i]!=0) choko++;
    }
    printf("%d",choko);
}


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

#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define forn(i, a, b) for (int i = (a); i < (b); i++)
#define ford(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define szof(x) ((int)(x).size())
#define rsz resize
#define lb lower_bound
#define ub upper_bound
#define INF (int)1e9
#define INFL (long long)1e18
#define re return
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector <int> >
#define VVLL vector<vector <long long> >
#define VLL vector <long long>
#define mt make_tuple

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <bool> dp(100*100+1, false);
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        for (int j = 100*100; j >= 0; j--) {
            if (j-d >= 0 && dp[j-d]) {
                dp[j] = true;
            }
        }
    }
    ll ans = 0;
    for (int i = 100*100; i >= 0; i--) {
        if (i % 10 != 0 && dp[i]) {
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
	return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	int ans=1;
	char hoge;
	cin>>hoge;
	fori(n-1){
		char s;
		cin>>s;
		if(s!=hoge){
			++ans;
		}
		hoge=s;
	}
	cout<<ans;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;

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

    i64 N;
    i64 sum = 0;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        i64 v;
        cin >> v;
        sum += v;
    }

    cout << sum - N * (N + 1) / 2 << endl;

    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int x, t; cin >> x >> t;
    cout << (x - t > 0 ? x - t : 0) << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=405,M=1e5+5;
bitset<N> f[N];
int a[M],b[M],g[N];
int main(){
	ri n,m,i,j,ans,x,y;
	gi(n);gi(m);
	for(i=1;i<=m;++i) gi(a[i]),gi(b[i]);
	for(i=1;i<=n;++i) f[i][i]=1;
	for(i=1;i<=n;++i)
		for(j=m;j;--j){
			x=a[j];y=b[j];
			if(f[i][x]&&f[i][y]){
				g[i]=1;
				break;
			}
			if(f[i][x]) f[i][y]=1;
			if(f[i][y]) f[i][x]=1;
		}
//	for(i=1;i<=n;++i) printf("%d ",g[i]); puts("");
	ans=0;
	for(i=1;i<=n;++i)
		if(!g[i])
			for(j=i+1;j<=n;++j)
				ans+=!g[j]&&!(f[i]&f[j]).any();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fo(i, u, v) for(int i= u; i<=v; ++i)
#define fob(i, u, v) for(int i = u; i>=v; --i)
#define fi first
#define se second
#define si size()
#define pb push_back

using namespace std;
typedef double db;
typedef long long ll;
typedef pair <int ,int> pii;
typedef pair <ll, ll> pll;
const long long MOD = 1e9 +7;
const long long N = 1e6 + 7;
const long long inf = ll(1e18);
const string name = "D";
template <class T> int getbit(T x,int y) {return x >> (y-1) & 1;}
template <class T> T offbit(T x, int y) {return x | 1 <<(y-1);}
template <class T> T onbit(T x, int y) {return x & (~1<<(y-1));}
template <class T> T sqr(T x) {return x*x;}
template <class T> void read_int(T &rs) {
    rs = 0;
    int neg = 1;
    char r;
    for(r = getchar(); r < '0' || r > '9'; r = getchar())
    if(r == '-') neg *= -1;
    rs = r - '0';
    for(r = getchar(); r >= '0' && r <= '9'; r = getchar())
    rs = rs*10 + (r - '0');
    rs *= neg;
}

long long n, m, v[N], res, ncc, num[N];
vector <long long> a[N];
priority_queue <ll, vector <ll>,  greater <ll> > qu[N];

void bfs(int u) {
    num[u] = ncc;
    qu[ncc].push(v[u]);
    for(int i = 0; i < a[u].size(); ++i)
    if(num[a[u][i]] == 0) bfs(a[u][i]);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((name + ".inp").c_str(), "r", stdin);
    //freopen((name + ".out").c_str(), "w", stdout);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> v[i];
    for(int i = 1; i <= m; ++i) {
        ll u, v;
        cin >> u >> v;
        ++u; ++v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i = 1; i <= n; ++i)
    if(num[i] == 0) {
        ncc++;
        bfs(i);
    }
    if(ncc == 1) {
        cout << 0;
        return 0;
    }
    for(int i = 1; i <= ncc; ++i) {
        res += qu[i].top();
        qu[i].pop();
        while(qu[i].size()) {
            qu[0].push(qu[i].top());
            qu[i].pop();
        }
    }
    if((int)qu[0].si < ncc - 2) cout << "Impossible";
    else {
        for(int i = 1;  i <= ncc - 2; ++i) {
            res += qu[0].top();
            qu[0].pop();
        }
        cout << res;
    }
    return 0;
}



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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int n, m; cin >> n >> m;
    vector<ll> h(n + 1);
    for(int i = 1; i <= n; i++) cin >> h[i];
    vector<vector<int> > v(n + 1);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        bool flag = true;
        for(auto j : v[i]){
            if(h[j] < h[i]){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(N==1) cout << "Hello World\n";
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
void dice(){
  int d1,d2,d3,d4,d5,d6;
  cin>>d1>>d2>>d3>>d4>>d5>>d6;

  char dir;
  int tmp;
  while(true){
      cin>>dir;
      if(cin.eof()) break;
      if(dir=='E'){
          tmp=d1;d1=d4;d4=d6;d6=d3;d3=tmp;
      }else if(dir=='N'){
          tmp=d1;d1=d2;d2=d6;d6=d5;d5=tmp;
      }else if(dir=='S'){
          tmp=d1;d1=d5;d5=d6;d6=d2;d2=tmp;
      }else if(dir=='W'){
          tmp=d1;d1=d3;d3=d6;d6=d4;d4=tmp;
      }
  }
  cout<<d1<<endl;
}
int main(){
  dice();
  return 0;
}


Measured memory_bytes: 3108
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define rank _rank
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int a[N];
int main(){
    int T,i,j,k,n,m=0;
    scanf("%d%d",&n,&m);
    rep(i,0,n)scanf("%d",&a[i]);
    int x=-1;
    rep(i,0,n-1)if(a[i]+a[i+1]>=m){x=i;break;}
    if(x==-1){puts("Impossible");return 0;}
    vi ans;
    rep(i,0,x)ans.pb(i+1);
    per(i,x+1,n)ans.pb(i);
    ans.pb(x+1);
    puts("Possible");
    rep(i,0,n-1)printf("%d\n",ans[i]);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >>n;
    if(65<=n&&n<=90){
        cout << 1 << endl;
    }else if(97<=n&&n<=122){
        cout << 2 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3120