akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
#define ws GON
#define MOD 1000000007

int n,m,s,t;
vector<pair<int,ll> > g[100005];
ll ds[100005],dt[100005],qs[100005],qt[100005];
priority_queue<pair<ll,int> > q;

void dijkstra(int x, ll *d, ll *qq){
	fore(i,0,n)d[i]=1LL<<61;
	d[x]=0;q.push(mp(0LL,x));
	qq[x]=1;
	while(!q.empty()){
		auto p=q.top();q.pop();
		int x=p.snd;ll dd=-p.fst;
		if(d[x]!=dd)continue;
		for(auto p:g[x]){
			int y=p.fst;ll c=p.snd;
			if(d[x]+c<d[y]){
				d[y]=d[x]+c;
				q.push(mp(-d[y],y));
				qq[y]=qq[x];
			}
			else if(d[x]+c==d[y])qq[y]+=qq[x],qq[y]%=MOD;
		}
	}
}

set<pair<pair<int,int>,ll> > ws,wt;

void doit(ll *d0, ll *d1, ll *q0, ll *q1, set<pair<pair<int,int>,ll> >& w, ll a){
	//printf(" %lld\n",a);
	fore(i,0,n)if(d0[i]==a&&d1[i]==a)w.insert(mp(mp(i,-1),q0[i]*q1[i]%MOD));
	fore(x,0,n)for(auto p:g[x]){
		int y=p.fst;ll c=p.snd;
		//if(d0[x]+d1[x]==2*a&&d0[y]+d1[y]==2*a)
		//if(d0[x]<a&&d0[y]>a&&d0[y]==d0[x]+c)
		if(d0[x]+c+d1[y]==2*a&&d0[x]+c>a&&d1[y]+c>a)
			w.insert(mp(mp(min(x,y),max(x,y)),q0[x]*q1[y]%MOD));
	}
}

int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);s--;t--;
	fore(_,0,m){
		int x,y;ll d;
		scanf("%d%d%lld",&x,&y,&d);d*=2;x--;y--;
		g[x].pb(mp(y,d));
		g[y].pb(mp(x,d));
	}
	dijkstra(s,ds,qs);
	dijkstra(t,dt,qt);
	doit(ds,dt,qs,qt,ws,ds[t]/2);
	//doit(dt,wt,dt[s]/2);
	ll r=0,s=0;

	for(auto p:ws)s+=p.snd,s%=MOD;
	for(auto p:ws){
		ll a=(s-p.snd+MOD)%MOD;
		r+=p.snd*a%MOD;
		r%=MOD;
	}


	printf("%lld\n",r);
	return 0;
}

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

using namespace std;

#pragma GCC optimize ("O3")

int readln(char* buf, int max)
{ 
   int len = 0;
   while ((max-- > 0) &&
          ((buf[len] = fgetc(stdin)) != '\n') &&
          (buf[len] != EOF)) ++len;
   buf[len] = 0;
   return len;
}

int N;

void solve(int N)
{
    cout << N / 3 << endl;
}

