akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pi 3.14159265358979323846264
using namespace std;

struct ca
{
  char a;
   int si,ei;
};



int binarySearch(vector<int> arr, int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
         
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
       
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    
    return -1; 
} 

int prime[1000001]={};

void pr()
{
  prime[1]=0;

 for(int i=2;i*i<1000001;i++)
  if(prime[i]==0)
  for(int j=i*i;j<1000001;j+=i)
  prime[j]=1;

}


ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
  
    x = x % p;  
  
    while (y > 0) 
    { 
         
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 


ll fac[1000001]={};

void facto(ll p)
{
   fac[0] = 1; 
    for (ll i=1 ; i<=1000000; i++) 
        fac[i] = (fac[i-1]*i)%p; 
}
  
 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
  
   if (r==0) 
      return 1;  
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 



/*
struct cmp
 {

     bool operator() (const ca &a , const ca &b) const
  {
      if(a.val>b.val)
       return true;

      return false;
  }
 };*/


int main()
{

  //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

   //pr();
   //facto(mod);
  int t;
  //cin>>t;
  t=1;
  int id=1;

  

  while(t--)
{
    int a,b;
     cin>>a>>b;

    cout<<a*b<<"\n";

}
     


return 0;
}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  int n;
  cin >> str;
  n = 0;
 
 for(int i =0; i < str.size(); i++){
  if (str.at(i) == '1') {
    n = n + 1;
    }
  }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int a, b;
  cin >> a >> b;
  for (int x = 0; x < 1000 * 1000; ++x) {
    if (x * 8 / 100 == a && x * 10 / 100 == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#N, K = map(int, input().split())
#p = list(map(int, input().split()))
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
A_count_list = collections.Counter(A)
A_sum = sum(A)
B = [0] * Q
C = [0] * Q
for _ in range(Q):
    B, C = map(int, input().split())
    A_sum += (C - B)*A_count_list[B]
    A_count_list[C] += A_count_list[B]
    A_count_list[B] = 0
    print(A_sum)

Measured memory_bytes: 24856
import sys
def f(a,b,c):
    return a if a!="s"and a==b==c else 0
for s in sys.stdin:
    for i in range(3):
        c=f(*s[i:9:3])
        if c: break
        j=i*3
        c=f(*s[j:j+3])
        if c: break
    else:
        a=s[4]
        if f(*s[0:9:4])or f(*s[2:7:2]):c=a
        else:c="d"
    print c

Measured memory_bytes: 4216
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;

	int dp[3010][3010] = { 0 };
	
	//i番目の数字より大きい数がjこあるときの場合の数

	eREP(i, N)dp[1][i] = 1;

	FOR(i, 1, N) {
		int cnt[3010];
		cnt[0] = 0;
		FOR(j, 0, N - i + 1)cnt[j+1] = (cnt[j] + dp[i][j]) % mod;
		REP(j, N - i) {
			if (S[i - 1] == '<')dp[i+1][j] = (cnt[N - i + 1] - cnt[j + 1] + mod) % mod;
			else dp[i+1][j] = cnt[j + 1];
		}
	}
	
	cout << dp[N][0] << endl;

	return 0;
}



Measured memory_bytes: 71040
N=int(input())
A=[int(input()) for i in range(N)]
def Solve(n,A):
    if n==1:
        return -1 if A[0]!=0 else 0
    else:
        ret=0
        for i in range(n):
            if i==0:
                if A[i]!=0:
                    return -1
            else:
                if A[i]==A[i-1]+1:
                    ret+=1
                elif A[i]<=A[i-1]:
                    ret+=A[i]
                else:
                    return -1
        return ret
print(Solve(N,A))

Measured memory_bytes: 11048
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        if (n < 1 || n > 25) {
            throw Exception("Illegal input")
        }
        val nodes = Array(n) { NodeForWalk() }
        for (i in 0 until n) {
            val id = sc.nextInt()
            val left = sc.nextInt()
            val right = sc.nextInt()
            nodes[id].left = left
            nodes[id].right = right
            if (left != -1) {
                nodes[left].parent = id
            }
            if (right != -1) {
                nodes[right].parent = id
            }
        }
        var rootId = -1
        for (i in 0 until n) {
            if (nodes[i].parent == -1) {
                rootId = i
            }
        }
        println("Preorder")
        walkPreorder(rootId, nodes)
        println()
        println("Inorder")
        walkInorder(rootId, nodes)
        println()
        println("Postorder")
        walkPostorder(rootId, nodes)
        println()
    } catch (e: Exception) {
        println(e)
    }
}

