akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  double X;cin>>X;
  cout<<M_PI*2*X<<endl;
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
const int N = 2e5;
const int mod = 998244353;
ll fac[M], inv[M];
ll n, m, k;
ll quick_mod(ll k, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = ans * k % mod;
        k = k * k % mod;
        b >>= 1;
    }
    return ans;
}
void init(){
    fac[0] = 1;
    for(int i = 1; i <= N; i++) fac[i] = i * fac[i - 1] % mod;
    inv[N] = quick_mod(fac[N], mod - 2);
    for(int i = N - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll C(ll x, ll y) {
    return (fac[x] * inv[y] % mod) * inv[x - y] % mod;
}
int main(){
    init();
    scanf("%lld%lld%lld", &n, &m, &k);
    ll res = 0;
    for(ll t = n - k; t <= n; t++) {
        res = (res + (C(n - 1, t - 1) * m % mod) * quick_mod(m - 1, t - 1) % mod) % mod;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 6932
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;cin>>n;
    int a[N];
    vector<int> v;
    map<int,int> m;
    rep(i,n){
        cin>>a[i];
        m[a[i]]=i;
        v.push_back(a[i]);
    }    
    sort(v.begin(),v.end());
    int res=0;
    rep(i,n){
        if(i%2!=m[v[i]]%2) res++;
    }
    cout<<res/2;

}

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

int main() {
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];

    vector<ll> tmp;

    rep(i, M) {
        ll x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        tmp.push_back(a[x] + b[y] - c);
    }
    sort(tmp.begin(), tmp.end());

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans = a[0] + b[0];

    cout << min(ans, tmp[0]) << endl;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
//const ll INF = 1e18+3;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;

#include <iostream>
#include <vector>
using namespace std;
using DD = int;
const int INF = 10000000;

////////////////////////////////////////
// grid dijkstra
// x = i/W, y = i%W;
// xy = j * W + i;

int D[1000001];
int main() {
    int H, W, K, S, G, x1, y1, x2, y2;
    cin >> H >> W >> K;
    cin >> x1 >> y1 >> x2 >> y2;
    //vector<string> A(H);
    //rep(i, H)cin >> A[i];
    char A[H][W]={};
    rep(i, H)rep(j,W)cin >> A[i][j];
    S = (x1 - 1) * W + (y1 - 1);
    G = (x2 - 1) * W + (y2 - 1);
    rep(i, H * W)D[i] = INF;
    D[S] = 0;
    queue<int> que;
    que.push(S);
    while(que.size() > 0){
        int now = que.front(); que.pop();
#if 1
        const int dir[4][2]={{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
        int x = now/W, y = now%W;
        for(int i=0;i<4;i++){
            int nx=x, ny=y;
            int nd=D[now]+1;
            for(int j=1; j<=K; j++)
            {
                nx+=dir[i][0];
                ny+=dir[i][1];
                if (nx<0||ny<0||nx>=H||ny>=W||A[nx][ny]=='@'||D[nx * W + ny]<nd)
                    break;
                if(D[nx * W + ny]>nd)
                {
                    D[nx * W + ny]=nd;
                    que.push(nx * W + ny);
                }
            }
        }
#else        
        int DD[4] = {-W, +1, +W, -1};
        for (int d = 0; d < 4; d++){
            for (int k = 0; k <= K; k++){
                int x = now + DD[d] * k;
                int i = x/W;
                int j = x%W;
                
                if (A[i][j] == '@'){
                    break;
                }
                if (D[x] < D[now])break;
                
                //fprintf(stderr, "hoge now = (%d, %d): %d\n", i, j, D[now]); 
                if (D[x] > D[now] + 1){
                    D[x] = D[now] + 1;
                    que.push(x);
                    //fprintf(stderr, "D(%d, %d) = %d\n", i, j, D[now] + 1);
                }
                if ((d == 0 && i == 0) || (d == 1 && j == W - 1) ||
                    (d == 2 && i == H - 1) || (d == 3 && j == 0)){
                    break;
                }
            }
        }
#endif
    }

    if (D[G] == INF){
       cout << -1;
    } else {
        cout << D[G];
    }
    return 0;
}


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

int main(){
    int n;cin>>n;
    map<int,int> A;
    for(int i=1;i<=n;i++){
        int a;cin>>a;
        A[a]=i;
    }
    for(auto it=A.begin();it!=A.end();it++){
      cout<<it->second<<' ';
    }  
}

Measured memory_bytes: 5504
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

int ans=0,used[10];
void dfs(int n,int s){
  if(s<0)return;
  if(n==0 && s==0){
    ++ans;
    return;
  }
  for(int i=0;i<=9;i++){
    if(used[i])continue;
    used[i]=true;
    dfs(n-1,s-n*i);
    used[i]=false;
  }
}
  
int memo[11][331];

main(){
  rep(i,10)used[i]=i;
  int p=0;
  do{
    ++p;
    int sum=0;
    rep(i,10){
      sum+=used[i]*(i+1);
      memo[i+1][sum]++;
    }
  }while(next_permutation(used,used+10));

  int n,s;
  while(cin>>n>>s){
    int t=1,f=10-n;
    while(f)t*=f--;
    if(s>=900)cout<<0<<endl;
    else cout<<memo[n][s]/t<<endl;
  }

}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 5000
#define MOD 1000000007

int main(){
  ll N,M;
  cin>>N>>M;
  if(M-2*N>0){
    ll x=M/2-N;
    cout<<N+x/2<<endl;
  }else{
    cout<<M/2<<endl;
  }
}


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

#define int long long
signed main() {
  priority_queue<int> my_q;
  int n,m;cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int x; cin >> x; my_q.push(x);
  }
  while(m != 0) {
    int k = my_q.top();
    my_q.pop();
    k = k/2;
    my_q.push(k);
    m--;
  }
  int ans = 0;
  while(!my_q.empty()) {
    int k = my_q.top(); ans += k;my_q.pop();
  }
  cout << ans << endl;

}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main()
{
	int N;
	int a[10000];
	int sum = 0;
	
	while (1)
	{
		sum = 0;
		cin >> N;
		if (N == 0) {
			return 0;
		}
		for (int i = 0; i < N; i++) {
			cin >> a[i];
			sum = sum + a[i];

		}
		int H;
		H = sum / N;
		int count = 0;
		for(int j=0; j<N; j++){
			
			if (a[j] <= H) {
				count = count + 1;
			}
			


		
			


		}
		cout << count << endl;

	}
	return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC127D
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve2();
        }

        void Solve2()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = temp[0];
            var M = temp[1];
            var A = Console.ReadLine().Split(' ').Select(long.Parse).OrderBy(x => x).ToArray();
            var rewriteMap = new Dictionary<long, long>();

            for (int i = 0; i < M; i++)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                if (rewriteMap.ContainsKey(temp[1]))
                {
                    rewriteMap[temp[1]] = temp[0] + rewriteMap[temp[1]];
                }
                else
                {
                    rewriteMap.Add(temp[1], temp[0]);
                }
            }

            var r = new long[N];
            var rindex = 0;

            foreach (long k in rewriteMap.Keys.OrderByDescending(x => x))
            {
                var v = rewriteMap[k];

                for (int i = 0; i < v; i++)
                {
                    r[rindex] = k;
                    rindex++;

                    if (rindex == N)
                    {
                        break;
                    }
                }

                if (rindex == N)
                {
                    break;
                }
            }

            var sum = 0L;

            for (int i = 0; i < N; i++)
            {
                // Console.Error.WriteLine(A[i] + ":" + r[i]);
                sum += Math.Max(A[i], r[i]);
            }

            Console.WriteLine(sum);
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = temp[0];
            var M = temp[1];
            var A = Console.ReadLine().Split(' ').Select(long.Parse).OrderBy(x => x).ToArray();
            var rewriteList = new List<long>();

            for (int i = 0; i < M; i++)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                for (int j = 0; j < temp[0]; j++)
                {
                    rewriteList.Add(temp[1]);
                }
            }

            var sorted = rewriteList.OrderBy(x => -x).ToArray();
            var numSorted = sorted.Count();
            var sum = 0L;

            for (int i = 0; i < N; i++)
            {

                sum += Math.Max(A[i], numSorted > i ? sorted[i] : 0);
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 34352
#include<bits/stdc++.h>
using namespace std;
int r[100000];
int main()
{
    int a,b,c,d,e,f;
    string ch;
    while(cin>>a>>b)
    {
        int v[100][100];
        for(c=1;c<=a;c++)
        {
            for(d=1;d<=b;d++)
            {
                v[c][d]=0;
            }
        }
        cin>>e>>f;
        for(int i=1;i<=e;i++)
        {
            for(int j=1;j<=b;j++)
            {
                v[i][j]=1;
            }
        }
        for(int i=1;i<=f;i++)
        {
            for(int j=1;j<=a;j++)
            {
                v[j][i]=1;
            }

        }
        d=0;
         for(int i=1;i<=a;i++)
        {
            for(int j=1;j<=b;j++)
            {
               if(v[i][j]==0)
               {
                   d++;
               }
            }

        }
        cout<<d<<endl;




    }



    return 0;
}


Measured memory_bytes: 256
import copy
row,col,kkk = map(int,input().split())
matrix = []
for i in range(row):
  matrix.append(list(input()))
combination = set()
rowcol=[]
for i in range(row):
  rowcol.append((i,0))
for i in range(col):
  rowcol.append((i,1))
  
def find(index,temp):
    if index==len(rowcol):
      combination.add(tuple(copy.deepcopy(temp)))
      return 
    find(index+1,temp+[rowcol[index]])
    find(index+1,temp)
find(0,[])
new = set()
combination = list(combination)
for i in combination:
  i = list(i)
  i.sort()
  i = tuple(i)
  new.add(i)
ans = 0
for i in new:
  #i is list of row col to be painted red
  tempmatrix = copy.deepcopy(matrix)
  for j in i:
    #j is tuple of row and col to be painter
    temp,flag = j
    if flag == 0:
        for k in range(col):
          tempmatrix[temp][k] = 0
    if flag == 1:    
        for l in range(row):
            tempmatrix[l][temp] = 0
  #now check black counte
  black = 0
  for m in range(row):
    for n in range(col):
      if tempmatrix[m][n] == "#":
        black += 1
  if black == kkk:
    ans += 1
print(ans)

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

using namespace std;
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  
  vector<vector<int>>	data(h,vector<int>(w));
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char s;
      cin >> s;
      if(s=='.')	data.at(i).at(j)=0;
      if(s=='#')	data.at(i).at(j)=1;
    }
  }
  
  int ans=0;
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int count=0;
      
      for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
          if(((i>>x)&(j>>y)&1)&&data.at(x).at(y)==1)	count++;
        }
      }
      
      if(count==k)	ans++;
    }
  }
  
  cout << ans;
      
  
  
  
  
  
  
  
  
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 28130
int cost[4] = {0, 300000, 200000, 100000};
int tot;

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

    int x, y;
    cin >> x >> y;
    if(x == 1 && y == 1){
        tot += 400000;
    }
    if(x <= 3) tot += cost[x];
    if(y <= 3) tot += cost[y];
    cout << tot << "\n";

    return 0;
}


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