int main()
{
    scanf("%d", &N);
    solve(N);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[4][4];
int b[20][20];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    rep(i,3)rep(j,3)cin >> a[i][j];
    int n;
    cin >> n;
    rep(x,n){
        int t;
        cin >> t;
        rep(i,3)rep(j,3){
            if(a[i][j]==t)b[i][j]=1;
        }
    }
    bool ok = 0;
    rep(i,3)rep(j,3){
        // 縦
        if(b[i][j]==1&&b[i+1][j]==1&&b[i+2][j]==1&&i+2<=2)ok = 1;
        // 横
        if(b[i][j]==1&&b[i][j+1]==1&&b[i][j+2]==1&&j+2<=2)ok = 1;
        // 斜め
        if(b[i][j]==1&&b[i+1][j+1]==1&&b[i+2][j+2]==1&&i+2<=2&&j+2<=2)ok = 1;
        if(b[i][j]&&b[i+1][j-1]&&b[i+2][j-2])ok = 1;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def resolve():
    (N, M) = list(map(int, input().split(" ")))
    As = [int(input()) for i in range(M)]
    As.sort()

    cnts = [False] * (N+1)
    ptr = 0
    for i in range(N+1):
        c = 0
        if ptr < len(As) and i == As[ptr]:
            c = 0
            ptr = ptr + 1
        elif i == 0:
            c = 1
        elif i == 1:
            c = 1
        elif i == 2:
            c = 2 if 1 not in As else 1
        else:
            c = (cnts[i-2] + cnts[i-1])%1000000007
        cnts[i] = c

    print(cnts[N])

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 7844
a, op ,b = input().split()
while op != '?':
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    else:
        print(int(a) // int(b))
    a, op, b = input().split()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3;
  cout << s1s2s3/100+s1s2s3/10-s1s2s3/100*10+s1s2s3-s1s2s3/10*10 << endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int H,W,K;
   cin>>H>>W>>K;

   vector<ull>lines;
   for(ull bit=0;bit<pow(2,W-1);bit++){
      bool ok = true;
      for(int i=0;i<W;i++){
         if((1&(bit>>i)) && (1&(bit>>(i+1))) )ok=false;
      }
      if(ok)lines.push_back(bit);
   }
   //for(auto it:lines)cout<<it<<endl;

   vector<vector<ull> >dp(H+1,vector<ull>(W+1,0));
   dp[0][1]=1;
   for(int i=0;i<H;i++){
      for(int j=1;j<=W;j++){
         dp[i][j]%=MOD;
         //-1
         if(j-1>=1){
            ull a=0;
            for(auto it:lines){
               if(1&(it>>(j-2)))a++;
            }
            //cout<<a<<endl;
            a%=MOD;
            dp[i+1][j-1]+=(dp[i][j]*a)%MOD;
            dp[i+1][j-1]%=MOD;
         }
         //1
         if(j+1<=W){
            ull a=0;
            for(auto it:lines){
               if(1&(it>>(j-1)))a++;
            }
            //cout<<a<<endl;
            a%=MOD;
            dp[i+1][j+1] += (dp[i][j]*a)%MOD;
            dp[i+1][j+1]%=MOD;
         }
         //0
         ull a=0;
         for(auto it:lines){
            if(j==1){
               if(!(1&it>>(j-1)))a++;
            }
            else if(j==W){
               if(!(1&(it>>(j-2))))a++;
            }
            else{
               if((!(1&(it>>(j-2)))) && (!((1&(it>>j-1)))))a++;
               //cout<<i<<" "<<j<<" "<<it<<" "<<a<<endl;
            }
         }
         //cout<<a<<" "<<i+1<<" "<<j<<endl;
         a%=MOD;
         dp[i+1][j]+=(dp[i][j]*a)%MOD;
         dp[i+1][j]%=MOD;
         //cout<<endl;
      }
   }
   /*
   cout<<endl;
   for(int i=0;i<=H;i++){
      for(int j=1;j<=W;j++){
         cout<<dp[i][j]<<" ";
      }
      cout<<endl;
   }
   cout<<endl;
   */
   cout<<dp[H][K]%MOD<<endl;
   return 0;
}


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

using namespace std;


int main() {

    int a, b, c, r;
    cin >> a >> b;

    if(a<=b) {

        for(int i=a; i<=b; i++) {

            r = a*b*i;

            if(r%2 != 0) {
                cout << "Yes" << endl;
                break;
            } 
            else if(r%2 ==0 && i == b) {
                 cout << "No" << endl;
            }
        }

    }
    else if(b<a) {

        for(int i=b; i<=a; i++) {
            
            r = a*b*i;

            if(r%2 != 0) {
                cout << "Yes" << endl;
                break;                
            }  
            else if(r%2 ==0 && i == b) {
                 cout << "No" << endl;
            }
        }
    }

    return 0;
}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, Q;
i64 c[202020];
vector<int> v[202020];
bool used[202020];
void solve(){
	cin >> n >> Q;
	for(int i = 0; i < n-1; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i = 0; i < Q; i++){
		int a,b;
		cin >> a >> b;
		c[a] += b;
	}
	
	queue<P> q;
	q.push({1,c[1]});
	used[1] = 1;
	while(!q.empty()){
		P p = q.front(); q.pop();
		int pos = p.first, cnt = p.second;
		c[pos] = cnt;
		for(int i = 0; i < v[pos].size(); i++){
			int I = v[pos][i];
			if(used[I]) continue;
			used[I] = 1;
			q.push({I,cnt+c[I]});
		}
	}
	for(int i = 1; i <= n; i++){
		cout << c[i];
		if(i != n) cout << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 19060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  int a = 0, b = 0;

  int ss = s.length();
  REP(i, ss) {
    if(s[i] == '0') a++;
    else b++;
  }

  cout << (2 * min(a, b)) << endl;
}


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

int main() {
    long long H, W; cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        cout << (H*W + 1) / 2 << endl;
    }
    return 0;
}

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

int main() {
	int a, b, c, f = 0;
		cin >> a >> b >> c;

		if (a + b == c) f++;
		else if (b + c == a) f++;
		else if (a + c == b) f++;

		if (f != 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
}

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

class Program {

    static int Main(string[] args) {
        int n = int.Parse(Console.ReadLine());

        decimal v = 100000;

        for (int i = 0; i < n; i++) {
            decimal r = v * 5 / 100;
            decimal mod = r % 1000;

            if (mod > 0) {
                r = r + 1000 - mod;
            }

            v += r;
        }

        Console.WriteLine("{0}", v);

        return 0;
    }
}

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

int main() {
    int p, n, m;
    while (cin >> p >> n >> m, n || m || p) {
        vector<int> v(p);
        for (auto& i : v) cin >> i;
        int ans, Max = -1;
        for (int i = n; i <= m; i++) {
            if (Max <= v[i-1] - v[i]) {
                ans = i;
                Max = v[i-1] - v[i];
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

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

  int output = 1;

  for (int i = 0; i < N; i++) {
    if (K >= output)
      output *= 2;
    else 
      output += K;
  }
  cout << output << endl;
  
}

Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.numeric, std.math;

  int n;
  long m;
  rd(n, m);
  auto a = readln.split.to!(long[]);
  auto p = readln.split.to!(int[]);

  auto dp = new long[](1 << n);
  foreach (bit; 1 .. (1 << n)) {
    auto mul = 1L;
    foreach (i; 0 .. n) {
      if (bit & (1 << i)) {
        auto g = gcd(mul, a[i]), b = mul / g;
        if (1.0 * b * a[i] > m) {
          mul = m + 1;
          break;
        }
        mul = mul / g * a[i];
      }
    }
    dp[bit] = m / mul;
  }
  foreach (i; 0 .. n) {
    foreach (bit; 0 .. (1 << n)) {
      if ((bit & (1 << i)) == 0) {
        dp[bit ^ (1 << i)] -= dp[bit];
      }
    }
  }
  auto ans = 0.0;
  foreach (bit; 0 .. (1 << n)) {
    auto q = 1.0;
    foreach (i; 0 .. n) {
      if (bit & (1 << i)) {
        q *= p[i] / 100.0;
      } else {
        q *= (100 - p[i]) / 100.0;
      }
    }
    ans += (dp[bit].abs) * q;
  }
  writefln("%.18f", ans);

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}



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

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

	A *= 100;
	B *= 100;

	vector<int> mizu;
	for(int water_a=0; water_a<=F; water_a+=A)
		for(int water_b=0; water_b<=F; water_b+=B)
			if(0<water_a+water_b && water_a+water_b<=F) mizu.push_back(water_a+water_b);

	vector<int> satou;
	for(int sugar_c=0; sugar_c<=F; sugar_c+=C)
		for(int sugar_d=0; sugar_d<=F; sugar_d+=D)
			if(sugar_c+sugar_d <= F) satou.push_back(sugar_c+sugar_d);

	int ans_w=0, ans_s=0;
	double nodo=0.0;
	for(int w : mizu)
		for(int s : satou)
			if(w + s <= F && 100*s <= w*E && nodo <= (double)s/(double)w ) {
				nodo = (double)s/(double)w;
				ans_w = w;
				ans_s = s;
			}

	cout << ans_w + ans_s << " " << ans_s << endl;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    int x[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
        x[i] -= a;
    }
    map<int, ll> mp;
    mp[0] = 1;
    for(int i=0;i<n;i++){
        map<int, ll> tmp;
        for(auto& e : mp){
            tmp[e.first + x[i]] += e.second;
        }
        for(auto & e : tmp){
            mp[e.first] += e.second;
        }
    }
    cout << mp[0] - 1 << endl;
    return 0;
}


Measured memory_bytes: 3676
#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 << "Balanced" << endl;
  
  if(a+b < c+d)
    cout << "Right" << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int sum=0;
  float ava=0;
  int ta,kz;
  int cou=0;
  char ten;
  while(cin>>ta>>ten>>kz){
    sum=(ta*kz)+sum;
    ava=ava+kz;
    cou++;
  }
  ava=ava/cou;
  ava=ava+0.5;
  cout<<sum<<endl<<(int)ava<<endl;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, C;
	cin >> A >> B >> C;

	set<int> s { A, B, C };
	cout << (s.size() == 2 ? "Yes" : "No") << endl;

	return 0;
}


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

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n-n/10*10==9 || n/10==9){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;

int main()
{
	int n,k,s;
	cin>>n>>k>>s;
	vector<int> v;
	for(int i=0;i<k;i++)
	{
		v.pb(s);
	}
	if(s<10000000)
	{
		for(int i=0;i<n-k;i++)
		v.pb(1000000000);
	}
	else{
		for(int i=0;i<n-k;i++)
	v.pb(1);}
	for(int i=0;i<n;i++)
	cout<<v[i]<<" ";
		return 0;	
	}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int dx[4] = {+1,-1, 0, 0};
int dy[4] = { 0, 0,+1,-1};
int main()
{
  int n;
  cin >> n;
  vector<int > t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
  REP(i,n){
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    t[i] = t[i+1] - t[i];
    x[i] = x[i+1] - x[i];
    y[i] = y[i+1] - y[i];
  }
  REP(i,n){
    int dr = abs(x[i]) + abs(y[i]);
    if(t[i] < dr || (t[i] - dr)%2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
  int N;
  char s[52][102];
  int p,t[52];
  scanf("%d\n",&N);
  t[0]=0;
  for(int i=1;i<=N;i++){
    scanf("%s %d\n",s[i],&p);
    t[i]=p+t[i-1];
  }
  char X[102];
  scanf("%s",X);
  int c=1;
  while(strcmp(s[c],X)!=0) c++;
  printf("%d\n",t[N]-t[c]);
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
ll i,j,k,m,n,x,y,a[N],ans;
int main() {
    cin >> n >> k;
    for (i = 0; i < n; ++i)cin >> a[i];
    ans = 1ll << 61;
    for (i = 0; i + k - 1 < n; ++i) {
        x = a[i], y = a[i + k - 1];
        ans = min(ans, min(abs(x), abs(y)) + y - x);
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
void solve(){
    int n;
    cin>>n;
    vector<bool> check(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        check[i] = (x==y); 
    }
    bool flag = 0;
    for(int i=0;i+2<n;i++){
        flag |= check[i]&check[i+1]&check[i+2];
    }
    cout<<(flag ? "Yes" : "No")<<"\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

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

int main()

{
    long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,t,flag=0;

    cin>>a>>b>>t;

    if(a%t==0)
    {
        cout<<(b/t)-(a/t)+1<<endl;
    }

     else if(a%t!=0)
     {
         cout<< (b/t)-(a/t)<<endl;
     }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int nmax=2*1e5+10;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll>v(n);
    map<ll,ll>mp;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        mp[v[i]]++;
    }
    ll sum=0;
    for(auto x:mp)
    {
       sum+=(x.second*(x.second-1))/2;
    }
    ll res=sum;
    for(int i=0;i<n;i++)
    {
        auto id=mp.find(v[i]);
        sum=res;
        if(id->second>=2)
        {
            sum=sum-(id->second*(id->second-1))/2 + ((id->second-1)*(id->second-2))/2;
        }
        cout<<sum<<"\n";;
    }
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(int i=0; i<n; ++i)
#define ford(i,n) for(int i=n-1; i>=0; --i)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd __gcd

#define fast_cin() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> i_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ll_set; 
/* new_data_set p; */
/* *p.find_by_order(3); The value at third place */
/* p.order_of_key(7); The expected index in the set in sorted order */



int main(int argc, char const *argv[]){
    fast_cin();
    ll n,i,k,j;
    cin>>n>>k;
    vector<ll> h(n);
    for(i=0; i<n; ++i) cin>>h[i];
    ll dp[100005]={0};
    dp[1]=0;
    for(i=2; i<=n; ++i){
        ll l;
        if (i>k) l=i-k;
        else  l=1;
        dp[i]=LLONG_MAX;
        for (j=i-1; j>=l; --j) {
            dp[i]=min(dp[i],dp[j]+abs(h[i-1]-h[j-1]));
        }
    }
    cout<<dp[n]<<"\n";
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, d;
  cin >> n >> d;
  int x[n][d];
  rep (i, n) {
    rep (j, d) {
      cin >> x[i][j];
    }
  }

  int ans = 0;
  rep (i, n) {
    for (int i2 = i + 1; i2 < n; i2++) {
      double dis = 0;
      rep (j, d) {
        dis += pow(x[i][j] - x[i2][j], 2);
      }
      dis = sqrt(dis);
      if (ceil(dis) == dis) ans++;
    }
  }

  P(ans);
  return 0;
}

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

int main() {
  long long N;
  cin >> N;
  
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long m = 1;
  for (int i = 0; i < N; i++) {
    if (m <= 1000000000000000000/A.at(i)) {
      m *= A.at(i);
    }
    else {
      cout << -1 << endl;
      return 0;
    }     
  }  
  cout << m << endl;
}





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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    string s;
    cin >> s;

    int N=0,W=0,S=0,E=0;
    for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] == 'N') {
            N++;
        }else if (s[i] == 'W'){
            W++;
        }else if (s[i] == 'S') {
            S++;
        }else{
            E++;
        }
    }

    if ((N > 0 && S == 0) || (N == 0 && S > 0) ||
        (E > 0 && W == 0) || (E == 0 && W > 0) ) {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int E = sc.nextInt();
    int F = sc.nextInt();

    double max = -1;
    int maxSugar = 0;
    int maxSugarWater = -1;
    for (int i = 0; i*100 <= F; i++) {
      for (int m = 0; m*A*100 <= i*100; m++) {
        if ((i-m*A)%B == 0) {
          int n = (i-m*A)/B;
          if (m == 0 && n == 0) {
            continue;
          }
        
          //System.err.println(F-i*100 + " " + i*E);
          int sugarCap = Math.min(F-i*100, i*E);
          for (int p = 0; p*C <= sugarCap; p++) {
            int q = (sugarCap-p*C) / D;
            int sugar = p*C + q*D;
            int sugarWater = sugar + m*A*100 + n*B*100;
            double v = (double) 100*sugar/sugarWater;
            //System.err.println(sugarWater + " " + sugar);
            if (sugarWater <= F && max < v) {
              max = v;
              maxSugar = sugar;
              maxSugarWater = sugarWater;
            }
          }
        }
      }
    }
    
    System.out.println(maxSugarWater + " " + maxSugar);
  }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	static int H;
	static int[][] stone=new int[11][6];
	
	static int search() {
		int len;
		int point=0;
		for(int row=0; row<H; row++) {
			for(int col=0; col<=2; col++) {
				for(len=1; col+len<=4; len++) {
					if(stone[row][col]!=stone[row][col+len]) {
						break;
					}
				}
				if(len<=2) {
					continue;
				}
				point+=stone[row][col]*len;
				for(int i=0; i<len; i++) {
					stone[row][col+i]=0;//消滅させる石
				}
			}
		}
		return point;//その状態のpoint
	}
	
	static void change() {
		for(int col=0; col<5; col++) {
			for(int min=1; min<H; min++) {
				for(int row=H-1; row>=min; row--) {//落とせるところまで落とす
					if(stone[row][col]==0) {
						stone[row][col]=stone[row-1][col];//下に落とす
						stone[row-1][col]=0;//一つ上は消去
					}
				}
			}
		}
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				H=sc.nextInt();
				if(H==0) break;
				for(int i=0; i<H; i++) {
					for(int j=0; j<5; j++) {
						stone[i][j]=sc.nextInt();
					}
				}
				int sum=0;
				int cont;
				while(true) {
					cont=search();
					if(cont==0) {
						System.out.println(sum);
						break;
					}
					sum+=cont;
					change();//移動
				}
			}
		}
	}
	
}


Measured memory_bytes: 55288
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int n = ni();
    int k = ni();
    int x = ni();
    int y = ni();
    int d2 = Math.max(0, n - k);
    int d1 = n - d2;
    debug(d1, d2);
    System.out.println(d1 * x + d2 * y);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> arr(n);
    for (int z=0;z<n;z++) cin >> arr[z];
    vector <ll> f(100001);
    vector <ll> e(100001);
    ll maxi1 = 0, maxi2 = 0;
    ll pos1 = 0, pos2 = 0;
    for (int z=0;z<n;z++){
        if (z & 1){
            f[arr[z]]++;
            if (f[arr[z]] > maxi1){
                pos1 = arr[z];
                maxi1 = f[arr[z]];
            }
        } else {
            e[arr[z]]++;
              if (e[arr[z]] > maxi2){
                pos2 = arr[z];
                maxi2 = e[arr[z]];
            }
        }
    }
    if (pos1 != pos2){
        cout << n/2-maxi1+n/2-maxi2 << endl;
    } else {
        ll m1 = 0,m2 = 0;
        for (int z=0;z<100001;z++){
            if (z == pos1) continue;
            m1 = max(m1,f[z]);
            m2 = max(m2,e[z]);
        }
        cout << min(n/2-maxi1+n/2-m2,n/2-maxi2+n/2-m1) << endl;
    }
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <typeinfo>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26];
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;i<s.size();i++){
		a[(int)(s[i]-97)]=1;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0){
			cout<<(char)(i+97)<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    string s,t;
    cin >> s >> t;

    int ans = INT_MAX;
    for(int i = 0; i < s.size() - t.size()+1; i++){
        int cnt = 0;

        for(int j = 0; j < t.size(); j++){
            if(t[j] != s[i+j]){
                cnt++;
            }
        }
        chmin(ans,cnt);
    }

    cout << ans << endl;

}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n, k; cin >> n >> k;
    ll cc[n+1]; f(i,0,n) cc[i] = 0;
    f(_,1,k) {
        ll num; cin >> num;
        f(i,1,num) {
            ll x; cin >> x;
            cc[x]++;
        }
    }
    ll ans = 0;
    f(i,1,n) if(cc[i] == 0) ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>

#define EPS 1e-9
#define PI 3.1415926535
#define NAP_E 2.718281828

#define REP(x, beg, end) (for(int x = beg; x < end; x++))
#define ABS(x) (((x) > 0) ? (x) : -(x))
#define to_char() c_str()
#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

int N, C, K;
int *times;
std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	std::stringstream ss(s);
	std::string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) elems.push_back(item);
	}
	return elems;
}

