akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n,t[110],m,p[110],x[110];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  cin>>m;
  for(int j=0;j<m;j++){
    cin>>p[j]>>x[j];
  }
  int ans=0;
  for(int l=0;l<m;l++){
    for(int k=0;k<n;k++){
      if(p[l]-1==k)
        ans+=x[l];
      else
        ans+=t[k];
    }
    cout<<ans<<endl;
    ans=0;
  }
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string ans="";

            List<int[]> dice = new List<int[]>();
            for (int j = 0; j < n; j++)
            {
                int[] dice1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                dice.Add(dice1);
            }

            for (int i = 0; i < n-1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    ans = Dice(dice, i, j);
                    if (ans == "No") break;
                }
                if (ans == "No") break;
            }
            Console.WriteLine(ans);
        }

        internal static string Dice(List<int[]> dice, int i, int j)
        {
            string ans = "";
            for (int k = 0; k < 6; k++)
            {
                int dir = 0;
                if (dice[i][0] == dice[j][k]) dir = k;
                else if (!(dice[i].Contains(dice[j][k])))
                {
                    ans = "Yes";  break;
                }
                else  continue;

                int d = dice[j][5 - dir];
                dice[j][5 - dir] = dice[j][0];
                dice[j][0] = dice[j][dir];
                dice[j][dir] = dice[j][5];
                dice[j][5] = d;

                if (dir == 5)
                {
                    int d2 = dice[j][2];
                    dice[j][2] = dice[j][3];
                    dice[j][3] = d2;
                }

                int[] side = { dice[j][1], dice[j][2], dice[j][4], dice[j][3], dice[j][1], dice[j][2] };
                for (int l = 0; l < 4; l++)
                {
                    if (side[l] == dice[i][1])
                    {
                        if (side[l + 1] == dice[i][2] && side[l + 2] == dice[i][4] && dice[j][5] == dice[i][5])
                        {
                            ans = "No"; break;
                        }
                        else
                            ans = "Yes";
                    }
                    else if (!(side.Contains(dice[i][1])))
                    {
                        ans = "Yes"; break;
                    }
                }
            }
            return ans;
        }
    }
}


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

int main()
{
          char a;


         /// cout<< "Enter a character:" << endl;
          cin >> a ;
          if (a == 'a' )
          {
                    cout << "vowel";
          }
          else if (a == 'e')
          {
                    cout << "vowel";
          }
           else if (a == 'i')
          {
                    cout << "vowel";
          }
           else if (a == 'o')
          {
                    cout << "vowel";
          }
           else if (a == 'u')
          {
                    cout << "vowel";
          }
          else
          {
                    cout << "consonant";
          }




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a>=b&&a>=c) cout<<b+c;
  else if(b>=c&&b>=a) cout<<a+c;
  else if(c>=b&&c>=a) cout<<b+a;
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n, w, h;

int r(int a, int b) {
    int c = a + b;
    if (c < 0) return 0;
    else if (c > h) return h;
    else return c;
}

int main(void){
    cin >> n >> w >> h;
    vector<int> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
    
    vector<int> gh(h+1,0);
    vector<int> gw(w+1,0);
    for (int i = 0; i < n; i++) {
        gh[r(y[i], z[i]*-1)]++;
        gh[r(y[i], z[i])]--;
    }
    for (int i = 0; i < n; i++) {
        gw[r(x[i], z[i]*-1)]++;
        gw[r(x[i], z[i])]--;
    }
    
    for (int i = 0; i < h; i++) gh[i+1] += gh[i];
    for (int i = 0; i < w; i++) gw[i+1] += gw[i];
    
    bool f1 = true, f2 = true;
    for (int i = 0; i < h; i++) if (gh[i] == 0) f1 = false;
    for (int i = 0; i < w; i++) if (gw[i] == 0) f2 = false;
    if (f1 || f2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4636
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  int x[16][16];
  int y[16][16];

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      int tx, ty;
      cin >> tx >> ty;
      x[i][j] = tx - 1;
      y[i][j] = ty;
    }
  }

  int max = 0;
  for (int b = 0; b < (1<<N); b++) {
    int cnt = 0;
    bool valid = true;
    int ta[N];
    for (int i = 0; i < N; i++) {
      if (b & (1<<i)) {
        cnt++;
        ta[i] = 1;
      } else {
        ta[i] = 0;
      }
    }

    for (int i = 0; i < N; i++) {
      if (ta[i] == 0) continue;
      for (int j = 0; j < A[i]; j++) {
        if (ta[x[i][j]] != y[i][j]) {
          valid = false;
        }
      }
    }

    if (valid && max < cnt) {
      max = cnt;
    }
  }
  cout << max << endl;
  return 0;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int a, b;
  cin >> a;
  cin >> b;
  cout << 6 - a - b;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        
   int X = sc.nextInt();
   int A = sc.nextInt();
   
   if(X < A){
       System.out.println(0);
   }else{
       System.out.println(10);
   }
    
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=2e5+10;
const int mod=998244353;
struct Tree
{
    ll c[M];
    ll ask(int x)
    {
        //printf("x=%d\n",x);
        ll ans=0;
        for(; x; x-=x&-x) ans=(ans+c[x])%mod;
        return ans;
    }
    void add(int x,ll y)
    {
        for(; x<=M; x+=x&-x) c[x]=(c[x]+y)%mod;
    }
    void clear()
    {
        fill(c,c+M,0);
    }
}tree;
struct Edge
{
    int l,r;
}e[15];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        cin>>e[i].l>>e[i].r;
    }
    tree.add(1,1);
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
           int l=i-e[j].r,r=i-e[j].l;
           if(r<1) continue;
           l=max(l,1);
           tree.add(i,(tree.ask(r)-tree.ask(l-1)+mod)%mod);
        }
    }
    cout<<(tree.ask(n)-tree.ask(n-1)+mod)%mod;

    return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i,N){
    cin >> A[i];
    A[i]--;
  }
  rep(i,N){
    cin >> B[i];
    //A[i] --;
  }
  rep(i,N-1){
    cin >> C[i];
    //A[i] --;
  }
  //rep(i,N-1){cout << A[i] << B[i] << C[i] << endl;}
  //cout << A[N-1] << B[N-1] << C[N-1] << endl;
  int happy = 0;
  rep(i,N-1){
    happy += B[A[i]];
    if(A[i+1] == A[i]+1){
      happy += C[A[i]];
      //cout << "add"<< A[i] << endl;
    }
    //cout << "happy" << happy << endl;
  //cout << A[i] << "," << B[A[i]] << "," << C[i] <<endl;
  }
  happy += B[A[N-1]];
  
  cout << happy << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void quad(int n)
{
    if (n == 0){
        return;
    }
    quad(n / 4);
    printf("%d", n % 4);
}

