akhauriyash/Code-Regression huggingface dataset:
#line 1 "../../library/template.cpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
  }
} io_setup;
#line 1 "../../library/union_find.cpp"
struct UnionFind {
  struct Node {
    ll parent;
    ll size;
  };
  vector<Node> tree;

  UnionFind(ll size) : tree(size) {
    for (ll i = 0; i < size; i++) {
      tree[i].parent = i;
      tree[i].size = 1;
    }
  }

  ll find(ll x) {
    while (tree[x].parent != x) {
      ll p = tree[x].parent;
      tree[x].parent = tree[p].parent;
      x = p;
    }
    return x;
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (tree[x].size < tree[y].size) swap(x, y);
    tree[y].parent = x;
    tree[x].size += tree[y].size;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};
#line 3 "e2.cpp"

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    ll x, y, z;
    cin >> x >> y >> z;
    uf.unite(x-1, y-1);
  }

  set<ll> s;
  rep(i, n) {
    s.insert(uf.find(i));
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
int main(){
    string s;
    cin >> s;
    
    int cnt = 1;
    char left = s[0];
    for (int i = 1; i < s.size(); i++){
        if (s[i] != left){
            cnt++;
            left = s[i];
        }
    }

    cout << cnt - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(void){
    char a[30];
    int n,i,m=100;
    fgets(a,m,stdin);
    n=strlen(a);
    for(i=n-1;i>=0;i--){
        if(a[i]!='\n'){
            printf("%c",a[i]);}
    }printf("\n");
}   

Measured memory_bytes: 1668
#include<iostream>
using namespace std;
int num,*pA;
bool solve(int i,int m);
int main(void){
    int q,m,i;
    cin >> num;
    pA = new int[num];
    for(i=0;i<num;i++){
        cin >> pA[i];
    }
    cin >> q;
    for(i=0;i<q;i++){
        cin >> m;
        if(solve(0,m)){
            cout << "yes" << '\n';
        }else{
            cout << "no" << '\n';
        }
    }
    delete[] pA;
    return 0;
}
bool solve(int i,int m){
    if(m==0){
        return 1;
    }
    if(i >=num){
        return 0;
    }
    int res = solve(i+1,m) || solve(i+1,m-pA[i]);
    return res;
}


Measured memory_bytes: 3104
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	
	switch N {
		case 1:
			fmt.Println("Hello World")
		case 2:
			var A,B int
			fmt.Scan(&A,&B)
			fmt.Println(A+B)
	}
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
 
int cnt[2][4005][4005];
 
int getCount(int xmax, int ymax, int xmin, int ymin, int color){
    if (xmin == 0 && ymin == 0) return cnt[color][xmax][ymax];
    if (xmin == 0) return cnt[color][xmax][ymax]-cnt[color][xmax][ymin-1];
    if (ymin == 0) return cnt[color][xmax][ymax]-cnt[color][xmin-1][ymax];
    return cnt[color][xmax][ymax] + cnt[color][xmin-1][ymin-1] - cnt[color][xmin-1][ymax] - cnt[color][xmax][ymin-1];
}
int main(){
    int n, k;
    scanf("%d%d",&n, &k);
    char str[2];
    int x, y;
    for(int i = 0; i < n; i ++){
        scanf("%d%d%s", &x, &y, str);
        x %= 2*k;
        y %= 2*k;
        int color = (str[0]=='W')?0:1;
        cnt[color][x][y] ++;
        cnt[color][x+2*k][y] ++;
        cnt[color][x][y+2*k] ++;
        cnt[color][x+2*k][y+2*k] ++;
    }
    for(int color = 0; color < 2; color ++){
        for(int i = 1; i < 4*k; i ++){
            cnt[color][0][i] += cnt[color][0][i-1];
        }
        for(int i = 1; i < 4*k; i ++){
            for(int j = 0; j < 4*k; j ++){
                if (j == 0) cnt[color][i][j] += cnt[color][i-1][j];
                else cnt[color][i][j] += cnt[color][i][j-1] + cnt[color][i-1][j] - cnt[color][i-1][j-1];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 2*k; i ++){
        for(int j = 0; j < k; j ++){
            int a = getCount(i+k-1, j+k-1, i, j, 0);
            int b = getCount(i+k-1, j+2*k-1, i, j+k, 1);
            int c = getCount(i+2*k-1, j+k-1, i+k, j, 1);
            int d = getCount(i+2*k-1, j+2*k-1, i+k, j+k, 0);
            ans = max(ans, a+b+c+d);
        }
    }
    printf("%d\n", ans);
    
}

Measured memory_bytes: 125440
<?php
  	fscanf(STDIN, '%d %d', $num, $limit);
	$input = trim(fgets(STDIN));
	$bound = explode(' ', $input);

	if(array_sum($bound) <= $limit){
      	echo ($num + 1);
      	exit();
    }

	$x = 0;
	foreach($bound as $value){
      	++$cnt;
      	$x += $value;
      	if($x > $limit)break;
    }

	echo $cnt;


Measured memory_bytes: 4856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] S = sc.next().split("");
		int slen = S.length;
		String[] key = {"k","e","y","e","n","c","e"};
		int keylen = key.length;
		sc.close();

		if(!(S[0].equals(key[0]))&&!(S[slen-1].equals(key[keylen-1]))) {
			System.out.println("NO");
			return;
		}
		int cnt = 0;
		for(int i=0,j=0;i<keylen&&j<keylen;i++) {
			if(S[i].equals(key[j])) {
				j++;
				cnt++;
			}else {
				break;
			}
		}
		if(cnt >= keylen) {
			System.out.println("YES");
			return;
		}
		for(int i=slen-1,j=keylen-1;j>=0&&i>=0;i--) {
			if(S[i].equals(key[j])) {
				j--;
				cnt++;
			}else {
				break;
			}
		}

		if(cnt >= keylen) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

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

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll A, B;
    cin >> A >> B;

    ll n = B - A + 1;
    if (A & 1) { // A is odd number
        if ( ( (n/2) % 2 == 0 ) && 
                n & 1) {
            cout << A << endl;
        } else if (( (n/2) % 2 == 0 ) && n % 2 == 0) {
            cout << ((A^1)^B) << endl;
        } else if ( (n/2) % 2 == 1 && n % 2 == 1 ) {
            cout << ( ( A ^ (B-1) ) ^ B ) << endl;
        } else if ( (n/2) % 2 == 1 && n % 2 == 0 ) {
            cout << (A ^ B) << endl;
        }
    } else {
        if ( ( (n/2) % 2 == 1 ) && n & 1 ) {
            cout << (B ^ 1) << endl;
        } else if ( ( (n/2) % 2 == 1 ) && n % 2 == 0 ) {
            cout << 1 << endl;
        } else if ( ( (n/2) % 2 == 0 ) && n & 1 ) {
            cout << B << endl;
        } else if ( ( (n/2) % 2 == 0 ) && n % 2 == 0 ) {
            cout << 0 << endl;
        }
    }

    return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int linearsearch(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i != n;
}
int main(){
  int i,n,A[10000+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearsearch(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N;
	cin >> N;
	if(N == 1){
		cout << "Hello World" << endl;
	}
	else{
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
A=[]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]

B = [A.count(i) for i in range(1,5)]
if B.count(2) == 2 and B.count(1) == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int ans = 0;

int N;

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

void dfs(int now,int parent,vector<vector<int>> &E,vector<int> &cnt){
	int C = 1;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		dfs(to,now,E,cnt);
		C += cnt[to];
	}
	cnt[now] = C;
}

void dfs2(int now,int parent,vector<vector<int>> &E,vector<int> &cnt){
	vector<int> B;
	int s = 0;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		dfs2(to,now,E,cnt);
		B.push_back(cnt[to]);
		s += cnt[to];
	}
	s++;
	s = N-s;
	if(s!=0)B.push_back(s);

	int ho = beki(gyakugen(2),N-1);
	for(int i=0;i<B.size();i++){
		int A = beki(gyakugen(2),N-1-B[i]);
		int C=mod( 1 - beki(gyakugen(2),B[i]));
		ho = mod(ho + mod(A*C));
	}
	ho = mod(1 - ho);
	ho - mod(ho * gyakugen(2));
	ans = mod(ans + ho);
	
}

int main(){
	
	
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	vector<int> cnt(N,0);
	
	dfs(0,-1,E,cnt);

	dfs2(0,-1,E,cnt);
	cout<<mod(gyakugen(2)*ans)<<endl;
	
    return 0;
}


Measured memory_bytes: 29952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String a = s.next();
        if(isPalin(a) && isPalin(a.substring(0,(a.length()-1)/2))&& isPalin(a.substring((a.length()+1)/2,a.length())))
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    private static boolean isPalin(String a){
        for(int i=0;i<a.length()/2;i++){
            if(a.charAt(i)!=a.charAt(a.length()-1-i))
                return false;
        }
        return true;
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n < 100) {
            cout << n << endl;
        } else {
            cout << 101 << endl;
        }
        return 0;
    }

    int i = 1;
    int cnt = 0;

    while ( true ) {
       if (i % (int(pow(100, d))) == 0 && (i / int(pow(100, d))) % 100 != 0) {
           ++cnt;
           if (cnt == n) {
               cout << i << endl;
               break;
           }
       }
       ++i;
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

/*
long long K;
long long lunlun[100000];

cin >> K;

long long k = 0;

for(long long i = 1;i <= 100000;++i){

    long long tmp = i;
    long long keta_bef;
    long long keta_aft;
    bool flg = true;

    while(tmp != 0 && flg){

        keta_bef = tmp % 10;
        tmp = tmp / 10;
        keta_aft = tmp % 10;
        if(abs(keta_aft - keta_bef) > 1 && tmp != 0) flg = false;

    }

    if(flg) {

        lunlun[k] = i;
        ++k; 
        cout << i << " " << k << endl;

    }

}

    cout << lunlun[K-1] << endl;

*/

ll K;
vector<ll> lunlun;

cin >> K;

for(ll i = 1;i<10;++i) lunlun.push_back(i);

while(1){

if(K<=lunlun.size()){

    cout << lunlun[K-1] << endl;
    return 0;
}

K-=lunlun.size();
vector<ll> old;
swap(old,lunlun);

for(ll x : old){

    for(ll j = -1;j <= 1;++j){

        ll d = x%10 + j;
        if(d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        lunlun.push_back(nx);

    }

}


}

return 0;

}   


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << max(c/a, 0)*b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5;
int f(string s){
	int n = s.size();
	for(int i=0 ; i<n/2 ; i++)
		if(s[i]!=s[n-i-1])return 0;
	n = (n-1)/2;
	for(int i=0 ; i<n/2 ; i++)
		if(s[i]!=s[n-i-1])return 0;

	return 1;
}

int main() {
	// ios_base::sync_with_stdio(false);
 //  cin.tie(NULL);
 //  cout.tie(NULL);
	int n,m;
	string s;
  while(cin >> s){
 		if(f(s))cout << "Yes\n";
 		else cout << "No" << endl;  	
  }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input[2] == input[3] && input[4] == input[5])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 13140
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n =  int(sys.stdin.readline())
h =  list(map(int, sys.stdin.readline().split()))

temp=0
ans=0
if n==1:
    print(0)
else:
    for i in range(n-1):
        if h[i] >= h[i+1]:
            temp+=1
        else:
            ans = max(temp,ans)
            temp=0
        ans = max(ans,temp)
    print(ans)

Measured memory_bytes: 16268
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;
const int N = 2e5 + 10;


int n , x , y;
int c[N] , w[N] , colormin[N] , smallest , secondsmallest;

int par[N] , sz[N] , inv[N];
map<int,int> exi[N];
int find(int x){
	if (par[x] != x){
		return par[x] = find(par[x]);
	}
	return par[x];
}

void merge(int x,int y){
//	printf("[%d %d]\n",x,y);
	x = find(x) , y = find(y);
	if (x ^ y){
		par[x] = y;
	}
}
int main(){
	
	scanf("%d%d%d",&n,&x,&y);
	for (int i = 1;i <= n;i++){
		scanf("%d%d" , c + i , w + i);
		par[i] = i;
		
		if (!colormin[c[i]] || w[colormin[c[i]]] > w[i]) colormin[c[i]] = i;
		if (!smallest || w[smallest] > w[i]){
			smallest = i;
		}
	}
	for (int i = 1;i <= n;i++){
		if (c[i] == c[smallest]) continue;
		if (!secondsmallest || w[secondsmallest] > w[i]){
			secondsmallest = i;
		}
	}
	
//	printf("[%d %d] (%d %d)\n",smallest,secondsmallest,colormin[c[smallest]],colormin[c[secondsmallest]]);
	
	inv[1] = 1;for (int i = 2;i <= n;i++) inv[i] = 1ll * (mod - (mod / i)) * inv[mod % i] % mod;
	
	for (int i = 1;i <= n;i++){
		if (w[i] + w[colormin[c[i]]] <= x) merge(i , colormin[c[i]]);
		
		if (smallest)
		if (c[i] != c[smallest] && w[i] + w[smallest] <= y){
			merge(i , smallest);
		}
		
		if (secondsmallest)	
		if (c[i] != c[secondsmallest] && w[i] + w[secondsmallest] <= y){
			merge(i , secondsmallest);
		}	
		
	}
	int res = 1;
	for (int i = 1;i <= n;i++){
		res = 1ll * res * (++sz[find(i)]) % mod;
		res = 1ll * res * inv[++exi[find(i)][c[i]]] % mod;
		
//		printf("[%d %d]\n",sz[find(i)] , exi[find(i)][c[i]]);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n=s.size();
  bool ok=true;
  for(int i=0;i<n;i++) {
    if(i%2==0 && s.at(i)=='L') ok=false;
    if(i%2==1 && s.at(i)=='R') ok=false;
    }
  if(ok) puts("Yes");else puts("No");
  return 0;
  }

Measured memory_bytes: 256
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mod = 10**9+7

A_ = set(A)
B_ = set(B)

if len(A) != len(A_) or len(B) != len(B_):
    print(0)
    exit()

A.sort()
B.sort()

import bisect

ans = 1
for i in reversed(range(1, n*m+1)):
    if i in A_ and i in B_:
        ans *= 1
    elif i in A_ and i not in B_:
        ans *= (len(B)-bisect.bisect_left(B, i))
    elif i not in A_ and i in B_:
        ans *= (len(A)-bisect.bisect_left(A, i))
    else:
        a = len(A)-bisect.bisect_left(A, i)
        b = len(B)-bisect.bisect_left(B, i)
        ans *= a*b-(len(A)*len(B)-i)
    ans %= mod
    
print(ans)

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

using namespace std;

#define MAX 1000000
 
bool prime[MAX];
 
void make()
{
    fill(prime, prime + MAX, true);
 
    prime[0] = prime[1] = false;
    for (int i = 2; i*i < MAX; i++) { 
	if (prime[i]) {
	    for (int j = 2*i; j < MAX; j += i) {
		prime[j] = false;
	    }
	}
    }
}
 
int main()
{
    make();
    int n;
    while (scanf("%d", &n), n) {
	int cnt = 0;
	for (int i = 2; i+i <= n; i++) {
	    if (prime[i] && prime[n-i]) {
		cnt++;
	    }
	} 
	printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 4148
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b;
  cin >> a >> b;
  cout << (b-1+a-2)/(a-1) << endl;

	return 0;
}

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

int n, x;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
    for(int i=0; i<n; ++i){
        T t;
        cin >> t;
        v.push_back(t);
    }
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> x;
	readVector(n, a);
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i=0; i<n; ++i){
		if(i == n-1){
			if(x == a[i]) ++ans;
		}else{
			if(x - a[i] < 0) break;
			x -= a[i];
			++ans;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
string s,t;
int ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> s >> t;
    int ns = s.size();
    rep1(i,0,ns){
        ans += s[i] != t[i];
    }
    cout << ans;
    return 0;  
}

Measured memory_bytes: 3776
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

int X,Y;
int board[20][20];
int cnt;
int memo[20][20];
int solve(int x,int y,int dir){
	if(x <1||x >X||board[y][x]==1||(board[y][x]==2&&dir !=0)){
		return 0;
	}else if(y >=Y){
		return 1;
	}
	if(memo[y][x]!=-1){
		return memo[y][x];
	}
	if(board[y][x]==2){
		return memo[y][x]=solve(x,y+2,0);
	}else {
		return memo[y][x] =solve(x-1,y+1,-1)+solve(x,y+1,0)+solve(x+1,y+1,1);
	}
}

int main(){
	while(cin>>X>>Y,X||Y){
		cnt =0;
		rep(i,20){
			rep(j,20){
				board[i][j]=0;
				memo[i][j] =-1;
			}
		}
		for(int i=1;i <=Y;i++){
			for(int j =1;j <=X;j++){
				cin>>board[i][j];
			}
		}
		for(int i =1;i <=X;i++){
			if(board[1][i]==0){
				cnt+=solve(i,1,0);
			}
			//cout <<endl;
		}
		cout <<cnt<<endl;
	}
	
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> P(N);
    rep(i,N){
        cin >> P[i];
    }
    vector<ll> a(N);
    REP(i,1,N){
        if(P[i-1] < P[i]) a[i] = 1;
        a[i] += a[i-1];
    }
    //PR(a,N);
    set<ll> st;
    rep(i,K){
        st.insert(P[i]);
    }
    bool cute = (a[K-1] == K-1);
    ll ans = !cute;
    rep(i,N-K){
        bool ok = (*st.begin() == P[i]);
        st.erase(P[i]);
        st.insert(P[i+K]);
        ok &= (*st.rbegin() == P[i+K]);
        if(a[i+K] - a[i+1] == K - 1){
            cute = true;
        }else if(!ok){
            ans++;
        }
    }
    cout << ans + ll(cute) << endl;
}

Measured memory_bytes: 15608
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 3000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,f[MN+5][MN+5],g[MN+5][MN+5],F[MN+5],G[MN+5],p[MN+5],inv[MN+5];
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    n=read();m=read();--n;--m;
    f[0][0]=F[0]=1;g[0][0]=G[0]=bool(n);
    p[0]=inv[0]=p[1]=inv[1]=1;
    for(int i=2;i<=m;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=m;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=1;i<=m;++i)
    {
        for(int j=0;j<=n;++j)
        {
            if(j) R(f[i][j-1],f[i-1][j]),R(g[i][j-1],g[i-1][j]);
            if(j<n) R(f[i][j+1],f[i-1][j]);
            if(j+1<n) R(g[i][j+1],g[i-1][j]);
        }
        for(int j=0;j<=n;++j) R(F[i],f[i][j]),R(G[i],g[i][j]);
    }
    int ans=0;
    for(int i=m,pw=1;~i;--i,pw=2*pw%mod)
    {
        int res=0;
        for(int j=0;j<=i;++j) res=(res+1LL*(j?G[j-1]:1)*F[i-j])%mod;
        ans=(ans+1LL*C(m,i)*pw%mod*res)%mod;
    }
    cout<<4LL*ans%mod;
    return 0;
}


Measured memory_bytes: 70784
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
 
string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}

int mod = 1e9 + 7;
ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}
 ll POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

int main() { 
	//8 4 2 1  //2 3   6 7  10 11   14 15 ...
	         //4 5 6 7   12 13
	         //8 9 10 11 12 13 14 15  24 25 26 27 
	ll n1, n2;
	cin >> n1 >> n2;
	//bool c = 0;
	//for (ll i = 2; i <= n2; i *= 2) {
		//if (i - 1 == n1) {
			//c = 1;
		//}
	//}
	//if (c) {
		//ll p = (n2 - n1) / 2;
		//ll x = 0;
		//if (p % 2 == 1) {
			//x = 1;
		//}
		//if ((n2 - n1) % 2 == 0) {
			//cout << (n1 ^ x);
		//}else {
		    //cout << ((n1 ^ n2) ^ x);
		//}
	//}else {
		//if ((n2 - n1 + 1) % 2 == 0) {
			//if (((n2 - n1) / 2) % 2 == 0) {
				//cout << 1;
			//}else {
				//cout << 0;
			//}
		//}else {
			//ll p1 = 0;
			//if (((n2 - n1 )/2) % 2 == 1) {
				//p1 = 1;
			//}
			//cout << (p1 ^ n2);
		//}
		
	if (n1 % 2 == 1 && n2 % 2 == 0) {
		ll p = 0;
		if (((n2 - n1 + 1 - 2)/ 2)% 2 == 1) {
			p = 1;
		}
		cout << ((n1 ^ n2) ^ p);
	}else if (n1 % 2 == 1){
		ll p = 0;
		if (((n2 - n1 + 1 - 1)/2) % 2 == 1) {
			p = 1;
		}
		cout << (n1 ^ p);
	}else if (n2 % 2 == 0) {
		ll p = 0;
		if (((n2 - n1 + 1 - 1) / 2) % 2 == 1) {
			p = 1;
		}
		cout << (n2 ^ p);
	}else {
		//ll p = 0
		if (((n2 - n1 + 1) / 2) % 2 == 1) {
			cout << 1;
		}else {
			cout << 0;
		}
	}
	//if ((n2 - n1) % 2 == 0) {
		//if (((n2 - n1) / 2) % 2 ==1){
			//cout << (n2 ^ 1);
		//}else {
			//cout << n2;
		//}
	//}else {
		//if (((n1 - n2)/2) % 2 == 0) {
			//cout << (n1 ^ n2);
		//}else {
			//cout << (n1 ^ 1);
		//}
	//}
	//}
	//for (ll i = 1; i <= n2; i = i * 2) {
		//ll p1 = (n1 - i + 2 * i - 1) / (2 * i);
		//ll p2 = (n2 - i + 2 * i) / (2 * i);
		//ll an1 = i + (p1 - 1)*(2 * i);
		//ll an2 = i + (p2 - 1)*(2 * i);
		//ll e = max(an1 + i - n1,(ll)0); 
		//ll cnt = (p2 - p1) * i + e;  
		//cnt -= max(an2 + i - n2,(ll)0);
		//if (cnt % 2) {
			//ans += i;
		//}
	//}
	//cout << ans;
}


//1 0 1 0 0 1  0  0 0 0 0 0 0   

//a + (n - 1)*d = an 
//an - a = nd - d
//an - a + d 
//elements in n2 - n1 

//  456 
//  123
//  333	


Measured memory_bytes: 3528
import java.lang.Math

fun main(args: Array<String>)
{
    val (a, b, x) = readLine()!!.split(" ").map{ it.toDouble() }
    val s = a * b / 2.0

    if (x / a > s) {
        val diff = 2.0 * (b - x / (a * a))
        println(Math.atan2(diff, a) * 180.0 / Math.PI)
    } else {
        val h = 2.0 * x / (a * b)
        println(Math.atan2(b, h) * 180.0 / Math.PI)
    }
}


Measured memory_bytes: 36144
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String testCase = input.next();
            map.put(testCase, map.getOrDefault(testCase, 0) + 1);
        }
        System.out.println("AC x " + map.getOrDefault("AC", 0));
        System.out.println("WA x " + map.getOrDefault("WA", 0));
        System.out.println("TLE x " + map.getOrDefault("TLE", 0));
        System.out.println("RE x " + map.getOrDefault("RE", 0));
    }
}

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

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

    int res = 1000;
    for(int i=0; i<s.size()-2; i++){
        string x;
        x = s.substr(i, 3);
        //cout << x << endl;
        int tmp = stoi(x);

        res = min(res, abs(tmp-753));
    }

    cout << res << endl;
}