void input() {
	scanf("%d",&N);
	scanf("%d",&C);
	scanf("%d",&K);

	times = new int[N];
	for(int i=0; i<N; i++) {
		scanf("%d", times + i);
	}
	sort(times, times + N);
}

int main() {
	input();
	
	int cnt = 0;
	// int p = 0; // beginning point of search

	int nowTime = 0;
	int busLeft;
	for(int i=0; i<N; i++){
		nowTime = times[i] + K; // 一番早く来た客の時間 + K にスキップ
		// cout << "Now at " << nowTime << endl;
		busLeft = C;
		for(int j=i; j<N; j++){
			if( nowTime - times[j] >= 0 ) { // 今いる人達全員バスに
				// cout << "Time: " << times[j] << endl;
				if( busLeft == C ) {
					if( j != i && j != N- 1 && times[j] + K >= times[j + 1] ) {
						break;
					}
					// cout << "Bus charter" << endl;
					cnt++;
				}
				busLeft--;
				if( busLeft == 0 ) {
					busLeft = C;
				}
				i = j; // ラスト連行マン
				// j++;
			}else{
				// cout << "OUT" << endl;
				busLeft = C;
				break;
			}
		}
	}

	cout << cnt << endl;


	delete[] times;
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
#include<random>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>ca;
    if(ca=='A')C 'T' E;
    if(ca=='T')C 'A' E;
    if(ca=='C')C 'G' E;
    if(ca=='G')C 'C' E;
    
}


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