const int N=2e5+5;
const int MOD=998244353;
int n,t,sm,ans;
char s[N];
int a[N];
int used[3][3][3];
int dp[N][3][3][2];

inline void add(int &x,int y){
	x+=y;
	if(x>=MOD) x-=MOD;
}

void dfs(int x,int y,int z){
	if(used[x][y][z]) return;
	used[x][y][z]=1;ans++;
	if(x!=y) dfs(3-x-y,3-x-y,z);
	if(y!=z) dfs(x,3-y-z,3-y-z);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		a[i]=s[i]-'a';
		t+=a[i];
	}
	t%=3;
	for(int i=1;i<n;i++) if(a[i]==a[i+1]) sm++;
	if(sm==n-1){
		puts("1");
		return 0;
	}
	if(n==1) puts("1");
	else if(n==2) puts("2");
	else if(n<=3){
		dfs(a[1],a[2],a[3]);
		printf("%d\n",ans);
	}else{
		if(sm==0) ans++;
		for(int i=0;i<3;i++) dp[1][i][i][0]=1;
		for(int i=1;i<n;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) for(int o=0;o<2;o++) for(int l=0;l<3;l++)
			add(dp[i+1][l][(l+k)%3][o|(l==j)],dp[i][j][k][o]);
		for(int i=0;i<3;i++) add(ans,dp[n][i][t][1]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 15232
X,Y,A,B,C = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)


taberu = p[0:X] + q[0:Y] + r
taberu.sort(reverse=True)

print(sum(taberu[0:X+Y]))

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

using namespace std;
#define IN 1000000007

int main(){
  int N,M;
  cin>>N>>M;
  int a[M];
  vector <bool> dan(N+1,true);
  for(int i=0;i<M;i++){
    cin>>a[i];
    dan[a[i]]=false;
  }
 long long int DP[N+1];
  DP[0]=1;
    if(dan[1])
    DP[1]=1;
  else
    DP[1]=0;
  for(int i=2;i<N+1;i++ ){
    if(dan[i])
      DP[i]=(DP[i-1]+DP[i-2])%IN;
    else
      DP[i]=0;

  }
  /*   for(int i=0;i<N+1;i++){
    cout<<DP[i]<<endl;
    cout<<"�i"<<dan[i]<<endl;
    }*/
  // cout<<DP[N]<<endl;
  cout<<(long long int)DP[N]%IN<<endl;
  return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int n;
int main() {
	read(n);
	if(n<1200)
		puts("ABC");
	else if(n<2800)
		puts("ARC");
	else
		puts("AGC");
}

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

int main() {
  int n;
  string s, t;
  cin >> n;
  cin >> s >> t;
  for ( int i = 0; i < n; i++ ) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3560
package main

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

func main() {
	in := bufio.NewScanner(os.Stdin)
	for in.Scan() {
		s := strings.Split(in.Text(), " ")
		if s[0] == "0" && s[1] == "0" {
			break
		}
		h, _ := strconv.Atoi(s[0])
		w, _ := strconv.Atoi(s[1])
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if i != 0 && i != h-1 {
					if j != 0 && j != w-1 {
						fmt.Print(".")
					} else {
						fmt.Print("#")
					}
				} else {
					fmt.Print("#")
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

ll g1(ll n, ll p){
    if (n == 0) return 0;
    return n/p + g1(n/p, p);
}

ll g2(ll n, ll p){
    ll res = g1(n/2, p);
    if (p == 2) res += n/2;
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    if (n % 2 == 0){
        ans = min(g2(n,2), g2(n,5));
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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


int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int mx = 0;
    rep(i, n - 1)mx = max(mx, a[i + 1] - a[i]);
    mx = max(mx, a[0] + k - a[n - 1]);
    cout << k - mx << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;

  ll K = 100007;
  vll even(K, 0), odd(K, 0);

  REP(i, N/2){
    ll e, o;
    cin >> e >> o;
    even[e-1]++;
    odd[o-1]++;
  }

  ll even_max=0;
  ll even_max_index=0;
  ll odd_max=0;
  ll odd_max_index=0;
  ll even_max2=0;
  ll even_max2_index=0;
  ll odd_max2=0;
  ll odd_max2_index=0;
  ll ans=0;

  REP(i, K){
    ans += even[i];
    ans += odd[i];
    if(even_max <= even[i]){
      even_max2 = even_max;
      even_max2_index = even_max_index;
      even_max = even[i];
      even_max_index = i;
    }else if(even_max2 <= even[i]){
      even_max2 = even[i];
      even_max2_index = i;
    }
    if(odd_max <= odd[i]){
      odd_max2 = odd_max;
      odd_max2_index = odd_max_index;
      odd_max = odd[i];
      odd_max_index = i;
    }else if(odd_max2 <= odd[i]){
      odd_max2 = odd[i];
      odd_max2_index = i;
    }
  }

  if(odd_max_index!=even_max_index){
    ans = ans - even_max - odd_max;
  }else{
    ll tmp = max(even_max+odd_max2, odd_max+even_max2);
    ans = ans - tmp;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		String[] s = saori.nextHayami().split("");
		boolean flg = true;
		for(int i = 0;i < a;i++){
			if(!Character.isDigit(s[i].charAt(0))){
				flg = false;
			}
		}
		if(!s[a].equals("-")){
			flg = false;
		}
		for(int i = a+1;i < a+b+1;i++){
			if(!Character.isDigit(s[i].charAt(0))){
				flg = false;
			}
		}
		if(flg){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
n=int(input())
X=list(map(int,input().split()))
sum=99999999

def f(i,X):
  sumf=0
  for j in X:
    sumf+=(j-i)**2
  return sumf

for i in range(min(X),max(X)+1):
  sum=min(sum,f(i,X))

print(sum)



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
#include <complex>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef complex<double> point;

//#define PI 3.141592653589793238462643383279
// e·éë·Ã
#define EPS (1e-10)
// 2ÂÌXJ[ªµ¢©Ç¤©
#define EQ(a,b) (abs((a)-(b)) < EPS)

bool used[440];

int main(){
    int n,i,j;

    while( cin >> n, n ){
        memset(used, false, sizeof(used));
        double run = 0.0;

        vector<point> p;
        rep(i,n){
            int x,y; cin >> x >> y;
            p.push_back(point(x,y));
        }

        point now(0,0), dir(0,1);

        for(;;){
            int id = -1;
            double ag = 1000;
            rep(i,n){
                if( !used[i] ){
                    double a = std::arg(dir/(p[i] - now));
                    if( ag > a || (EQ(ag,a) && abs(p[id] - now) > abs(p[i] - now)) ){
                        ag = a;
                        id = i;
                    }
                }
            }
            if( id == -1 ) break;
            run += abs(p[id] - now);
            dir = (p[id] - now) / abs(p[id] - now);
            now = p[id];
            used[id] = true;
        }

        printf("%.1lf\n",run);
    }

    return 0;
}

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	LL a, b;
	LL v;

	cin >> a >> b;

	if (a < b) swap(a, b);

	v = a * b;
	int r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	cout << v / b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
static const int MAX_N = 1000;

int n;
string s[MAX_N];

ifstream input_file("in.txt");
ofstream output_file("out.dat");

int main(){
	for(;;){
		scanf("%d", &n);
		//input_file >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> s[i];
			//input_file >> s[i];
			for(int j = 0; j < s[i].length(); j++){
				if(islower(s[i][j])){
					if(j != 0) s[i][j - 1] = '+';
					break;
				}
			}
		}
		for(int i = 0; i < n; i++){
			if(islower(s[i][0])) continue;
			int j;
			for(j = 0; j < s[i].length(); j++){
				if(s[i][j] == '+') break;
			}
			int index = -1;
			for(int k = i + 1; k < n; k++){
				if(islower(s[k][j])) break;
				if(s[k].length() < j) break;
				if(s[k][j] == '+') index = k;
			}
			if(index == -1) continue;
			for(int k = i; k <= index; k++){
				if(s[k][j] == '+') continue;
				s[k][j] = '|';
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < s[i].length(); j++){
				if(s[i][j] == '.') s[i][j] = ' ';
			}
		}
		for(int i = 0; i < n; i++) cout << s[i] << '\n';
		//for(int i = 0; i < n; i++) output_file << s[i] << '\n';
	}
	return 0;
}



Measured memory_bytes: 3952
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<llll> vllll;
typedef vector<int> vi;
typedef vector<ull> vull;

// TIMER
std::clock_t __start;
double __duration;
void start_timer() { __start = std::clock(); }
void print_timer() {
	__duration = (std::clock() - __start) / (double)CLOCKS_PER_SEC;
	std::cout << "Duration (msec): " << __duration * 1000 << '\n';
}
// END TIMER

//PI
// fast input
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
//char _;

template <class T>
T min_(T a, T b) { return (a < b ? a : b); }
template <class T>
T max_(T a, T b) { return (a > b ? a : b); }
double EPS = 1e-9;
bool eq_(const double& lhs, const double &rhs) {
	return (fabs(lhs - rhs) < EPS);
}

const int INF = int(2e9);
const ll INF_LL = LLONG_MAX;


bool is_set(int num, int bit) {
	return (num & (1 << bit)) != 0;
}

void split(string st, vector<ll>& summands) {
	string curr = "";
	for (int i = 0; i < st.size(); ++i) {
		if (st[i] != '+')
			curr.push_back(st[i]);
		else {
			stringstream ss(curr);
			ll num;
			ss >> num;
			summands.push_back(num);
			curr = "";
		}
	}
	if (!curr.empty()) {
		stringstream ss(curr);
		ll num;
		ss >> num;
		summands.push_back(num);
	}
}

ll eval(string st) {
	vector<ll> summands;
	split(st, summands);
	ll res = 0;
	for (ll num : summands) 
		res += num;
	return res;
}
ll H, W, N;

bool legal(int r, int c) {
	return r >= 1 && c >= 1 && r+2 <= H && c+2 <= W;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	map<ll, ll> res_counts;
	cin >> H >> W >> N;
	res_counts[0] = (H - 2)*(W - 2);
	set<ii> black;
	set<ii> seen_3x3;
	int r, c;
	for (int i = 0; i < N; ++i) {
		cin >> r >> c;
		black.insert({ r, c });
	}
	for (ii cell : black) {
		r = cell.first;
		c = cell.second;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				int curr_tl_row = r - i;
				int curr_tl_col = c - j;
				if (!legal(curr_tl_row, curr_tl_col) || 
					seen_3x3.count({ curr_tl_row, curr_tl_col }) != 0)
					continue;
				seen_3x3.insert({ curr_tl_row, curr_tl_col });
				ll curr_black = 0;
				for (int x = 0; x < 3; ++x) {
					for (int y = 0; y < 3; ++y) {
						ii curr_cell = { curr_tl_row + x, curr_tl_col + y };
						if (black.count(curr_cell) != 0)
							curr_black++;
					}
				}
				res_counts[curr_black]++;
				res_counts[0]--;
			}
		}
	}
	for (int i = 0; i <= 9; ++i)
		cout << res_counts[i] << '\n';
	return 0;
}



Measured memory_bytes: 47104
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	set<char>dis;
	for(char i:s){
		dis.insert(i);
	}
	dis.insert('z' + 6);
	for (char i = 'a'; i <= 'z'; i++) {
		if(*dis.lower_bound(i)!=i){
			cout << i << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
using namespace std;
string s[101];int n,l;
int main()
{
	cin>>n>>l;
	for(int i=1;i<=n;i++)cin>>s[i];
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define swap(a,b,type)do{type temp; temp= a;a = b; b= temp;}while(0); 
int main(){
 int a,b,c,d;
 cin >> a>> b>> c>> d;
 int e = min(a,d);
 d -=e;
 int f = min(b,d);
 d -=f;
 int g = d;
 int ans = e-g;
 cout << ans << endl;
 
 return 0; 
}


Measured memory_bytes: 3524
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<time.h>
#include<chrono>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    ll n,a[1010][1010],ans=-1;
    bool b[1010]={};
    vll v[1010];
    cin>>n;
    rep(i,n)rep(j,n-1){
        cin>>a[i][j];
        v[i+1].pb(a[i][j]);
    }
    rep(i,n*(n-1)/2+1){
        end = chrono::system_clock::now();
        double time = (double)(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
        if(time>=1950){
            cout<<(n-1)*n/2<<endl;
            return 0;
        } 
        bool flag=false;
        rep2(j,1,n+1) b[j]=0;
        rep2(j,1,n+1){
            if(!v[j].empty()){
                flag=true;
                break;
            }
        }
        if(!flag){
            ans=i;
            break;
        }
        rep2(j,1,n+1){
            if(b[j]||v[j].empty()) continue;
            ll u=v[j][0];
            if(b[u]) continue;
            if(v[u].empty()){
                cout<<-1<<endl;
                return 0;
            }
            if(v[u][0]!=j) continue;
            b[j]=1;b[u]=1;
            v[j].erase(v[j].begin());
            v[u].erase(v[u].begin());
        }
        rep2(j,1,n+1){
            if(b[j]) flag=false;
        }
        if(flag){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  unordered_map<string, int> m{{"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4}, {"THU", 3}, {"FRI", 2}, {"SAT", 1}};
  cout << m[s] << '\n';
  return 0;
}

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

int main(){
    long long n, x;cin>>n>>x;
    vector<long long> children(n);for(int i=0;i<n;i++){cin>>children[i];}
    sort(children.begin(), children.end());

    long long acc = 0;
    for(int i=0;i<n;i++){
        if (x >= children[i]){
            x -= children[i];
            acc++;
            if (i==n-1 && x > 0){
                acc--;
            }
        } else {
            break;
        }
    }
    if (acc == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll Inf = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    b[0] = a[0];
    REP(i, 1, n) b[i] = b[i-1] + a[i];
    ll res = Inf;
    rep(i, n-1){
        ll rest = b[n-1] - b[i];
        res = min(res, abs(rest - b[i]));
    }

    cout << res << endl;





}

Measured memory_bytes: 3328
N = int(input())

E = []

for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x-1, y))

ans = 0
for k in range((1<<N)-1, -1, -1):
    l = [(k>>i)&1 for i in range(N)]
    OK = True
    for e0, e1, e2 in E:
        if (l[e0]==1 and l[e1]!=e2):
            OK = False
            break
    if OK: ans = max(ans, sum(l))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s;
    else 
        cout << s.substr(0, k) << "...";
    return 0;
}

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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;

  if (A+B > C+D ) {
    cout << "Left" << endl;
  }
  if (A+B < C+D ) {
    cout << "Right" << endl;
  }
  if (A+B == C+D ) {
    cout << "Balanced" << endl;
  }
 }

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

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
	vivek_ghosh;
	
	cin>>n;
	vl a(n);
	map<ll,ll> m;
	ans = 0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ans^=a[i];
		m[a[i]]++;
	}
	
	if(ans>0)
		cout<<"No";
	else
		cout<<"Yes";
	cout<<endl;
	
	




	
	
	
	
	
	return 0;
}







Measured memory_bytes: 5888
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
# define pe "Possible"
# define ie "Impossible"
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define rep1(n) for (int qwerty = 1;qwerty <= n;++qwerty)
# ifdef CF
# define DEBUG
# endif // CF
# ifdef DEBUG
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
# define aprint(x,y,z) for (int i = x;i <= y;++i) cerr << z[i] << ' ';cerr << '\n'
# else
# define pp(n) ;
# define ppp(v) ;
# define aprint(x,y,z);
# endif // DEBUG
# define rep(n) for (int i = 1;i <= n;++i)
const int mod = 1e9 + 7;
int s[1 << 20];
int main(void)
{
    # ifdef CF
    freopen("input","r",stdin);
    # endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    fi>>m>>n;
    for (int i = 1;i <= n;++i) fi>>s[i];
    int cnt = 0;
    for (int i = 1;i <= n;++i)
        cnt += s[i] & 1;
    if (cnt > 2) halt(ie);
    cnt = 0;
    sort(s+1,s+1+n,[](int a,int b)
         {
            return (a&1) < (b&1);
         });
    if (n != 1) swap(s[1],s[n-1]);
    for (int i = 1;i <= n;++i)
        fo << s[i] << ' ';
    fo << '\n';
    vector < int > ans;
    if (s[1] != 1) ans.push_back(s[1] - 1);
    if (n == 1) ans.push_back(m - s[1] + 1);
    else
    for (int i = 2;i <= n;++i)
        ans.push_back(s[i] + (i == n));
    cnt = 0;
    for (auto it : ans) cnt += it > 0;
    fo << cnt << '\n';
    for (auto it : ans)
        if (it > 0) fo << it << ' ';
    fo << '\n';
    return 0;
}

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

#ifndef DEBUG
#define dump(...)
#endif

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

    int N, X;
    std::cin >> N >> X;

    int minv = INT_MAX;
    for (size_t i = 0; i < N; ++i) {
        int m; std::cin >> m;
        X -= m;
        minv = std::min(minv, m);
    }

    std::cout << N + (X / minv) << "\n";

    return 0;
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n, k;
Int ans;

int main(){
	cin >> n >> k;
	for(Int i = k; i <= n + 1; ++i){
		ans += (2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
}


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

int main() {
  int N,K; cin >> N >> K;
  vector<long> H(N);
  for (int i =0; i<N; i++) cin >> H.at(i);

  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  
  long ans =0;
  for (int i=K; i<N; i++) {
    ans += H.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840