Measured memory_bytes: 256
// finish date: 2018/01/31
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;


int main() {
    int N;
    cin >> N;
    map<int, int> count;
    int A;
    rep(i, N) {
        cin >> A;
        count[A]++;
    }
    int hasuu = 0;
    for (auto itr:count) {
        if (itr.second % 2 == 0) hasuu++;
    }
    int ans = count.size();
    ans -= hasuu % 2;
    cout << ans << endl;

    return 0;
}



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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());
            var y = int.Parse(Console.ReadLine());

            if(n<=k)
            {
                Console.WriteLine(x * n);
            }
            else
            {
                Console.WriteLine(x * k + y * (n - k));
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  char b = 'c';
  for(const char& c : s){
    if(b==c){
      cout << "Bad" << endl;
      return 0;
    }
    b = c;
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,g;
int m[2][3333];
int x,y=1e9;
int main(){
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;b*=100;
    m[0][0]=m[1][0]=1;
    for(int i=1;i<=f;i++){
        if(i-c>=0&&m[0][i-c])m[0][i]++;
        if(i-d>=0&&m[0][i-d])m[0][i]++;
    }
    for(int i=1;i<=f;i++){
        if(i-a>=0&&m[1][i-a])m[1][i]++;
        if(i-b>=0&&m[1][i-b])m[1][i]++;
    }
    for(int i=0;i<=f;i++){
        if(m[0][i]){
            for(int j=1;i+j<=f;j++){
                if(m[1][j]){
                    if(e*j>=i*100){
                        if(x*(i+j)<=i*(x+y)){
                            x=i;
                            y=j;
                        }
                    }
                }
            }
        }
    }
    cout<<x+y<<' '<<x;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main (void) {
    int n, a[200000], max1 = 0, k, max2 = 0;;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < n; i++) {
        if (max1 < a[i]) {
            max1 = a[i];
            k = i;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == k) continue;
        if (max2 < a[i]) max2 = a[i];
    }

    for (int i = 0; i < n; i++) {
        if (i == k) printf("%d\n", max2);
        else {printf("%d\n", max1);}
    }

    return 0;
}

Measured memory_bytes: 2304
#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;
#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;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll gcd(ll a, ll b){
  if(a%b) return gcd(b, a%b);
  else return b;
}


int main(){
  int T; cin >> T;
  rep(i, T){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A<B){
      cout << "No" << endl; continue;
    }
    if(D<B){
      cout << "No" << endl; continue;
    }
    if(C>B){
      cout << "Yes" << endl; continue;
    }
    ll G = gcd(B, D);
    ll ma = A%G + ((B - A%G)/G)*G;
    if(ma>=B) ma-=G;
    if(ma>C){
      cout << "No" << endl;
    }
    else cout << "Yes" << endl;
  }
}

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