int main() {
    string s;
    cin >> s;
    string a;
    a = s[0];
    for(int i = 1; i < s.size(); i++) {
        bool ok = true;
        for(int j = 0; j < a.size(); j++) {
            if(s[i] == a[j]) {
                ok = false;
                break;
            }
        }
        if(ok) a += s[i];
        else {
            cout << "no\n";
            return 0;
        }
    }

    cout << "yes\n";

    return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Math;
using static System.Console;
class E { static void Main() => new K(); }
class K
{
	public K()
	{
		var N = int.Parse(ReadLine());
		var surf = new uint[N][];
		var per = new int[N];
		var hash = new ulong[N];
		var dict = new Dictionary<ulong, int>();
		for (var i = 0; i < N; i++)
		{
			surf[i] = ReadLine().Split().Select(uint.Parse).ToArray();
			per[i] = surf[i][0] == surf[i][2] && surf[i][1] == surf[i][3] ? surf[i][0] == surf[i][1] ? 1 : 2 : 4;
			if (per[i] == 1) hash[i] = Hash1(surf[i][0]);
			else if (per[i] == 2) hash[i] = Hash2(surf[i][0], surf[i][1]);
			else hash[i] = Hash(surf[i][0], surf[i][1], surf[i][2], surf[i][3]);
			if (!dict.ContainsKey(hash[i])) dict[hash[i]] = 0;
			dict[hash[i]]++;
		}
		var a = 0L;
		var y = new uint[4];
		for (var i = 0; i < N; i++)
			for (var j = i + 1; j < N; j++)
			{
				var count = 0L;
				dict[hash[i]]--;
				dict[hash[j]]--;
				for (var rj = 0; rj < per[j]; rj++)
				{
					var x = surf[i];
					for (var k = 0; k < 4; k++) y[k] = surf[j][(k + rj) % 4];
					var s = new[] {
						Hash(y[3], y[2], x[3], x[2]),
						Hash(y[2], y[1], x[0], x[3]),
						Hash(y[1], y[0], x[1], x[0]),
						Hash(y[0], y[3], x[2], x[1])
					};
					var p = 1L;
					var dup = new Dictionary<ulong, int>();
					foreach (var h in s)
					{
						if (!dict.ContainsKey(h)) { p = 0; break; }
						if (!dup.ContainsKey(h)) dup[h] = 0;
						p *= (h % p2 == 0 ? h % p1 == 0 ? 4 : 2 : 1) * (dict[h] - dup[h]);
						dup[h]++;
					}
					count += p;
				}
				a += count * (4 / per[j]);
				dict[hash[i]]++;
				dict[hash[j]]++;
			}
		WriteLine(a / 3);
	}
	static ulong Hash(uint i, uint j, uint k, uint l)
	{
		var a = ((ulong)i << 30) | (j << 20) | (k << 10) | l;
		a = Min(a, ((ulong)j << 30) | (k << 20) | (l << 10) | i);
		a = Min(a, ((ulong)k << 30) | (l << 20) | (i << 10) | j);
		a = Min(a, ((ulong)l << 30) | (i << 20) | (j << 10) | k);
		return a;
	}
	static ulong Hash1(uint i) => ((ulong)i << 30) | (i << 20) | (i << 10) | i;
	static ulong Hash2(uint i, uint j)
	{
		if (i > j) return ((ulong)j << 30) | (i << 20) | (j << 10) | i;
		return ((ulong)i << 30) | (j << 20) | (i << 10) | j;
	}
	const ulong p1 = (1 << 30) | (1 << 20) | (1 << 10) | 1;
	const ulong p2 = (1 << 20) | 1;
}


Measured memory_bytes: 17612
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <array>
#include <time.h>
#include <limits.h>
#pragma comment(lib, "winmm.lib")
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
using namespace std;

vector<int> C(100);
int dp[101][100001] = { 1 << 20 };

void Hoge(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int n, sum;

	cin >> sum >> n;
	rep(i, n) cin >> C[i + 1];

	rep(i, n + 1) dp[i][0] = 0;
	rep(i, sum + 1) dp[0][i] = 1 << 20;

	FOR(i,1, n){
		FOR(j, 1, sum){
			
			if (j - C[i] >= 0) dp[i][j] = min(dp[i - 1][j], dp[i][j - C[i]] + 1);
			else dp[i][j] = dp[i - 1][j];
		}
	}

	
	cout << dp[n][sum] << endl;

}

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

	Hoge();
	return 0;
}