int main(void)
{
    int n;
    
    while (1){
        scanf("%d", &n);
        if (n == -1){
            break;
        }
        if (n == 0){
            printf("0\n");
        }
        else {
            quad(n);
            printf("\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
#define ll long long int 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define f first
#define s second

const ll mod = 1000000007;
const ll N = 1e6;

bool cmp(pair<pair<int,int>,pair<int,int>> a, pair<pair<int,int>,pair<int,int>> b){
	return (a.s).s > (b.s).s ;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,n;cin >> a >> b >> n;
	ll x = min(b-1,n);
	cout << ((a*x)/b) - (a*(x/b)) ;
 	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;
int D, G;
int main(){
    cin >> D >> G;
    int p[D], c[D];
    rep(i, D){
        cin >> p[i] >> c[i];
    }

    int ans = INF;
    for(int bit = 0;bit < (1 << D);++bit){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0;i < D; ++i){
            if((1 << i) & bit){
                s += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            }
        }
        if(s < G){
            for(int i = D - 1;i >= 0;--i){
                if((1 << i)&bit)continue;
                int s1 = (i + 1) * 100;
                num += min((G - s + s1 - 1) / (s1), p[i]);
                s += s1 * min((G - s + s1 - 1) / (s1), p[i]);
                if(s >= G)break;
            }
        }
        ans = min(ans, num);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll c[1111111];

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll d=a[n-1],f=0,ff=1,cc=0;
  rrep(k,n) {
    d=__gcd(d,a[k]);
    if(a[k]!=1) {
      ff=0;
      cc++;
    }
    if(f) continue;
    vector<ll> v;
    for(ll i=2; i*i<=a[k]; i++) {
      if(a[k]%i==0) {
        v.pb(i);
        if(i*i!=a[k]) v.pb(a[k]/i);
      }
    }
    v.pb(a[k]);
    rep(i,v.size()) {
      c[v[i]]++;
      if(c[v[i]]>=2) {
        f=1;
        break;
      }
    }
  }
  if(cc<=1) ff=1;
  if(ff) pr("pairwise coprime");
  else if(d!=1) pr("not coprime");
  else if(f) pr("setwise coprime");
  else pr("pairwise coprime");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main()
{
   int n;
   cin >> n;
   vector<int>a(n);
   for(int i = 0; i < n; i++) cin >> a[i];
   int alice = 0, bob = 0;
   sort(a.begin(),a.end(), greater<int>());
   for(int i = 0; i < n; i++){
      if(i % 2 == 0){
         alice += a[i];
      }else{
         bob += a[i];
      }
   }
   cout << alice - bob << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
using namespace std;
typedef long long LL;
class KMP {
private:
    // 検索する文字列
    string S;
    LL len;
    vector<LL> table;
    void createTable() {
        table[0] = -1;
        int j = -1;
        for (int i = 0; i < len; i++) {
            while (j >= 0 && S[i] != S[j]) j = table[j];
            table[i+1] = ++j;
        }
    }
public:
    KMP(const string &s) : S(s),len(S.size()),table(S.size()+1,0) {
        createTable();
    }

    LL searchFirst(string &target) {
        LL m = 0LL,i = 0LL,n = target.size();
        while ( m + i < n) {
            if (S[i] == target[i+m]) {
                if ( i == (len-1) ) {
                    return m;
                }
                i++;
            }
            else {
                if (i == 0) m++;
                else {
                    m = m + i - table[i];
                    i = table[i];
                }
            }
        }
        return (-1);
    }

    // 最初にSと一致する位置 O(target.size()) 
    vector<LL> searchAll(string &target) {
        vector<LL> ret;
        LL m = 0LL,i = 0LL,n = target.size();
        while ( m + i < n) {
            if (S[i] == target[i+m]) {
                if ( (i++) == (len-1) ) {
                    ret.push_back(m);
                    m = m+i-table[i];
                    i = table[i];
                }
            }
            else {
                if (i == 0) m++;
                else {
                    m = m + i - table[i];
                    i = table[i];
                }
            }
        }
        return ret;
    }


};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string T,P;
    cin >> T >> P;
    KMP kmp(P);
    vector<LL> ans = kmp.searchAll(T);
    REP(i,ans.size()) cout << ans[i] << endl;


}


Measured memory_bytes: 13220
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

int n;
map <int, int> cnt;

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

    int x, diff = 0;

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x;
        if(cnt.count(x) == 0)
            diff++;
        cnt[x]++;
    }

    if(cnt[0] == n)
    {
        cout << "Yes" << endl;
        return 0;
    }

    if(n % 3)
    {
        cout << "No" << endl;
        return 0;
    }

    if(cnt[0] == n / 3 && diff == 2)
    {
        cout << "Yes" << endl;
        return 0;
    }

    if(diff != 3)
    {
        cout << "No" << endl;
        return 0;
    }

    x = 0;
    for(auto it: cnt)
    {
        if(it.second == 0)
            continue;
        x ^= it.first;
        if(it.second != n / 3)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if(x != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 1000,mod = 998244353;
ll n,sum,A[N],S[N];
ll ksm(ll x,ll y)
{
	ll res = 1; 
	for(;y;y >>= 1,x = x * x % mod) 
		if(y & 1) res = res * x % mod; 
	return res;
}
void Xor(ll *f,ll opt)
{
	ll a,b;
	for(int len = 2,mid = 1;len <= n;len <<= 1,mid <<= 1)
		for(int i = 0;i < n;i += len)
			for(int j = 0;j < mid;j ++)
			{
				a = f[i + j]; b = f[i + j + mid];
				f[i + j] = (a + b) % mod * opt % mod;
				f[i + j + mid] = (a - b) % mod * opt % mod;
			}
	for(int i = 0;i < n;i ++) f[i] = (f[i] + mod) % mod;
}
int main()
{
	n = read(); n = (1 << n);
	for(int i = 0;i < n;i ++) sum = sum + (A[i] = read());
	sum = ksm(sum,mod - 2); 
	for(int i = 0;i < n;i ++) A[i] = A[i] * sum % mod;
	A[0] --; if(A[0] < 0) A[0] += mod; 
	S[0] = n - 1; for(int i = 1;i < n;i ++) S[i] = mod - 1;
	Xor(S,1); Xor(A,1);
	for(int i = 0;i < n;i ++) A[i] = ksm(A[i],mod - 2) * S[i] % mod;
	Xor(A,(mod + 1) >> 1);
	ll x = mod - A[0];
	for(int i = 0;i < n;i ++) cout << ((x + A[i]) % mod + mod) % mod << "\n";
}

Measured memory_bytes: 11008
import std.stdio;import std.conv;import std.algorithm;import std.array;

auto 	raia(){ return readln().split().map!(to!int); }	//read as a int[]

static const int mint =60;
static const int hour = 60*mint;

void main()
{
	auto it = raia();
	writeln( it[0] /hour,":",it[0]%hour/mint,":",it[0]%mint);
}

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

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
typedef pair<int,P> iP;

const int INF = 1 << 28;
const int dx[] = {0, 1, 0,-1};
const int dy[] = {1, 0,-1, 0};

int main () {
    int R, C;
    cin >> R >> C;

    vector<string> g(R);
    for (auto &i : g) cin >> i;

    int sx, sy, gx, gy;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            if (g[i][j] == 'S') sx = i, sy = j;
            if (g[i][j] == 'G') gx = i, gy = j;
        }
    }

    mat d(R, vec(C, INF));
    d[sx][sy] = 0;

    priority_queue <iP, vector<iP>, greater<iP> > que;
    que.push(iP(0, P(sx, sy)));

    while (que.size()) {
        iP ip = que.top(); que.pop();
        int cost = ip.first;
        int x = ip.second.first;
        int y = ip.second.second;

        if (d[x][y] < cost) continue;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (0 <= nx && nx < R && 0 <= ny && ny < C) {
                if (g[nx][ny] != '#' && g[nx][ny] != 'x') {
                    int cost_ = cost + (g[nx][ny] == 'o' ? 1 : 2);
                    if (cost_ < d[nx][ny]) {
                        d[nx][ny] = cost_;
                        que.push(iP(cost_, P(nx, ny)));
                    }
                }
            }
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 3; j++) {
                int nx = x + dx[i] * j;
                int ny = y + dy[i] * j;
                if (0 <= nx && nx < R && 0 <= ny && ny < C) {
                    if (g[nx][ny] != '#') {
                        int cost_ = cost + 2 + j;
                        if (cost_ < d[nx][ny]) {
                            d[nx][ny] = cost_;
                            que.push(iP(cost_ , P(nx,ny)));
                        }
                    } else {
                        break;
                    }
                }
            }
        }
    }

    cout << d[gx][gy] << endl;


    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
using namespace std;
#define Nmax 100000
#define INF 2000000000

struct card
{
	char suit;
	int value;
};

card L[Nmax / 2 + 2];
card R[Nmax / 2 + 2];

int partition(card a[],int p, int r)
{
	card x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j].value <= x.value) {
			i++;
			card temp = a[i];
			a[i] = a[j];
			a[j] = temp;
		}
	}
	card temp = a[i + 1];
	a[i + 1] = a[r];
	a[r] = temp;
	return (i + 1);
}

void quickSort(card a[], int p, int r)
{
	if (p < r) {
		int q = partition(a, p, r);
		quickSort(a, p, q - 1);
		quickSort(a, q + 1, r);
	}
}

void merge(card a[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	
	for (int i = 0; i < n1; i++) {
		L[i] = a[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = a[mid + i];
	}
	L[n1].value = INF;
	R[n2].value = INF;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].value <= R[j].value) {
			a[k] = L[i];
			i++;
		}
		else
		{
			a[k] = R[j];
			j++;
		}
	}
}