int main(){
  int n,x,count;

  while(1){
    cin>>n>>x;
    if(n==0 && x==0) break;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
	  if(i+j+k==x && i!=j && i!=k && j!=k && i<j && j<k) count++;
	}
      }
    }
    cout<<count<<endl;
    count=0;
  }
  return 0;
}



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

int main()
{
	int N, out = 0, x = 0;
	std::string S;
	std::cin >> N;
	std::cin >> S;
	for (auto c : S) {
		if (c == 'I') { x++; }
		else { x--; }
		if (out < x) out = x;
	}
	std::cout << out << std::endl;

    return 0;
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k,s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n >> k >> s;
  for(int i=1;i<=k;i++){
    cout << s << " ";
  }
  if(s<1000000000)s = 1000000000;
  else s--;
  for(int j=k+1;j<=n;j++){
    cout << s << " ";
  }
  cout << endl;

return 0;
}
///....


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

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long max = a*c;

    if (a * d > max) {
        max = a * d;
    }
    if (b * c > max) {
        max = b * c;
    }
    if (b * d > max) {
        max = b * d;
    }

    cout << max << "\n";
    return 0;
}


Measured memory_bytes: 3668
N, H = map(int, input().split())

class Sord:
  def __init__(self, a, b):
    self.hit = a
    self.throw = b

