akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

//#pragma GCC optimize("Ofast", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;

typedef long double old;
typedef long long ll;

const ll MOD = 998244353;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll ans = 1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        ans = ans * gcd(a[i], i) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] S = in.next().toCharArray();
        int count = 0;
        long answer = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i] == 'W') {
                answer += i - count;
//                System.err.println("i:" + i + "\ncount:" + count + "\nanswer:" + answer);
                count++;
            }
        }
        System.out.println(answer);
    }
}


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

using namespace std;

int main()
{
	int wf[101][101],n;	cin>>n;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)wf[i][j]=1000000;
	for(int i=0;i<n;i++){
		int r,k;	cin>>r>>k;
		for(int t;k--;)	cin>>t,wf[r][t]=1;
	}

	for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);

	int p;	cin>>p;
	while(p--){
		int s,d,ttl;	cin>>s>>d>>ttl;
		if(wf[s][d]<ttl)	cout<<wf[s][d]+1<<endl;
		else	cout<<"NA"<<endl;
	}

	return 0;
}

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

typedef pair<int,int> P;

int main(){
  int n;

  while(cin >> n){
    P t[n + 2];

    for(int i = 0; i < n; i++){
      t[i] = P(0, i);
    }

    for(int i = 0; i < n * (n - 1) / 2; i++){
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      if(c > d){
        t[a - 1].first += 3;
      }
      else if(c < d){
        t[b - 1].first += 3;
      }
      else{
        t[a - 1].first++;
        t[b - 1].first++;
      }
    }

    sort(t, t + n, greater<P>());

    int rank[n];

    for(int i = 0; i < n; i++){
      if(i != 0 && t[i].first == t[i - 1].first){
        rank[t[i].second] = rank[t[i - 1].second];
      }
      else{
        rank[t[i].second] = i + 1;
      }
    }

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

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

vector<pair<int,int>> v;
int fact(int n)
{
    int ans = 1;
    for(int i=2;i<n+1;i++)
    {
        ans *= i;
    }
    return ans;
}


int main(){
    int n;
    cin>>n;
    int x,y;
    repl(){
        cin>>x>>y;
        v.push_back({x,y});
    }
    int f = fact(n-1);
    double sum=0;
    for(int j=0;j<n;j++)
    {
        for(int k=j+1;k<n;k++)
        {
            if(j!=k)
            {
                double X = (v[j].first-v[k].first);
                double Y = (v[j].second-v[k].second);
                double ans = sqrt(X*X+Y*Y);
                sum+= ans;
            }
        }
    }

    sum*= f*2;
    sum = sum/(f*n);
    printf("%.10f\n",sum);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
	int n;cin>>n;
	string s;cin>>s;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<s.length();j++)
		{
			if(s[j]=='Z')s[j]='A';
			else s[j]=(char)(s[j]+1);
		}
	}
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

string s;
int v1, u1;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0') v1++;
            else u1++;
        }
        else
        {
            if (s[i] == '1') v1++;
            else u1++;
        }
    }
    cout << min(v1, u1);
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 100000

string s[MAX];

bool ask(int k){
	cout << k << endl;
	cin >> s[k];
	if(s[k]=="Vacant"){
		return true;
	}
	return false;
}

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

	if(ask(0)) return 0;
	int l=0, r=n-1;
	while(r-l>1){
		int m=(l+r)/2;
		if(ask(m)) break;
		if((s[l]==s[m] && (m-l)%2==0) || (s[l]!=s[m] && (m-l)%2==1)) l=m;
		else r=m;
	}
	if(ask(l)) return 0;
	else if(ask(r)) return 0;
	return 0;
}

Measured memory_bytes: 1620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

