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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n, k;
    vector<ll > v;
    string s;

    cin >> n >> k;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        v.PB(tmp);
    }

    sort(ALL(v));

    ll ans = 0;
    REP(i, k){
        ans += v[i];
    }

  	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int  MOD = 1e9 + 7, OO = 1e9;
const int  N = 1e5 + 10;
int vis[N][3];
vector<int> g[3][N];
set<int> st[2];
void dfs(int u, int t) {
	if (vis[u][t])return;
	vis[u][t] = 1;
	st[t].insert(u);
	for (int i = 0; i < g[t][u].size(); ++i) {
		dfs(g[t][u][i], !t);
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		g[0][a].pb(b);
		g[1][b].pb(a);
	}
	ll ans = 0;
	for (int it = 0; it < 2; ++it) {
		for (int i = 1; i < N; ++i) {
			dfs(i, it);
			ans += st[0].size()*1ll*st[1].size();
			st[1].clear();
			st[0].clear();
		}
	}
	cout << ans - n << endl;

}

Measured memory_bytes: 19200
fun main(args:Array<String>) {
    val (n,m,c) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0
    (1..n).forEach {
        val src = readLine()!!.split(" ").map { it.toInt() }
        val total = (0 until m).map { list[it]*src[it] }.sum()
        if (total + c > 0) {
            ans+=1
        }
    }
    println(ans)

}


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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i,n) cin >> h.at(i);
    rep(i,m) cin >> a.at(i) >> b.at(i);

    vector<ll> ans_layer(n,1);
    rep(i,m){
        if(h.at(a.at(i)-1) > h.at(b.at(i)-1)) ans_layer.at(b.at(i)-1)--;
        else if(h.at(a.at(i)-1) < h.at(b.at(i)-1)) ans_layer.at(a.at(i)-1)--;
        else {
            ans_layer.at(a.at(i)-1)-- ;
            ans_layer.at(b.at(i)-1)--;
        }
    }
    ll ans=0;
    rep(i,n) {
//        cout << ans_layer.at(i) << endl;
        if(ans_layer.at(i) == 1) ans++;
    }
    cout << ans <<endl;



    return 0;
}

Measured memory_bytes: 6372
#!/usr/bin/python3
#coding: utf-8

N, A, B = (int(i) for i in input().split())
X = [int(x) for x in input().split()]

ret = 0

for i in range(1, N):
    d = X[i] - X[i-1]
    if d * A <= B:
        ret += d*A
    else:
        ret += B

print(ret)


Measured memory_bytes: 20144
package main

import (
	"fmt"
	"sort"
)

func sliceUnique(target []int) (unique []int) {
	m := map[int]bool{}

	for _, v := range target {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}

	return unique
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if m > n {
		return
	}
	points := make([]int, n)
	sum := 0

	for i:=0; i<n; i++{
		fmt.Scan(&points[i])
		sum += points[i]
	}


	sort.Sort(sort.Reverse(sort.IntSlice(points)))
	unique_points := sliceUnique(points)

	count := 0
	for i := 0; i < n; i++ {
		if unique_points[i]*4*m >= sum {
			count++
		}
	}
	if count >= m {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")


}

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

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	
	for(string::iterator it = S.begin(); it != S.end(); it++){
		*it = (char) ((((int) *it - 65 + N)%26) + 65);
		cout << *it;
	}
	
	cout << endl;
	return 0;
}
	
	


Measured memory_bytes: 256
import math


def main():
    S = input()
    arr = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT',
           'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
    ans = 0
    flag = False

    if S == 'SUN':
        print(7)
        return

    for i in range(len(arr)):
        if arr[i] == S:
            flag = True

        if flag and arr[i] == 'SUN':
            break

        if flag:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=555;