sords = []
maxhit = None
for a, b in (map(int, input().split()) for _ in range(N)):
  s = Sord(a, b)
  sords.append(s)
  if maxhit is None:
    maxhit = s
  elif s.hit > maxhit.hit or s.hit == maxhit.hit and s.throw > maxhit.throw:
    maxhit = s

cnt = 0
for s in sorted([s for s in sords if s.throw > maxhit.hit], key=lambda x:x.throw, reverse=True):
  H -= s.throw
  cnt += 1
  if H <= 0:
    break
else:
  cnt += H // maxhit.hit + (H % maxhit.hit != 0)*1

print(cnt)



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

using namespace std;

int main() {
    vector<int> m;
    for(int i=0; i<10; ++i) {
        int t;
        cin >> t;
        m.push_back(t);
    }

    sort(m.rbegin(),m.rend());

    cout << m[0] << endl;
    cout << m[1] << endl;
    cout << m[2] << endl;

    return 0;
}


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

string rlm(string s) {
  int a=0;
  char prev = s.at(0);
  string res="";
  stringstream ss;

  for(int i=0; i<s.length(); i++) {
    if( prev != s.at(i) ) {
      if(a<=9)
	res += string(1,a+'0') + string(1,prev);
      else {
	ss.str("");
	ss << a;
	res += ss.str() + string(1,prev) ;
      }
      prev = s.at(i);
      a = 1;
    }else{
      a++;
    }
  }

  if(a<=9)
    res += string(1,a+'0') + string(1,prev);
  else {
    ss.str("");
    ss << a;
    res += ss.str() + string(1,prev) ;
  }
  //cout<<res<<endl;
  return res;
}
      

