akhauriyash/Code-Regression huggingface dataset:
#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++)
  
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;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

struct point {
    int x, y;
};

bool in(int tx, int ty, int lx, int rx, int by, int uy) {
    return lx <= tx && tx <= rx && by <= ty && ty <= uy; 
}
int main() {
    int N, K;
    cin >> N >> K;

    vector<point> P;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        P.push_back((point){x, y});
    }
    ll ans = 2e9 * 2e9 + 1;
    for (int l = 0; l < N; l++) {
        for (int r = 0; r < N; r++) {
            if (l == r) continue;
            if (P[l].x >= P[r].x) continue;
            for (int u = 0; u < N; u++) {
                for (int b = 0; b < N; b++) {
                    if (u == b) continue;
                    if (P[u].y <= P[b].y) continue;
                    
                    int count = 0;
                    for (int k = 0; k < N; k++) {
                        if (in(P[k].x, P[k].y, P[l].x, P[r].x, P[b].y, P[u].y)) count++;
                    }
                    if (count >= K) {
                        ans = min(ans, ((ll)P[r].x - P[l].x) * ((ll)P[u].y - P[b].y));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)           


void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();

	int n, x, t; 

	cin >> n >> x >> t; 

	int ans = (n + x - 1) / x; 

	cout << ans * t; 
	

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    ll ans=0;
    ll r,d,x;
    cin >> r >> d >> x;
  	for(int i=2001;i<=2010;i++){
    x=r*x-d;
      cout << x << endl;
    }
    return 0;
}



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

using namespace std;

int isprime(int x)
{
    if(x<2){
        return 0;
    }else if(x==2){
        return 1;
    }
    if(x%2==0){
        return 0;
    }
    int temp=ceil(sqrt(x*1.0));
    for(int i=3;i<=temp;i+=2){
        if(x%i==0){
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n,x,cnt=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(isprime(x)){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}
/*
6
2
3
4
5
6
7
*/



Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;

int const N = 1e5 + 41;

char s[N];
int n;

void fWin(){
	printf("First\n");
	exit(0);
}

void sWin(){
	printf("Second\n");
	exit(0);
}

void read(){
	scanf("%s",&s);
	n = strlen(s);
}

void solve1(){
	int cnt = 0;
	for(int i=0;i<n;++i){
		if(s[i] == s[0]){
			++cnt;
		}
	}
	int remChar = cnt + (cnt - 1);
	int cntMoves = n - remChar;
	if(cntMoves & 1){
		fWin();
	}else{
		sWin();
	}
}

void solve2(){
	int cnt1 = 0;
	int cnt2 = 0;
	bool needFirst = true;
	for(int i=0;i<n;++i){
		if(needFirst){
			if(s[i] == s[0]){
				++cnt1;
				needFirst = false;
			}
		}else{
			if(s[i] == s[n-1]){
				++cnt2;
				needFirst = true;
			}
		}
	}
	int remChar = cnt1 + cnt2;
	int cntMoves = n - remChar;
	if(cntMoves & 1){
		fWin();
	}else{
		sWin();
	}
}

void solve(){
	if(s[0] == s[n-1]){
		solve1();
	}else{
		solve2();
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();






	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main()
{
    int i, j, n, m;
    int result = 0;

    cin >> n;
    int t[n];
    for (i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    cin >> m;

    int p[m];
    int x[m];
    for (i = 0; i < m; i++)
    {
        cin >> p[i] >> x[i];
    }
    for (i = 0; i < m; i++)
    {
        result = 0;
        for (j = 0; j < n; j++)
        {
            result += t[j];
        }
        result = result - t[p[i] - 1] + x[i];
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;
int main ()
{
	char s[4];
	scanf("%s",&s);
	int a=0,b=0,c=0;
	for(int i=0;i<=2;i++)
	{
		if(s[i]=='a')	a++;
		else if(s[i]=='b')	b++;
		else	c++;
	}
	if(a==1 && b==1 && c==1)
	{
		printf("Yes");
	}
	else	printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

int main() {
    int n;
    cin >> n;
    cout << lcm(2, n) << '\n';
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

ca_inner = 0
ca_outer = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            ca_outer += 1
            if i < j:
                ca_inner += 1

ca_inner *= K
ca_outer *= (K - 1) * K // 2

print((ca_inner + ca_outer) % (10**9 + 7))

Measured memory_bytes: 3316
import sys
ary = list(map(int,input().split()))
count = 0
#最初から同じだった時
if ary[0] == ary[1] == ary[2]:
    print(0)
    sys.exit()

#和が偶数だった時
if (ary[0] + ary[1] + ary[2]) % 2 == 0:
    for i in range(3):
        if ary[i] % 2 == 1:
            ary[i] += 1
            count += 0.5
# 和が奇数だった時
elif (ary[0] + ary[1] + ary[2]) % 2 == 1:
    for i in range(3):
        if ary[i] % 2 == 0:
            ary[i] += 1
            count += 0.5

while not ary[0] == ary[1] == ary[2]:
    ary.sort()
    ary[0] += 2
    count += 1

print(int(count))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,d;
	cin>>n>>m>>d;
	ll k=0;
	if(d==0) k=n;
	else k=2*(n-d);
	cout<<fixed<<setprecision(100)<<k*(m-1)/(ld)(n*n)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

vector<int> g[10000];
int nex[10000]={0};
int ans=0;



void topogi(int i){
	nex[i]=1;
	for(int j=0;j<g[i].size();j++){
		if(nex[g[i][j]]==0){
			topogi(g[i][j]);
		}
		else if(nex[g[i][j]]==1){
			ans=1;
		}
	}
	nex[i]=2;
}
int main(){
	int v,e,s,t;
	int temp;
	
	cin>>v>>e;
	for(int i=0;i<e;i++){
		cin>>s>>t;
		g[s].push_back(t);
	}
	for(int i=0;i<v;i++){
		if(nex[i]==0){
			topogi(i);
		}
	}

	/*while(!A.empty()){
		temp=A.front();
		A.pop();
		printf("%d\n",temp);
		for(int i=0;i<g[temp].size();i++){
			next[g[temp][i]]--;
			if(next[g[temp][i]]==0)A.push(g[temp][i]);
		}
	}*/
	cout<<ans<<endl;
	return 0;
}






Measured memory_bytes: 3404
# coding: utf-8

#桁数判定
def num_of_digits(n):
    digit = 0
    #nが0になるまで
    while n > 0:
        n //= 10
        digit += 1
    return digit

#main
N = int(input())
F = []

i = 1
while i * i <= N:
    if N % i == 0:
        F.append(max(num_of_digits(i), num_of_digits(N//i)))
    i += 1

print(min(F))

Measured memory_bytes: 3060
N,A=map(int,input().split())
x=input().split()

for i in range(N):
    x[i]=int(x[i])
X=max(max(x),A)
for i in range(N):
    x[i]=x[i]-A
dp=[[0 for t in range(2*N*X+1)] for j in range(N+1)]

for j in range(N+1):
    for t in range(2*N*X+1):
        if j==0 and t==N*X:dp[j][t]=1
        elif j>=1:
            if t-x[j-1]<0 or t-x[j-1]>2*N*X:
                dp[j][t]=dp[j-1][t]
            elif t-x[j-1]>=0 and t-x[j-1]<=2*N*X:
                dp[j][t]=dp[j-1][t]+dp[j-1][t-x[j-1]]
print(dp[N][N*X]-1)
#http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf

Measured memory_bytes: 5740
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define prl pair<ll,ll>
#define pri pair<int,int>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define db double
#define N 100005
#define mod 1000000007
#define INF 2147483647
using namespace std;
mt19937 mrand(random_device{}());
uniform_int_distribution<ll> dist(0, 100000000);
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll qpow(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }

int main() {
	IOS;
	int x;
	cin >> x;
	string a;
	a = x >= 30 ? "Yes" : "No";
	cout <<a;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

set<int> S;

int main(){
  ll N,M,A[307][307],top[307],C[307],mi=INF;
  cin >> N >> M;
  rep(i,N){
    rep(j,M){
      cin >> A[i][j];
    }
    top[i]=0;
  }
  rep(i,M){
    // 頭を数える
    Rep(j,1,M+1){
      C[j]=0;
    }
    rep(j,N){
      C[A[j][top[j]]]++;
    }
    // 最大値と数を出す
    ll ma=-1,key=0;
    Rep(i,1,M+1){
      if(ma<C[i]){
        ma=C[i];
        key=i;
      }
    }
    mi = min(ma,mi);
    // 頭をずらす
    S.insert(key);
    rep(i,N){
      while(S.find(A[i][top[i]])!=S.end()){
        top[i]++;
      }
    }
  }
  cout << mi << endl;
}

Measured memory_bytes: 1024
n = int(input())
L = list(map(int, input().split()))
rep = []
for i in range(n):
  for j in range(n-1-i, -1, -1):
    if L[j] == j+1:
      rep.append(L.pop(j))
      break
  else:
    print(-1)
    exit()
print(*rep[::-1], sep="\n")

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

int main(){
    int N; cin >> N;
    int h[N], DP[N];
    for(int i=0; i<N; i++) cin >> h[i];
    DP[0] = 0;
    DP[1] = abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        DP[i] = min(DP[i-2]+abs(h[i]-h[i-2]), DP[i-1]+abs(h[i]-h[i-1]));
    }
    cout << DP[N-1] << endl;
}


Measured memory_bytes: 1024
num = input()
N = num.split()
a = int(N[0])
b = int(N[1])

b1 = 0
if b // 100 == 0:
    if b // 10 ==  0:
        b1 = 10
    else:
        b1 = 100
else:
    b1 = 1000

n = a * b1 + b

n1 = 0
while n > n1 * n1:
    n1 += 1
if n == n1 * n1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import string


class SuffixArray:
    def __init__(self, S):
        self.N = len(S)
        self.S = S
        self.atoi = {x: i for i, x in enumerate(string.printable)}
        self.sa = self.__make_sa()

    def show(self):
        for i, s in enumerate(self.sa):
            print(i, s, self.S[s:])

    def __make_sa(self):
        """配列（文字列）Sのsuffix arrayを返す O(N(logN)^2)"""
        N = self.N
        SA = list(range(N + 1))
        rank = [-1] * (N + 1)
        tmp = [0] * (N + 1)
        k = 1

        for i, s in enumerate(self.S):
            rank[i] = self.atoi[s]

        def key(i):
            if i + k <= N:
                return (rank[i], rank[i + k])
            return (rank[i], -1)

        def cmp(i, j):
            return key(i) < key(j)

        while k <= N:
            SA.sort(key=key)
            tmp[SA[0]] = 0
            for i in range(1, N + 1):
                tmp[SA[i]] = tmp[SA[i - 1]] + cmp(SA[i - 1], SA[i])
            for i in range(N + 1):
                rank[i] = tmp[i]
            k *= 2
        return SA

    def contain(self, T, side="left"):
        """文字列SにTが含まれているかを返すO(|T|log|S|)
        input
            T: 検索する文字列（配列）
            side: left　-> S[sa[i]:sa[i]+NT] == Tとなる最小のindex iを返す
                  right -> 最大のindexを返す
        output:
            含まれる場合: S[sa[i]: sa[i]+NT] == Tとなる最小or最大のi
            含まれない場合: -1
        """
        NT = len(T)
        if NT > self.N:
            return -1
        L = 0
        R = self.N
        if side == "left":
            while R - L > 1:
                m = (L + R) // 2
                i = self.sa[m]
                if self.S[i:i + NT] < T:
                    L = m
                else:
                    R = m
            i = self.sa[R]
            if self.S[i:i + NT] == T:
                return R
        else:
            R += 1
            while R - L > 1:
                m = (L + R) // 2
                i = self.sa[m]
                if self.S[i:i + NT] <= T:
                    L = m
                else:
                    R = m
            i = self.sa[L]
            if self.S[i:i + NT] == T:
                return L
        return -1

    def get_indices(self, T):
        """Sの中に含まれるTの位置を格納したindexのリストを返す"""
        L = self.contain(T, side="left")
        if L == -1:
            return []
        R = self.contain(T, side="right")
        return [self.sa[i] for i in range(L, R+1)]


SA = SuffixArray(input())
res = SA.get_indices(input())
if res:
    res.sort()
    print(*res, sep="\n")


Measured memory_bytes: 6804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


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

int main() {
  int N, A = 0;
  string S;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    
    if (S == "Y") {
      A = 1;
    }
  }
  
  if (A == 1) {
    cout << "Four" << endl;
  }
  
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            String line;
            double degree= 90;
            double x = 0;
            double y = 0;

            while (true) {
                line = br.readLine();
                st = new StringTokenizer(line,",");
                double d = Double.parseDouble(st.nextToken());
                double t = Double.parseDouble(st.nextToken());
                if(d == 0 && t == 0){
                    break;
                }
                x += d * Math.cos(degree / 180 * Math.PI);
                y += d * Math.sin(degree / 180 * Math.PI);
                degree -= t;
            }

            System.out.println((int)x);
            System.out.println((int)y);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 24140
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=100010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,m,cnt;
LL a[N],ans;
int fa[N],vis[N];
priority_queue<pii,vector<pii>,greater<pii>>q;
inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	int x,y;
	file();
	read(n),read(m);
	if(m==n-1){puts("0");exit(0);}
	For(i,1,n)read(a[i]),fa[i]=i,q.push(pii(a[i],i));
	For(i,1,m)read(x),read(y),x++,y++,fa[find(x)]=find(y);
	int tot=n-m-2;
	while(!q.empty())
	{
		pii now=q.top();q.pop();
		x=now.first,y=find(now.second);
		if(vis[y]&&cnt<tot)cnt++,ans+=x;
		else if(!vis[y])vis[y]=1,ans+=x;
	}
	cnt==tot?printf("%lld\n",ans):puts("Impossible");
	return 0;
}


Measured memory_bytes: 2676
#include<iostream>
#include<string.h>
#include<string>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  bool prime[1000000]={};
  int i,j,k,l;
  for(i=2;i<1000000;i++)
    if(prime[i]==false)
      for(j=2;i*j<1000000;j++)
	prime[i*j]=true;
  prime[0]=prime[1]=true;

  int n,p;
  while(1){
    cin>>n>>p;
    if(n==-1 && p==-1)break;
    int m[100005]={};
    int num=0;
 
    for(i=n+1;i<1000+n;i++)
      if(prime[i]==false)
	for(j=i;j<1000+n;j++)
	  if(prime[j]==false){
	    m[num]=i+j;
	    num++;
	  }
    sort(m,m+num);
    cout<<m[p-1]<<endl;
  }
}

Measured memory_bytes: 4468
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a[100010], ans;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] = a[i] - i;
	}
	for(int i = 1; i <= n; i++) {
		if(!a[i] && !a[i + 1]) {
			i++;
			ans++;
		} else if(!a[i]) ans++; 
	}
	printf("%d\n", ans);
} 

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;

int n;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=9;i++)
		if(n%i==0&&n/i<=9) {
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  ll prev;
  ll money = 1000;
  ll n = 0;
  cin >> prev;
  for (int i = 1; i < N; i++) {
    int a;
    cin >> a;
    if (prev > a) {
      money += n * prev;
      n = 0;
    } else if (prev < a) {
      n += money / prev;
      money -= (money / prev) * prev;
    }
    prev = a;
  }
  cout << money + n * prev << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define f .first
#define s .second
using namespace std;
using ll=long long;
int n,W;
pair<ll,ll> item[100005];
ll dp[100005],maxv;
int main(){
	cin>>n>>W;
	for(int i=1;i<=n;++i){
		cin>>item[i]f>>item[i]s;
	}
	for(int i=0;i<=W;++i){
		dp[i]=-1;
	}
	sort(item+1,item+1+n);
	dp[0]=0; 
	for(int i=1;i<=n;++i){
		for(int j=W;j>=item[i]f;--j){
			if(dp[j-item[i]f]!=-1){
				dp[j]=max(dp[j],dp[j-item[i]f]+item[i]s);
			}
		}
	}
	for(int i=1;i<=W;++i){
		maxv=max(maxv,dp[i]);
	}
	cout<<maxv<<'\n';
	return 0;
}

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

using namespace std;

const int MAXN = 100005;

int n, a[MAXN], ans[MAXN];

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

    for(int i = 1; i <= n; ++i)
        printf("%d ", ans[i]);

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

ll a[maxN];
ll b[maxN];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll s = a[1];
	
	for(int i=2;i<=n;i++)
	{
		s = (s * a[i]) / __gcd(s,a[i]);
	}
	int flag = 1;
	for(int i=1;i<=n;i++)
	{
		if( (s / a[i]) %2 != 1)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 0)
	{
		puts("0");
		return 0;
	}
	int ans = 0;
	for(int i=1;(s*i/2) <= m;i+=2)
	{
		if((s * i / 2) >= 1 && (s*i/2) <= m)
		{
			ans ++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
n=int(input())
a=[0]+list(map(int,input().split()))
a.append(0)
temp=0
for i in range(n+1): temp+=abs(a[i+1]-a[i])
for i in range(1,n+1):
    go=a[i]-a[i-1]
    back=a[i+1]-a[i]
    if go*back>0: print(temp)
    else: print(temp-2*(min(abs(go),abs(back))))

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,x,t;
    while(cin >> n >> x >> t){
        int total=0;
        while(n>0){
            total+=t;
            n-=x;
        }cout << total << '\n';
    }
}

Measured memory_bytes: 3548
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;
	char S[101];

	scanf("%zu\n%s", &N, S);

	int32_t x = 0;
	int32_t max = 0;

	for (size_t i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x++;
		}
		else {
			x--;
		}

		if (max < x) {
			max = x;
		}
	}

	printf("%"PRId32"\n", max);

	return 0;
}

Measured memory_bytes: 128
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
   int N;
   cin >> N;
   vector<int> vec(N+1);
   vec.at(0) = -1000000;
   for(int i = 0; i < N; i++)cin >> vec.at(i+1);
   vector<int> dp(N+1);
   dp.at(0) = 1000000;
   dp.at(1) = 0;
   for(int i = 2; i <= N; i++){
       dp.at(i) = min(dp.at(i-1) + abs(vec.at(i) - vec.at(i-1)) , dp.at(i-2) + abs(vec.at(i) - vec.at(i-2)));
   }
   cout << dp.at(N) << endl;
}



Measured memory_bytes: 1024
N, M = map(int, input().split())
PYi = [list(map(int, input().split()))+[i] for i in range(M)]
PYi.sort()
ans = ['']*M
counter = {}

for v in PYi:
    P, Y, i = v

    if not P in counter:
        counter[P] = 1
    else:
        counter[P] += 1

    tmp = ''
    tmp += str(P).zfill(6)
    tmp += str(counter[P]).zfill(6)
    ans[i] = tmp

for v in ans:
    print(v)


Measured memory_bytes: 84440
module List = struct
  include List
  let rec init_tailrec_aux acc i n f =
    if i >= n then acc
    else init_tailrec_aux (f i :: acc) (i+1) n f

  let rec init_aux i n f =
    if i >= n then []
    else
      let r = f i in
      r :: init_aux (i+1) n f

  let init len f =
    if len < 0 then invalid_arg "List.init" else
    if len > 10_000 then rev (init_tailrec_aux [] 0 len f)
    else init_aux 0 len f

  let rec find_opt p = function
    | [] -> None
    | x :: l -> if p x then Some x else find_opt p l
end

let () =
  let a, b = Scanf.scanf "%s %s " (fun a b -> a, b) in
  let ab = int_of_string (a^b) in
  let pows = List.init 10000 (fun i -> (10000-i) * (10000-i)) in
  Printf.printf "%s\n" (
    match (List.find_opt (fun x -> x = ab) pows) with
      Some x -> "Yes"
    | None -> "No"
  )


Measured memory_bytes: 1152
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){ 
  ll n;cin>>n;
  string s="YES";
  vector<ll>p(n);
  rep(i,n)
    cin>>p.at(i);
  sort(p.begin(),p.end());
for(int i=1;i<n;i++)
{
  if(p.at(i-1)==p.at(i))
    s="NO";
}
  cout<<s;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
int main(){
    int ans=0,n,a,b,p,q,r;
    cin>>p>>q>>r;
    ans=INF;
    ans=min(p+q,q+r);
    ans=min(ans,p+r);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
      
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  int sum=0;
  for(int i=1;i<=min(9,n);i++){
    sum++;
  }
  for(int i=100;i<=min(999,n);i++){
    sum++;
  }
  for(int i=10000;i<=min(99999,n);i++){
    sum++;
  }
  cout<<sum<<'\n';
  return 0;
}


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

const int N = 1e5 + 5;

int n;
vector<int> g[N];
int A, newA, lim;

int dfs(int u,int p) {
	multiset<int> ms;
	for (int v : g[u]) if (v != p) {
		ms.insert(dfs(v, u) + 1);
	}
	
	vector<int> rem;
	while (!ms.empty()) {
		multiset<int>::iterator it = ms.end();
		int x = *(--it);
		ms.erase(it);
		it = ms.upper_bound(lim - x);
		if (it == ms.begin()) rem.push_back(x);
		else ms.erase(--it), newA++; 
	}
	
	reverse(rem.begin(), rem.end());
	while (!rem.empty() && rem.back() == lim) newA++, rem.pop_back();
	if (rem.empty()) return 0;
	else { newA += rem.size() - 1; return rem[0]; }
}

bool check() {
	newA = 0;
	newA += dfs(1, 1) > 0;
	return newA == A;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n - 1; ++i) {
		int u, v; cin >> u >> v;
		g[u].push_back(v), g[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) {
		A += g[i].size() & 1;
	}
	A /= 2;
	int l = 1, r = n;
	while (l < r) {
		lim = l + r >> 1;
		if (check()) r = lim;
		else l = lim + 1;
	}
	cout << A << ' ' << l << '\n';
}

Measured memory_bytes: 20352
// inputに入力データ全体が入る
function Main(input) {
    "use strict";
    // 1行目がinput[0], 2行目がinput[1], …に入る
    const input_ = input.split(" ");
    const toInt = function (n, array) {
        let result = [];
        for (let i = 0; i < n; i++) {
            result[i] = parseInt(array[i]);
        }
        return result;
    };
    const input_i = toInt(input_.length, input_);
    let lcm = 0; // 最小公倍数
    let gcd = 0; // 最大公約数
    /* Variadic function -- Returns the greatest common divisor of a list of arguments */
    Math.gcd = function () {
        if (arguments[1] == 0)
            return arguments[0];
        else
            return Math.gcd(arguments[1], arguments[0] % arguments[1]);
    };
    input_i.sort((a, b) => b - a);
        gcd = Math.gcd(input_i[0], input_i[1]);
        lcm = input_i[0] * input_i[1] / gcd;
    // 出力
    console.log('%d', lcm);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
import string
from sys import stdin

chs = dict([(ch, 0) for ch in string.ascii_lowercase])

for line in stdin:
    for ch in line:
        c = ch.lower()

        if c not in chs:
            continue

        chs[c] += 1

for ch in string.ascii_lowercase:
    print(ch, ':', chs[ch])

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

int main(){
    int n, k, x;
    cin >> n >> k;

    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> x;
        sum += 2 * min(x, abs(x-k));
    }
    cout << sum << endl;
  
    return 0;
}


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  char s1[300000];
  char s2[300000];
  
  scanf("%s", s1);
  scanf("%s", s2);
  
  int ans=0;
  for(int i=0;i<250000;i++){
    if(s1[i]=='\0')break;
    if(s1[i]!=s2[i])ans++;
  }
  
  printf("%d",ans);
  
  return 0;
}


Measured memory_bytes: 4140
#include <stdio.h>
#include <iostream>
#include <string> 
using namespace std;

int main(void) {
    int K,S,a=0;
    cin >> K >> S;
    for (int x = 0; x < K + 1; x++) {
        for (int y = 0; y < K + 1; y++) {
            if (S-x-y <= K && S-x-y >= 0) a++;
        }
    }
    cout << a << endl;
    return 0;
}

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;

    bool check  = false;

    for(int i = 1; i <= b; i++){
        if( (a * i - c) % b == 0){
            check = true;
        }
    }
    if(check){
        cout << "YES" << endl;
        return 0;
    }
    else{
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n,d;
ld x[25][25];

int main(){
	cin >> n >> d;
	FOR(i,1,n){
		FOR(j,1,d){
			cin >> x[i][j];
		}
	}
	int ans = 0;
	FOR(i,1,n-1){
		FOR(j,i+1,n){
			float dist=0;
			FOR(k,1,d){
				dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			dist = sqrt(dist);
			if(dist-int(dist) == 0.0){
				ans += 1;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

	int h, w;
	int ii, jj;

	for (;;) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}
		for (ii = 0; ii < h; ii++) {
			for (jj = 0; jj < w; jj++) {
				if (ii == 0 || ii == h - 1) {
					printf("#");
				}
				else if (jj != 0 && jj != w - 1) {
					printf(".");
				}
				else {
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;

  if (B >= C) out(B + C);
  else {
    if (A >= C - B) out(B + C);
    else out(2 * B + A + 1);
  }
  return 0;
}


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

using namespace std;

const int MAXN = 2E5;
int freq[26];
int cnt[26];
int a[MAXN];
int b[MAXN];
deque<int> occ1[26];
deque<int> occ2[26];
int bit1[MAXN];
int bit2[MAXN];

void inc(int bit[MAXN], int pos, int amt)
{
    if (pos == 0)
    {
        bit[0] += amt;
        return;
    }
    while (pos < MAXN)
    {
        bit[pos] += amt;
        pos += pos & -pos;
    }
}

int query(int bit[MAXN], int pos)
{
    int ans = bit[0];
    while (pos > 0)
    {
        ans += bit[pos];
        pos -= pos & -pos;
    }
    return ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int n = (int) s.length();
    int parity = 0;
    for (int i = 0; i < n; i++)
    {
        int key = s[i] - 'a';
        freq[key]++;
        if (freq[key] % 2 != 0)
        {
            parity++;
        }
        else
            parity--;
    }
    int odd = 0;
    for (int i = 0; i < 26; i++)
        if (freq[i] % 2 != 0)
            odd = i;
    if ((n % 2 == 0 && parity != 0) || (n % 2 != 0 && parity != 1))
    {
        cout << -1 << endl;
    }
    else
    {
        long long ans = 0;
        int numRight = 0;
        int x = 0;
        int y = n / 2 - 1;
        bool flag = false;
        for (int i = 0; i < n; i++)
        {
            int key = s[i] - 'a';
            if (n % 2 != 0 && key == odd && cnt[key] == freq[key] / 2)
            {
                flag = true;
                ans += numRight;
            }
            else if (cnt[key] < freq[key] / 2)
            {
                occ1[key].push_back(x);
                if (flag)
                    ans++;
                ans += numRight;
                a[x++] = key;
            }
            else
            {
                occ2[key].push_front(y);
                numRight++;
                b[y--] = key;
            }
            cnt[key]++;
        }
        int len = n / 2;
        for (int i = 0; i < len; i++)
        {
            int best = 10 * MAXN;
            int p1, p2;
            p1 = p2 = 0;
            int key =  0;
            for (int j = 0; j < 26; j++)
            {
                if (!occ1[j].empty())
                {
                    int pos1 = occ1[j].front();
                    int pos2 = occ2[j].front();
                    int d = pos1 + pos2 - query(bit1, pos1 - 1) - query(bit2, pos2 - 1);
                    if (d < best)
                    {
                        key = j;
                        best = d;
                        p1 = pos1;
                        p2 = pos2;
                    }
                }
            }
            ans += best;
            inc(bit1, p1, 1);
            inc(bit2, p2, 1);
            occ1[key].pop_front();
            occ2[key].pop_front();
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main(){
    string m;
    getline(cin, m);
    for(int i=0;i<(int)m.size();i++){
        if(m[i] >= 'A'&&m[i] <= 'Z'){
            m[i] -= ('A' - 'a');
        }
        else if(m[i] >= 'a'&&m[i] <= 'z'){
            m[i] += ('A' - 'a');
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3236
Scanf.scanf "%d" (fun n ->
    let rec loop i acc highest =
        if i = n then acc else
            let h = Scanf.scanf " %d" (fun h -> h) in
            if h >= highest then loop (i + 1) (acc + 1) h else loop (i + 1) acc highest
    in
    loop 0 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 384
import sys
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if i*10000 + j*5000 + (N-(i+j))*1000 == Y:
            print(i,j,N-(i+j))
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    double a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    double x=ceil(a[1]/a[3]);
    double y=ceil(a[2]/a[4]);
    
    if(x>y)cout<<a[0]-x<<endl;
    else cout<<a[0]-y<<endl;
    
}

Measured memory_bytes: 3240
n, k, c = map(int, input().split())
s = input()
left_to_right = [0 for _ in range(n)]
right_to_left = [0 for _ in range(n)]

now = 1
i = 0
while i < n:
    if s[i] == "x":
        i += 1
        continue
    left_to_right[i] = now
    now += 1
    i += c + 1
for i in range(1, n):
    if left_to_right[i] == 0:
        left_to_right[i] = left_to_right[i - 1]

s = s[::-1]
now = 1
i = 0
while i < n:
    if s[i] == "x":
        i += 1
        continue
    right_to_left[i] = now
    now += 1
    i += c + 1
right_to_left = right_to_left[::-1]
for i in range(n - 2, -1, -1):
    if right_to_left[i] == 0:
        right_to_left[i] = right_to_left[i + 1]

ans = 0
for i in range(n):
    tmp = 0
    if i - 1 >= 0:
        tmp += left_to_right[i - 1]
    if i + 1 < n:
        tmp += right_to_left[i + 1]
    if tmp < k:
        print(i + 1)

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

int main() {
  int n;
  cin>>n;
  int mod = 1e9 + 7;
  string s[2];
  cin>>s[0];
  cin>>s[1];

  int idx;
  long long ans;
  if (s[0][0] == s[1][0]) {
    ans = 3;
    idx = 1;
  } else {
    ans = 6;
    idx = 2;
  }
  while (idx < n) {
    if (s[0][idx] == s[1][idx]) {
      if (s[0][idx-1] == s[1][idx-1]) {
        ans = (ans * 2) % mod;
      }
      idx += 1;
    } else {
      if (s[0][idx-1] == s[1][idx-1]) {
        ans = (ans * 2) % mod;
      } else {
        ans = (ans * 3) % mod;
      }
      idx += 2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int YJ,MUR,KMR;
    cin>>YJ>>MUR>>KMR;
    if(YJ<MUR && MUR<KMR){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    
}
    


Measured memory_bytes: 3076
import sys
from collections import deque

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    n = int(input_raw[0])
    input_raw = list(read_func().strip().split())
    b_list = deque([])
    is_last_first = False
    for i in range(n):
        is_last_first = not(is_last_first)
        if is_last_first == True:
            b_list.append((input_raw[i]))
        else:
            b_list.appendleft(input_raw[i])

    if is_last_first == True:
        b_list.reverse()
    print " ".join(b_list)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27316
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let s: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut ans = 0;
    for i in 1..n {
        let mut now = 0;
        let mut v = vec![false; n];
        for j in 1..n {
            let (k1, k2) = (i * j, n - 1 - i * j);
            if k1 == k2 || k2 <= i || v[k1] || v[k2] {
                break;
            }
            v[k1] = true;
            v[k2] = true;
            now += s[k1] + s[k2];
            ans = std::cmp::max(ans, now);
        }
    }

    println!("{}", ans);
}


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

int main() {
    int N;
    int c[4] = {0, 0, 0, 0};
    cin >> N;

    string input[N];

    string Lis[4] = {"AC", "WA", "TLE", "RE"};

    for (int i = 0; i < N; i++) {
        cin >> input[i];
        for (int j = 0; j < 4; j++) {
            if (input[i] == Lis[j]) c[j]++;
        }
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;

    return 0;
}


Measured memory_bytes: 6752
n,m=map(int,input().split())
H=list(map(int,input().split()))
ans=[i  for i in range(1,n+1)]
low=[]
for i in range(m):
    x,y=map(int,input().split())
    if H[x-1]==H[y-1]:
        low.append(x)
        low.append(y)
    elif  H[x-1]>H[y-1]:
        low.append(y)
    else:
        low.append(x)
low=list(set(low))
print(len(ans)-len(low))

Measured memory_bytes: 23696
#include <stdio.h>
#define N 100

int main(void) 
{
	int i,v,k,j,n,m,a[N];
	scanf("%d",&n);
	for(m=0;m<n;m++){
		scanf("%d",&a[m]);
	}
	for(k=0;k<n;k++){
		printf("%d",a[k]);
		if(k != n-1){
			printf(" ");
		}
	}
	printf("\n");

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

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


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

	int n;
	cin >> n;

	priority_queue<pair<int, int> > que;
	vector<int> a(n);
	vector<int> b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
		if(b[i] > a[i])
			que.push(make_pair(b[i], i));
		else if(b[i] < a[i]){
			cout << -1 << endl;
			return 0;
		}
	}

	unsigned long long cnt = 0;
	while(!que.empty()){
		auto p = que.top(); que.pop();

		int i = p.second;
		int l = b[(i-1+n) % n], r = b[(i+1+n) % n];
		unsigned long long target = max(a[i], max(l, r));
		unsigned long long mod = l+r;
		int num = (p.first - target + mod - 1)/mod;
		int x = p.first - num*mod;
		cnt+=num;
		b[i] = x;

		if(x == a[i]){
			continue;
		}else if(x < a[i]){
			cout << -1 << endl;
			return 0;
		}
		que.push(make_pair(x, i));
	}
	for(int i=0;i<n;i++){
		if(a[i] != b[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int sosuu(long x) {
    for (long i = 2; i < x; i++){
    	if (x%i == 0) return 0;
    }
    return 1;
}

int main() {
    long a;
    int c;
    cin >> a;
    for (int i = a; 100000; i++){
        c = sosuu(i);
        if (c == 0) continue;
        cout << i << endl;
        return 0;
    }
}



Measured memory_bytes: 256
#include<cstdio>
#define gc ch=getchar()
inline int read(){
	int x=0,f=1;char gc;
	for(;ch<'0'||ch>'9';gc)if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';gc)x=x*10+ch-'0';
	return x*f;
}
#undef gc
int main(){
	int n=read();
	printf("%d\n",n*n-read());
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long[] x = new long[N];
    for (int i = 0; i < N; i++) {
      x[i] = sc.nextLong();
    }
    long ans = Long.MAX_VALUE;
    for (int i = 0; i < N - K + 1; i++) {
      long tmp = Math.min(Math.abs(x[i]), Math.abs(x[i + K - 1]));
      tmp += Math.abs(x[i] - x[i + K - 1]);
      if (ans > tmp) {
        ans = tmp;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 60976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N){
        cin >>A[i];
    }
    ll now =1000;
    ll mx;
    //vector<vector<ll>> dp(N,vector<ll>()
    mx = A[0];
  
    rep(i,N){
        if( A[i]>mx){
            now = (now/mx)*A[i] + now - (now/mx)*mx;
            mx = A[i];
        }
        if(A[i]<mx){
            mx = A[i];
        }
        
    }
    cout << now << endl;


    return 0;
    

}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
  string S;
  cin >> S;
  int a = S.size();
  int b = S.size();
  for (int i = 1; i < S.size(); i++) {
    if (S[i] != S[i - 1])
      a = min(a, max(i, b - i));
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 512