void mergeSort(card a[], int left, int right)
{
	if ((left + 1) < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

int main()
{
	card a[Nmax];
	card b[Nmax];
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		char ch;
		int m;
		cin >> ch >> m;
		a[i].suit = b[i].suit = ch;
		a[i].value = b[i].value = m;
	}

	quickSort(a, 0, n - 1);
	mergeSort(b, 0, n);

	bool stable = true;
	for (int i = 0; i < n; i++) {
		if (a[i].suit != b[i].suit) {
			stable = false;
			break;
		}
	}

	cout << (stable ? "Stable" : "Not stable") << endl;
	for (int i = 0; i < n; i++) {
		cout << a[i].suit << " " << a[i].value << endl;
	}

	return 0;
	
}


Measured memory_bytes: 5432
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18
int INF = 100000000;//10^8
int X,Y,Z,K;
vector<ll> A(1000),B(1000),C(1000);
int main(void){
    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++)cin >> A.at(i);
    for(int i = 0; i < Y; i++)cin >> B.at(i);
    for(int i = 0; i < Z; i++)cin >> C.at(i);
    vector<ll> AB;
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            AB.push_back(A.at(i) + B.at(j));
        }
    }
    sort(AB.begin(),AB.end());
    reverse(AB.begin(),AB.end());
    vector<ll> ABC;
    for(int i = 0; i < min(K, X * Y); i++){
        for(int j = 0; j < Z; j++){
            ABC.push_back(AB.at(i) + C.at(j));
        }
    }
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(),ABC.end());
    for(int i = 0; i < K; i++){
        cout << ABC.at(i) << endl;
    }
}