Measured memory_bytes: 7304
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

#define INF 1e+9




int main(){

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

double n;
cin>>n;
cout << fixed << setprecision(15) <<(n*2)*M_PI << endl;

}


Measured memory_bytes: 3792
#include<cstdio>

int main()  {
    int W,H,x,y,r,f;

    scanf ("%d %d %d %d %d",&W,&H,&x,&y,&r);

    f = 0;
    if (x - r < 0){
        f = 1;
    }
    
    if (x + r > W){
        f = 1;
    }
    if (y - r < 0){
        f = 1;
    }

    if (y + r > H){
        f = 1;
    }
    if (f == 0){
        printf("Yes\n");
    }

    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2680
import java.util.*;

class Main {
  public static void main(String[] args) {
    int n, k;
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    k = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i = 0; i < n; i++)
      arr[i] = sc.nextInt();
    
    Arrays.sort(arr);
    int res = 0;
    for(int i = 0; i < k; i++)
      res += arr[i];
    
    System.out.println(res);
  }
}


Measured memory_bytes: 39068
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi a(n);
    rep(i, n) cin >> a[i];
    int t = 32;
    for (int i = 0;; i++) {
      t -= (t - 1) % 5;
      cmax(t, 0);
      cout << t << endl;
      if (t == 0) break;
      t -= a[i % n];
      cmax(t, 0);
      cout << t << endl;
      if (t == 0) break;
    }
  }
}