struct UnionFind {  
  vector<int> par,sizes;                     // par[i]:iの親の番号(ex)par[3]=2 : 3の親が2
  UnionFind(int n) : par(n),sizes(n,1)  {    //最初は全てが根であるとして初期化
    for(int i=0; i<n; i++){ par[i]=i; }  
  }
  int root(int x) {                       //xが属する木の根を再帰で得る:root(x)={xの木の根}
    if(par[x]==x){ return x; }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {                 // xとyの木を併合
    int rx = root(x);                        //xの根をrx
    int ry = root(y);                        //yの根をry
    if(rx == ry){ return; }                  //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]<sizes[ry]){ swap(rx, ry); } //xの木をおおきくする
    par[ry] = rx; 
    sizes[rx] += sizes[ry];                  //sizes[ry]はもう使わない
  }
  bool check(int x, int y) {                 // x,yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
  int size(int x){                           //xが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main(){
  ll n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());

  vector<ll> cnt(m,n*(n-1)/2);
  UnionFind uf(n);
  rep(i,m-1){
    cnt[m-2-i] = cnt[m-1-i];
    if(!uf.check(a[i],b[i])){
      cnt[m-2-i] -= (ll)uf.size(a[i]) * (ll)uf.size(b[i]);
    }
    uf.unite(a[i],b[i]);
  }
  for(auto ans:cnt){
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;
class Dice{
	int A,S,D,F,G,H,Z;
	Dice(int a,int s,int d,int f,int g,int h){
		A=a;S=s;D=d;F=f;G=g;H=h;
	}
	void turnN() {
		Z=A;
		A=S;S=H;H=G;G=Z;
	}
	void turnS() {
		Z=A;
		A=G;G=H;H=S;S=Z;
	}
	void turnW() {
		Z=A;
		A=D;D=H;H=F;F=Z;
	}
	void turnE() {
		Z=A;
		A=F;F=H;H=D;D=Z;
	}
	void turnright() {
		Z=S;
		S=F;F=G;G=D;D=Z;
	}
	void turnleft() {
		Z=S;
		S=D;D=G;G=F;F=Z;
	}
}
class SameDice{
	boolean b=false;
	Dice ss;
	Dice s;
	void isSameDice() {
	for(int i=0;i<3;i++) {
		ss.turnN();
		for(int j=0;j<4;j++) {
			ss.turnleft();
			if(ss.A==s.A&&ss.S==s.S&&ss.D==s.D&&ss.F==s.F&&ss.G==s.G&&ss.H==s.H) {
				b=true;
			}
		}
		ss.turnE();
		for(int j=0;j<4;j++) {
			ss.turnleft();
			if(ss.A==s.A&&ss.S==s.S&&ss.D==s.D&&ss.F==s.F&&ss.G==s.G&&ss.H==s.H) {
				b=true;
			}
		}
	}
	}
}
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		SameDice S=new SameDice();
		S.ss=new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),
				sc.nextInt(),sc.nextInt(),sc.nextInt());
		S.s=new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),
				sc.nextInt(),sc.nextInt(),sc.nextInt());
		S.isSameDice();
		if(S.b==true) {
			System.out.println("Yes");
		}
		else if(S.b==false) {
			System.out.println("No");
		}
		sc.close();
	}
}



Measured memory_bytes: 26444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if( a % 2 == 0
			|| b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

		scan.close();
	}
}


Measured memory_bytes: 21840
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
  
 int main()
 {
   int arr[5];
   for(int i=0;i<5;i++) cin>>arr[i];
   sort(arr,arr+5);
   for(int i=4;i>=1;i--) cout<<arr[i]<<" ";
   cout<<arr[0]<<endl;
   //while(1);      
   return 0;    
 }

 
 

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