Measured memory_bytes: 43240
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    string s,t;
    cin >> s >> t;
	a = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i]) a++;
	}
	cout << a;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main(void) {
    int n, m,count = 0,k;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i,m) cin >> l.at(i) >> r.at(i);
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    rep3(i,l.at(m-1),r.at(0)) {
        count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 100000000000000000
#define LLINF 922337203685477807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X, K, D; cin >> X >> K >> D;
	if (X < 0)X *= -1;

	int cnt = min(K, X / D);
	K -= cnt;
	X -= cnt * D;

	if (K & 1)cout << D - X << endl;
	else cout << X << endl;


	return 0;
}



Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
	 public static void main(String[] args){
	        Scanner sc=new Scanner(System.in);
	        int w=sc.nextInt();
	        int n=sc.nextInt();
	        int[] values=new int[w];
	        
	        for(int i=0;i<values.length;i++){
	        	values[i]=i+1;
	        }
	        
	        for(int i=0;i<n;i++){
	        	String str=sc.next();
	        	String[] ab=str.split(",");
	        	int a=Integer.parseInt(ab[0])-1;
	        	int b=Integer.parseInt(ab[1])-1;
	        	
	        	int tmp;
	        	tmp=values[a];
	        	values[a]=values[b];
	        	values[b]=tmp;
	        	
	        }
	        
	        for(int i=0;i<values.length;i++){
	        	System.out.println(values[i]);
	        }
	        
	 }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    int n;
    cin >> n;
    vi h(n);
    for (auto &i : h)   cin >> i;
    ll dp[n];
    dp[1] = abs(h[1] - h[0]);
    dp[0] = 0;
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include<iostream>
#include<stack>
using namespace std;
#define ll long long
const ll maxn = 1005;
const ll mod = 1e9 + 7;
const ll inf = 1 << 30;
int main()
{
	int n,m,flag=0,a[maxn],i;
	double sum=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sum=sum/(m*4.0);
	for(i=1;i<=n;i++)
		if(a[i]>=sum)
			flag++;
	if(flag>=m)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	int i;
	double ans=0;
	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
		ans += (double)(1.0 / a.at(i));
		//cout << ans << endl;
	}
	ans = 1 / ans;
	printf("%.10f\n", ans);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007