fun walkPreorder(id: Int, nodes: Array<NodeForWalk>) {
    print(" $id")
    if (nodes[id].left != -1) {
        walkPreorder(nodes[id].left, nodes)
    }
    if (nodes[id].right != -1) {
        walkPreorder(nodes[id].right, nodes)
    }
}

fun walkInorder(id: Int, nodes: Array<NodeForWalk>) {
    if (nodes[id].left != -1) {
        walkInorder(nodes[id].left, nodes)
    }
    print(" $id")
    if (nodes[id].right != -1) {
        walkInorder(nodes[id].right, nodes)
    }
}

fun walkPostorder(id: Int, nodes: Array<NodeForWalk>) {
    if (nodes[id].left != -1) {
        walkPostorder(nodes[id].left, nodes)
    }
    if (nodes[id].right != -1) {
        walkPostorder(nodes[id].right, nodes)
    }
    print(" $id")
}

class NodeForWalk(
        var parent: Int = -1,
        var left: Int = -1,
        var right: Int = -1
)



Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 10 ;
double p[N] ;
const double esp = 1e-12 ;
int main()
{
  int n , k ;
  cin >> n >> k ;
  for(int i = 1; i <= n ;i ++)
   {
     double t ;
     cin >> t ;
     p[i] = (1 + t) / 2.0 ;
     p[i] += p[i - 1] ;
   }
   double ans = 0 ;
   for(int i = k ;i <= n ;i ++)
    ans = max(ans , p[i] - p[i - k]) ;
   printf("%.12lf\n" , ans + esp) ;
  return 0 ;
}


Measured memory_bytes: 1792
from collections import defaultdict