int main() {

  int d;
  string s;
  while(true) {
    cin>>d;
    if(d==0) break;
    cin>>s;

    for(int i=0; i<d; i++)
      s = rlm(s);

    cout<<s<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int factorial(int n)
{
    return (n==1 || n==0) ? 1: n * factorial(n - 1);
}

ld distance(int x1, int y1, int x2, int y2)
{
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2) * 1.0);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ld ans = 0;
    int n; cin >> n;
    vector<pii> points(n);
    for(int i = 0; i < n; i++) cin >> points[i].first >> points[i].second;
    vector<int> p(n);
    for(int i = 0; i < n; i++) p[i] = i;
    do
    {
        for(int i = 0; i < n - 1; i++)
            ans += distance(points[p[i]].first, points[p[i]].second, points[p[i + 1]].first, points[p[i + 1]].second);
    } while(next_permutation(p.begin(), p.end()));
    cout << fixed;
    cout << setprecision(20);
    cout << ans / (factorial(n) * 1.0);

    return 0;
}


Measured memory_bytes: 256
/**
 * This line was copied from template
 * This is csol.cpp
 * 
 * @author: Nikolay Kalinin
 * @date: Sat, 23 Mar 2019 16:09:25 +0300
 */
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;

vector<int> gr[maxn];
int n, m;