int n,mod;
LL dp[Maxn][Maxn];
int f[Maxn],g[Maxn];
int rf[Maxn],rg[Maxn];
int pf[Maxn];
int ord[Maxn*2],ko;
LL coef[Maxn][Maxn];
bool cmp(int x,int y){
	int vx,vy;
	if (x<0) vx=g[~x];
	else vx=f[x];
	if (y<0) vy=g[~y];
	else vy=f[y];
	if (vx!=vy) return vx<vy;
	if (x<0 && y>=0) return x<y;
	if (x>=0 && y<0) return x<y;
	if (x<0)return x<y;
	return x>y;
}
void Add(LL &x,LL y){
	x+=y;
	if (x>=mod) x-=mod;
}
int main(){
	scanf("%d%d",&n,&mod);
	int t=n;
	for (int i=0;i<n;i++){
		while (t*t+i*i>=n*n) t--;
		f[i]=t+1;
	}
	t=2*n-1;
	for (int i=0;i<2*n;i++){
		while (t*t+i*i>n*n*4) t--;
		g[i]=t+1;
	}
	for (int i=0;i<n;i++) ord[ko++]=i;
	for (int i=0;i<2*n;i++) ord[ko++]=~i;
	sort(ord,ord+ko,cmp);
	for (int i=0;i<ko;i++){
		if (ord[i]>=0) rf[ord[i]]=i;
		else rg[~ord[i]]=i;
	}
	int tmp=0;
	for (int i=0;i<n;i++){
		while (tmp<=2*n-1 && rg[tmp]>rf[i]){
			tmp++;
		}
		pf[i]=tmp;
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<=2*n;j++){
			coef[i][j]=1;
			int cur=j;
			int pp=(i)?pf[i-1]:n;
		//	cout<<i<<' '<<j<<' '<<pp<<endl;
			for (int k=pf[i]-1;k>=pp;k--){
				coef[i][j]=coef[i][j]*(g[k]-cur)%mod;
		//		cout<<g[k]-cur<<endl;
				cur++;
			}
		//	cout<<coef[i][j]<<endl;
		}
	}
	LL ans=0;
	for (int k=0;k<=n;k++){
		LL cf=(k&1)?1:-1;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
	//	cout<<k<<endl;
		for (int i=0;i<=n;i++){
			for (int j=0;j<=min(i,k);j++){
			//	cout<<i<<' '<<j<<" "<<dp[i][j]<<endl;
				if (!dp[i][j] || i==n) continue;
				int pos=n-k+j+pf[i]-n;
				pos=2*n-1-pos;
				if (j+1<=k){
					LL C1=1ll*(f[i]-pos)*coef[i][pos+1]%mod;
					Add(dp[i+1][j+1],dp[i][j]*C1%mod);
				}
				
				int pos2=2*n-1-(i-j);
			//	cout<<g[i]-pos2<<endl;
			//	cout<<"FF"<<" "<<g[i]-pos2<<' '<<coef[i][pos+1]<<' '<<pos<<endl;
				Add(dp[i+1][j],dp[i][j]*(g[i]-pos2)%mod*coef[i][pos+1]%mod);
			}
		}
	//	cout<<k<<' '<<dp[n][k]<<endl;
		if (k&1) ans-=dp[n][k];
		else ans+=dp[n][k];
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main() {
    int a;
    int 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: 3088
def f(x):
    y=x[:n];heapify(y);z=sum(y);s=[z]
    for i in x[n:n*2]:z+=i-heappushpop(y,i);s+=[z]
    return s
from heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f([-i for i in a[n:][::-1]]),f(a)[::-1]))))

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