int main() {
  int i;
  string S;
  cin >> S;
  for(i=0; i<S.size(); i++) {
    if(S[i]=='U' || S[i]=='D')
      continue;
    if(i%2==0 && S[i]=='L')
      break;
    if(i%2!=0 && S[i]=='R')
      break;
  }
  
  cout << ((i==S.size())?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>

using namespace std;

bool is_game_end(uint32_t num, vector<int32_t> &players)
{
  uint32_t has_stones = 0;
  uint32_t count = 0;

  for(uint32_t i = 0; i < players.size(); i++){
    if(players[i] > 0){
      has_stones++;
    }
    count += players[i];
  }

  return has_stones == 1 && count == num;
}

int32_t main()
{
  while(true){
    int32_t n, p;
    cin >> n >> p;
    if(n == 0) break;
    vector<int32_t> players(n, 0);

    int32_t in_pot = p;
    do{
      for(uint32_t i = 0; i < players.size(); i++){
        if(in_pot > 0){
          players[i]++;
          in_pot--;
        } else {
          in_pot += players[i];
          players[i] = 0;
        }
      }
    } while(!is_game_end(p, players));

    for(uint32_t i = 0; i < players.size(); i++){
      if(players[i] > 0){
        cout << i << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> edge;
struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> cmp;
	int size;
	UnionFind(int n) :size(n) {
		par.resize(size);
		rank.resize(size);
		cmp.resize(size);
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
			cmp[i] = 1;
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
			cmp[y] += cmp[x];
		}
		else {
			par[y] = x;
			cmp[x] += cmp[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		x = find(x);
		y = find(y);
		return x == y;
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<edge> E;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		E.emplace_back(a, b);
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		UnionFind U(N);
		for (int j = 0; j < M; j++) {
			if (i == j) continue;
			U.unite(E[j].first, E[j].second);
		}
		set<int> S;
		for (int j = 0; j < N; j++) {
			S.insert(U.find(j));
		}
		if (S.size() > 1) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;


int main() {
	int r;
	cin >> r;
	cout << pow(r, 2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
    t = t.substr(1) + t.front();
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int N,i,j,v,k;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
     
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1)printf(" ");    
    }
    printf("\n");
  
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
       
    }
    A[j+1]=v;
  }
 
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k!=N-1)printf(" ");    
  }
  printf("\n");
   
  return 0;
}

Measured memory_bytes: 604
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int min = 100_001;
        for(int i=0; i<n; i++){
            int m = sc.nextInt();
            x -= m;
            min = Math.min(min,m);
        }
        n += (int)(x/min);
        System.out.println(n);
    }
}


Measured memory_bytes: 21844
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    def gen_pattern(x):
        if x < K-1:
            return [[0, x+1], [x+K+1, 2*K]]
        else:
            return [[x-K+1, x+1]]
    def inputs():
        return [int(x) for x in input().split()]
    def inputstr():
        return list(input().split())
    N,K = inputs()
    BB = [[0]*(2*K+1) for _ in range(2*K+1)]
    for i in range(N):
        x,y,c = inputstr()
        if c=="W":
            y = int(y)+K
        x = int(x)%(2*K)
        y = int(y)%(2*K)
        #BB[x,y] += 1
        for shift in [0,K]:
            for b,t in gen_pattern((y+shift)%(2*K)):
                for l,r in gen_pattern((x+shift)%(2*K)):
                    BB[b][l] +=1
                    BB[b][r] -=1
                    BB[t][l] -=1
                    BB[t][r] +=1
    ans = (np.max(np.cumsum(np.cumsum(BB, axis=1), axis=0)))
    #print(BB)
    print(int(ans))
main()


Measured memory_bytes: 106408
N = int(input())
L = list(map(int,input().split()))

dp = [0 for i in range(N)]
dp[1] = abs(L[0] - L[1])

for i in range(2,N) :
    dp[i] = min(dp[i-1] + abs(L[i-1] - L[i]), dp[i-2] + abs(L[i-2] - abs(L[i])))

ans = dp[N-1]

print(ans)


Measured memory_bytes: 13928
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (N) = readInts()
    val xu = (0 until N).map { readLine()!!.split(" ") }

    var yen = 0
    var coin = 0.0
    for ((x, u) in xu) {
        if (u == "JPY") {
            yen += x.toInt()
        } else {
            coin += x.toDouble()
        }
    }
    println(yen + coin * 380000.0)
}

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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;

  int tmp;
  int tmpy;
  if(a+b >= c*2){
    ans = min(x,y) * c*2;
    tmp = min(x,y);
    x -= tmp;
    y -= tmp;
    if(x > y){
      tmp = x;
      tmpy = a;
    }else{
      tmp = y;
      tmpy = b;
    }


    if(tmpy <= c*2){
      ans += tmp * tmpy;
    }else{
      ans += tmp * c*2;
    }
  }else{
    if(a > c*2){
      ans = x * c*2;
      y -= x;
      if(y > 0){
        if(b > c*2){
          ans += y*c*2;
        }else{
          ans += y*b;
        }
      }
    }else if(b > c*2){
      ans = y * c*2;
      x -= y;
      if(x > 0){
        if(a > c*2){
          ans += x*c*2;
        }else{
          ans += x*a;
        }
      }
    }else{
      ans = x*a+y*b;
    }
  }

  cout << ans << endl;
  return 0;
}


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


typedef unsigned long long int ulint;


ulint gs(char v, ulint r, ulint s, ulint p) {
  switch (v) {
  case 'r':
    return p;
  case 's':
    return r;
  case 'p':
    return s;
  }
}
  


int main(){
  ulint N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;

  string T;
  cin >> T;
  
  vector<vector<char>> ts(K);

  for (int i = 0; i < T.size(); ++i) {
    ts[i % K].push_back(T[i]);
  }

  ulint score = 0;



  for (int i = 0; i < K; ++i) {
    bool used = false;
    for (int j = 0; j < ts[i].size(); ++j) {
      if ((j == 0) || (ts[i][j] != ts[i][j-1])) {
	score += gs(ts[i][j], R, S, P);
	used = true;
      } else if (used) {
	used = false;
      } else {
	score += gs(ts[i][j], R, S, P);
	used = true;
      }
      //cout << ts[i][j] << ":" << score << " ";
     
    }
    //cout << endl;
  }
  cout << score << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e3) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int n,m;
vector<P> g[55];

int bfs(int k){
    queue<int> que;
    que.push(0);
    int cnt = 0;
    bool visited[55]{};
    while(!que.empty()){
        int p = que.front();
        que.pop();
        if(visited[p])continue;
        visited[p] = true;
        cnt++;
        for(auto u : g[p]){
            if(u.second == k || visited[u.first])continue;
            que.push(u.first);
        }
    }
    return cnt;
}