const int MAXN = 1e5 + 50;
int pa[MAXN];
ll cnt, E;
void init(ll sz) {
	for(int i = 0; i < sz; i++)
		pa[i] = i;
	cnt = sz;
}

int find(int x) {
	return (pa[x] == x) ? x : pa[x] = find(pa[x]);
}

void merge(int x, int y) {
	if(find(x) != find(y)) {
		pa[pa[x]] = pa[y];
		cnt--;
		E++;
	}
}


void yes() {
	printf("Yes\n");
	exit(0);
}

void no() {
	printf("No\n");
	exit(0);
}


bool vis[MAXN];
int main() {
	ll n, m, q;
	scanf("%lld%lld%lld", &n, &m, &q);
	init(n);
	vector<pii> qlist;
	while(q--) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if(c == 0) merge(a, b);
		else qlist.emplace_back(a, b);
	}

	for(auto e : qlist)
		if(find(e.first) == find(e.second))
			no();

	if(E + cnt*(cnt-1)/2 < m) no();
	else if(qlist.empty()) yes();
	else if(cnt <= 2) no();

	for(auto e : qlist)
		vis[find(e.first)] = vis[find(e.second)] = true;

	int edgeNum = 0;
	for(int i = 0; i < n; i++)
		if(vis[i]) edgeNum++;
	edgeNum = max(edgeNum, 3);
	if(m-E >= edgeNum) yes();
	else no();
}

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

int main() {
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    double tt = 0;
    int len = 0;
    int nc = 0;
    for (int i = 0; i < n; ++i) {
        int d;
        cin >> d;
        while (len <= d && nc) {
            len += t * v;
            tt += t;
            --nc;
        }
        if (len < d) {
            tt += (d - len) / (u * 1.0);
            len = d;
        }
        if (nc == k) {
            tt += t - (len - d) / (v * 1.0);
            len = d + t * v;
            --nc;
        }
        ++nc;
    }
    {
        int d = l;
        while (len <= d && nc) {
            len += t * v;
            tt += t;
            --nc;
        }
        if (len < d) {
            tt += (d - len) / (u * 1.0);
            len = d;
        }
    }
    printf("%.9lf\n", tt - (len - l) / (v * 1.0));
    return 0;
}

Measured memory_bytes: 3220
import sys
input = sys.stdin.buffer.readline
N=int(input())
val=[list(map(int, input().split())) for i in range(N-1)]

arr=[set() for i in range(N)]
col=[set() for i in range(N)]
colarr=[0]*(N-1)
coldict={}
for i in range(N-1):
    a=val[i][0]-1
    b=val[i][1]-1
    arr[a].add(b)
    arr[b].add(a)
    coldict[(a,b)]=i
colmax=0
flag=0
for i in range(N):
    if len(arr[i])>colmax:
        colmax=len(arr[i])
        flag=i
colall=set(range(1,colmax+1))
coltemp=1
arrtemp=set(arr[flag])
for f in arrtemp:
    p=coltemp
    coltemp+=1
    if flag<f:
        colarr[coldict[(flag,f)]]=p
    else:
        colarr[coldict[(f,flag)]]=p
    col[f].add(p)
    arr[f].remove(flag)
que=[set() for i in range(N)]
que[0]=que[0] | arr[flag]

for i in range(N-1):
    for t in que[i]:
        arrtemp=arr[t]
        if len(arrtemp)>0:
            coltemp=1
            que[i+1] |= arrtemp
            for f in arrtemp:
                while(1):
                    if coltemp not in col[t]:
                        break
                    coltemp+=1
                p=coltemp
                coltemp+=1
                col[f].add(p)
                arr[f].remove(t)
                if t<f:
                    colarr[coldict[(t,f)]]=p
                else:
                    colarr[coldict[(f,t)]]=p
print(colmax)
for i in range(N-1):
    print(colarr[i])

Measured memory_bytes: 126684
//
//  DPL_1_B.cpp
//  
//
//  Created by ?±±?´? ??? on 2015/08/29.
//
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int calc(int, int);

vector<int> v, w;
int N;
vector< vector<int> > memo;

int main(){
    int W;
    
    cin >> N >> W;
    
    v.resize(N);
    w.resize(N);
    memo.resize(N + 1, vector<int>(10001));
    
    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < 10001; j++){
            memo[i][j] = -1;
        }
    }
    
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    
    cout << calc(0, W) << endl;
    
    return 0;
}