inline int find(int cur, int pr)
{
    if (gr[cur].size() > 2) return cur;
    if (gr[cur][0] == pr) return find(gr[cur][1], cur);
    else return find(gr[cur][0], cur);
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    bool ok = true;
    for (int i = 0; i < n; i++) if (gr[i].size() % 2 == 1) ok = false;
    if (!ok)
    {
        cout << "No" << endl;
        return 0;
    }
    int cnt4 = 0;
    for (int i = 0; i < n; i++) cnt4 += (gr[i].size() / 2) - 1;
    if (cnt4 < 2)
    {
        cout << "No" << endl;
        return 0;
    }
    if (cnt4 > 2)
    {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) if (gr[i].size() == 6)
    {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) if (gr[i].size() == 4)
    {
        bool found = false;
        for (auto t : gr[i]) if (find(t, i) == i) found = true;
        if (found)
        {
            cout << "Yes" << endl;
            return 0;
        } else
        {
            cout << "No" << endl;
            return 0;
            
        }
    }
    return 0;
}


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

#define int long long

struct edge{
  int u, v, cost;
  bool operator < (edge const& other){
	  return cost < other.cost;  
	}	
};

const int N = 100 + 11;
int p[N], sz[N];
vector<edge> edge_list;
vector<edge> ret;
int weight;