int main() {
    cin >> n >> m;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(P(b,i));
        g[b].push_back(P(a,i));
    }
    int ans = 0;
    REP(i,m){
        if(bfs(i)!=n)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
str = gets.chomp

2.step(str.size-2,2) do |n|
  s = str.slice(0,str.size - n)
  s1 = s.slice(0,s.size/2)
  s2 = s.slice(s.size/2,s.size/2)
  if s1 == s2
    puts s.size
    break
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    vector<int> ans(n);
    for (int i=0; i < n; i++){
        int pos=-1;
        for (int j=v.size()-1; j >= 0; j--){
            if (v[j] == j+1){
                pos = j;
                break;
            }
        }
        if (pos==-1){
            cout << -1;
            return 0;
        }
        ans[n-i-1] = pos+1;
        vector<int> p;
        for (int j=0; j < v.size(); j++) if (j != pos) p.push_back(v[j]);
        v=p;
    }
    for (int i=0;i<n;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];

		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();

		int max0 = Math.max(A[0], A[1]);
		int max1 = Math.min(A[0], A[1]);

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

			if (max0 < A[i]) {
				max0 = A[i];
			}
		}

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

			if (A[i] == max0)
				count++;

			if (max1 < A[i] && A[i] != max0)
				max1 = A[i];
		}

		if (count > 1) {
			for (int i = 0; i < N; i++) {
				System.out.println(max0);
			}
		} else {
			for (int i = 0; i < N; i++) {

				if (A[i] != max0)
					System.out.println(max0);
				else
					System.out.println(max1);
			}
		}
	}
}

