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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s; cin>>s;
    map<char,ll> mp;
    rep(i,s.size()) mp[s[i]]++;
    rep(i,26){
        if(!mp[(char)('a'+i)]){
            cout<<(char)('a'+i)<<endl;
            return 0;
        } 
    }
    cout<<"None"<<endl;
    return 0;
}

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

using namespace std;


int main(){

    int a , b;
    cin >> a >> b;

    if (a == b) cout << "Draw\n";

    else if(a == 1 ) cout << "Alice\n";

    else if(b == 1 ) cout << "Bob\n";
    else if(a > b) cout << "Alice\n";
    else cout << "Bob\n";

    return 0;
}


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

int main(){
        long double N,P;
        long ans;
        cin >> N >> P;
        ans = (long)pow(P,1/N);
        while((long)P % (long)pow(ans,N) != 0){
          ans--;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: *

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
// int n;
// vector<int> a;
// void solution() {
	// cin >> n;
	// a.resize(n);
	// for (auto& e:a) {
		// cin >> e;
	// }
// }

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
int n;
cin >> n;
vector<int> a(n);
bool y = 1;
rep(i,0,n) {
	int x;
	cin >> x;
if (x % 2 == 0) {
	y &= (x%3 == 0 || x%5 == 0);
}
}
cout << (y  ? "APPROVED" : "DENIED");
	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++)
			a[i] = s.nextInt();
		
		int dp[] = new int[n];
		
		dp[n-1]=1;
		for(int i=n-2;i>=0;i--) {
			if(a[i]>=a[i+1]) {
				dp[i]=dp[i+1]+1;
			}
			else {
				dp[i]=1;
			}
		}
		int max = 0;
		for(int i=0;i<n;i++) {
			max = Math.max(dp[i],max);
		}
		System.out.println(max-1);
		
		
	}
}


