akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


bool prime[50010];
int n;

int main(){
	rep(i,50010) prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i*i<=50010;i++){
		if(prime[i]){
			for(int j=i*i;j<50010;j+=i){
				prime[j]=false;
			}
		}
	}
	
	while(cin>>n,n!=0){
		int res=0;
		//cout<<"n= "<<n<<endl;
		for(int i=2;2*i<=n;i++){
			if(prime[i]&&prime[n-i]){
				//cout<<i<<" "<<n-i<<endl;
				res++;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N;
  ll x;
  cin >> N >> x;
  vector<ll> as(N, 0L);
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
  }
  ll ans = 0L;
  for(int i = 1; i < N; ++i) {
    // すでにx以下
    if(as[i] + as[i - 1] <= x) {
      continue;
    }
    auto v = as[i] + as[i - 1] - x;
    ans += v;
    if(as[i] >= v) {
      as[i] -= v;
    } else {
      as[i - 1] -= v - as[i];
      as[i] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
	int  i, j, n;
	string str;
	char s[100];

	cin >> n;

	double num; int flag;
	for (i = n; i > 0; i--) {
		num = sqrt(i);
		sprintf(s, "%f", num);
		flag = 0;
		for (j = 0; j < strlen(s); j++) {
			//if (!isdigit(s[j])) {
			if(s[j] == '.'){
				for (int k = j + 1; k < strlen(s); k++) {
					if (s[k] != '0') {
						flag = 1;
						break;
					}
				}
			}
		}

		if (flag == 0) {
			cout << i << endl;
			break;
		}
	}




	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  int n = in;
  auto a = in.Array(n);
  for (auto& i : a) {
    i--;
  }
  int ans = 0;
  rep(i, n) {
    if (i == a[a[i]]) ans++;
  }
  cout << (ans / 2) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
typedef struct{
  double x;
  double y;
} P;
void kock(int, P , P);/* コッホ曲線の頂点の座標を順番に出力する関数。*/
int main()
{
  int n;
  P P1 = {0,0}, P2 = {100,0};
  
  scanf("%d",&n);

  printf("%.8f %.8f\n",P1.x,P1.y);
  kock(n, P1, P2);
  printf("%.8f %.8f\n",P2.x,P2.y);

  return 0;
}

void kock(int n, P p1, P p2)
{
  P s, t, u;

  if(n == 0) return;

  s.x = (double)(2 * p1.x + 1 * p2.x)/(double)3;
  s.y = (double)(2 * p1.y + 1 * p2.y)/(double)3;
  t.x = (double)(1 * p1.x + 2 * p2.x)/(double)3;
  t.y = (double)(1 * p1.y + 2 * p2.y)/(double)3;

  u.x = (t.x - s.x) * cos(M_PI/(double)3) - (t.y - s.y) * sin(M_PI/(double)3) + s.x;
  /* M_PIはmath.hに円周率πとして定義されている */
  u.y = (t.x - s.x) * sin(M_PI/(double)3) + (t.y - s.y) * cos(M_PI/(double)3) + s.y;

  kock(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1, t, p2);
  
}



Measured memory_bytes: 2048
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
M=4*m
s=sum(a)
count=0

for i in range(n):
  if a[i]<s/M:
    a[i]=0

for i in range(m):
  if a[i]!=0:
    count+=1

if count==m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>

char C[2][3];

int main() {
    bool f = true;
    std::cin >> C[0][2] >> C[0][1] >> C[0][0];
    for (int i=0; i<3; ++i) {
        std::cin >> C[1][i];
        if (C[1][i] != C[0][i]) f = false;
    }
    if (f) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int a,b;
  while(scanf("%d %d",&a,&b)!=EOF)cout<<a+b<<endl;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
int n,m,sum[100005],vis[100005],ans;
int main(){
	n=read(),m=read();vis[1]=1;
	for(int i=1;i<=n;++i) sum[i]=1;
	for(int i=1;i<=m;++i){
		int x=read(),y=read();
		sum[x]--,sum[y]++;
		if(vis[x]) vis[y]=1;
		if(!sum[x]) vis[x]=0;
	//	cout<<x<<' '<<vis[x]<<' '<<y<<' '<<vis[y]<<endl;
	}
	for(int i=1;i<=n;++i){
	//	cout<<i<<' '<<vis[i]<<endl;
		if(vis[i]) ++ans;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
    sc.nextLine();
        String input = sc.nextLine();
//System.out.println(input);
       System.out.println(execute(input));

    }

    public static int execute(String input) {

       long[] list = Arrays.asList(input.split(" ")).stream().mapToLong(Long::parseLong).toArray();
        int sum = 0;

        for (int i = 1; i <= list.length - 1; i++) {
            if (list[i-1] == list[i]) {
                i++;
                sum++;
            }
        }
        return sum;

    }
}


Measured memory_bytes: 28884
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    ll n,x,t;
    cin>>n>>x>>t;
    if (n%x==0)cout<<(n/x)*t<<endl;
    else cout<<(n/x+1)*t<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
		solve();
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a[6];
int main(){
for(int i=1;i<=5;i++){
  cin>>a[i];
}
int index_ans=0;
for(int i=1;i<=5;i++){
  if(a[i]==0){
    index_ans=i;
    break;
  }
}
cout<<index_ans<<endl;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
         Scanner scanner =new Scanner(System.in);
        String  s= scanner.next();
        int count=0;
        if (s.charAt(0)=='1'){count++;}
        if (s.charAt(1)=='1'){count++;}
        if (s.charAt(2)=='1'){count++;}
        System.out.println(count);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    vector<int> a;
    rep(i,3){
        int A;
        cin >> A;
        a.push_back(A);
    }
    sort(a.begin(), a.end());
    if(a[2]-a[1]-a[0]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const int INF = 1e8;

int main() {
  int h, n;
  cin >> h >> n;
  V<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  V<int> dp(h + 10, INF);
  rep(i, h + 1) {
    rep(j, n) {
      if (i + 1 > a[j]) {
        dp[i + 1] = min(dp[i + 1], dp[i + 1 - a[j]] + b[j]);
      } else {
        dp[i + 1] = min(dp[i + 1], b[j]);
      }
    }
  }
  cout << dp[h] << endl;
}


Measured memory_bytes: 3472
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e18);
const int mod = (int)(1e9) + 7; // check modulo
const double eps = (1e-6);


void solve(int test) {
    int n, k; cin >> n >>  k;
    vector <int> v;
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        v.pb(x);
    }
    sort(all(v));
    int res = 0;
    for(int i = 0; i < k; ++i) res += v[i];
    cout << res;
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;// cin >> test;
    for(int tt = 1; tt <= test; ++tt) {
        solve(tt);
    }


    return 0;
}

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

int main(){
  long long N,ans=100000000000;
 
  cin>>N;
  vector<int > x(N);
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  for(int i=x[0];i<=x[N-1];i++){
    long long a=0;
    for(int j=0;j<N;j++){
      a+=(i-x[j])*(i-x[j]);
    }
    ans=min(a,ans);
  }
  cout<<ans;
  
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    multiset<ld> s;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s.insert(a);
    }
    while(s.size() >= 2) {
        ld a = *s.begin();
        s.erase(s.begin());
        ld b = *s.begin();
        s.erase(s.begin());
        s.insert((a + b) / 2);
    }
    cout << fixed << setprecision(15) << *s.begin() << endl;


    return 0;
}




Measured memory_bytes: 256
import sys
def f(A,N):
    INF=10**18+1
    C=[0 for _ in [0]*N]
    C[0],cp=1,0
    for i in range(2,N+2):
        if C[A[cp]]>0:return (A[cp],C[A[cp]]-1,i-C[A[cp]])
        else:C[A[cp]],cp=i,A[cp]
    return (-1,0,INF)
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    A=list(map(lambda x:int(x)-1,sys.stdin.readline().split()))
    a,n,m=f(A,N)
    (cp,X)=(0,K) if a==-1 or K<=n else (a,(K-n)%m)
    for _ in range(X):cp=A[cp]
    print(cp+1)
if __name__=='__main__':main()

Measured memory_bytes: 31404
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	int n,m;
	int a[51],b[51];
	int e=0;
	cin>>n>>m;

	for(int i=1; i<m+1; i++){
		cin>>a[i]>>b[i];
	}


	for(int j=1; j<n+1; ++j){
		e=0;
		for(int i=1; i<m+1; ++i){
			if(a[i]==j){
				e++;
			}
			if(b[i]==j){
				e++;
			}
		}
		cout<<e<<endl;
	}



	return 0;
}



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n = readln.chomp.to!int;

  bool[string] dic;

  for (int i = 0; i < n; i++) {
    auto input = readln.chomp.split;

    auto key = input[1];

    if (input[0] == "insert") {
      dic[key] = true;
    } else {
      if (dic.get(key, false)) {
	"yes".writeln;
      } else {
	"no".writeln;
      }
    }
  }
}

Measured memory_bytes: 57628
import bisect
primes = [0, 0] + [1] * 49999
for i in range(2, 225):
    if primes[i]:
        for j in range(i*i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(input())
    if n == 0:
        break
    I = bisect.bisect(values, n//2)
    print(sum(primes[n-v] for v in values[:I]))

Measured memory_bytes: 8264
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll n,ans;
int main()
{
    go;
    cin>>n;
    ll ans=n*(n+1)/2 -n;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
i,m=0,1e9
while(i+len(t)<=len(s)):
    c=0
    for j in range(len(t)):
        if(s[i+j]!=t[j]):
            c+=1
    m=min(m,c)
    i+=1
print(m)       
    

Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#include <queue>
#define INF 1000000000000000009;

using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}

int main() {
	long long num[5],ans=0;
	ans = -9223372036854775806;
	for (int i = 0; i < 4; i++) {
		cin >> num[i];
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (2 <= i + j && i + j <= 4 && i != j) {
				if (ans <= num[i] * num[j]) {
					ans = num[i] * num[j];
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3628
n, ma, mb = gets.chomp.split(" ").map(&:to_i)
a, b, c = [], [], []
n.times do |i|
    a[i], b[i], c[i] = gets.chomp.split.map(&:to_i)
end

INF = 10**7

dp = Array.new(n+1, INF).map{Array.new(401, INF).map{Array.new(401, INF)}}

dp[0][0][0] = 0

for i in 0..(n-1)
    for j in 0..400
        for k in 0..400
            next if dp[i][j][k] == INF
            dp[i+1][j][k] = dp[i][j][k] if dp[i][j][k] < dp[i+1][j][k] 
            dp[i+1][j+a[i]][k+b[i]] = dp[i][j][k] + c[i] if dp[i][j][k] + c[i] < dp[i+1][j+a[i]][k+b[i]] 
        end
    end
end

ans = INF
for i in 1..n
    for j in 1..400
        for k in 1..400
            next if k * ma != j * mb
            ans = dp[i][j][k] if dp[i][j][k] < ans
        end
    end
end

puts ans == INF ? -1 : ans

Measured memory_bytes: 56216
N, P = [int(i) for i in input().strip().split(" ")]
S = [i for i in input()]

r = [int(i) % P for i in S]

ret = 0

if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            ret += (i+1)
else:
    from collections import defaultdict
    S.reverse()
    mp = defaultdict(int)
    mp[0] = 1
    cur = 0
    p10 = 1
    for c in S:
        cur = (cur + int(c) * p10) % P
        ret += mp[cur]
        mp[cur] += 1
        p10 *= 10
        p10 %= P

print(ret)

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

int main() {
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (s - x - y >= 0 && s - x - y <= k) ans++;
		}
	}

	cout << ans << endl;

 	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a_ = list(map(int, input().split()))
MOD = 1000000007

cnt = 1
rbg = [0, 0, 0]

for a in a_:
    tmp = 0
    flg = 0
    for i in range(3):
        if rbg[i] == a:
            tmp += 1
            if flg == 0:
                rbg[i] += 1
            flg = 1
    cnt = cnt*tmp%MOD
print(cnt)

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

int main(void){
	char str[21];
	char str2[21];
	int len;
	int i;

	scanf("%s", str);
	len = strlen(str);

	for(i=0; i < len; i++){
		str2[i] = str[len-1-i];
	}
	str2[i] = '\0';

	printf("%s\n", str2);

	return 0;
}

Measured memory_bytes: 0
def main(N,xs):
    # type: (int, List[int]) -> None
    xs.sort(reverse=True)
    alice = xs[0::2]
    bob = xs[1::2]
    print(sum(alice)-sum(bob))
    return

if __name__ == '__main__':
    N = int(input())
    xs = list(map(int,input().split()))
    main(N,xs)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >>  N;
    vector<int> L(N);
    for (auto& l : L) cin >> l;
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            const auto& litr = upper_bound(L.cbegin() + j, L.cend(), abs(L[i] - L[j]));
            const auto& ritr = lower_bound(L.cbegin() + j, L.cend(), L[i] + L[j]) - 1;
            ans += distance(litr, ritr);
        }
    }
    cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    rep(i, 1000000000) {
        if(abs(A - i) == abs(B - i)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int inp[100010];
int dp[100010];

int main(){


    int n;
    cin>>n;

    int k;
    cin>>k;

    for(int i = 0; i < n; i++) {
        cin>>inp[i];
        dp[i] = 2000000000;
    }

    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if(i-j < 0) break;
            dp[i] = min(dp[i], dp[i-j] + abs(inp[i] - inp[i-j]));
        }
    }

    cout<<dp[n-1]<<endl;
    


}


Measured memory_bytes: 1024
import sys
import numpy as np
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int, readline().split()))

arr = np.array(a)
a1 = np.where(arr % 2 != 0)

#print(a1)
a2 = a1[0] + 1
a3 = np.where(a2 % 2 != 0)
#print(a3)
print(len(a3[0]))


Measured memory_bytes: 27268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

int main(){
  int k, a, b;  cin >> k >> a >> b;
  string ans="NG";
  for(int i=a; i<=b; i++){
    if(i%k==0) ans = "OK";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001];
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	ll ans[100001];
	ans[0]=0;
	rep(i,N){
		ans[i+1]=A[i]-ans[i];
	}
	ans[0]=(ans[0]+ans[N])/2;
	rep(i,N-1){
		ans[i+1]=A[i]-ans[i];
	}
	rep(i,N) printf("%lld ",ans[i]*2);
	kaigyo;
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








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

	if (n % 2 == 1) {
		cout << "0" << endl;
		return 0;
	}
	long long int ans = 0;

	while (n > 0) {
		ans += (n / 10);
		n /= 5;
	}

	cout << ans << endl;


	return 0;

}



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

using namespace std;

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

    int W, H, x, y; cin>>W>>H>>x>>y;
    double ans = double(W)*H/2;
    bool not_only = x*2 == W and y*2 == H;
    cout << fixed << setprecision(10) << ans << ' ';
    cout << not_only << endl;

    return 0;
}



Measured memory_bytes: 384
def main():
	import itertools
	n,m = map(int,input().split())
	l = [list(map(int,input().split())) for i in range(m)]
	gaterange = []
	#gate1とgate2の共通部分を出す
	li = []
	ri = []
	for i in range(m):
		li.append(l[i][0])
		ri.append(l[i][1])
	print(len(list(range(max(li)-1,min(ri)))))
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 73176
fn main() {
    let input = read().parse::<u32>().unwrap();
    let add = if input % 2 == 1 { 1 } else { 0 };
    println!("{}", input / 2 + add);
}
fn read() -> String {
    use std::io::Read;
    let mut line = String::new();
    std::io::stdin().read_to_string(&mut line).unwrap();
    line.trim().to_string()
}


Measured memory_bytes: 4352
from collections import deque
n = int(input())
di = 0
Q = deque()
for i in map(int,input().split()):
    if di: Q.appendleft(i)
    else: Q.append(i)
    di = 1-di
for i in range(n):
    if n%2 == 0: print(Q.popleft(), end=' ')
    else: print(Q.pop(), end=' ')

Measured memory_bytes: 25544
#include<stdio.h>
int main()
{
    int n,i;
  double answer;
  
  scanf("%d\n",&n);
  
  double x[n];
  char u[n][3];
  
  for(i=0;i<n;i++){
  scanf("%lf ",&x[i]);
  scanf("%c%c%c",&u[i][0],&u[i][1],&u[i][2]);
  }
  
 for(i=0;i<n;i++){
   if(u[i][0]=='J')
     answer+=x[i];
  
   if(u[i][0]=='B')
     answer+=380000*x[i];
 }
  
  printf("%f\n",answer);
  
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[2][230];
//int t[100005] , x[100005] , y[100005];
int gcd(int a , int b , int c)
{
		int x = __gcd(a ,b);
		return __gcd(x , c);
}

int main(){
	dhoom;
	int n;
	cin >> n;
	ll m = 0 , a = 0 , r = 0 , c = 0 , h = 0;
	for(int i = 0 ; i < n ;i++){
		string s;
		cin >> s;
		if(s[0] == 'M')
			m++;
		if(s[0] == 'A')
			a++;
		if(s[0] == 'R')
			r++;
		if(s[0] == 'C')
			c++;
		if(s[0] == 'H')
			h++;
	}
	ll d[] = {m , a , r , c , h};
	ll ans = 0;
	for(int i = 0 ; i < 5; i ++){
		for(int j = i + 1 ; j < 5 ; j++)
			for(int k = j + 1 ; k < 5 ; k++){
				ans += d[i] * d[j] * d[k];
				
			}
	}
	cout << ans << endl;
	return 0;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i=0; i<n; i++){
            array[i] = sc.nextInt();
        }

        System.out.println(cal(array));
    }

    public static int cal(int[] array){
        int ans = -1000000000;
        int min = array[0];

        for(int i=0; i < array.length-1; i++){
            if(array[i] < min) min = array[i];
            int def = array[i+1] - min;
            if(ans < def) ans = def;
        }
        return ans;
    }
}

Measured memory_bytes: 96312
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = 998244353;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int s = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        long[][] dp = new long[n+1][s+1];

        dp[0][0] = 1;

        for (int i=1; i<=n; i++) {
            for (int j=0; j<=s; j++) {
                int tmp = arr[i-1];
                dp[i][j] += dp[i-1][j] * 2;
                dp[i][j] %= MOD;
//                if (j+tmp<=s) dp[i][j+tmp] += dp[i-1][j];
                if (tmp<=j) dp[i][j] += dp[i-1][j-tmp];
                dp[i][j] %= MOD;
            }
        }

        for (int i=0; i<=n; i++) {
            for (int j=0; j<s; j++) {
//                System.out.print(dp[i][j]+" ");
            }
//            System.out.println(dp[i][s]);
        }

        System.out.println(dp[n][s]);

    }
}