int calc(int i, int j){
    if(memo[i][j] != -1){
        return memo[i][j];
    }
    
    int res;
    
    if(i > N - 1){
        res = 0;
    }else if(j < w[i]){
        res = calc(i + 1, j);
    }else{
        res = (int)max(calc(i + 1, j), calc(i + 1, j - w[i]) + v[i]);
    }
    
    memo[i][j] = res;
    return res;
}

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

int main() {
  ll h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
  } else {
    cout << ((h*w)%2==1 ? (h*w)/2+1 : h*w/2) << endl;
  }
  return 0;
}

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

int n,ans=0;

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		if (i%3!=0&&i%5!=0)  ans+=i;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var T = Console.ReadLine();

            var sb = new StringBuilder(T.Length);
            foreach (var c in T)
            {
                switch (c)
                {
                    case '?':
                        sb.Append('D');
                        break;
                    default:
                        sb.Append(c);
                        break;
                }
            }

            Console.WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 27368
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define vi vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define INF 1e18
#define mod 1000000007
#define pb push_back
#define For(k,j) for(int i = k ;i < j ; ++i)
#define endl "\n"
using namespace std;

bool cmp(int a,int b){
	return a>b;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	while(t--){
		int n,l; cin>>n>>l;
		string ar[n];

		For(0,n){
			cin>>ar[i];
		}

		sort(ar,ar+n);

		For(0,n){
			cout<<ar[i];
		}
	}
	return 0;
}

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

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

#define INF 100000000
#define MOD 10007
#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 A,B,C;
  cin>>A>>B>>C;
  cout<<min(B/A,C)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int digits(int x) { return x == 0 ? 0 : 1 + digits(x / 10); }

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += digits(i) % 2;
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
     
     int a,b,c,d;
     cin>>a>>b>>c>>d;
     if((c-1)/b<=(a-1)/d)cout<<"Yes";
     else cout<<"No";
                  
}


        


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> mem(n, 0);
    for(auto& val: mem)
        cin >> val;
    vector<ll> food(n, 0);
    for(auto& val: food)
        cin >> val;
    sort(mem.begin(), mem.end());
    sort(food.begin(), food.end());
    reverse(food.begin(), food.end());
    ll lo = 0, hi = food[0] * mem.back();
    while(lo < hi) {
        ll used = 0;
        ll guess = lo + (hi-lo) / 2;
        for(int i = 0; i < n; i++) {
            if (guess/food[i] < mem[i])
                used += (mem[i]-guess/food[i]);
        }
        // m[i] - x <= guess / f[i]
        if (used > k) { // guess too small
            lo = guess+1;
        } else {
            hi = guess;
        }
    }
    cout << lo << endl;
    return 0;
}




Measured memory_bytes: 3456
def bubble_sort(c, n):
    is_swapped = True
    i = 0
    while is_swapped:
        is_swapped = False
        for j in range(n-1, i, -1):
            if c[j][1] < c[j-1][1]:
                tmp = c[j]
                c[j] = c[j-1]
                c[j-1] = tmp
                is_swapped = True
        i += 1


def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if c[j][1] < c[minj][1]:
                minj = j
        if i != minj:
            tmp = c[i]
            c[i] = c[minj]
            c[minj] = tmp


def make_dict(l):
    result = {}
    for v in l:
        num = v[1]
        if num in result:
            result[num].append(v)
        else:
            result[num] = [v]
    result = {k: v for k, v in result.items() if len(v) >= 2}

    return result


def print_is_stable(before, after):
    is_stable = True
    before_dict = make_dict(before)
    after_dict = make_dict(after)
    for k in before_dict:
        if before_dict[k] != after_dict[k]:
            is_stable = False
            break

    if is_stable:
        print('Stable')
    else:
        print('Not stable')


n = int(input())
a = [i for i in input().split()]
c = a[:]

bubble_sort(c, n)
print(' '.join([str(i) for i in c]))
print_is_stable(a, c)

c = a[:]
selection_sort(c, n)
print(' '.join([str(i) for i in c]))
print_is_stable(a, c)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int C[200000],D[200000];
int rootA(int x){
    if(C[x]==x) return x;
    else return C[x]=rootA(C[x]);
}
int rootB(int x){
    if(D[x]==x) return x;
    else return D[x]=rootB(D[x]);
}
int main(){
    int n,k,l,A[200000][2],B[200000][2];
    cin>>n>>k>>l;
    rep(i,n) C[i+1]=i+1,D[i+1]=i+1;
    rep(i,k){
        cin>>A[i][0]>>A[i][1];
        int a=A[i][0],b=A[i][1];
        a=rootA(a),b=rootA(b);
        if(a!=b) C[a]=b;
    }
    rep(i,l){
        cin>>B[i][0]>>B[i][1];
        int a=B[i][0],b=B[i][1];
        a=rootB(a),b=rootB(b);
        if(a!=b) D[a]=b;
    }
    map<pair<int,int>,int> E;
    rep(i,n) E[make_pair(rootA(i+1),rootB(i+1))]++;
    rep(i,n) cout<<E[make_pair(rootA(i+1),rootB(i+1))]<<" ";
    cout<<endl;
}