int main() {
  int n;
  string s;
  cin >> s;
  n = s.length();
  for (int i = 0; i <= (n - 1) / 2 - 1 - i; i++) {
    if (s[i] != s[(n - 1) / 2 - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n / 2 - 1 - i; i++) {
    if (s[(n + 3) / 2 - 1 + i] != s[n - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << 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 A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        sc.close();

        int count=0;
        for (int i = A; i < B; i++) {
            if (C <= i && i < D) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23508
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
# if any(item%2==1 for item in a):
if not all(item%2==0 for item in a):
    ans = "first"
else:
    ans = "second"
print(ans)

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

#define NIL -1
#define MAX 500000

struct node{
  int parent;
  int left;
  int right;
  int key;
};
typedef struct node Node;

void insert(int);
void inorder(int);
void preorder(int);

int  root=-1;
Node T[MAX];

int main(){
  int i, n;
  char str[10];

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].left=T[i].right=T[i].parent=-1;

  for (i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%d",&T[i].key);
      insert(i);
    }
    else if(strcmp(str,"print")==0){
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}

void insert(int z){//printf("in\n" );
  int y = -1;
  int x = root;

  while(x != -1){
    y = x;
    if(T[z].key < T[x].key) x = T[x].left;
    else x = T[x].right;
  }

  T[z].parent = y;

  if(y == -1) root = z;

  else if(T[z].key < T[y].key) T[y].left = z;

  else T[y].right = z;
}

void inorder(int t){
  if(t != -1){
    inorder(T[t].left);
    printf(" %d",T[t].key);
    inorder(T[t].right);
  }
}

void preorder(int t){
  if(t != -1){
    printf(" %d",T[t].key);
    preorder(T[t].left);
    preorder(T[t].right);
  }
}

Measured memory_bytes: 8412
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		boolean[][] found = new boolean[4][13];
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		while(n-- > 0){
			String mark = sc.next();
			int markNum = 0;
			if(mark.equals("S")) markNum = 0;
			else if(mark.equals("H")) markNum = 1;
			else if(mark.equals("C")) markNum = 2;
			else if(mark.equals("D")) markNum = 3;
			int num = sc.nextInt();
			found[markNum][num-1] = true;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				if(!found[i][j]){
					if(i == 0) System.out.print("S");
					else if(i == 1) System.out.print("H");
					else if(i == 2) System.out.print("C");
					else if(i == 3) System.out.print("D");
					System.out.println(" " + (j+1));
				}
			}
		}
	}

}

Measured memory_bytes: 26336
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int four = 0;
  int two = 0;
  for(int i=0; i<N; i++){
    if(vec.at(i) %4 == 0){
      four++;
    }
    else if(vec.at(i) %2 == 0){
      two++;
    }
  }
  
  bool exist = false;
  if(four >= N/2){
    exist = true;
  }
  if(N - four*2 <= two){
    exist = true;
  }
  
  if(exist){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 640
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int h = in.nextInt();
        int w = in.nextInt();
        int n = in.nextInt();
        int[][] map = new int[h][w];
        int y = 0, x = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            for (int j = 0; j < a; j++) {
                map[y][x] = i + 1;
                if (y % 2 == 0) {
                    if (x < w - 1) x++;
                    else y++;
                } else {
                    if (x > 0) x--;
                    else y++;
                }
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j > 0) out.print(" ");
                out.print(map[i][j]);
            }
            out.println();
        }
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 25556
#include <stdio.h>
#include <math.h>

#define DEBUG

#ifndef DEBUG 
#define fprintf (void)
#endif 

int main(void){
	int i,j;
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 2604
import re

S = input()
N = [0]*len(S)

RL = [m.start() for m in re.finditer('RL', S)]

def search(k):
    i = k
    j = k+1
    count_a = 0
    count_b = 0
    #左側探索
    while S[i] != "L":
        if (k-i) % 2 ==0:
            count_a += 1
        else:
            count_b += 1
        i -= 1
    
    while S[j] != "R":
        if (k-j) % 2 ==0:
            count_a += 1
        else:
            count_b += 1
        j += 1
        if j == len(S):
            break
        
    return [count_a, count_b]

for i in range(len(RL)):
    k = RL[i] 
    p = search(k)
    N[k] = p[0]
    N[k+1] = p[1]

print(*N)

Measured memory_bytes: 50396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int x;
    cin>>x;
    if(x<1200) cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    return 0;
}

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

int n, k;
int a[200000];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());
  
  long sum = 0;
  for (int i = k; i < n; ++i) {
    sum += a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
const int maxn = 200009;
const int MOD = 1e9 + 7;
const long double inf = 2e18;
long long N, A, B, C, D;
map<long long, long long> dp;
long long gao(__int128_t n) {
  if (dp.count((long long)n)) return dp[(long long)n];
  __int128_t res = 1e27;
  res = min(res, n * D);
  res = min(res, gao(n / 2) + A + (n % 2) * D);
  if (n % 2)
    res = min(res, gao(n / 2 + 1) + A + (2 - (n % 2)) * D);
  res = min(res, gao(n / 3) + B + (n % 3) * D);
  if (n % 3)
    res = min(res, gao(n / 3 + 1) + B + (3 - (n % 3)) * D);
  res = min(res, gao(n / 5) + C + (n % 5) * D);
  if (n % 5)
    res = min(res, gao(n / 5 + 1) + C + (5 - (n % 5)) * D);
  return dp[(long long)n] = (long long)res;
}
int main() {
  FPEN FPEN2;
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> N >> A >> B >> C >> D;
    dp.clear();
    dp[0] = 0;
    dp[1] = D;
    cout << gao(N) << '\n';
  }
  return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
vector<vector<lint> > G;
vector<lint> color;
lint N, M;
lint ans;

bool dfs(lint v, lint c){
	color[v] = c;
	for(lint i = 0; i < G[v].size(); i++){
		lint next = G[v][i];
		if(color[next] == c) return false;
		if(color[next] == 0 && !dfs(next, -c)) return false;
	}
	return true;
}

signed main(){
	cin >> N >> M;
	G.resize(N); color.resize(N, 0);
	for(lint i = 0; i < M; i++){
		lint a, b; scanf("%d%d", &a, &b); --a; --b;
		G[a].push_back(b); G[b].push_back(a);
	}
	bool ok = true;
	for(lint i = 0; i < N; i++){
		if(color[i] == 0){
			if(!dfs(i, 1)) ok = false;
		}
	}
	if(ok){
		lint W = 0;
		for(int i = 0; i < N; i++) if(color[i] == -1) W++;
		lint B = N - W;
		ans = W * B - M;
	}
	else  ans = N * (N - 1) / 2 - M;
	cout << ans << endl;
}


Measured memory_bytes: 7424
n, m, l = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
s = [[0] * l for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            s[i][j] += a[i][k] * b[k][j]

for i in range(n):
        print(" ".join(map(str, s[i])))


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

using namespace std;

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int c, a, n;
        cin >> c >> a >> n;
        int g1 = min(c, min(a, n));
        int g2 = min(max(c - g1, 0) / 2, max(a - g1, 0));
        cout << g1 + g2 + max(c - g1 - g2 * 2, 0) / 3 << endl;
    }
}

Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b;
    }
    else if (a>=6&&a<13)
    {
        cout<<b*.5;
    }
    else
        cout<<0;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        string[] t = s.Split(' ');

        //変数の割り当て
        ulong N = ulong.Parse(t[0]);
        ulong P = ulong.Parse(t[1]);

        //回答となる数字
        ulong ans = 1;

        //PのN乗根から、割り切れる最大の値をチェックする
        for (ulong i = (ulong)Math.Pow(P, 1.0 / (double)N) + 1; i >= 1; i--) {
            //iのN乗でPを割り切れるか判定
            if (P % (Math.Pow(i, N)) == 0) {
                ans = i; 
                break;
            }
        }

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

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

  long long N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int g = A[0];
  for(int i = 1; i < N; i++) {
    g = gcd(g, A[i]);
  }

  cout << g << endl;
  
  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while (N) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


def judge_prime_num(n):
    if n % 2 == 0 and n != 2:
        return False
    else:
        for num in range(3, int(math.sqrt(n) + 2)):
            if n % num == 0:
                return False
        return True


prime_list = []
for i in range(2, 1121):
    if judge_prime_num(i):
        prime_list.append(i)

dp = [[[0] * 1122 for _ in range(16)] for _ in range(190)]
dp[0][0][0] = 1
for i in range(len(prime_list)):
    for j in range(15):
        for k in range(1121):
            if k + prime_list[i] <= 1120:
                dp[i + 1][j + 1][k + prime_list[i]] += dp[i][j][k]
            dp[i + 1][j][k] += dp[i][j][k]
n, k = map(int, input().split())
while not n == k == 0:
    print(dp[len(prime_list)][k][n])
    n, k = map(int, input().split())



Measured memory_bytes: 85540
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int N, M, A;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A;
		N -= A;
	}
	if (N < 0) {
		cout << -1 << endl;
	}
	else {
		cout << N << endl;
	}
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(){

    long X,K,D;//初期、回数、移動

    scanf("%ld %ld %ld",&X,&K,&D);

    long Q;

    if(X<0){
        X*=-1;
    }

    Q=X/D;//チェックポイント
    //printf("%d\n",Q);

    if(K<=Q){
        printf("%ld\n",(X-K*D));
    }else{
        K-=Q;
        //printf("%d\n",K);
        if(K%2==0){
            printf("%ld\n",(X-D*Q));
        }else{
            printf("%ld\n",(X-D*(Q+1))*(-1));
        }
    }
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int n;
  n=s.size();
  int saidai=0;
  for(int i=0;i<n;i++){
    int count=0;
    while(s[i+count]=='A'||s[i+count]=='T'||s[i+count]=='C'||s[i+count]=='G'){
      //cout<<s[i+count];
      count++;
      if(count>=n)break;
      if(s[i+count]!='A'&&s[i+count]!='T'&&s[i+count]!='C'&&s[i+count]!='G')break;
    }
    saidai=max(saidai,count);
  }
  cout<<saidai<<endl;
  return 0;
}

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