Measured memory_bytes: 3080
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<ll> A;
vector<ll> B;
vector<ll> C;

vector<ll> ans;

bool cond(const ll border, const ll K) {
    ll cnt = 0;
    for (int i = 0; i < (int) A.size(); i++) {
        for (int j = 0; j < (int) B.size(); j++) {
            for (int k = 0; k < (int) C.size(); k++) {
                ll sum = A[i] + B[j] + C[k];
                if (sum < border) {
                    break;
                }
                cnt++;
                if (cnt >= K) {
                    return true;
                }
            }
        }
    }
    return false;
}

ll calc_border(const ll K) {
    ll left = -1, right = LONG_LONG_MAX / 2, mid;
    while (right - left > 1) {
        mid = ((right - left) / 2) + left;
        // printf("left: %lld, right: %lld, mid: %lld\n", left, right, mid);
        if (cond(mid, K)) {
            left = mid;
        } else {
            right = mid;
        }
    }
    return left;
}

void collect_cakes(const ll border, const ll K) {
    ll cnt = 0;
    for (int i = 0; i < (int) A.size(); i++) {
        for (int j = 0; j < (int) B.size(); j++) {
            for (int k = 0; k < (int) C.size(); k++) {
                ll sum = A[i] + B[j] + C[k];
                if (sum <= border) {
                    break;
                }
                ans.push_back(sum);
                cnt++;
                if (cnt >= K) {
                    return;
                }
            }
        }
    }

    while (cnt < K) {
        ans.push_back(border);
        cnt++;
    }
}