Measured memory_bytes: 50316
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void Output(const vector<string>& List)
{
    for(std::size_t i = 0; i < List.size(); ++i){
        if(i) std::cout << " ";
        std::cout << List[i];
    }
    std::cout << std::endl;
}
int BubbleSort(vector<string> &A)
{
    int count = 0;
    for(int i = 0; i < A.size(); i++){
        for(int j = A.size()-1; j >= i+1; j--){
            if(A[j][1] < A[j-1][1]){
                swap(A[j], A[j-1]);
                count++;
            }
        }
    }
    return count;
}
int selectionSort(vector<string>& A){
    int count = 0;
    for(int i = 0; i < A.size(); i++){
        int minj = i;
        for(int j = i; j < A.size(); j++){
            if(A[j][1] < A[minj][1]){
                minj = j;
            }
        }
        count += i != minj;
        swap(A[i], A[minj]);
    }
    return count;
}
int main()
{
    int n;
    cin >> n;
    vector<string> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    vector<string> B = A;
    vector<string> S = A;
    BubbleSort(B);
    Output(B);
    cout << "Stable" << endl;
    selectionSort(S);
    Output(S);
    if(B == S){
        cout << "Stable" << endl;
    }else {
        cout << "Not stable" << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int A = 0;
  int answer = 0;
  for(int j = 0;j < N;j++) {
    if(A != vec.at(j)) {
      answer++;
      A = vec.at(j);
    }
  }
  cout << answer << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Papers, Please
            int N = int.Parse(Console.ReadLine());
            var A = ReadLine();

            if (IsApproved(A))
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }

        static bool IsApproved(List<int> A)
        {
            foreach(var a in A)
            {
                if (a % 2 == 0)
                {
                    if (a % 3 != 0 && a % 5 != 0)
                    {
                        return false;
                    }
                }
            }

            return true;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, M, X, Y;
const int MAX_NM = 100;
int x[MAX_NM], y[MAX_NM];

int main() {
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];
    sort(x, x+N, greater<int>());
    sort(y, y+M);
    if (x[0] < y[0] && X < y[0] && y[0] <= Y) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
// using ll = long long;
// using P = pair<int,int>;
// using vi = vector<int>;
// using vvi = vector<vi>;

int N,q;
vector<int> A(20);
vector<string> ans;

bool calc(int d, int sum) {
  if(sum == 0) return true;
  if(sum < 0 || d == N) return false;
  bool f1 = calc(d+1,sum-A[d]);
  bool f2 = calc(d+1,sum);
  return f1||f2;
  
}

int main() {
  cin >> N;
  rep(i,N) cin >> A[i];
  
  cin >> q;
  rep(i,q) {
    int m;
    cin >> m;
    if(calc(0,m)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}






Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n, cnt = 0;
    ll tmp;
    vector<ll> l(n);
    cin >> n;
    rep(i, n) {
        cin >> tmp;
        l.push_back(tmp);
    }
    for(int i = 0; i < n-2; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if((l[i] < l[j] + l[k]) && (l[j] < l[i] + l[k]) &&
                   (l[k] < l[j] + l[i]) && (l[i] != l[j]) && (l[i] != l[k]) &&
                   (l[j] != l[k])) {
                    cnt++;
                    // cout << l[i] << l[j] << l[k] << endl;
                }
            }
        }
    }
 
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 3628
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      String s = f.readLine();
      
      if(s.charAt(0) == '7' || s.charAt(1) == '7'|| s.charAt(2)=='7'){
         out.println("Yes");
      } else {
         out.println("No");
      }
      
      

      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 32512
#include <stdio.h>
int main(){
 int i, data[10000], x;
 for(i = 0; i < 10000; i++){
  scanf("%d", &x);
  if(x == 0) break;
  data[i] = x;
  
 }
 for(i = 0; i < 10000; i++){
   printf("Case %d: %d\n", i+1, data[i]);
 }
 return 0;
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    int n,w;
    cin >> n >> w;
    int weights[n],values[n];
    for(int i=0;i<n;++i)
    {
        cin >> weights[i] >> values[i];
    }
    int dp[n+1][w+1];

    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else if(weights[i-1] <=j)
            {
                dp[i][j] = max(dp[i-1][j-weights[i-1]] + values[i-1],dp[i-1][j]);
            }  
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 82336
#include <stdio.h>

int max(int a, int b);

int main(void)
{
	int w, h, n, i, j, cost = 0;
	int sx,  sy, gx, gy;
	
	scanf("%d %d %d", &w, &h, &n);
	
	scanf("%d %d", &sx, &sy);
	
	for (i = 1; i < n; i++){
		
		scanf("%d %d", &gx, &gy);
		
		if (sx < gx && sy < gy){
			if (gx - sx < gy - sy){
				cost += gx - sx;
				sy += gx - sx;
				sx = gx;
			}
			else{
				cost += gy - sy;;
				sx += gy - sy;
				sy = gy;
			}
		}
		else if (sx > gx && sy > gy){
			if (sx - gx < sy - gy){
				cost += sx - gx;
				sy -= sx - gx;
				sx = gx;
			}
			else{
				cost += sy - gy;;
				sx -= sy - gy;
				sy = gy;
			}
		}
		cost += max(sx - gx, gx - sx);
		cost += max(sy - gy, gy - sy);
		sx = gx;sy = gy;
	}
	printf("%d\n", cost);
	
	return (0);
}

int max(int a, int b)
{
	if (a > b) return (a);
	
	else return (b);
}

Measured memory_bytes: 596
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, M;
int H[1 << 18];
bool used[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> H[i];
	for (int i = 1; i <= M; i++) {
		int a, b; cin >> a >> b;
		if (H[a] >= H[b]) used[b] = true;
		if (H[a] <= H[b]) used[a] = true;
	}
	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (used[i] == false) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int n,D,count=0;
    cin >> n >> D;
    while(n--)
    {
        double x,y,d;
        cin >> x >> y;
        d = sqrt((abs(x)*abs(x))+(abs(y)*abs(y)));
        if(d<=D)
        count++;
    }
    cout << count;
}

Measured memory_bytes: 3820
n, m = map(int, input().split())
a = sorted([ int(x) for x in input().split() ], reverse=True)
bc = []

for _ in range(m):
    b, c = map(int, input().split())
    bc += [ (b, c) ]

bc.sort(key=lambda x: -x[1])
i, j, cnt, ans = 0, 0, 0, 0

while cnt < n:
    if j < m and a[i] < bc[j][1]:
        b, c = bc[j]
        ans += c * min(n-cnt, b)
        j += 1
        cnt += b
    else:
        ans += a[i]
        i += 1
        cnt += 1

print(ans)

Measured memory_bytes: 25708
import java.util.Scanner;

public class Main {
	public static boolean[] array;
	public static int count = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		array = new boolean[str.length()];
		for (int i = 0; i < array.length; ++i) {
			if (str.charAt(i) == '1') {
				array[i] = true;
			}
		}
		exec(0);
		System.out.println(count);
	}
	
	public static void exec(int index) {
		if (index >= array.length - 1) {
			return;
		} else if (array[index] == array[++index]) {
			array[index] = !array[index];
			count++;
		}
		exec(index);
	}
}


Measured memory_bytes: 31308
#include<bits/stdc++.h>
using namespace std;
deque<int> dq;
int n,w;
int main()
{
    cin>>n;
    for(int i=n%2;i<n+n%2;i++)
    {
        cin>>w;
        if(i%2==0) dq.push_back(w);
        else dq.push_front(w);
    }
    for(deque<int>::iterator i=dq.begin();i!=dq.end();i++)
    cout<<*i<<" ";
}

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

int main(){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int n[3],t[3];
  for(int i=0;i<3;i++){
    n[i]=0;
    t[i]=s[i].size();
  }
  int now=0;
  char ans;
  bool ok=true;
  while(ok){
    n[now]++;
    char c=s[now].at(n[now]-1);
    if(c=='a') now=0;
    else if(c=='b') now=1;
    else now=2;
    if(n[0]==t[0]&&now==0){
      ans='A'; ok=false;
    }
    else if(n[1]==t[1]&&now==1){
      ans='B'; ok=false;
    }
    else if(n[2]==t[2]&&now==2){
      ans='C'; ok=false;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int seg[2000005][26];
string a;
void build(int ver,int tl,int tr)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
    {
        seg[ver][a[tl]-'a']=1;
    }
    else
    {
        int tm=(tl+tr)/2;
        build(2*ver,tl,tm);
        build(2*ver+1,tm+1,tr);
        for(int i=0;i<26;i++)
            seg[ver][i]=seg[2*ver][i]+seg[2*ver+1][i];
    }
}

void upd(int ver,int tl,int tr,int pos,int val,int k)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
    {
        seg[ver][val]+=k;
    }
    else
    {
        int tm=(tl+tr)/2;
        if(tm>=pos)
            upd(2*ver,tl,tm,pos,val,k);
        else
            upd(2*ver+1,tm+1,tr,pos,val,k);
        for(int i=0;i<26;i++)
            seg[ver][i]=seg[2*ver][i]+seg[2*ver+1][i];
        
    }
}

int get(int ver,int tl,int tr,int l,int r,int ind)
{
    if(tl>tr||l>r||tr<l||r<tl)
        return 0;
    else if(tl==l&&tr==r)
        return seg[ver][ind];
    else
    {
        int tm=(tl+tr)/2;
        return get(2*ver,tl,tm,l,min(tm,r),ind)+get(2*ver+1,tm+1,tr,max(tm+1,l),r,ind);
    }    
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;

    cin>>a;
    a="@"+a;
    int q;
    cin>>q;
    int z;
    int x,y;
    char s;
    build(1,1,n);
    while (q--)
    {
        cin>>z;
        if(z==1)
        {
            cin>>x>>s;
            upd(1,1,n,x,a[x]-'a',-1);
            a[x]=s;
            upd(1,1,n,x,a[x]-'a',1);            
        }
        else
        {
            cin>>x>>y;
            int cnt=0;
            for(int i=0;i<26;i++)
            {
                cnt+=(get(1,1,n,x,y,i)>0);
            }
            cout<<cnt<<'\n';
        }
        
    }
    

} 



Measured memory_bytes: 215984
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int max;
		int min;

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



		 System.out.println(c*10+b+a);


	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, H;
    cin >> N >> H;
    vector<ll> a(N);vector<ll> b(N);
    ll max_a = 0; ll max_a_index=0;
    ll max_a2 = 0; ll max_a2_index=0;
    for(size_t i=0;i<N; i++)
    {
        //aは何回でもできるがbは１回だけ
        cin >> a[i] >> b[i];
        if(a[i] > max_a)
        {
            max_a2 = max_a;max_a2_index=max_a_index;
            max_a = a[i];max_a_index=i;
        }
    }
    sort(b.rbegin(), b.rend());
    ll count = 0;
    for(ll i=0;i<N; i++)
    {
        if(/*(i != max_a_index || i != max_a2_index) &&*/ b[i] > max_a)
        {
            H -= b[i];
            count++;
        }
        if(H <= 0){cout << count << endl;return 0;}
    }

    ll a_count;
    /*
    if(max_a < b[max_a_index])
    {
        a_count = (H - b[max_a_index]) / max_a;
        if((H - b[max_a_index]) % max_a > 0) a_count++;
        cout << a_count + count + 1 << endl;
    }else
    {
        a_count = H / max_a;
        if(H % max_a > 0) a_count++;
        cout << a_count + count << endl;
    }
    */
    a_count = H / max_a;
    if(H % max_a > 0) a_count++;
    cout << a_count + count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4728
#include <stdio.h>

#define M 20
#define L 2000
int range;
int A[L];
int solve(int,int);

int main(void){
  int i;
  int g,m;
  int n,q;
  scanf("%d",&n);
  range = n;
  for(i=0;i<n;i++){
    scanf("%d",&g);
    A[i]=g;
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1)printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m)
{
  if(m==0)return 1;
  if(i>=range)return 0;
  if(solve(i+1,m)==1)return 1;
  else if(solve(i+1,m-A[i]) ==1)return 1;
  else return 0;
}



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

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

	int i=0,j=0,k=0; // a,b,cの先頭をマーク


	char now='a';
	bool dead=false;
	
	char ans;

	while(1){
		switch(now){
			case 'a':
				now=a[i];
				++i;
				if(i>a.length()){
					dead=true;
					ans='A';
				}
				break;

			case 'b':
				now=b[j];
				++j;
				if(j>b.length()){
					dead=true;
					ans='B';
				}
				break;

			case 'c':
				now=c[k];
				++k;
				if(k>c.length()){
					dead=true;
					ans='C';
				}
				break;

			default:
				break;
		}

		if(dead)break;
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(ll i=0;i<n;i++)
#define ll long long
int main(){
	ll n,k;
	cin>>n;
	ll a[n];
	f(i,n)cin>>a[i];
	vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
	// memset(dp,1,sizeof dp)    ;
	//keeps track of winners
// cout<<dp[1]<<endl;
// =1;
	for(ll len =1;len<=n;len++){
		for(ll i=0;i<n-len+1;i++){
			ll j=len+i-1;
			if(i==j)dp[i][j]=a[i];
			dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	}
	// f(i,n){
	// 	f(j,n)cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	cout<<dp[0][n-1]<<endl;
	return 0;
}


Measured memory_bytes: 73684
#include<bits/stdc++.h>
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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




int main(){
    int n;  cin >>n;
    if(n%2!=0) cout << n/2+1;
    else cout << n/2;
cout << endl;

}

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

using namespace std;
using ll = long long;
const ll INF = (ll)1e15;

int main(){
    ll X,K,D;
    cin >> X >> K >> D;

    ll res;
    if(abs(X)/D > K){
        if(X>0){
            res = abs(X - D*K);
        }else{
            res = abs(X + D*K);
        }
    }else{
        // ll num, amari;
        // if(X%D > 0){
        //     if(X%D > abs(X%D-D))num = X%D;
        //     else num = X%D+1;
        // }else{
        //     if(X%D > abs(X%D+D))num = X%D;
        //     else num = X%D+1;
        // }

        ll num = abs(X)/D;
        res = X%D;
        if((K-num)%2 == 1)res = min(abs(res+D), abs(res-D));
    }

    cout << abs(res) << endl;
}

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

#define INF 0x3f3f3f3f3f3f3f3fLL

int n, k;

vector<long long>v;

long long memo[101010];

long long solve(int pos){
	
	if(pos == n) return 0;
	if(memo[pos] != -1) return memo[pos];
	
	long long here = INF;
	
	for(int i = pos + 1; i <= min(n , pos + k) ; i ++)
		here = min(here, solve(i) + abs(v[pos] - v[i]));
	
	return memo[pos] = here;
}


int main(){
	
	memset(memo,-1,sizeof memo);
	
	cin>>n>>k;
	
	v.resize(n + 1);
	v[0] = 0;
	
	for(int i = 1 ; i <= n ; i ++)
		cin>>v[i];
	
	cout<<solve(1)<<"\n";
	
	return 0;
}

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

int k[10];
int s[10][10];
int p[10];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            cin >> s[i][j];
        }
    }

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

    int ans = 0;
    for(int bit_set = 0; bit_set < (1 << N); bit_set++){
        bool all_on = true;
        for(int i = 0; i < M; i++){
            int on_no = 0;
            for(int j = 0; j < k[i]; j++){
                if(((bit_set >> (s[i][j] - 1)) & 1) == 1){
                    on_no++;
                }
            }
            if(on_no % 2 != p[i]){
                all_on = false;
                break;
            }
        }
        if(all_on){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,t,a,i,j,cc=0;
    double mn=111111111111.0000;
    cin>>n;
    cin>>t>>a;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    for(i=0;i<n;i++){
        double x=t-ara[i]*0.006;
        if(abs(x-a)<mn){
            mn=abs(x-a)*1.0;
            cc=i+1;
        }
    }
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n; std::cin >> n;
  vt<int> T(n);
  rep(i,n) std::cin >> T[i];

  int m; std::cin >> m;
  vt<std::pair<int,int>> px(m);
  rep(i,m) std::cin >> px[i].first >> px[i].second;

  const int ans = std::accumulate(T.begin(),T.end(),0);
  rep(i,m) {
    int num = px[i].first -1;
    int time = px[i].second;
    std::cout << ans - T[num] + time << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math.*;
 
public class Main
{
    public static void main(String[] args)
    {
	Scanner cin = new Scanner(System.in);
	int a,b,c;
 	while(cin.hasNext()){
		a = cin.nextInt();
		b = cin.nextInt();
		c = a + b;
		int cnt = 0;
		for(int i=1; i<=20; i++){
			if(c/Math.pow(10,i) < 1 && cnt == 0){System.out.println(i); cnt = 1;}
		}
	}
    }
}

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

int main(){

    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; ++i){
            bool check;
            if(i & 1){
                check = false;
            }
            else{
                check = true;
            }
            for(int j = 0; j < W; ++j){
                if(check){
                    cout << '#';
                }
                else{
                    cout << '.';
                }
                check ^= true;
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

void hawawa()
{
  char a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "H\n";
  } else {
    cout << "D\n";
  }
}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, c, i, a2, b2, c2;
int main(){
    cin>> a >> b >> c;
    for(i = 0; i <= 100000; i++){
        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
            cout<< i;
            return 0;
        }
        a2 = b / 2 + c / 2;
        b2 = a / 2 + c / 2;
        c2 = a / 2 + b / 2;
        a = a2;
        b = b2;
        c = c2;
    }
    cout<< -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int r, c;
  cin >> r >> c;
  int a[r + 1][c + 1] = {};
  for (int i = 0; i < r; ++i)
    for (int j = 0; j < c; ++j)
      cin >> a[i][j];

  for (int i = 0; i < r; ++i)
  {
    for (int j = 0; j < c; ++j)
    {
      a[i][c] += a[i][j];
    }
  }
  for (int i = 0; i <= c; ++i)
  {
    for (int j = 0; j < r; ++j)
    {
      a[r][i] += a[j][i];
    }
  }

  for (int i = 0; i <= r; ++i)
  {
    for (int j = 0; j <= c; ++j)
    {
      if (j == 0)
        cout << a[i][j];
      else
        cout << ' ' << a[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll 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));
  return (ret);
}

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

  cin >> n >> m;
  vector<ll> yakusuu = divisor(m);
  rrrep(i, Size(yakusuu) - 1, 0) {
    cnt = yakusuu[i];
    cnt = cnt * n;
    if (cnt > m) continue;
    ll sa = m - cnt;
    if (sa % yakusuu[i] == 0) {
      Cout(yakusuu[i]);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10**7)
    input = sys.stdin.readline
    from collections import deque
    n,m = map(int,input().split())
    Es = [[] for i in range(n)]
    Et = [[] for i in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        Es[a].append(b)
        Et[b].append(a)
    s,t = map(int,input().split())

    diss = [[float("INF")] for i in range(n)]
    dist = [[float("INF")] for i in range(n)]
    diss[s-1] = [0]
    dist[t-1] = [0]
    def bfs(x,E,dis):
        q = deque([])
        q.append((x,0))
        while q:
            now,d = q.popleft()
            for nex in E[now]:
                if dis[nex] == [float("INF")]:
                    dis[nex] = [d+1]
                    q.append((nex,d+1))
                else:
                    check = True
                    for i in dis[nex]:
                        if i%3 == (d+1)%3:
                            check = False
                    if check:
                        q.append((nex,d+1))
                        dis[nex].append(d+1)

    bfs(s-1,Es,diss)
    bfs(t-1,Et,dist)

    ans = float("INF")
    for i in range(n):
        for j in diss[i]:
            for k in dist[i]:
                if (j+k)%3 == 0:
                    ans = min(ans,(j+k)//3)
    if ans == float("INF"):
        print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 113200
#include <iostream>
#include <vector>

int main()
{
    using std::cin;
    using std::cout;

    int N;
    cin >> N;

    std::vector A(2 * 100010, 0);
    for (int i = 0; i < N - 1; i++) {
        int a;
        cin >> a;
        A[a - 1]++;
    }

    for (int i = 0; i < N; i++) {
        cout << A[i] << '\n';
    }
}

Measured memory_bytes: 4044
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

if "##" in s[a-1:c] or "##" in s[b-1:d]:
    print("No")
else:
    if c < d:
        print("Yes")
    else:
        if "..." in s[b-2:d+1]:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 3572
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int N = sc.nextInt();
			int[][] act = new int[N][3];
			for(int i = 0 ; i < N; i++) {
				act[i][0] = sc.nextInt();
				act[i][1] = sc.nextInt();
				act[i][2] = sc.nextInt();
			}

			int[][] dp = new int[N + 1][3];
			for(int i = 0; i < 3; i++) dp[0][i] = act[0][i];

			for(int i = 1; i < N; i++) {
				for(int j = 0; j < 3; j++) {
					dp[i][j] = Math.max(dp[i - 1][(j + 1) % 3] + act[i][j], dp[i - 1][(j + 2) % 3] + act[i][j]);
				}
			}
			System.out.println(Math.max(dp[N - 1][0], Math.max(dp[N - 1][1], dp[N - 1][2])));
		}
	}
}


Measured memory_bytes: 99744
mod = 10**9+7
N = int(input())
T = []
U = list(map(str, input()))
B = list(map(str, input()))

cond = 0
for i in range(N):
    if cond:
        cond = 0
        continue
    if U[i] == B[i]:
        T.append(1)
    else:
        T.append(2)
        cond = 1

if T[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(1,len(T)):
    if T[i-1] == 1:
        ans *= 2
        ans %= mod
    else:
        if T[i] == 1:
            ans *= 1
        else:
            ans *= 3
            ans %= mod

ans %= mod
print(ans)

Measured memory_bytes: 3064
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            TreeMap<Integer,Integer> map=new TreeMap<>();
            for(int i=1;i<=100;i++){
                for(int j=i;j<=100;j++){
                    for(int k=j;k<=100;k++){
                        int v=i*i+j*j+k*k+i*j+j*k+k*i;
                        int ocs=0;
                        if(i==j&&i==k){
                            ocs=1;
                        }else if(i!=j&&i!=k&&j!=k){
                            ocs=6;
                        }else{
                            ocs=3;
                        }
                        map.putIfAbsent(v,0);
                        map.put(v,map.get(v)+ocs);
                    }
                }
            }
            for(int i=1;i<=n;i++){
                map.putIfAbsent(i,0);
                out.println(map.get(i));
            }
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

using namespace std;
#define ll long long
const int N=1e6+5,mod=1e9+7;
ll f[N];
ll inv[N];
ll fp(ll b,ll p)
{
    if(p==0) return 1;
    ll t=fp(b,p/2);
    if(p%2) return t*t%mod*b%mod;
    return t*t%mod;
}
ll ncr(int n,int r)
{
    long long a=1,b=1;
    for(int i=n;i>(n-r);i--)
    {
        a*=i;
        a%=mod;
    }
    for(int i=r;i>=1;i--)
    {
        b*=i;
        b%=mod;
    }
    return a*fp(b,mod-2)%mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n,a,b;
    cin>>n>>a>>b;
    cout<<((fp(2,n)-1-ncr(n,a)-ncr(n,b))%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
	val s = (0..2).map {readLine()!!.toList().map {it-'a'}.toMutableList() }
	var turn = 0
	
	while(s[turn].isNotEmpty()){
		turn = s[turn].removeAt(0)
	}
	println(('A'+turn).toChar())
}

Measured memory_bytes: 33912
import sys

N = int(input())
# 5^26 > 10^18
if N % 2 == 1:
    print(0)
    sys.exit()

ans = 0
mul = 1
for i in range(1, 27):
    mul *= 5
    add = N // (2 * mul)
    if add == 0: break
    ans += add

print(ans)

Measured memory_bytes: 3060
n, p = map(int, input().split())
if n==1:
  print(p)
  exit()
elif p==1 or n>=60:
  print(1)
  exit()
for i in range(int(p**(1/n))+1, 0, -1):
  if p%(i**n)==0:
    print(i)
    exit()

Measured memory_bytes: 9380
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

const int kMod = 1000 * 1000 * 1000 + 7;

void Add(int& a, int b) {
  a += b;
  if (a >= kMod) {
    a -= kMod;
  }
}

bool IsGood(string S) {
  string s1 = S.substr(0, 3);
  if (s1 == "AGC") {
    return false;
  }
  string s2 = S.substr(1, 3);
  if (s2 == "AGC") {
    return false;
  }

  for (int i = 1; i < S.size(); ++i) {
    swap(S[i - 1], S[i]);

    string s1 = S.substr(0, 3);
    if (s1 == "AGC") {
      return false;
    }
    string s2 = S.substr(1, 3);
    if (s2 == "AGC") {
      return false;
    }

    swap(S[i - 1], S[i]);
  }

  return true;
}

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

  int N;
  cin >> N;

  vector<map<string, int>> dp(N);
  const char* C[] = {"A", "C", "G", "T"};
  for (const char* c : C) {
    dp[0][c] = 1;
  }

  for (int i = 1; i < N; ++i) {
    for (const auto& p : dp[i - 1]) {
      for (const char* c : C) {
        string cand = p.first;
        cand.push_back(c[0]);
        if (cand.size() > 4) {
          cand.erase(cand.begin());
        }

        if (IsGood(cand)) {
          Add(dp[i][cand], p.second);
        }
      }
    }
  }

  int result = 0;
  for (const auto& p : dp[N - 1]) {
    Add(result, p.second);
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>

int main()
{
	int w, h, x, y, r;

	scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);

	printf(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h? "Yes\n" : "No\n");

	return 0;
}



Measured memory_bytes: 2096
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int dfs(vv<int> &g,int v,int p){
  int re=0;
  for(int w:g[v])if(w!=p) re^=dfs(g,w,v);
  return re+1;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vv<int> g(n);
  rep(i,n-1){
    int x,y;
    cin>>x>>y; --x; --y;
    g[x].pb(y);
    g[y].pb(x);
  }
  cout<<(dfs(g,0,-1)==1?"Bob":"Alice")<<endl;
  return 0;
}


Measured memory_bytes: 12032
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc_lst = []
for i in range(M):
    xyc_lst.append(list(map(int, input().split())))
ans = min(a) + min(b)
for i in range(M):
    x = xyc_lst[i][0]
    y = xyc_lst[i][1]
    c = xyc_lst[i][2]
    price = a[x-1] + b[y-1] - c
    if price < ans:
        ans = price
print(ans)

Measured memory_bytes: 38476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = sc.nextInt();
		String slimes = sc.next();
		int type =0;

		for(int i=0 ; i<sum ; i++) {
			//iが0、またはslimesのi-1番目とi番目の文字が違うときに、typeを+1する
			if(i == 0 || (i>0 && slimes.charAt(i-1) != slimes.charAt(i))) {
				type++;
			}
		}
		System.out.print(type);
		sc.close();
	}
}


Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long MOD = 1000000007;
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;


signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;long long N = S.size();
    long long D;cin >> D;
    mint dp[10010][2][110] = {};
    dp[0][0][0] = 1;
    REP(i,N)REP(k,D)REP(j,2){
        long long nd = S[i] - '0';
        REP(d,10){
            long long ni = i + 1,nj = j,nk = (d + k)%D;
            if(j == 0 && d > nd) continue;
            if(d < nd) nj = 1;
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    mint ans = dp[N][1][0] + dp[N][0][0] - 1;
    cout << ans << endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    int ans = 0;
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    rep(i,N - 2) {
        if (A[i] == B[i] && A[i + 1] == B[i + 1] && A[i + 2] == B[i + 2]) ++ans;
    }
    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int R,G,B,N,L;
long long res;
void Count()
{
	int g=L/G;
	for(int i=0;i<=g;i++)
	{
		int LL=L-i*G;
		if(LL%B==0)
			res++;
	}
	return ;
}
int main()
{
	cin>>R>>G>>B>>N;
	int r=N/R;
	for(int i=0;i<=r;i++)
	{
		L=N-i*R;
		Count();
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
n = int(stdin.readline().rstrip())
m = n
k = 0
t = 0
while k == 0:
    for i in range(int(math.sqrt(m))+1):
        if i >= 2:
            if m % i == 0:
                t = 1
    if t == 0:
        k = 1
        l = m
    t = 0        
    m += 1
print(l)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	for(int n,k;cin>>n>>k;)
		while(k--){
			int i,j; cin>>i>>j;
			cout<<min(min(i-1,n-i),min(j-1,n-j))%3+1<<endl;
		}
	
	return 0;
}

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

using namespace std;

int main ()
{
    int x,y;
    cin>>x>>y;
    while(x!=0||y!=0)
    {
        if(x>y)
        {
            swap(x,y);
        }
        cout<<x<<" "<<y<<endl;
        cin>>x>>y;
    }
}


Measured memory_bytes: 3004