typedef pair<long long, long long> pi;
typedef pair<long long, pi> pii;

long long n, m, a, b, c, f, d[101][101];
vector<pii> edges;
int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){\
		for(int j = 1; j <= n; j++){
			if(i != j) d[i][j] = INT_MAX;
		}
	}
	for(int i = 0; i < m; i++){
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
		edges.push_back(pii(c, pi(a, b)));
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
	for(int i = 0; i < edges.size(); i++){
		bool found = false;
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(d[j][edges[i].second.first]+d[k][edges[i].second.second]+edges[i].first == d[j][k]){
					found = true;
					break;
				}
			}
		}
		if(!found) f++;
	}
	cout << f;
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  n <- readLn :: IO Int
  let ans = VU.length $ VU.filter (\n -> odd n) $ VU.map (\n -> length $ show n) $ VU.generate n (\i -> i+1)
  -- print n
  print ans


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int s;
  cin >> s;
  vector<int> a = {s};
  int i = 0;
  while (true) {
    bool flag = false;
    if (a.at(i) % 2 == 0) {
      a.push_back(a.at(i) / 2);
    }
    else {
      a.push_back(a.at(i) * 3 + 1);
    }
    REP(j, a.size() - 1) {
      if (a.at(i + 1) == a.at(j)) {
        flag = true;
        break;
      }
    }
    i++;
    if (flag) {
      break;
    }
  }
  cout << i + 1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            long[] H = cin.ReadLongArray(N);
            long tmpCount = 0;
            long ans = 0;
            for(long i = 0; i < N - 1; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    tmpCount++;
                    if (tmpCount > ans)
                    {
                        ans = tmpCount;
                    }
                }
                else
                {
                    tmpCount = 0;
                }
            }
            Console.WriteLine(ans);
        }
            

                
    }  
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  int N,M;
  cin >> N >> M;
  vector<string> v(N);
  vector<string> w(M);

  for(int i =0; i < N; i++){
    cin >> v[i];
  }
  for(int i =0; i < M; i++){
    cin >> w[i];
  }

  bool ans_flg = false;
  for(int i = 0; i < N-M+1; i++){
    for(int j = 0; j < N-M+1; j++){
      bool flg = true;
      // 1つでもfalseになれば、ijを更新する
      for(int k = 0; k < M; k++){
        for(int l = 0; l < M; l++){
          if(v[i+k][j+l] != w[k][l]){
            flg = false;
            break;
          }
        }
        if(!flg) break;
      }
      if(flg){
        ans_flg = true;
        break;
      }
      if(!flg){
        continue;
      }
    }
    if(ans_flg){
      break;
    }
  }

  cout << (ans_flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>

#define FOR(n) for(int cnt=0;cnt<(n);++cnt)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))

using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int N,X,Y,Z;
ll MOD = 1ll * 1000 * 1000* 1000 + 7;
ll dp[45][1<<17];
ll pow10(int ind) {
  if (ind==0) return 1;
  return  AS_MOD(10 * pow10(ind-1),MOD);
}
bool ok(vector<int>& refV) {
  int zyx[]={Z,Y,X};
  for(int i=refV.size()-1,j=0;i>=0;--i) {
    zyx[j]-=refV[i];
    if (zyx[j]<0) return true;
    if (zyx[j]==0) {
      ++j;
      if (j==3) {
        return false;
      }
    }
  }
  return true;
}
int toPrev(vector<int>& refV) {
  int answer = 0;
  for(int i=refV.size()-1,j=0;i>=0;--i) {
    answer += 1<<(refV[i]-1 + j);
    j+= refV[i];
    if (answer>1<<16) {
      return answer & ((1<<16)-1);
    }
  }
  return answer & ((1<<16)-1);
}
ll doDP(int cur, int prev) {
  if (cur==N) {
    return 1;
  }
  if (dp[cur][prev]!=-1) {
    return dp[cur][prev];
  }
  ll sub=0;
  vector<int> temp;
  for(int i=0,j=0;i<16;++i) {
    if (prev>>i & 1) {
      temp.insert(temp.begin(), j+1);
      j=0;
    } else {
      ++j;
    }
  }
  temp.push_back(0);
  for(int i=1;i<=10;++i) {
    temp[temp.size()-1]=i;
    if (ok(temp)) {
      sub += AS_MOD(doDP(cur+1, toPrev(temp)),MOD);
      sub = AS_MOD(sub, MOD);
    }
  }
  return dp[cur][prev]=AS_MOD(sub, MOD);
}
int main() {
  scanf("%d%d%d%d", &N, &X, &Y, &Z);
  for(int i=0;i<41;++i) {
    for(int j=0;j< 1 << 17;++j) {
      dp[i][j]=-1;
    }
  }
  printf("%lld\n", AS_MOD(pow10(N)-doDP(0,0), MOD));
  return 0;
}


Measured memory_bytes: 43264
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n;
	long long x,y,t[1000],a[1000],syo1,syo2,ama1,ama2,mx,xx,yy;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%lld %lld",&t[i],&a[i]);
	x=t[0];	y=a[0];
	for(i=1;i<n;i++)	{
		syo1=x/t[i];	syo2=y/a[i];
		if(x%t[i]!=0)	syo1++;
		if(y%a[i]!=0)	syo2++;
		mx=max(syo1,syo2);
		x=mx*t[i];	y=mx*a[i];
	}
	printf("%lld\n",x+y);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int tree[500000];
int n;
void update(int i,int x);
int find(int s,int t,int node,int left,int right);
int main(){
  int i,q,com,x,y,a=2;
  scanf("%d %d",&n,&q);
  while(a<n){
    a*=2;
  }
  n=a;
  for(i=0;i<2*n-1;i++)tree[i]=(1<<31)-1;
  for(i=0;i<q;i++){
    scanf("%d %d %d",&com,&x,&y);
    if(com==0){
      update(x,y);
    }
    if(com==1){
      printf("%d\n",find(x,y,0,0,n-1));
    }
  }
  return(0);
}
void update(int i,int x){
  i=i+n-1;
  tree[i]=x;
  while(i>0){
    i=(i-1)/2;
    tree[i]=min(tree[i*2+1],tree[i*2+2]);
  }
  return;
}
int find(int s,int t,int node,int left,int right){
  if(right<s||t<left)return((1<<31)-1);
  if(s<=left&&right<=t)return(tree[node]);
  int vleft=find(s,t,node*2+1,left,(right+left)/2);
  int vright=find(s,t,node*2+2,(left+right)/2+1,right);
  return min(vleft,vright);
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string s;
  cin >> s;
  
  int n;
  n = s.size();
  
  vector<int> ans(n);
  
  for(int k = 0 ; k < 2 ; k++){
    int cnt = 0;
    for(int i = 0 ; i < n ; i++){

      if(s.at(i) == 'R'){
        cnt++;
      }
      else{
        ans.at(i-1) += (cnt+1)/2;
        ans.at(i) += cnt/2;
        cnt = 0;
      }
    }
    reverse(s.begin() , s.end() );
    reverse(ans.begin() , ans.end() );

    for(int j = 0 ; j < n ; j++){
      if(s.at(j) == 'R'){
        s.at(j) = 'L';
      }
      else{
        s.at(j) = 'R';
      }
    }
  }
    
  for(int i = 0 ; i < n ; i++){
    cout << ans.at(i) << " ";
  }
}
      
  
  

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


char str[100];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    str[strlen(str)-8]='\0';
    printf("%s\n", str);

    return 0;
}