def solve():
    N, M = map(int, input().split())
    p_dict = defaultdict(list)
    P = [0] * M
    Y = [0] * M
    for i in range(M):
        p, y = map(int, input().split())
        p_dict[p].append(y)
        P[i], Y[i] = p, y
    
    recog_num = defaultdict(int)
    for i in range(1, N+1):
        birth = sorted(p_dict[i])
        for index, y in enumerate(birth):
            recog_num[y] = index + 1
    
    for i in range(M):
        print('{:06d}'.format(P[i]) + '{:06d}'.format(recog_num[Y[i]]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 43520
#include <iostream>

using namespace std;

int prime(int n)
{
	if(n < 2){
		return 0;
	} else if(n == 2){
		return 1;
	}
	
	if(n % 2 == 0){
		return 0;
	}
	
	for(int i = 3; i*i <= n; i+= 2){
		if(n % i == 0){
			return 0;
		}
	}
	
	return 1;
}

int main(int argc, char **argv)
{
	int n, s;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		s = 0;
		for(int i = 2, c = 0; c < n; i++){
			if(prime(i) == 1){
				s += i;
				c++;
			}
		}
		
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 868
# -*- coding: utf-8 -*-
# 整数の入力
 
a, b = map(int, input().split())
 
sa = ""
sb = ""
for i in range(b):
    sa = sa + str(a)
for i in range(a):
    sb = sb + str(b)
if sa < sb:
    print(sa)
else:
    print(sb)


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

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

int main(void)
{
  int n, a[100001];
  cin >> n;
  REP(i, n) cin >> a[i + 1];

  int pos = 1;
  int ans = 0;
  set<int> his;
  while (pos != 2)
  {
    if (his.find(pos) != his.end())
    {
      ans = -1;
      break;
    }
    else
    {
      his.insert(pos);
      pos = a[pos];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

        if (n - m == 0) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
}

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

#define int long long 
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

signed main(){
    string S;
    string ans = "";

    cin>>S;
    FOR(i,0,S.size()){
        if(i%2 == 0) ans += S[i];
    }

    put(ans);
}

Measured memory_bytes: 512
n = int(input())
t, a = map(int, input().split(" "))
hs = list(map(int, input().split(" ")))
dif = list()
for h in hs:
    ave = t - h*0.006
    dif.append(abs(a-ave))

mindif = min(dif)

for i in range(n):
    if dif[i] == mindif:
        print(i+1)
        break


Measured memory_bytes: 3060
using System;

class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int a = int.Parse( values[ 0 ] );
        int b = int.Parse( values[ 1 ] );
        
        string mark;
        if( a < b ) {
            mark = "<";
        } else if( a > b ) {
            mark = ">";
        } else {
            mark = "==";
        }

        var output = string.Format( "a {0} b", mark );
        Console.WriteLine( output );

        return 0;
    }
}

Measured memory_bytes: 5392
N=int(input())

max_x=int(N**0.5)
ans_list=[0]*N

for x in range(1,max_x):
    for y in range(1,max_x):
        for z in range(1,max_x):
            s=x**2+y**2+z**2+x*y+y*z+z*x
            if s<=N:
                ans_list[s-1]+=1
                
for i in range(N):
    print(ans_list[i])

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

const int MAX = 100000;

struct Node {int parent, left, right; };
Node node[MAX];

void init(int n) {
    for (int i = 0; i < n; i++) {
        node[i].parent = -1;
        node[i].left = -1;
        node[i].right = -1;
    }
}

int getDepth(int i) {
	int ret = 0;
	while (node[i].parent != -1) {
		i = node[i].parent;
		ret++;
	}
	return ret;
}

void getType(int i, char type[]) {
    if (node[i].parent == -1)
        strcpy(type, "root");
    else if (node[i].left == -1)
        strcpy(type, "leaf");
    else
        strcpy(type, "internal node");
}

void printNode(int i) {
	char type[20];
	getType(i, type);
	printf("node %d: parent = %d, depth = %d, %s, [", i, node[i].parent, getDepth(i), type);
	if (node[i].left != -1) {
		i = node[i].left;
		printf("%d", i);
		while(node[i].right != -1) {
			i = node[i].right;
			printf(", %d", i);
		}
	}
	printf("]\n");
}

int main() {
	int n; cin >> n;
	init(n);
	for (int i = 0; i < n; i++) {
		int idx, n_ch; cin >> idx >> n_ch;
		int tmp_idx = idx;
		for (int j = 0; j < n_ch; j++) {
			int ch; cin >> ch;
			node[ch].parent = idx;
			if (j == 0)
				node[tmp_idx].left = ch;
			else
				node[tmp_idx].right = ch;
			tmp_idx = ch;
		}
	}
	for (int i = 0; i < n; i++) printNode(i);
}



Measured memory_bytes: 4320
if __name__ == "__main__":
    s = input()

    ans = ''

    for ss in s:
        if ss == 'S':
            ans += ss
        else:
            if len(ans) == 0:
                ans += ss
            elif ans[len(ans) - 1] == 'S':
                ans = ans[:-1]
            elif ans[len(ans) - 1] == 'T':
                ans += ss

    print(len(ans))


Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int n;
int a[100010];
map<int, int> mp;
void divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    for(auto e : ret){
        mp[e]++;
    }
}

int main(){
    cin >> n;
    rep(i, n) cin >> a[i];
    divisor(a[0]);
    ll ans = 1;
    int cnt = 0;
    for(auto kv : mp){
        rep(i, n){
             if(a[i]%kv.first) {
                 cnt++;
                 if(cnt == 2) goto E;
             }

        }
        if(ans < kv.first)ans = kv.first;
E:;
        cnt = 0;
    }
        mp.clear();
        divisor(a[1]);
        for(auto kv : mp){
            rep(i, n){
                if(a[i]%kv.first) {
                    cnt++;
                    if(cnt == 2) goto F;
                }
            }
            if(ans < kv.first)ans = kv.first;
            F:;
            cnt = 0;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int a,b,c;  cin >> a >> b >> c;
  if(a*c <= b)  cout << c << endl;
  else {
    cout << b/a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,m,i,j;
int main(){
	cin>>m;
	if(m==1){
		cout<<"1\n1\n";
		return 0;
	}
	n=(m+3)/4*2;
	printf("%d\n",n);
	rep(i,n){
		rep(j,n){
			printf("%d%c",1+(i+j)%n+((j&1)&&(i+j)%n+n<m?n:0),(j==n?'\n':' '));
		}
	}
	return 0;
}

Measured memory_bytes: 3740
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,C,N,X;

    long double x;

    string S,T;

    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;

    vector<ll>  bb,cc, hh, ff;
    vector< vector<ll> >  aa;

    cin >>N>>M>>X;
    rep(i,M){
        bb.push_back(0);
    }
rep(i,N){
    cin>>temp;
    cc.push_back(temp);
    
    rep(j,M){
        cin>>temp;
        bb[j]=temp;
    }
    aa.push_back(bb);
}


rep(j,M){
            ff.push_back(0);
        }
ans=-1;
    repr(i,0,pow(2,N)){

        flag=0;
        ll cost = 0;
        count=i;
        rep(j,M){
            ff[j]=0;
        }
        rep(j,N){
            if(count>=pow(2,N-j-1)){
                count-=pow(2,N-j-1);
                cost+=cc[j];
                rep(h,M){
                    ff[h]+=aa[j][h];
                }
            }
        }
        
        
        rep(j,M){
            if(ff[j]<X){
                
                flag=1;
            }
        }
        if(flag==0){
            if(ans==-1){
            ans=max(ans,cost);
            }else{
                ans=min(ans,cost);
            }
        }


    }


    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
#define mod ll(10e8+7)
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;

    cout<<floor(log(n)/log(k))+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a[10001], n;
	for(int i = 0 ; ; i++)
	{
		scanf("%d", &a[i]);
		if(a[i]==0)
		{
			n = i;
			break;
		}
	}
	for(int i = 0 ; i < n ; i++)
	{
		printf("Case %d: %d\n", i+1, a[i]);
	}
	return 0;
}


Measured memory_bytes: 2016
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        int[] a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = Character.getNumericValue(s[n-i]);
        }
        int[] s1 = new int[n+1];
        int[] s2 = new int[n+1];
        int r = 10;
        s1[1] = a[1];
        s2[1] = a[1] % 3;
        Map<Integer, Integer> map = new HashMap<>();
        map.put(s1[1]*10 + s2[1], 1);
        for (int i = 2; i <= n; i++) {
            s1[i] = (s1[i-1] + a[i]*r) % 673;
            s2[i] = (s2[i-1] + a[i]) % 3;
            int t = s1[i] * 10 + s2[i];
            if(!map.containsKey(t)) map.put(t, 0);
            map.put(t, map.get(t) + 1);
            r = r*10%673;
        }
        long ans = 0;
        if(map.containsKey(0)){
            ans += map.get(0);
        }
        for(Integer k : map.keySet()){
            int c = map.get(k);
            if(1 < 2){
                ans += c * (c-1) / 2;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
  FASTIO;
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b;
}


Measured memory_bytes: 256
a,b,m = map(int, input().split())
pricea = list(map(int, input().split()))
priceb = list(map(int, input().split()))
min = min(pricea) + min(priceb)
for i in range(m):
  x, y, c = map(int, input().split())
  tmp = pricea[x - 1] + priceb[y - 1] - c
  if tmp < min:
    min = tmp
print(min)

Measured memory_bytes: 18736
n,m = gets.split.map(&:to_i).sort
x=y=z=0
q=m.divmod(5000)
y=q[0]
z=q[1]/1000
s=x+y+z
loop do
    break if s==n
    if s<n
        y-=1
        z+=5
    else
        y-=2
        x+=1
    end
    s=x+y+z
end
if x<0||y<0||z<0
    puts "-1 -1 -1"
else
    puts "#{x} #{y} #{z}"
end

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int n;
	cin>>n;
	string s[n];
	int c1=0,c2=0,c3=0,c4=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=="AC")
			c1++;
		if(s[i]=="WA")
			c2++;
		if(s[i]=="TLE")
			c3++;
		if(s[i]=="RE")
			c4++;
	}
	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  for (auto a : A) if (a % 2 == 0) if (a % 3 && a % 5) return cout << "DENIED" << "\n", 0;
  cout << "APPROVED" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   long double n,k;
   cin>>n>>k;

   cout<<ceil(n/k);

   return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string str;cin>>str;
  if(str[0]==str[str.size()-1]){
    if(str.size()%2){
      cout<<"Second"<<endl;
    }else{
      cout<<"First"<<endl;
    }
  }else{
    if(str.size()%2){
      cout<<"First"<<endl;
    }else{
      cout<<"Second"<<endl;
    }
  }
  return 0;
}


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

int fld[17][17];
int cnt[17][17];

int main()
{
	int X,Y,S;
	while(cin >> X >> Y, (X||Y))
	{
		for(int y=0; y<17; y++)
		for(int x=0; x<17; x++)
		{
			fld[y][x] = 3;
			cnt[y][x] = 0;
		}

		for(int y=0; y< Y; y++)
		for(int x=1; x<=X; x++)
		{
			cin >> fld[y][x];
			cnt[y][x] = ((y==0&&fld[y][x]==0)?1:0);
		}

		for(int y=0; y< Y-1; y++)
		for(int x=1; x<=X  ; x++)
		{
			if(fld[y][x]==0)
			{
				if(fld[y+1][x+1]==0) cnt[y+1][x+1]+=cnt[y][x];
				if(fld[y+1][x-1]==0) cnt[y+1][x-1]+=cnt[y][x];
				if(fld[y+1][x  ]!=1) cnt[y+1][x  ]+=cnt[y][x]; 
			}
			if(fld[y][x]==2&&fld[y+2][x]!=1)
			{
				cnt[y+2][x]+=cnt[y][x];
			}
		}

		S=0;
		for(int y=Y-1; y< Y+2; y++)
		for(int x=1  ; x<=X  ; x++)
		{
			S+=cnt[y][x];
		}

		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 0
n,m = list(map(int, input().split()))
#data={}
#l=[]
data = [tuple(map(int, input().split())) for _ in range(m)]
#for i in range(m):
#    tup = tuple(map(int, input().split()))
#    data[i]=tup
#    l.append(tup)

m={}
n=0
p=None
for t in sorted(data):
#    print('p=',p,'t[0]=',t[0])
    if p!=t[0]:
        p=t[0]
        n=1
    m[t]='%06d%06d' % (t[0], n)
    n+=1
#print(m)
for k in data:
    print(m[k])


Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool a[52][52],ch[52];
ll b[2][52];
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll l,r;
		cin>>l>>r;
		l--;r--;
		a[l][r]=a[r][l]=1;
		b[0][i]=l;
		b[1][i]=r;
	}
	ll ans=0;
	for(int i=0;i<m;i++){
		ll nowl=b[0][i],nowr=b[1][i];
		a[nowl][nowr]=a[nowr][nowl]=0;
		queue <ll>q;
		q.push(0);
		while(!q.empty()){
			ll now=q.front();q.pop();
			ch[now]=1;
			for(int j=0;j<n;j++){
				if(ch[j]==1||a[now][j]==0){
					continue;
				}
				q.push(j);
			}
		}
		bool ANS=true;
		for(int i=0;i<n;i++){
			if(ch[i]!=1){
				ANS=false;
			}
			ch[i]=0;
		}
		if(ANS==false){
			ans++;
		}
				a[nowl][nowr]=a[nowr][nowl]=1;
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
bool col;
int ans=1;

int main(){
	cin>>s;
	if(s[0]=='W'){
		col=true;
	}else{
		col=false;
	}
	for(int i=1;i<s.length();i++){
		if(col){
			if(s[i]=='B'){
				col=false;
				ans++;
			}
		}else{
			if(s[i]=='W'){
				col=true;
				ans++;
			}
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 512
h,w = gets.chomp.split(' ').map(&:to_i)
if h == 1 || w == 1
  puts 1
elsif h % 2 == 0 || w % 2 == 0
  puts (h * w) / 2
else
  puts ((h + 1) / 2) * ((w + 1) / 2) + (((h + 1) / 2) - 1) * (((w + 1) / 2) - 1)
end

Measured memory_bytes: 14436
#include <stdio.h>
int main()
{
  int i, a, num;
  int c;
 
  scanf("%d", &num);
 
  for (a = num; a < 100003; a++)
  {
 	c = 0;
    for (i = 2; i < a; i++)
    {
 
      if (a % i == 0)
      {
        c++;
        break;
      }
    }
 
    if (c == 0)
    {
      break;
    }
  }
  printf("%d", a);
  return 0;
}

Measured memory_bytes: 128
from itertools import permutations

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

p_order = q_order = cnt = 0
for d in permutations(range(1, n+1)):
    cnt += 1
    if not p_order:
        if list(d) == p:
            p_order = cnt
    if not q_order:
        if list(d) == q:
            q_order = cnt
    if p_order and q_order:
        break

print(abs(p_order - q_order))


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
using namespace std;

int main()
{
    int n, i, j, pnum = 0;
    int l;
    scanf("%d", &n);
    for(i = 0; i<n ; i++)
    {
        scanf("%d", &l);
        for(j = 2; j<= sqrt(l)&&(int)l%j != 0; j++);
        if(j == (int)sqrt(l)+1 || l == 2 || l == 3 || l ==5 || l == 7)
            pnum++;
    }
    printf("%d\n", pnum);
    return 0;
}



Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int a, b, k;
  cin >> a >> b >> k;
  if(a > b) swap(a, b);
  int ans, j = k;
  for(int i = a; i > 0; i--){
    if(a%i == 0 && b%i == 0){
      j--;
      if(j == 0){
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.Array.ST (STUArray, runSTUArray, newArray, writeArray, getBounds)
import Data.Array.Unboxed
import Data.Ix (range)
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type PosXY = (Int,Int)
type Board = UArray PosXY Char
type STBoard s = ST s (STUArray s PosXY Char)

mkChessBoard :: Int -> Int -> Board
mkChessBoard h w =
    runSTUArray $ do
        box <- newArray ((1,1),(w,h)) '.' :: STBoard s
        rng <- range <$> getBounds box
        forM_ rng $ \idx@(y,x) -> do
            let c = if even (y+x) then '#' else '.'
            writeArray box idx c
        return box

solve :: [Int] -> String
solve [h,w] =
    let box = mkChessBoard h w in
    let ((sx,sy), (ex,ey)) = bounds box in
    unlines [[box!(x,y) | x<-[sx..ex]] | y<-[sy..ey]]

main =
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = takeWhile (not . all (== 0)) . map (map read . words)

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

const int DIM = 2e5 + 5;

int dp[DIM];
vector<int> edg[DIM];

inline bool cmp(int x, int y)
{
    return dp[x] > dp[y];
}

int dfs(int x)
{
    for (int y : edg[x])
        dp[y] = dfs(y);
    sort(edg[x].begin(), edg[x].end(), cmp);
    
    int mxm = 0, nr = 0;
    for (int y : edg[x])
        mxm = max(mxm, dp[y] + (++nr));
    
    return mxm;
}

int main(void)
{
    int n; cin >> n;
    for (int i = 2; i <= n; ++i) {
        int x; cin >> x;
        edg[x].push_back(i);
    }
    
    cout << dfs(1) << endl;
    return 0;
}


Measured memory_bytes: 13184
N,A,B = map(int,input().split())
if (A-B)%2 == 0:
    print(abs((A-B)//2))
elif A == 1 or B == N:
    print((abs(A-B)-1)//2+1)
else:
    which = min((A-1),N-B)
    if which == A-1:
        count = A-1+1
        A = 1
        B -= count
        print(abs(A-B)//2+count)
    else:
        count = N-B+1
        A += count
        B = N
        print(abs(A-B)//2+count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        // int cardCount = inpt[0];
        int queryCount = inpt[1];

        int[] cards = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        bool[] arr = new bool[cards.Max() + 1];

        cards.ToList().ForEach(a => arr[a] = true);
        StringBuilder ansText = new StringBuilder();
        for (int i = 0; i < queryCount; i++)
        {
            int ans = 0;
            
            int mod = int.Parse(Reader.ReadLine());
            for (int j = mod - 1; j >= 1; j--)
            {
                for (int k = j; k < arr.Length; k += mod)
                {
                    if (arr[k])
                    {
                        ans = j;
                        break;
                    }
                }
                if (ans > 0)
                {
                    break;
                }
            }

            ansText.AppendLine("" + ans);
        }
        Console.Write(ansText.ToString());

    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


3 3
9 3 8
4
6
5


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 42024
#include<stdio.h>

int main(){
  int n,i,j;
  int minj=0,temp,cnt=0;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);

  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj])minj=j;
    }
      temp=a[i];
      a[i]=a[minj];
      a[minj]=temp;
      if(i!=minj)cnt++;
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
    printf("%d\n",cnt);
    return 0;
  }



Measured memory_bytes: 2144
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        int j = 0;
        FOR(i,0,n) {
            int a; cin >> a;
            if (a == 1)
                j = i;
        }         
        int ans = inf;
        FOR(i,0,n) if (i <= j && j < i+k) {
            const int a = ceil(1.0*(i)/(k-1));
            const int b = ceil(1.0*(n-i-k)/(k-1));
            const int res = 1 + max(a,0) + max(b,0);
            ans = min(ans,res);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll K,N;
  cin>>K>>N;
  vec A(N);
  rep(i,0,N) cin>>A[i];
  ll C;
  ll B=0;
  rep(i,0,N-1) {
    C=A[i+1]-A[i];
    B=max(B,C);
  }
  ll D=max(B,A[0]+K-A[N-1]);
  cout<<K-D<<endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

bool dp[100010] = { 0 };
int main()
{
	string div[] = { "dream", "dreamer", "erase", "eraser" };
	string S; cin >> S;
	dp[0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		if (!dp[i]) continue;
		for (string s : div) {
			if (s == S.substr(i, s.size())) {
				dp[i + s.size()] = 1;
			}
		}
	}
	cout << (dp[S.size()] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool debug = false;

int main() {
  int Ans = 0;  // 回答：
  int N; cin >> N; // マス数

  int wk_cur_time=0;    // 今何回移動したか
  int wk_pre_H=0,wk_H=0;  // マスの高さ

  rep(i,N){
    cin >> wk_H;
    if(wk_H <= wk_pre_H ){        // 今のマスが左以下の高さ
      wk_cur_time++;
      Ans = max(Ans,wk_cur_time);
    } else {                      // 今のマスが左より高い
      wk_cur_time=0;
    }
    wk_pre_H = wk_H;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#define SIZE 1028
char str[SIZE];
void apple(int len);
int main() {

	int len,n,i;

	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&n);
	for(i=0;i<n;i++){
		fgets(str,sizeof(str),stdin);
		len = strlen(str)-1;
		apple(len);
		printf("%s",str);
	}
	return 0;
}

void apple(int len){
	int i;
	for(i=0;i<len;i++){
		if(strncmp(&str[i],"Hoshino",7)==0)
			strncpy(&str[i],"Hoshina",7);
	}
}

Measured memory_bytes: 600
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string n;
int k;

int main() {
    fastio();

    cin >> n >> k;

    ll ans = 0;

    int m = n.size();

    ll num = 1, denom = 1;
    for (int i = 1, j = m - 1; i <= k; i++, j--) {
        num *= j * 9;
        denom *= i;
    }

    ans += num / denom;

    for (int i = 1; i < n[0] - '0'; i++) {
        ll num = 1, denom = 1;
        for (int i = 1, j = m - 1; i <= k - 1; i++, j--) {
            num *= j * 9;
            denom *= i;
        }

        ans += num / denom;
    }

    if (k == 1) {
        ans++;
    }

    if (k == 2) {
        for (int i = 1; i < m; i++) {
            forn1(j, 9) {
                string t(m, '0');
                t[0] = n[0];
                t[i] = j + '0';
                if (t <= n) ans++;
            }
        }
    }

    if (k == 3) {
        for (int i = 1; i < m; i++) {
            for (int j = i + 1; j < m; j++) {
                forn1(l, 9) {
                    forn1(k, 9) {
                        string t(m, '0');
                        t[0] = n[0];
                        t[i] = l + '0';
                        t[j] = k + '0';
                        if (t <= n) ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//In ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(x)
    LIN(y)
    ll ans = INF;
    if(x<=y) ans=min(ans,y-x);
    if(x<=-y) ans=min(ans,-y-x+1);
    if(-x<=y) ans=min(ans,y+x+1);
    if(-x<=-y) ans=min(ans,-y+x+2);
    cout << ans << endl;
    return 0;
}


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

int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

 //    #ifndef ONLINE_JUDGE
	// 	freopen("../../a.in","r",stdin);
	// 	freopen("../../a.out","w",stdout);
	// #endif

	int n, x, ct=1;
	cin >> n;
	cin >> x;
	int mx = x;
	for (int i=1; i<n; i++){
		cin >> x;
		if (x>=mx){
			mx = x;
			++ct;
		}
	}
	cout << ct << "\n";
}

Measured memory_bytes: 256
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <deque>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  
  int main(){
    ll n;
    cin >> n;
    ll ans;
    if (n%11LL > 6 ) ans=(n/11LL)*2+2;
    else if (n%11LL <= 6  && n%11LL >=1) ans=(n/11LL)*2+1;
    else if (n%11LL == 0) ans=(n/11LL)*2;
    cout << ans << endl;
    return 0;
  }


Measured memory_bytes: 256
class Union:
  def __init__(s, num):
    s.T = [-1 for i in range(num)]
 
  def root(s, x):
    if s.T[x] < 0: return x, -s.T[x]
    t, k = s.root(s.T[x])
    s.T[x] = t
    return t, k
 
  def merge(s, x, y):
    an, am = s.root(x)
    bn, bm = s.root(y)
    if an == bn: return False
    if am < bm: an, bn  = bn, an
    s.T[an] += s.T[bn]
    s.T[bn] = an
    return True
 
  def size(s, x):
    return s.root(x)[1]

  def same(s, x, y):
    return s.root(x)[0] == s.root(y)[0]


N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

uni = Union(N)

for a, b in AB:
  a -= 1
  b -= 1
  uni.merge(a, b)

ans = 0
for i in range(N):
  ans = max(ans, uni.size(i))

print(ans)

Measured memory_bytes: 119556
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    a,b = map(int, input().split())
    ans = a-2*b
    if ans < 0:
        print(0)
    else:
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5624
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        //var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine(ar[0] * ar[1] / 2);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
bool chmin(ll&a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll&a,ll b){if(a<b){a=b;return true;}return false;}
#define debg cout<<"debg"<<endl
#define out(a) cout<<(a)<<endl

signed main(){
  
  ll n,k;
  cin>>n>>k;
  out((n-2)/(k-1)+1);

  return 0;
}



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

int main(){
  int64_t A;
  double B;
  cin >> A >> B;
  int64_t C=B*100+0.5;
  int64_t ans=A*C;
  ans/=100;
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s;
  int q;
  cin >> s;
  cin >> q;
  int query;
  int command;
  bool rev_flag = false;
  string query_s;
  for(int i = 0; i < q; i++){
    cin >> query;
    if (query == 2){
      cin >> command >> query_s;
      if (command == 1 && rev_flag == false){
        s.insert(0, query_s);
      } else if (command == 2 && rev_flag == false){
        s.append(query_s);
      } else if (command == 1 && rev_flag){
        s.append(query_s);
      } else if (command == 2 && rev_flag){
        s.insert(0, query_s);
      }
    } else {
      rev_flag = !rev_flag;
    }
  }
  if (rev_flag){
    reverse(s.begin(), s.end());
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 900
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
int a,b,c,x,ans;
int main(){
	ans=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k==x) ans++;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

int f[30];
int solve(string str1, string str2){
	fill(f, f+30, 0);
	int cnt = 0, n = str1.size(), m = str2.size();
	rep(i,n){
		int c = 0;
		rep(j,m)if(str1[i] == str2[j])c = 1;
		if(c)f[str1[i]-'a'] = 1;
	}
	rep(i,30)cnt += f[i];
	return cnt;
}

signed main(){
	string str;
	int n, ans = 0;
	scanf("%lld", &n);
	cin >> str;
	rep(i,n-1){
		chmax(ans, solve(str.substr(0, i+1), str.substr(i+1, n-i-1)));
	}
	printf("%lld\n", ans);
	return 0;
}




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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >>d;
  vector<int> v(max({a, b, c, d})+2, 0);
  v[a]++;
  v[b+1]--;
  v[c]++;
  v[d+1]--;

  int begin = 0, end = 0;

  for (int i = 1; i < max({a, b, c, d})+2; i++)
  {
    v[i] += v[i-1];
  }
  int res = 0;
  for (int i = 1; i < max({a, b, c, d})+2; i++)
  {
    res += (v[i] == 2);
    //if(v[i-1] == 2 && v[i] == 1) end = i;
    //if(v[i-1] == 1 && v[i] == 2) begin = i;
  }

  if(b <= c || d <= a) cout << 0 << endl;
  else if(c >= a && d <= b) cout << d - c << endl;
  else if(a >= c && b <= d) cout << b - a << endl;
  else
  {
    if(a <= c) cout << abs(c - b) << endl;
    else cout << abs(d - a) << endl;
  }
//   for(int i : v) cout << i << endl;



















  // if(res == 0) cout << res << endl;
  // else cout << res - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N, K;
	int ans = 1;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		if (ans*2<ans+K)
		{
			ans *= 2;
		}
		else
		{
			ans += K;
		}
	}
    cout << ans << endl;
}

Measured memory_bytes: 256