int get(int x){
  if (p[x] == x) return x;
  return p[x] = get(p[x]);	
}

void unite(int x, int y){
  x = get(x), y = get(y);
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  p[y] = x;
}

void KruskalMST( vector<edge> &edge_list){
	sort(edge_list.begin(), edge_list.end());
	for(auto it : edge_list){
	  if (get(it.u)  != get(it.v)){
	    unite(it.u, it.v);
	    weight += it.cost;
	    ret.push_back(it);	  
     }	
  }	
}

int32_t main(){
  	int n;
  	cin >> n;
  	vector<edge> g;
  	for(int i = 0; i < n; i++){
	  p[i] = i;
	  sz[i] = 0;	
	}
  	for (int i = 0; i < n; i++){
	  for (int j = 0; j < n; j++){
		  int x;
		  cin >> x;
		  if ( x != -1) g.push_back({i, j, x});  
	  }	
	}
  KruskalMST(g);
  cout << weight << endl;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
 
using namespace std;
 
const int md = 1e9 + 7;
 
int add(int x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
  return x;
}
 
int sub(int x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
  return x;
}
 
int mul(int x, int y) {
  return (long long)x * y % md;
}
 
int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> inv(n + 1);
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    inv[i] = mul(md - md / i, inv[md % i]);
  }
  int coef = 0;
  for (int i = 1; i <= n; ++i) {
    coef = add(coef, inv[i]);
  }
  int answer = 0;
  for (int i = 0; i < n; ++i) {
    answer = add(answer, mul(coef, a[i]));
    if (i + 1 < n) {
      coef = add(coef, inv[i + 2]);
      coef = sub(coef, inv[n - i]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    answer = mul(answer, i);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
A, B, C, D = [int(_) for _ in input().split()]
N = int(input())

values = [(0.25, A), (0.5, B), (1, C), (2, D)]
values.sort(key=lambda x: x[1] / x[0])

ans = 0
for l, p in values:
    if l > N: continue

    tmp = int(N // l)
    ans += tmp * p
    N -= tmp * l
print(ans)

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

int main(){
  int N;cin >> N;
  int A[20], B[20], C[20];
  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 - 1;++i)
    cin >> C[i];
  int ans = 0;
  for(int i = 0;i < N;++i) {
    ans += B[A[i] - 1];
    if(i != 0)
      if(A[i] - A[i - 1] == 1)
        ans += C[A[i-1] - 1];
  }
  cout << ans;
}


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

vvi tetra(2);
vvi dp(2, vi(1e6, 1e6));

void preset() {
    int n;
    for (int i=0; (n = i*(i+1)*(i+2)/6) < 1e6; i++) {
        tetra[0].push_back(n);
        if (n % 2 == 1) tetra[1].push_back(n);
    }

    for (int i=0; i<2; i++) {
        dp[i][0] = 0;
        for (int k : tetra[i]) {
            for (int j=k; j<1e6; j++) {
                dp[i][j] = min(dp[i][j], dp[i][j-k]+1);
            }
        }
    }
}

int main() {
    preset();

    int a;
    while (cin >> a) {
        if (a == 0) break;
        cout << dp[0][a] << " " << dp[1][a] << endl;
    }

    return 0;
}

Measured memory_bytes: 14296
#include <algorithm>
#include <iostream>
using namespace std;
#define LL long long

LL gcd(LL a,LL b){
	if(a<b)swap(a,b);
	while(b!=0){
		LL t=b;
		b=a%b;
		a=t;
	}
	return a;
}


int main(){
	
	int n;
	while(cin>>n,n){
		LL d[10],v[10];
		for(int i=0;i<n;i++){
			cin>>d[i]>>v[i];
			LL t=gcd(d[i],v[i]);
			d[i]/=t;
			v[i]/=t;
		}
		LL dk=d[0],vk=v[0];
		for(int i=1;i<n;i++){
			dk=dk*d[i]/gcd(d[i],dk);
			vk=gcd(vk,v[i]);
		}
		for(int i=0;i<n;i++){
			cout<<(v[i]/vk)*(dk/d[i])<<endl;
		}
	}
	
	return 0;
}


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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>
#define int ll

void solve(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int min = 1e9;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        min = std::min(min, a[i]);
        if (min == a[i])
            k++;
    }
    cout << k << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 1792