Measured memory_bytes: 91708
#include<stdio.h>
#include<string.h>
main(){
  int i,l;
  char a[20];
  scanf("%s",a);
  l=strlen(a);
  for(i=l-1;i>=0;i--){
    printf("%c",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include<queue>
using namespace std;
struct ST{
    char name[11];
    int tim;
};
int main(void){
    queue<ST> Q;
    ST syori;
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>syori.name>>syori.tim;
        Q.push(syori);
    }
    int sum=0;
    while(!Q.empty()){
        syori=Q.front();
        Q.pop();
        if(syori.tim<=q){
            cout<<syori.name<<" "<<syori.tim+sum<<endl;
            sum+=syori.tim;
        }
        else{
            sum+=q;
            syori.tim-=q;
            Q.push(syori);
        }
    }
}



Measured memory_bytes: 3596
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let mut an = read_vec::<i64>();
    an.sort();
    an.reverse();
    let a = an.iter()
        .enumerate()
        .filter(|&(k,v)| k % 2 == 0)
        .map(|(k,v)|v)
        .fold(0,|y,x| y+x);
    let b = an.iter()
        .enumerate()
        .filter(|&(k,v)| k % 2 == 1)
        .map(|(k,v)|v)
        .fold(0,|y,x| y+x);
    println!("{}", a -b );
} 

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

int main() {
  int a, b[3], i, num=0;
  cin >> a;
  b[0] = a / 100;
  b[1] = (a % 100) / 10;
  b[2] = (a % 100 % 10) / 1;
  for (i=0; i<3; i++) {
    if (b[i]==1) num++;
  }
  cout << num;

  return 0;
}


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

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
    }

    int ans = 0;
    rep(l,p.size()){
        if(l==0 || l==p.size()-1)
            continue;
        if((p[l-1]>p[l] && p[l+1]<p[l])
        || (p[l-1]<p[l] && p[l+1]>p[l])){
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a < b)
        cout << "a < b" << endl;
    else if (a > b)
        cout << "a > b" << endl;
    else 
        cout << "a == b" << endl;
        return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>

#include<chrono>
#include<initializer_list>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

int main() {
	int a[100]={};
	int x;
	cin>>x;
	--x;
	++a[x];
	cin>>x;
	--x;
	++a[x];
	cin>>x;
	--x;
	++a[x];

	int ans=0;
	for(int i=0;i<100;++i)
		if(a[i]>0)++ans;

	cout<<ans<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> s(3);
  for(int i=0;i<3;i++){
    cin>>s[i];
  }
  int x=700;
  for(int i=0;i<3;i++){
    if(s[i]=='o'){
      x+=100;
    }
  }
  cout<<x;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    if(n / 1000 == (n / 100) % 10) goto A;
    if((n / 100) % 10 == (n / 10) % 10) goto A;
    if((n / 10) % 10 == n % 10) goto A;

    cout << "Good"; return 0;
A:
    cout << "Bad"; return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
D = list(map(int, input().split()))
strN = str(N)
setN = set(list(map(int, strN)))
setD = set(D)

# 10Nが最大という全探索

for ans in range(N, 10 * N + 1):
    s = str(ans)
    flag = True
    for ch in s:
        if int(ch) in setD:
            flag = False
            break
    if flag:
        print(ans)
        exit()

Measured memory_bytes: 40668
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int mod = 1000000007;
const int maxn = 10000005;

template <class T>
inline void write(T x) {
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}

inline int pow(int a, int b) {
	int ans = 1;
	for (; b; a = (LL) a * a % mod, b >>= 1) {
		if (b & 1) {
			ans = (LL) ans * a % mod;
		}
	}
	return ans;
}

int n, k;
int fac[maxn];
int inv[maxn];

inline int C(int m, int n) {
	if (n > m || m < 0 || n < 0) {
		return 0;
	}
	return (LL) fac[m] * inv[n] % mod * inv[m - n] % mod;
}

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

int main() {
//	freopen("ball.in", "r", stdin);
//	freopen("ball.out", "w", stdout);
	scanf("%d%d", &n, &k);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = (LL) fac[i - 1] * i % mod;
	}
	inv[n] = pow(fac[n], mod - 2);
	for (int i = n - 1; ~i; --i) {
		inv[i] = (LL) inv[i + 1] * (i + 1) % mod;
	}
	int A = k, B = n - k;
	for (int i = 1; i <= k; ++i) {
		if (!B && i == 1) {
			puts("1");
		} else {
			int k = 0;
			Add(k, C(B - 1, i - 2));
			Add(k, (C(B - 1, i - 1) << 1));
			Add(k, C(B - 1, i));
			int ans = (LL) C(A - 1, i - 1) * k % mod;
			write(ans);
			puts("");
		}
	}
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

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

vector<P>dat[1500000];
struct st { int a, b, c; }p[500000];
bool operator<(st a, st b) {
	return P(a.a, a.b) < P(b.a, b.b);
}
void init(int k, int l, int r) {
	if (r - l == 1) {
		dat[k].push_back(P(p[l].b, p[l].c)); return;
	}
	int lb = k * 2 + 1, rb = k * 2 + 2;
	init(lb, l, (l + r) / 2);
	init(rb, (l + r) / 2, r);
	dat[k].resize(r - l);
	merge(dat[lb].begin(), dat[lb].end(), dat[rb].begin(), dat[rb].end(), dat[k].begin());
}
vector<int>query(int a, int b, int c, int d, int k, int l, int r) {
	if (b <= l || r <= a)return vector<int>();
	if (a <= l&&r <= b) {
		int u = upper_bound(dat[k].begin(), dat[k].end(), P(d, INT_MAX)) - dat[k].begin();
		int v = upper_bound(dat[k].begin(), dat[k].end(), P(c, INT_MIN)) - dat[k].begin();
		vector<int>res;
		for (int i = v; i < u; i++)res.push_back(dat[k][i].second);
		return res;
	}
	auto lb = query(a, b, c, d, k * 2 + 1, l, (l + r) / 2);
	auto rb = query(a, b, c, d, k * 2 + 2, (l + r) / 2, r);
	for (int i : rb)lb.push_back(i);
	return lb;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d", &p[i].a, &p[i].b), p[i].c = i;
	sort(p, p + n);
	init(0, 0, n);
	int q; scanf("%d", &q);
	rep(i, q) {
		int sx, tx, sy, ty; scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		int a = lower_bound(p, p + n, st{ sx, INT_MIN,0 }) - p;
		int b = lower_bound(p, p + n, st{ tx, INT_MAX,0 }) - p;
		auto res = query(a, b, sy, ty, 0, 0, n);
		sort(res.begin(), res.end());
		for (int j : res)printf("%d\n", j);
		puts("");
	}
}

Measured memory_bytes: 137692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	ll h,w,n;
	cin>>h>>w>>n;
	ll a,b;
	map<pair<ll,ll>,ll>m;
	rep(i,n){
		cin>>a>>b;
		a--;b--;
		rep(j,3){
			rep(k,3){
				if(a-j<0||b-k<0)continue;
				if(a-j>h-3||b-k>w-3)continue;
				m[mpr(a-j,b-k)]++;//正方形の左上の座標で数える
			}
		}
	}vector<ll>v(10,0);
	for(auto x:m){
		v[x.se]++;
	}ll sub=0;
	rep(i,10)sub+=v[i];
	v[0]=(h-2)*(w-2)-sub;
	rep(i,10)cout<<v[i]<<endl;
}


Measured memory_bytes: 58368
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    permitted = 'ACGT'
    continuous_count = []
    count = 0

    for i in range(len(s)):
        char = s[i]
        if char in permitted:
            count += 1
        else:
            continuous_count.append(count)
            count = 0
        if i == len(s) - 1:
            continuous_count.append(count)
    
    if not continuous_count:
        print(len(s))
    else:
        print(max(continuous_count))



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
s = input().split()
a = int(s[0])
x = int(s[1][:-3])
p = int(s[1][-2])
q = int(s[1][-1])
y = a * (100 * x + 10 * p + q)
y = str(y)
if len(y) <= 2:
    print(0)
else :
    print(y[:-2])


Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
#define MIN(a, b) ((a) < (b)? (a): (b))
#define MAX(a, b) ((a) > (b)? (a): (b))
using namespace std;
bool cmp(int a, int b){
	return a > b;
}
int n ,k0;
int v[55];
int hand[55];
int m, sum;

int main(){
	cin >> n >> k0;
	for(int i = 0; i < n; i ++)cin >> v[i];
	
	for(int i = 1; i <= MIN(k0, n); i ++){
		for(int j = 0; j <= i; j ++ ){
			for(int k = 0; k < i; k ++){
				hand[k] = v[(k - j + n) % n];
			}
			sort(hand, hand + i, cmp);
			sum = 0;
			for(int k = 0; k < i - (k0 - i); k ++)sum += hand[k];
			for(int k = MAX(0, i - (k0 - i)); k < i; k ++){
				if(hand[k] > 0)sum += hand[k];
				else break;
			} 
			if(sum > m)m = sum;
		}
			
	}
	cout << m;
	return 0;
}

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

using namespace std;
using ll = long long;

ll sum(ll k){
  ll ret{0};
  while (k != 0){
    ret += k % 10;
    k /= 10;
  }
  return ret;
}


int main(){
  ll N;
  cin >> N;
  if (N % sum(N) == 0){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<long long> p(a), q(b), r(c);
    for (int i = 0; i < a; i++)
        cin >> p[i];
    for (int i = 0; i < b; i++)
        cin >> q[i];
    for (int i = 0; i < c; i++)
        cin >> r[i];
        
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    sort(r.rbegin(),r.rend());

    long long ans = 0;
    vector<long long> v;
    for (int i = 0; i < x; i++)
        v.push_back(p[i]);

    for (int i = 0; i < y; i++)
        v.push_back(q[i]);
        
    for (int i = 0; i < c; i++)
        v.push_back(r[i]);
    
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < x + y; i++)
        ans += v[i];
    
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 8816
#include <cstdio>
#include <iostream>
#include <deque>
#include <cstring>
using namespace std;
bool beginC(char c) {
	return (c == '[' || '(' == c);
}
bool endC(char c) {
	return (c == ']' || ')' == c);
}
bool cuple(char l, char r) {
	return (l == '(' && r == ')') || (l == '[' && r == ']');
}
int size;
bool solve(char str[]) {
	deque<char> deq;
	for (int i = 0; i < size; i++) {
		if (beginC(str[i])) {
			deq.push_front(str[i]);
		}
		else if (endC(str[i])) {
			if (deq.empty()) return false;
			char recent = deq.front();
			if (!cuple(recent, str[i])) {
				return false;
			}
			deq.pop_front();
		}
	}
	return deq.size() == 0;
}

int main() {
	char str_c[128];
	while (1) {
		cin.getline(str_c, 128);
		size = strlen(str_c);
		string str(str_c);
		if (str == ".") return 0;
		cout << (solve(str_c) ? "yes" : "no") <<endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>

int main(){
    using namespace std;
    vector <int> vec{};
    int q;
    int inst1,inst2;

    cin>>q;

    for(int i=0;i<q;i++){
        cin>>inst1;
        switch(inst1){
            case 0:{
                cin>>inst2;
                vec.push_back(inst2);
                break;
            }
            case 1:{
                cin>>inst2;
                cout<<vec[inst2]<<endl;
                break;
            }
            case 2:{
                vec.pop_back();
                break;
            }
        }
    
    }
    return 0;
}


Measured memory_bytes: 3908
function main(input) {
  const formatted_input = input.split('\n');

  const N = parseInt(formatted_input[0], 10);
  const As = formatted_input[1].split(' ').map(x => parseInt(x));

  dp = [];

  for(var i=0;i<N;i++){
    var results = [];
    if(i==0){
      results=[As[i], As[i]*-1]
    }else{
      var not_flipped = Math.max(dp[i-1][0] + As[i], dp[i-1][1] - As[i]);
      var flipped = Math.max(dp[i-1][0] - As[i], dp[i-1][1] + As[i]);
      results = [not_flipped, flipped]
    }
    dp.push(results);
  }

  //console.log(dp);
  console.log(dp[N-1][0]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 49732
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main() {
    int a;
    cin >> a;
    cout << a * a * a << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0;i<n;i++)
using ll = long long;
using P = pair<double,double>;
using Graph = vector<vector<char>>;

int main() {
  double n,t,a;
  cin>>n>>t>>a;
  vector<P> v(n);
  rep(i,n){
    cin>>v.at(i).first;
    v.at(i).second = i+1;
  }
  int sum = -1;
  double ans = 1e5;
  rep(i,n){
    double temp = t - v.at(i).first*0.006;
    if (ans != min(ans,abs(a-temp))){
      sum = v.at(i).second;
      ans = min(ans,abs(a-temp));
    }
  }
  cout << sum << endl;
}

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

#define ll long long

int main()
{
    ll h,w,ans;
    cin>>h>>w;
    if(h%2==0)
    {
        if(w%2==0)
        {
            ans=(w/2)*h;
        }
        else
        {
            ll a=((w/2)+1)*(h/2);
            ll b=(w/2)*(h/2);
            ans=a+b;
        }
    }
    else if(w==1||h==1)
        ans=1;
    else
    {
        if(w%2==0)
        {
            ans=(w/2)*h;
        }
        else
        {
            ll a=((w/2)+1)*((h/2)+1);
            ll b=(w/2)*(h/2);
            ans=a+b;
        }
    }
    printf("%lld\n",ans);
}


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

int main(){
  int N, K, i, num = 1;
  cin >> N;
  cin >> K;
  for(i = 0; i < N; i++)
  {
    if(num*2 <= num + K)
    {
      num *= 2;
    }else
    {
      num += K;
    }
  }
  cout << num << endl;

  return 0;
}

Measured memory_bytes: 3600
n = int(input())
kuku = [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81]
if n in kuku:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

find={}
find["S"]=array(13,1,0)
find["H"]=array(13,1,0)
find["C"]=array(13,1,0)
find["D"]=array(13,1,0)

n=gets.to_i
n.times do|i|
  a,b=get
  find[a][b.to_i-1]=1
end
["S","H","C","D"].each do|rank|
  13.times do|i|
    if find[rank][i].zero?
      puts "#{rank} #{i+1}"
    end
  end
end


Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll cnt = 0LL;
  rep(i,n) if(s[i]=='R') cnt++;
  ll cnt2 = 0LL;
  rep(i,cnt) if(s[i]=='R') cnt2++;
  ll ans = cnt - cnt2;
  cout << min(ans,n-ans) << endl;
  return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int h[200000],dp[200000];
int k;
int cost(int i)
{
	if(i==1)
	{
		dp[1] = 0;
		return 0;
	}
	if(dp[i]!=-1)
	{
		return dp[i];
	}
	int min = INT_MAX;
	for(int j = i-1; j >0 && j>=i-k ;j--)
	{
		int g = cost(j) + abs(h[i]-h[j]);
		if((g) < min  )
		{
			min = g;
		}
	}
	dp[i] = min;
	return dp[i];
}
int main()
{
	int n;
	cin>>n>>k;
	for (int i = 1; i <= n; ++i)
	{
		dp[i] = -1;
	}
	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i];
	}

	cout<<cost(n)<<endl;

	
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    ll dx, dy;
    cin >> s >> dx >> dy;
    s.push_back('T');
    set<ll> x, y;
    x.insert(0);
    y.insert(0);
    ll seq = 0, cnt = 0;
    for(auto e : s){
        if(e == 'F'){
            seq++;
        }else{
            set<ll> st;
            if(cnt % 2 == 0){
                for(auto p : x){
                    st.insert(p + seq);
                    if(cnt != 0) st.insert(p - seq);
                }
                x = st;
            }else{
                for(auto p : y){
                    st.insert(p + seq);
                    st.insert(p - seq);
                }
                y = st;
            }
            seq = 0;
            cnt++;
        }
    }
    if(x.count(dx) > 0 && y.count(dy) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  n%=10;
  if(n==2 or n==4 or n==5 or n==7 or n==9) cout<<"hon"<<newl;
  if(n==0 or n==1 or n==6 or n==8) cout<<"pon"<<newl;
  if(n==3) cout<<"bon"<<newl;

  return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;

int main()
{
    string s;
    cin >> s;
    char prev = s[0]; int cnt = 0;
    for (int i=1; i<s.length(); i++) {
        //cout << prev << ' ' << s[i] << ' ' << cnt << '\n';
        if (prev == s[i]) {
            cnt++;
            if (s[i] == '1') prev = '0';
            else prev = '1';
        }
        else prev = s[i];
    }
    cout << cnt << '\n';
    
    return 0;
}

Measured memory_bytes: 3700
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll R;

int main() {
	scanf("%lld", &R);
	cout << 3 * R * R << " ";
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  int n , m;
  cin >> n >> m;
  
  ll count =0;
  vector<int>a(m);
  for(int i=0; i<m; i++){
    cin >> a[i];
    count+=a[i];
  }
  
  ll ans = n-count;
  
  if(ans<0) cout << -1 << endl;
  else cout << ans << endl;
    
  
  

}

Measured memory_bytes: 3672
/**
 * ?????????:O(n^2)
 * ??±?????????????¨?????????´??\?????¢??????????????????????´?,?±????????¨???????????????????
 */
#include <stdio.h>

// ????????????,????????????????????¢????¬???°
int selectionSort(int A[], int N){
	int i, j, minj, sw = 0, tmp;
	for(i = 0; i < N-1; i++){
		minj = i;
		for(j = i+1; j < N; j++){ // ???????????°????°????
			if(A[minj] > A[j]) minj = j;
		}
		if(i != minj) { // ?????¢
			tmp = A[minj]; A[minj] = A[i]; A[i] = tmp; 
			sw++;
		} 
	}
	return sw;
}

int main(){
	//freopen("in.txt", "r", stdin);
	int i,N,A[100],sw;
	while(~scanf("%d", &N)) {
	    for(i = 0; i < N; i++) scanf("%d", &A[i]);
           sw = selectionSort(A, N);
           for(i = 0; i < N; i++){
           	if(i > 0) printf(" ");
           	printf("%d", A[i]);
           }
           printf("\n");
           printf("%d\n", sw);
	}
	return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	FORR(a, 0, 9)FORR(b, 0, 9)FORR(c, 0, 9) {
		bool ok = false;
		bool ok2 = false;
		bool ok3 = false;
		rep(i, n) {
			if (ok2&&s[i] - '0' == c)ok3 = true;
			else if (ok&&s[i] - '0' == b)ok2 = true;
			else if (s[i] - '0' == a)ok = true;
		}
		if (ok3)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
//typedef cpp_int c_i;
#include<bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define p0(x) cout <<x <<" "
#define p1(x) cout <<x <<endl
#define p2(x,y) cout <<x <<" " <<y <<endl
#define p3(x,y,z) cout <<x <<" " <<y <<" " <<z <<endl
#define p4(w,x,y,z) cout <<w <<" " <<x <<" " <<y <<" " <<z <<endl
#define nl cout<<endl
# define pb push_back
#define mp make_pair
#define mp make_pair
# define vi vector<int>
# define vll vector<ll>
# define vvi vector< vector <int> >
#define ff first
#define ss second
# define vvll vector<vector <ll> >
# define srt(a) sort(a.begin(),a.end())
# define f(i,a,b) for(int i=a;i<b;i++)
# define frev(i,a,b) for(int i=a;i>=b;i--)
# define srtrev(a) sort(a.begin(),a.end(),cmp)
#define gcd(a,b) __gcd(a,b);
#define lcm(a,b)   (a/gcd(a,b))*b;
using namespace std;
#define Map map<int,int>
#define Umap unordered_map<int,int> 
ll limit = 1000000007;
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);  
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool cmp(ll a,ll b)
{
	return a>b;
}
ll Pow(ll a,ll b )  //for modulus power
{
	ll ans=1,mul=a;
	while(b)
	{
		if(b&1)ans=(ans*mul)%limit;
		mul=(mul*mul)%limit;
		b/=2;
	}
	return ans;
}
 
 
void solve()
{
	int n;
	cin>>n;
	int arr[n],a[n];
	f(i,0,n)
	{
		cin>>arr[i];
		a[i]=arr[i];
	}
	sort(a,a+n,cmp);
	f(i,0,n)
	{
		if(arr[i]==a[0])
		cout<<a[1]<<'\n';
		else
		cout<<a[0]<<'\n';
	}
}
//driver function
    int main()
    {
		//fast
		int t=1;
		//cin>>t;
		f(T,1,t+1)
		{
			//cout<<"Case #"<<T<<": ";
			solve();
		}
    }


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    ll cnt = 0;
    rep(i,0,n){
        cin >> a[i];
        if(i % 2 == 0 && a[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	repl(i, 1, m + 1) {
		repl(j, 1, d + 1) {
			int p = j / 10, q = j % 10;
			if (2 <= p and p <= 9 and 2 <= q and q <= 9) {
				if (p * q == i) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 500
struct P{int z,k;}p[MN+5];
bool cmp(const P&a,const P&b){return a.k<b.k;}
int s1[MN+5],s2[MN+5],x[MN*MN+5];
int main()
{
	int n=read(),i,j,k;
	for(i=1;i<=n;++i)p[i].z=i,x[p[i].k=read()]=i,s1[i]=i-1,s2[i]=n-i;
	sort(p+1,p+n+1,cmp);
	for(i=j=k=1;i<=n*n;++i)if(!x[i])
	{
		while(j<=n&&!s1[p[j].z])++j;
		if(j<=n){if(i>p[j].k)return 0*puts("No");--s1[x[i]=p[j].z];continue;}
		while(!s2[p[k].z])++k;
		if(i<p[k].k)return 0*puts("No");--s2[x[i]=p[k].z];
	}
	puts("Yes");
	for(i=1;i<=n*n;++i)printf("%d ",x[i]);
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define inf 1000000000000000000
const double pi = acos(-1);
const int sz = 200002;
ll n, m, q, k;
void solve(ll n) 
{ 
    char str[5000]; 
    ll i = 0; 
  
    while (n > 0) { 
        ll rem = n % 26; 
  
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  
    return; 
} 
int main() {
	io
	cin>>n;
	solve(n);
}


Measured memory_bytes: 3664
X=int(input())
if 1800<=X:
    print(1)
elif 1600<=X:
    print(2)
elif 1400<=X:
    print(3)
elif 1200<=X:
    print(4)
elif 1000<=X:
    print(5)
elif 800<=X:
    print(6)
elif 600<=X:
    print(7)
elif 400<=X:
    print(8)


Measured memory_bytes: 61656