Measured memory_bytes: 15360
n, m = gets.to_s.split.map{|t|t.to_i}
 
card_min = 1
card_max =10**5
 
m.times do
  l, r = gets.to_s.split.map{|t|t.to_i}
  card_min = l if card_min < l
  card_max = r if card_max > r
end
 
ans = card_max - card_min + 1

puts ans > 0 ? ans : 0

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);

  if(a>b){
    printf("a > b\n");
  }
  else if(a<b){
    printf("a < b\n");
  }
  else{
    printf("a == b\n");
  }
  
  return 0;
}

Measured memory_bytes: 580
use proconio::input;

fn main() {
    input!{
        s: String,
    };

    let mut count = 0;
    if &s[0..1] == "1" {count += 1}
    if &s[1..2] == "1" {count += 1}
    if &s[2..3] == "1" {count += 1}
    println!("{}", count);
}


Measured memory_bytes: 2144
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem2016a(n, a))
}

fun problem2016a(n: Int, a: List<Int>): Int {
    val map = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        map[i+1] = a[i]
    }
    var count = 0
    for (i in 0 until n) {
        val v = map[i+1]!!
        if (map[v] == i+1) count++
    }
    return count / 2
}

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

const int  maxn=200008;

int n,m,t; 
int b[maxn][3];
int p[maxn];
int a[maxn],l[maxn],r[maxn],sign[maxn];
void build(int x,int y)
{
  t++; b[t][0]=p[x]; p[x]=t; b[t][1]=y;
}
void dfs(int u,int fa)
{
   if (a[u]>=0)
     {
       l[u]=r[u]=a[u];
       sign[u]=a[u] % 2;
     }
   else 
     {
       l[u]=-1e8; r[u]=1e8;
       sign[u]=-1;
     }
   int t=p[u];
   while (t) 
   {
     int y=b[t][1];
     if (y!=fa) 
     {
       dfs(y,u);
       if (sign[y] != -1)
       {
         if (sign[u]==sign[y])
           {
             puts("No");
             exit(0);
           }
       sign[u]=sign[y] ^ 1;
       l[u]=max(l[u],l[y]-1);
       r[u]=min(r[u],r[y]+1);
       if (l[u]>r[u])
         {
           puts("No");
             exit(0);
         }
       }
     }
     t=b[t][0];
   }
}
void redfs(int x,int fa)
{
  if (sign[x]==-1) a[x]=a[fa]+1;
  else
  {
    if (fa)
      if (a[fa]+1>=l[x] && a[fa]+1<=r[x])
        a[x]=a[fa]+1;
       else
        a[x]=a[fa]-1;
    else
      a[x]=l[x];
  }
  int t=p[x];
  while (t)
    {
      int y=b[t][1];
      if (y!=fa) redfs(y,x);
      t=b[t][0];
    }
  
}
int main(){
  cin>>n;
  memset(p,0,sizeof(p));
  memset(a,-1,sizeof(a));
  t=0;
  int x,y;
  for (int i=1;i<=n-1;i++)
    {
      scanf("%d%d",&x,&y);
      build(x,y);
      build(y,x); 
    }
  cin>>m;
  int dis=1000006;
  for (int i=1;i<=n;i++)
    {
      l[i]=-dis;
      r[i]=dis;
    }
    
  for (int i=1;i<=m;i++)
    {
      scanf("%d%d",&x,&y);
      a[x]=y; 
    }
  
  dfs(1,0);
  redfs(1,0);
  puts("Yes");
  for (int i=1;i<=n;i++)
    printf("%d\n",a[i]);
  return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  int dp[k+1][2];
  memset(dp,0,sizeof(dp));

  for(int i=0;i<=k;i++)
  {
    for(int j=0;j<2;j++)
    {
      for(int m=0;m<n;m++)
      {
        if(i-arr[m]>=0)
        dp[i][j] |= !dp[i-arr[m]][1^j];
      }
    }
  }
  cout << (dp[k][0] ? "First" : "Second") << endl;
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn],b[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;rep(i,0,n-1)cin>>a[i];
    int m;cin>>m;rep(i,0,m-1)cin>>b[i];
    cout<<includes(a,a+n,b,b+m)<<endl;
}
/* 
4
1 2 3 4
2
2 4
 */


Measured memory_bytes: 4684
import sys
import numpy as np

#n=int(sys.stdin.readline())
n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

print(max(-1,n-np.sum(a)))


Measured memory_bytes: 27688
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = min(n, m/2);
    n -= ans;
    m -= ans*2;
    ans += m / 4;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 100001

typedef struct {
	char name[10];
	int time;
} process;

typedef struct {
	int head,tail,count,size;
	process *data;
} Queue;