int main(void) {
    int X, Y, Z;
    ll K;
    cin >> X >> Y >> Z >> K;

    A.resize(X);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    B.resize(Y);
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());

    C.resize(Z);
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());

    ll border = calc_border(K);
    // cout << border << endl;

    collect_cakes(border, K);
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < (int) ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

using namespace std;

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

    vector<int> ai(a);
    for (int i = 0; i < a; i++) {
        cin >> ai[i];
    }

    vector<int> bi(b);
    for (int i = 0; i < b; i++) {
        cin >> bi[i];
    }

    int res = *min_element(ai.begin(), ai.end()) + *min_element(bi.begin(), bi.end());
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        res = min(res, ai[x - 1] + bi[y - 1] - c);
    }

    cout << res << endl;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
S = []
for i in range(M):
    s = map(int, input().split())
    sl = list(s)
    S.append(sl[1:])

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

a = []
for i in range(2 ** N):
    i_bin = bin(i)
    a.append(i_bin[2:].zfill(N))

c = 0
for ai in a:
    # print('ai:', ai)
    r = True
    for i, si in enumerate(S):
        x = 0
        for sii in si:
            # print('x', si, sii)
            x += int(ai[sii-1])
        if x % 2 != P[i]:
            r = False
    if r:
        c += 1