Measured memory_bytes: 128
n = int(input())
lst = list(map(int,input().split()))
lad = [0] * (n+1)
for i in reversed(range(1,n)):
    if lst[i] <= lst[i-1]:
        lad[i-1] = lad[i] + 1
    else:
        continue
print(max(lad))

Measured memory_bytes: 14252
#include <iostream>
#include <string>

int main()
{
    std::string N;
    std::cin >> N;
    int n = 0;
    for (auto const &c : N)
    {
        n = (n + c - '0') % 9;
    }
    if (n == 0)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3720
#include <algorithm>
#include <iostream> //標準入出力
#include <fstream>  //ファイルでの入出力
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <utility> //pair
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define MAX 1000000
#define pair(a) pair<a,a>

int bfs(vector<string>& field,int fb){
    int h=field.size(),w=field[0].size();
    vector<vector<int>> dfroms(h,vector<int>(w,200000));
    queue<pair(int)> later;
    const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0}; //東西南北の順

    later.push({0,0});
    dfroms[0][0] = 1;

    while(!later.empty()){
        pair(int) now = later.front();
        int x = now.first, y = now.second;
        later.pop();
        rep(i,4){
            pair(int) next = {x+dx[i],y+dy[i]};
            int nx = next.first,ny = next.second;
            if(nx<0||nx>=h||ny<0||ny>w) continue;
            if(field[nx][ny]=='#') continue;
            if(dfroms[nx][ny]!=200000) continue;
            dfroms[nx][ny] = dfroms[x][y] + 1;
            later.push(next);
        }
    }
    int out = h*w - dfroms[h-1][w-1] - fb;
    if(dfroms[h-1][w-1] == 200000) return -1;
    else return out;
}