process nullp = {"", 0};

bool isFull(Queue *que);
bool enqueue(Queue *que, process p);
bool isEmpty(Queue *que);
process dequeue(Queue *que, int *err);



int main(){

	int n, q, time=0, i;
	int err;
	process p;

	scanf("%d %d",&n,&q);
	Queue *que = malloc(sizeof(Queue));
  	if (que != NULL) {
    	que->head = 0;
    	que->tail = 0;
    	que->count = 0;
    	que->size = n;
    	que->data = malloc(sizeof(process) * que->size);
    }
    for(i=0; i<n; i++){
    	scanf("%s %d",&p.name, &p.time);
    	enqueue(que, p);
    }

    while(!isEmpty(que)){
    	p = dequeue(que, &err);
    	if(p.time > q){
    		time += q;
    		p.time -=q;
    		enqueue(que, p);
    	}else{
    		time += p.time;
    		printf("%s %d\n",p.name,time);
    	}
    }


	return 0;
}

bool isFull(Queue *que){
  return que->count == que->size;
}

bool enqueue(Queue *que, process p){
  if (isFull(que)) return false;
  que->data[que->tail++] = p;
  que->count++;
  if (que->tail == que->size)
    que->tail = 0;
  return true;
}

bool isEmpty(Queue *que){
  return que->count == 0;
}

process dequeue(Queue *que, int *err){
  if (isEmpty(que)) {
    *err = 0;
    return nullp;
  }
  process p = que->data[que->head++];
  que->count--;
  *err = 1;
  if (que->head == que->size)
    que->head = 0;
  return p;
}

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

int64_t combi( int64_t n, int64_t r ) {
	int64_t p = 1;

	for( int64_t i = 1; i <= r; ++i ) {
		p = p * (n-i + 1) / i;
	}

	return p;
}

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

	map<string,int64_t> sm;
	for( int i = 0; i < N; ++i ) {
		string s;
		cin >> s;

		sort( s.begin(), s.end() );
		sm[s] += 1;
	}

	int64_t result = 0;
	for( const auto& p: sm ) {
		if( p.second >= 2 ) {
			result += combi( p.second, 2 );
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 11264
#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N=100000;
int n,a[MAX_N]={},c=0;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(int i=0;i<n;i++){
		if(a[i]==i+1){
			c++;
			i++;
		}
	}

	cout << c << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int mod = 1e9 + 7;
const int MAXN = 100005;

int n, m;
vector<int> gph[MAXN];
vector<pi> ans;

int vis[MAXN], instk[MAXN];
int prt[MAXN];

int dfs(int x, int p){
	instk[x] = 1;
	vis[x] = 1;
	for(auto &i : gph[x]){
		if(i == p) continue;
		if(!vis[i]){
			int out = dfs(i, x);
			if(out == 0) ans.emplace_back(x, i);
			else ans.emplace_back(i, x);
			prt[x] ^= (1 - out);
		}
		else if(instk[i] && i != p){
			prt[x] ^= 1;
			ans.emplace_back(x, i);
		}
	}
	instk[x] = 0;
	return prt[x];
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=0; i<m; i++){
		int s, e; scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	if(dfs(1, 0)){
		puts("-1");
		return 0;
	}
	for(auto &i : ans) printf("%d %d\n", i.first, i.second);
}


Measured memory_bytes: 15220
n=int(input())
p=0
t=0
for i in range(1,n+1):
  p+=i
  if p>=n:
    t=i
    break
l=range(1,t+1)
if p==n:
  for i in l:
    print(i)
else:
  for i in l:
    if i==p-n:
      continue
    print(i)

Measured memory_bytes: 3408
use std::io;
use std::str::FromStr;

fn seqmax<T>(v: &Vec<T>) -> Option<T> where T: Copy + Ord {
    if v.len() == 0 {
        return None;
    }
    let mut ret = v[0];
    for x in v {
        if ret < *x {
            ret = *x;
        }
    }
    return Some(ret);
}

fn seqmin<T>(v: &Vec<T>) -> Option<T> where T: Copy + Ord {
    if v.len() == 0 {
        return None;
    }
    let mut ret = v[0];
    for x in v {
        if ret > *x {
            ret = *x;
        }
    }
    return Some(ret);
}

fn main() {
    let mut line = String::new();

    io::stdin().read_line(&mut line).unwrap();
    let first_line_words: Vec<&str> = line.trim().split(" ").collect();
    let x = i32::from_str(first_line_words[2]).unwrap();
    let y = i32::from_str(first_line_words[3]).unwrap();

    let mut xs = vec![x];
    let mut ys = vec![y];
   
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    xs.extend(line.trim().split(" ").map(|x| i32::from_str(x).unwrap()));

    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    ys.extend(line.trim().split(" ").map(|x| i32::from_str(x).unwrap()));

    if seqmax(&xs).unwrap() < seqmin(&ys).unwrap() {
        println!("No War");
    } else {
        println!("War");
    }
}

Measured memory_bytes: 4352