print(c)

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

using namespace std;

#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef vector< pair<int,int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int,int> pii;

const ll INF= ll (1e18);
const int MOD= 1e9+7;
const int N=100000+10;

int main()
{
    std::ios::sync_with_stdio(0);

    ll n,m;
    cin>>n>>m;

    if(m-2*n>0)
    {ll x= ceil((m-2*n)/2);

    cout<<n+ (x/2)<<endl;
    }
    else
    {
        m/=2;
        cout<<min(n,m)<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int MOD = 1e9 + 7;

//素因数分解
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      res[i] += 1;
      n = n/i;
    }
  }
  if (n != 1) {
    res[n] += 1;
  }
  return res;
}

int main() {
  int i;
  int yakusuu[1010];
  for (i = 1; i <= 1000; i++) {
    yakusuu[i] = 1;
  }
  int n;
  scanf("%d", &n);
  for (i = 2; i < n+1; i++) {
    map<int, int> fact = prime_factor(i);
    for (auto x : fact) {
      yakusuu[x.first] += x.second;
    }
  }
  long long ans = 1;
  for (i = 1; i < n+1; i++) {
    ans = (ans * yakusuu[i]) % MOD;
  }
  printf("%lld", ans);
  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++)

int main() {
  string s;
  cin >> s;
  int res = 0;
  for (char c : s) {
    res += c - '0';
    res %= 9;
  }

  if (res%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

ll lcm(ll a, ll b)
{
    ll x = a * b;
    if (a < b)
    {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return x / b;
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    ll ans;
    ans = (b - ((b / c + b / d) - b / lcm(c, d))) - (a - ((a / c + a / d) - a / lcm(c, d)));
    cout << ans << endl;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d){
    cout << "Left" << endl;
  }
  else if (a+b==c+d){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> str(h);
  for (int i = 0; i < h; ++i) {
    cin >> str[i];
  }

  for (int i = 0; i < w + 2; ++i) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < h; ++i) {
    cout << "#" << str[i] << "#" << endl;
  }

  for (int i = 0; i < w + 2; ++i) {
    cout << "#";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
//abc 158:A

     #include <bits/stdc++.h>
     #include <cstdio>
     #include <cstring>
     #include <cmath>
     #include <cstring>
     #include <chrono>
     #include <complex>
     #define endl "\n"
     #define ll long long int
     #define vi vector<int>
     #define vll vector<ll>
     #define vvi vector < vi >
     #define pii pair<int,int>
     #define pll pair<long long, long long>
     #define mod 1000000007
     #define inf 1000000000000000001;
     #define all(c) c.begin(),c.end()
     #define mp(x,y) make_pair(x,y)
     #define mem(a,val) memset(a,val,sizeof(a))
     #define eb emplace_back
     #define f first
     #define s second

     using namespace std;
     int main()
     {
         std::ios::sync_with_stdio(false);
         string s;
         cin>>s;
         int cnt1=count(s.begin(),s.end(),'A');
         if(cnt1==3 || cnt1==0)
            cout<<"No"<<endl;
         else
            cout<<"Yes"<<endl;
         return 0;
     }


Measured memory_bytes: 256