void _main(){
    int h,w;
    cin >> h >> w;
    vector<string> field; 
    field.resize(h);
    rep(i,h) cin >> field[i];
    int firstblack = 0;
    rep(i,h) rep(j,w) if(field[i][j]=='#') firstblack++;
    cout << bfs(field,firstblack) << endl;
    
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3184
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
//const ll MOD = INF + 7;
//Combination MOD
const int MOD = 1e9 + 7;



int main(){
   int n;
   cin >> n;
   map<string, int> mp;
   rep(i, n){
      string s;
      cin >> s;
      mp[s]++;
   }
   cout << "AC x " << mp["AC"] << endl;
   cout << "WA x " << mp["WA"] << endl;
   cout << "TLE x " << mp["TLE"] << endl;
   cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b){
        for(int i=0;i<b;i++)
            printf("%d",a);
    }
    else{
        for(int i=0;i<a;i++)
            printf("%d",b);
    }
    printf("\n");
    return 0;
}

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

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


int N, K;
string S;

int main(){


    cin >> N >> K; K--;
    cin >> S;
    char ch = S[K];
    if(ch >= 'A' && ch <= 'Z'){
        S[K] = ch - 'A' + 'a';
    }
    cout << S << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    while(1){
        int m,n;
        char cha[100000],con[100000],a[100000];
        cin>>m;
        if(m==0)break;
        for(int i=0;i<m;i++){
            cin>>cha[i]>>con[i];
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
            for(int j=0;j<m;j++){
                if(a[i]==cha[j]){
                    a[i]=con[j];
                    break;
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i];
        }
        cout<<"\n";
    }
    return 0;
}

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

int main(){
  ll n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    ll x=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    ll y=upper_bound(c.begin(),c.end(),b[i])-c.begin();
    ans += x*(n-y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4544
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,i;
  vector<char> s(4);
  
  cin >> a;
  for(i=0;i<4;++i)
  {cin >> s.at(i);}
  
  b=int(s.at(0)-'0')*100+int(s.at(2)-'0')*10+int(s.at(3)-'0');
  
  c=(a*b)/100;
  cout << c;
return 0;
}

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

using namespace std;

void printv(vector<int> a){
	for (int i = 0; i < a.size(); i++){
		cout << a[i];
		if (i != a.size() - 1) cout << " ";
	}
	cout << endl;
}

void insertionSort(vector<int> &a, int n){
	int v, j;
	for (int i = 1; i < n; i++){
		printv(a);
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	insertionSort(a, n);
	printv(a);
}

Measured memory_bytes: 3140
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='a'){
            if(a+b>0){
                cout<<"Yes"<<endl;
                a--;
            }
            else cout<<"No"<<endl;
            
        }
        else if(s[i]=='b'){
            if(a+b>0 && b>0){
                cout<<"Yes"<<endl;
                b--;
            }
            else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

vector<vector<pair<int, int>>> constranints;
int N, M;
int memo[302][302][302];

int dfs(int r, int g, int b, int k){
    if(memo[r][g][b] != -1) return memo[r][g][b];
    for(auto p : constranints[k]){
        int l = p.first, x = p.second;
        if(x != (l <= r) + (l <= g) + (l <= b)){
            return 0;
        }
    }
    if(k == N){
        return 1;
    }

    int ret = 0;
    ret = (ret + dfs(k+1, g, b, k+1)) % MOD;
    ret = (ret + dfs(r, k+1, b, k+1)) % MOD;
    ret = (ret + dfs(r, g, k+1, k+1)) % MOD;

    memo[r][g][b] = ret;
    return ret;
}

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

    constranints.assign(N+1, {});
    for(int i=0;i<M;i++){
        int l, r, x;
        cin >> l >> r >> x;
        constranints[r].emplace_back(l, x);
    }

    memset(memo, -1, sizeof(memo));
    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}

Measured memory_bytes: 107904
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

class DisjointSet{
    public:
    vector<ll> rank,p,sz;
    DisjointSet(){}
    DisjointSet(ll size){ //作られうる木の頂点数の最大値を入れる。
        rank.resize(size,0);
        p.resize(size,0);
        sz.resize(size,1);
        rep(i,size) makeSet(i);
    }
    void makeSet(ll x){ //xだけが属する木を作る。
        p[x]=x;
        rank[x]=0;
    }
    bool same(ll x,ll y){ //xとyが同じ木に属するかどうか
        return findSet(x)==findSet(y);
    }
    void unite(ll x, ll y){
        link(findSet(x),findSet(y));
    }
    void link(ll x, ll y){ //rankが大きい方の根に小さい方の根をつける。
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++; //xとyの木のrankが同じであれば、統合するとrankが1増える。
            }
        }
        sz[x]+=sz[y];
        sz[y]=sz[x];
    }
    ll findSet(ll x){ //xが属する木の根の番号を返す
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};


int main()
{
    ll n,m;
    cin >> n >> m;
    DisjointSet dist=DisjointSet(n+1);
    vector<ll> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll comb=0;
    vector<ll> ans;
    for(ll i=m-1;i>=0;i--){
        if(dist.same(a[i],b[i])){
            ans.push_back(comb);
            continue;
        }
        if(i==m-1){
            comb=n*(n-1)/2;
        }
        ans.push_back(comb);
        comb-=dist.sz[dist.findSet(a[i])]*dist.sz[dist.findSet(b[i])];
        dist.unite(a[i],b[i]);
    }
    rep(i,m){
        cout << ans[m-1-i] << endl;
    }
    return 0;
} 

Measured memory_bytes: 6132
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 

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

int main(void)
{
    string s;
    std::cin >> s;
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(0)!=s.at(2))std::cout << "Yes" << std::endl;
    else if(s.at(0)==s.at(3)&&s.at(2)==s.at(1)&&s.at(0)!=s.at(2))std::cout << "Yes" << std::endl;
    else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)&&s.at(0)!=s.at(1))std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 正整数入力
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int num2 = scan.nextInt();

		// 結果出力
		if(num1 * num2 % 2 == 0) {
			System.out.println("Even");
		}
		else {
			System.out.println("Odd");
		}

		scan.close();

	}

}