Measured memory_bytes: 137016
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){
  
  int c[6];
  cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4] >> c[5];
  
  cout << (c[0] + c[1] * 5 + c[2] * 10 + c[3] * 50 + c[4] * 100 + c[5] * 500 >= 1000) << endl;
 
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int n,a; cin >> n >> a;
    Ans(n%500 <= a);
    return 0;
}

Measured memory_bytes: 256
/*Filename: aoj0001.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	const int MOUNTAIN_NUM = 10;
	int mountain[MOUNTAIN_NUM];

    for(int i = 0; i < MOUNTAIN_NUM; ++i){
    	cin >> mountain[i];
    }

    sort(mountain, mountain + MOUNTAIN_NUM, greater<int>());

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

	return 0;
}

Measured memory_bytes: 1176
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif_min = 100000
for i in range(N):
    temp = T - H[i] * 0.006
    dif = abs(temp-A)
    if dif_min > dif:
        dif_min = dif
        ans = i+1
print(ans)

Measured memory_bytes: 3060
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT








#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vvi vector<vector<int>>
#define viil vector<vector<long long>>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define mci map<char , int >
#define mcl map<char , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto i=0 ; i<x; ++i)
#define repa(i,a,b) for(auto i=a; i<b; ++i)
#define repe(i,x) for(auto i=0; i<=x; ++i)
#define repea(i,a,b) for(auto i=a;i<=b;++i)
#define ef else if
#define wh while
#define el else
#define ivar(x) int x; cin>>x
#define lvar(x) bint x; cin>>x
#define svar(x) string x; cin>>x
#define cvar(x) char x; cin>>x
#define fvar(x) float x; cin>>x
#define dvar(x) double x; cin>>x
#define endl '\n'
using namespace std;


auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivar(n);ivar(m);
    cout<<max(0,n-2*m)<<endl;
    return ;
}

int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

int main(void) {
	// input
	std::string str;
	std::cin >> str;
	
	// string to vector<int>
	int n = str.size();
	std::vector<int> t(n);
	for(int i = 0; i < n; ++i) {
		t[i] = (str[i] - '0');
	}
	
	// final states
	std::vector<int> ioio(n), oioi(n);
	for(int i = 0; i < n; ++i) {
		if(i % 2 == 1) {
			ioio[i] = 1;
			oioi[i] = 0;
		}
		else {
			ioio[i] = 0;
			oioi[i] = 1;
		}
	}
	
	// xor
	int n_ioio = 0, n_oioi = 0;
	for(int i = 0; i < n; ++i) {
		n_ioio += t[i] ^ ioio[i];
		n_oioi += t[i] ^ oioi[i];
	}
	
	// min
	int n_paint = (n_ioio < n_oioi ? n_ioio : n_oioi);

	std::cout << n_paint << std::endl;

	return 0;
}


Measured memory_bytes: 1664
/*
±¾±¦±¦µÄ³ÌÐò±ðÏë¿´£¡£¡

name: [ÏÄ±¦±¦]
run time:[] ms
compilation time: [] s
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	double a;
	
	cin>>a;
	
	a/=3;
	a=a*a*a*1.000000;
	
	cout<<fixed<<setprecision(12)<<a<<endl;
	
	return 0;
}


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

int main(){
    ll a,b,c,m,n,sm=0,i,j,x,y,ar[200010];
    scanf("%lld",&n);
    for(i=0;i<n;i++) scanf("%lld",&ar[i]);
    for(i=1;i<n;i++){
        if(ar[i]<ar[i-1]){
            sm+=(ar[i-1]-ar[i]);
            ar[i]=ar[i-1];
        }
    }
    printf("%lld\n",sm);

    return 0;
}


Measured memory_bytes: 5328
from bisect import bisect_left
from random import randint
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

def change(d, afterIdx):
    global score
    i = d - 1
    beforeIdx = Ts[i] - 1
    afterIdx -= 1
    if beforeIdx == afterIdx:
        return

    newScore = score

    before = lasts[beforeIdx]
    # dが何番目にあるか
    k1 = bisect_left(before, d)
    w = before[k1+1] - d
    h = d - before[k1-1]
    newScore -= Sss[i][beforeIdx]
    newScore -= w * h * Cs[beforeIdx]

    after = lasts[afterIdx]
    # dが何番目にあるか
    k2 = bisect_left(after, d)
    w = after[k2] - d
    h = d - after[k2-1]
    newScore += Sss[i][afterIdx]
    newScore += w * h * Cs[afterIdx]

    if newScore > score:
        lasts[beforeIdx].pop(k1)
        lasts[afterIdx].insert(k2, d)
        Ts[i] = afterIdx + 1
        score = newScore

Ts = []
for _ in range(D):
    Ts.append(randint(1, 26))

score = 0
lasts = [[0] for _ in range(26)]
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t].append(d)
    for j in range(26):
        score -= (d - lasts[j][-1]) * Cs[j]

for i in range(26):
    lasts[i].append(D+1)


for i in range(3000000):
    change(randint(1, D), randint(1, 26))

for t in Ts:
    print(t)


Measured memory_bytes: 84136
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

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

    int ans = 1;
    int index = num[0] - 1;
    if (index == 1)
    {
        cout << ans << endl;
        return 0;
    }
    
    for (int i = 0; i < n; i++)
    {
        ans++;
        index = num[index] - 1;
        if (index == 1)
        {
            cout << ans << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)
#define pyfor(j,s,n,i) for(int j = s;j < n;j += i)

using namespace std;
typedef long long ll;
const int INF = INT_MAX;

const int max_n = 1e3;

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

  int N, M;
  cin >> N >> M;

  int cubes[N];
  REP(i, N){
    cubes[i] = 1;
  }
  bool canRed[N] = {0};
  canRed[0] = 1;

  REP(i, M){
    int x, y;
    cin >> x >> y;
    x--; y--;
    cubes[x]--; cubes[y]++;
    if(canRed[x]) canRed[y] = 1;
    if(cubes[x] == 0) canRed[x] = 0;
  }
  int cnt = 0;
  REP(i, N){
    cnt += canRed[i];
  }

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


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define M first
#define I second

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n; cin >> n, n;){
        int y; cin >> y;

        pair<double, int> res;
        while(n --){
            int b, r, t; cin >> b >> r >> t;

            double cur;
            if(t == 1) cur = 1 + y * r / 100.;
            else cur = pow(1 + r / 100., y);

            if(cur > res.M) res = mp(cur, b);
        }

        cout << res.I << endl;
    }
 
    return 0;
}

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

using namespace std;

long long int attacks(long long int h) {
	if (h == 1) {
		return 1;
	}
	else {
		return attacks(h / 2) * 2;
	}
}

int main() {
	long long int h;
	cin >> h;
	cout << attacks(h) * 2 - 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7, mod = 998244353;
#define debug(x) cerr << #x << " " << x << "\n";
#define int long long
int rep[N];
vector <pair<int, int> > kra;

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

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

int re(int x) {
	if(rep[x] != x) rep[x] = re(rep[x]);
	return rep[x];
}

void uni(int a, int b) {
	rep[re(a)] = re(b);
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	long long n, m, q;
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i++) rep[i] = i;

	for(int i = 0; i < q; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a++;
		b++;
		if(c == 0) {
			uni(a, b);
		} else {
			kra.push_back(make_pair(a, b));
		}
	}

	if(m == n - 1) {
		if(kra.size() == 0) yes();
		else no();
	}

	for(auto x : kra) {
		if(re(x.first) == re(x.second)) no();
	}

	set <int> S;
	for(int i = 1; i <= n; i++) S.insert(re(i));
	long long k = S.size();

	if(m <= n - k + ((k * (k - 1)) / 2)) yes();
	no();
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, n, m;
ll x, k, d, ans;

int main() {
    scanf(" %lld %lld %lld", &x, &k, &d);
    if (x == 0) {
        if (k%2 == 0) ans = 0;
        else ans = d;
    } else  {
        x = abs(x);
        i = floor(x / d);
        if ((double)x /(double)d >= k) ans = abs(x - k * d);
        else {
            if ((k-i)%2 == 0) ans = abs(x - i*d);
            else ans = abs(x - (i+1)*d);
        }
    } 
    printf("%lld\n", ans);
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, P; cin >> N >> P;
  map<int, int> m;
  rep(i, N) {
    int a; cin >> a;
    m[a % 2]++;
  }
  ll ans = 0;
  ll p = 1;
//  for (int i = 0; i < N + 1; i += 2) {
  rep(i, N + 1) {
    if (i % 2 == P) {
      ans += (1LL << m[0]) * p;
    }
    p = p * (m[1] - i) / (i + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(sum(alist))


Measured memory_bytes: 3444
object Main{
 def main(args:Array[String]) = {
  val sc = new java.util.Scanner(System.in)
  val List(a,b,c) = List.fill(3)(sc.nextInt)
  if(a == b && b == c){
   println("Yes")
  }else{
   println("No")
   }
   }
   }

Measured memory_bytes: 27448
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n;
    string s;
    cin>>n>>s;
    if(n%2!=0) {
        cout<<"No"<<endl;
    }
    else
    {
        int det=0;
        int i=0,j=n/2;
        while(i<n/2 && j<n) {
            if(s[i]!=s[j])++det;
            ++i;
            ++j;
        }
        (det)?cout<<"No"<<endl:cout<<"Yes"<<endl;
    }
    
    
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3516
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    cout << 1.0 - static_cast<double>(N / 2) / static_cast<double>(N) << endl;
}


Measured memory_bytes: 256