Measured memory_bytes: 22996
/*  ex3_3
    yy8332  */
 
#include <stdio.h>
 
int main(void){
  int number,base_number;
  int i = 1;
 
  //入力受け取り
  scanf("%d %d", &number, &base_number);
 
  //何桁か求める
  while(number >= base_number){
    number = number / base_number;
    i++;
  }
 
  //出力
  printf("%d\n",i);
 
  return 0;
}

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

int gozyo(int P,int Q){
  while(Q!=0){
    int R=P%Q;
    P=Q;
    Q=R;
  }
  return P;
}
signed main(){
  int K;
  cin>>K;
  int ans=0;
  rep(a,K){
    rep(b,K){
      rep(c,K){
        ans+=gozyo(gozyo(a,b),c);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3672
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int l, r, ans = INF;

int main(){
	scanf("%d%d", &l, &r);
	if(r - l >= 2019){
		puts("0");
		return 0;
	}
	l %= 2019; r %= 2019;
	if(r < l) r += 2019;
	REP(i, l, r) REP(j, i + 1, r) ans = min(ans, i * j % 2019);
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int a,b,i,x,ans;
    while(scanf("%d %d",&a,&b)!=EOF){
        ans=0;
        x = a + b;
        while(1){
            ans++;
            if(x < 10)break;
            x = x / 10;
        }
    printf("%d\n",ans);
    }


    return 0;
}

Measured memory_bytes: 600