akhauriyash/Code-Regression huggingface dataset:
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, x = 0;
  scanf("%lld", &n);
  ll nn = n;
  while (nn)
  {
    x += nn % 10;
    nn /= 10;
  }
  puts(n % x == 0 ? "Yes" : "No");
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, k;
inline li solve() {
    if (n >= k) {
        n = n % k;
    }
    return min(n, k - n);
}
int main() {
    cin >> n >> k;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
l = [str(a) for a in A]
print(" ".join(l))

for i in range(1,n):
    v = A[i]
    j = i - 1
    while j>=0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    l = [str(a) for a in A]
    print(" ".join(l))
    


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

using namespace std;

const int MAX_N = 13;

int cnt [MAX_N];

vector<int> build (int mask) {
  vector<int> has (24, 0);
  if (cnt[0]) has[0] = 1;
  if (cnt[12]) has[12] = 1;
  for (int i = 1; i < 12; i++) {
    if (cnt[i] == 2) {
      has[i] = 1;
      has[24 - i] = 1;
    } else if (cnt[i] == 1) {
      if (mask & 1 << i) {
        has[i] = 1;
      } else {
        has[24 - i] = 1;
      }
    }
  }
  return has;
}

int dist (int u, int v) {
  return min((v - u + 24) % 24, (u - v + 24) % 24);
}

int eval (vector<int> table) {
  int ans = 100;
  for (int i = 0; i < 24; i++) {
    for (int j = i + 1; j < 24; j++) {
      if (table[i] && table[j]) {
        ans = min(ans, dist(i, j));
      }
    }
  }
  return ans;
}

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

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

    cnt[D]++;
  }

  if (cnt[0] > 1 || cnt[12] > 1) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 1; i < 12; i++) {
    if (cnt[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 0;
  for (int mask = 0; mask < 1 << MAX_N; mask++) {
    ans = max(ans, eval(build(mask)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
N = int(input())
AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))

A = []
B = []
for i in range(N):
    A.append(AB[i][0])
    B.append(AB[i][1])
A.sort()
B.sort()
if N%2==0:
    A1 = A[N//2-1]
    A2 = A[N//2]
    B1 = B[N//2-1]
    B2 = B[N//2]
    print((B1+B2)-(A1+A2)+1)
else:
    A1 = A[N//2]
    B1 = B[N//2]
    print((B1-A1)+1)

Measured memory_bytes: 132400
use std::io::stdin;
use std::process::exit;

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => "".split_whitespace().map(|s| s.parse().unwrap()).collect(),
    }
}

#[allow(unused_variables)]
fn solve() {
    let n = input_ints()[0] as usize;
    let ns = input_ints();

    let total: u64 = ns.iter().fold(0, |acc, i| acc + i);
    let total_to_n: u64 = (n * (n + 1) / 2) as u64;

    if total % total_to_n != 0 {
        println!("NO");
        exit(0);
    }
    let k = total / total_to_n;
    
    let mut d = vec![0i64; n];

    for i in 0..n-1 {
        d[i] = ns[i + 1] as i64 - ns[i] as i64 - k as i64;
    }
    d[n - 1] = ns[0] as i64 - ns[n - 1] as i64 - k as i64;

    if d.iter().all(|&x| x <= 0 && x.abs() % n as i64 == 0) {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int N;
char number[11][8] = {
		"0111111",//0
		"0000110",//1
		"1011011",//2
		"1001111",//3
		"1100110",//4
		"1101101",//5
		"1111101",//6
		"0100111",//7
		"1111111",//8
		"1101111",//9
		"0000000"//default
};

void func(){
	int num,pre = 10;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&num);

		for(int i = 0; i <= 6; i++){
			if(number[num][i] == number[pre][i]){
				printf("0");
			}else{
				printf("1");
			}
		}
		printf("\n");
		pre = num;
	}

}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == -1)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2552
L, R = map(int, input().split())

ans = 10**8

if R-L>=2019:
    ans = 0
else:
    for l in range(L, R):
        for r in range(l+1,R+1):
            ans = min(ans, (l%2019)*(r%2019)%2019)
        
print(ans)

Measured memory_bytes: 3060
def t(h):
    a = True
    for i, x in enumerate(h[:-1]):
        if x > h[i + 1]:
            if x - 1 > h[i + 1] or a is False:
                return 'No'
            else:
                a = False
        elif x < h[i + 1]:
            a = True
    return 'Yes'


if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    print(t(h))

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2<k) cout<<-1;
    else{
        cout<<n*(n-1)/2-k<<endl;
        vector<pair<int,int>> A;
        rep(i,n)rep(j,n) if(i<j) A.push_back(make_pair(i+1,j+1));
        rep(i,n*(n-1)/2-k) cout<<A[i].first<<" "<<A[i].second<<endl;
    }
}

Measured memory_bytes: 384
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for _ in range(n):
    i = input()
    i = i[0]
    if i == 'M':
        m += 1
    elif i == 'A':
        a += 1
    elif i == 'R':
        r += 1
    elif i == 'C':
        c += 1
    elif i == 'H':
        h += 1

ans = 0
from itertools import combinations
for i in combinations([m, a, r, c, h], 3):
    i, j, k = i
    ans += i * j * k
print(ans)


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

int main() {
  string s;
  cin >> s;
  bool ans = true;

  if (s[0] != 'A') ans = false;

  int count = 0;
  for (int i = 2; i <= s.size() - 2; i++)
    if (s[i] == 'C') count++;
  if (count != 1) ans = false;

  count = 0;
  for (int i = 0; i < s.size(); i++)
    if ('A' <= s[i] && s[i] <= 'Z') count++;
  if (count != 2) ans = false;

  if (ans)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 54024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a[100],sum=0,p,m,x;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i]; 
    sum=sum+a[i];
  }
  cin>>m;
  for(int i=0;i<m;i++)
  {
    cin>>p>>x;
    cout<<sum-a[p-1]+x<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%d ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	std::bitset<10> f[n];
	REP(i, 0, n){
		REP(j, 0, 10){
			getchar();
			if(getchar()%2) f[i].set(j);
			else f[i].reset(j);
		}
	}
	
	int p[n][11];
	REP(i, 0, n) REP(j, 0, 11) scanf("%d", &p[i][j]);

	int c[n], ans = -1e9;
	REP(i, 1, 1<<10){
		memset(c, 0, sizeof(c));
		REP(j, 0, 10) if((i>>j)&1) {
			REP(I, 0, n) if(f[I][j]) {
				c[I]++;
			}
		}
		int tmp = 0;
		REP(I, 0, n) tmp += p[I][c[I]];
		if(ans<tmp) ans = tmp;
	}

	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;
string s, t;

int32_t main(){_
   
   int r;
   cin >> r;
   
   L pi = acosl(-1);


   cout << fixed << setprecision(15);

   cout<<2*pi*r;


   return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=N-K+1;
  set<int> S;
  rep(i,0,K) S.insert(A[i]);
  int count=1,sum=0;
  vector<bool> F(N,1);
  rep(i,1,N){
    if(A[i-1]<A[i]) count++;
    else count=1;
    if(count>=K){
      F[i]=0;
      sum++;
    }
  }
  ans-=max(sum-1,0ll);
  rep(i,K,N){
    S.erase(A[i-K]);
    int X=*begin(S),Y=*rbegin(S);
    if(F[i]&&A[i-K]<X&&Y<A[i]) ans--;
    S.insert(A[i]);
  }
  rep(i,0,N){
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s, t, r;
  cin>>s>>t;
  for(int i = 0; i < n; ++i){
    r += s[i];
    r += t[i];
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int int_sort(const void* a, const void* b) {
  return *( int * )a - *( int * )b;
}

int main(void) {
	int T[10000];
	int S[500];
	int R[500];
	int i,j,k,n,q,t;
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &T[i]);
	}

	scanf("%d\n", &q);
	for(i=0;i<q;i++) {
		scanf("%d", &S[i]);
	}
	
	qsort((void*)T, n, sizeof(T[0]), int_sort);
	qsort((void*)S, q, sizeof(S[0]), int_sort);
	
	i=j=k=0;
	while(i<n&&j<q) {
		if(T[i] == S[j]) {
			R[k] = T[i];
			i++;j++;k++;
		} else if(T[i] > S[j]) {
			j++;
		} else if(T[i] < S[j]) {
			i++;
		}
	}
	printf("%d\n", k);

	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ll n,k;cin >> n >> k;
    int cnt = 1;
    n /= k;
    while(n > 0){
        cnt++;
        n /= k;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long k = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int[] b = sc.nextIntArray(m);
        long[] al = new long[n+1];
        long[] bl = new long[m+1];
        for(int i = 1; i <= n; i++){
            al[i] += al[i-1]+a[i-1];
        }
        for(int i = 1; i <= m; i++){
            bl[i] += bl[i-1]+b[i-1];
        }
        int ans = 0;
        for(int i = 0; i <= n; i++){
            if(al[i] > k){
                break;
            }
            ans = Math.max(ans,i+beamSearch(bl,k-al[i]));
        }
        System.out.println(ans);
    }
    
    public static int beamSearch(long[] arr, long k){
        int left = 0;
        int right = arr.length;
        while(right - left > 1){
            int mid = (right+left)/2;
            if(arr[mid] > k){
                right = mid;
            }else{
                left = mid;
            }
        }
        return left;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 59700
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        String hoge;
        if (a < b && b < c) {
        	hoge = "Yes";
        }
        else {
        	hoge = "No";
        }
        System.out.println(hoge);
	}

}



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

using namespace std;

typedef long long ll;

int n, m, q;
int Ans = 0;
vector <int> A;

struct Quadruple
{
    int a, b, c, d;

    Quadruple(int a = 0, int b = 0, int c = 0, int d = 0) : a(a), b(b), c(c), d(d) {}

    void Read()
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        a--, b--;
    }

    int Check()
    {
        return A[b] - A[a] == c ? d : 0;
    }
};

vector <Quadruple> B;

void Check()
{
    int Res = 0;

    for(int i = 0; i < q; i++)  Res += B[i].Check();

    Ans = max(Ans, Res);
}

void Rec(int i = 0, int Last = 1)
{
    if(i == n)  return Check();

    for(int x = Last; x <= m; x++)
    {
        A[i] = x;
        Rec(i + 1, x);
    }
}

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

    A.assign(n, 0);
    B.assign(q, Quadruple());
    for(int i = 0; i < q; i++)  B[i].Read();

    Rec();

    cout << Ans << endl;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	ll XOR = 0;
	ll tmp,num_KI = 0;

	for(int loop = 0; loop < N; loop++){

		scanf("%lld",&tmp);
		if(tmp%2 == 1)num_KI++;

		XOR ^= tmp;
	}

	if(XOR == 1){

		printf("Bob\n");

	}else if(XOR == 0){

		if(num_KI > 0){

			printf("Alice\n");

		}else{

			printf("Bob\n");
		}

	}else{

		printf("Alice\n");
	}

	return 0;
}



Measured memory_bytes: 3176
#include<stdio.h>
//小さい順にソート
int c[200002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i,count=1,sum=0;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  merge(0,n-1,a);
  for(i=0;i<n;i++){
    if(a[i]!=a[i+1] ||i==n-1){
      if(a[i]<count)
        sum+=count-a[i];
      else if(a[i]>count)
        sum+=count;
      count=1;
    }
    else
      count++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 896
#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>;

ll cnt;
int l;
int A[2000000];
int n;
vector<int> G;



// 挿入ソート
void insertionSort( int A[], int n, int g ) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

// シェルソート
void shellSort(int A[], int n) {
  // 数列G{1, 4, 13, 40, 121, 364, ...}を生成
  for ( int h = 1; ; ) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}



int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> A[i];
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  // Gの出力
  for ( int i = G.size()-1; i >= 0; i--) {
    if (i != 0) cout << G[i] << " ";
    else  cout << G[i] << endl;
  }
  // ソート済み配列の出力
  cout << cnt << endl;
  rep (i, n) {
    cout << A[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<double> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    double n,t,a; cin >> n >> t >> a;
    VI h(n); VIin(h);
    rep(i,n) h[i] = (double)t - (double)h[i] * 0.006;
    double les = INF;
    int ans;
    rep(i,n) if(abs(a - h[i]) < les) ans = i + 1 , les = abs(a - h[i]);
    ANS;

    return 0;
}

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

int n;
string s[105];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>n;
}

int main(){
	init();
	cin>>s[1];
	for(int i=2;i<=n;++i){
		cin>>s[i];
		if(s[i][0]!=s[i-1][s[i-1].size()-1]){
			puts("No");
			return 0;
		}
		for(int j=1;j<i;++j)
		if(s[i]==s[j]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		s=sc.next();
		int max=0;
		int sum=0;
		for(int i=0;i<s.length();i++) {
			if(s.substring(i,i+1).equals("I"))sum++;
			if(s.substring(i,i+1).equals("D"))sum--;
			max=Math.max(max, sum);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int64_t MOD = pow(10, 9) + 7;

int64_t myPow(int64_t x, int64_t n, int64_t m)
{
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int64_t modinv(int64_t a, int64_t m)
{
  int64_t b = m, u = 1, v = 0;
  while (b)
  {
    int64_t t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

int64_t nCk(int64_t n, int64_t k)
{
  int64_t x = 1;
  for (int64_t i = 0; i < k; i++)
  {
    x = ((x % MOD) * ((n - i) % MOD)) % MOD;
  }
  for (int64_t i = 1; i <= k; i++)
  {
    x = (x % MOD) * modinv(i, MOD) % MOD;
  }
  return x;
}

int main()
{
  int64_t n, a, b, total = 1, nCa = 1, nCb = 1;
  cin >> n >> a >> b;
  // 総数
  total = myPow(2, n, MOD) % MOD;
  total = (total - 1) % MOD;

  nCa = nCk(n, a) % MOD;
  nCb = nCk(n, b) % MOD;
  if ((total - nCa - nCb) % MOD < 0)
  {
    cout << (total - nCa - nCb) % MOD + MOD << endl;
  }
  else
  {
    cout << (total - nCa - nCb) % MOD << endl;
  }
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._


  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val series = readLine.trim.split(' ').map(_.toLong)
  var list: List[Long] = series.head :: Nil
  for (i ← 0 until n - 1){
    series(i + 1) += series(i)
    list ::= series(i + 1)
  }
  for (i ← 0 until n - 2){
    for (j ← (i + 2) until n){
      list ::= series(j) - series(i)
    }
  }
  for (bit ← 40 to 0 by -1){
    val filtered = list.filter(l ⇒ (l & (1L << bit)) != 0)
    if (filtered.size >= k){
      list = filtered
    }
  }
  println(
    list.foldLeft((1L << 63) - 1){case (a, b) ⇒ a & b}
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

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

int main()
{
    long long int N;
    cin >> N;
    for (long long int i = N; i > 0; i--)
    {
        long long int sqr = int(sqrt(i));
        if (sqr * sqr == i)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, tmp;
    vector<ll> a;
    cin >> n;
    rep(i, n){
        cin >> tmp;
        a.push_back(tmp);
    }

    int r=0;
    int cnt=0;
    ll res = 0;
    ll sum = 0;

    rep(l, n){
        while(r < n && !(sum & a[r])){
            //cout << l << " " << r << endl;
            sum ^= a[r++];
        }
        res += r-l;
        sum ^= a[l];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		char c[] = S.toCharArray();
		c[K - 1] = Character.toLowerCase(c[K - 1]);
		System.out.println(new String(c));
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>> n;
  string str;
  cin>>str;
  int left=0;
  int right=str.length()-1;
  int count=0;
  while(left<right){
    if(str[left]=='W' && str[right]=='R'){
      swap(str[left],str[right]);
      left++;
      right--;
      count++;}
    else if(str[left]=='R'){
      left++;}
    else if(str[right]=='W'){
      right--;}
  }
  int index=0;
  for(int i=1;i<str.length();i++)
  {
    if(str[index]=='W' && str[i]=='R'){
      str[i]=='W';
      index++;
      count++;
    }
    else{
      index++;}
  }
  cout<<count;
}
    

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    vector<int> ar(n);
    int k = 0;
    rep(i,n){
        cin >> ar[i];
        k ^= ar[i];
    }
    vector<int> ans(n);
    rep(i,n){
        ans[i] = k ^ ar[i];
    }
    rep(i,n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue <ll> L;
priority_queue <ll,vector<ll>,greater<ll>> R;
int l[100005],r[100005],n;
ll dl,dr,ans;
int main(){
	scanf("%d",&n);
	scanf("%d%d",&l[1],&r[1]);
	L.push(l[1]),R.push(l[1]);
	for (int i=2;i<=n;i++){
		scanf("%d%d",&l[i],&r[i]);
		int len=r[i]-l[i],len1=r[i-1]-l[i-1];
		dl+=len,dr+=len1;
		ll lmin=L.top()-dl,rmin=R.top()+dr;
		if (l[i]<lmin){
			ans=ans+(lmin-l[i]);
			L.pop(),R.push(lmin-dr);
			L.push(l[i]+dl),L.push(l[i]+dl);
		}else
		if(l[i]>rmin){
			ans=ans+(l[i]-rmin);
			R.pop(),L.push(rmin+dl);
			R.push(l[i]-dr),R.push(l[i]-dr);
		}else{
			L.push(l[i]+dl),R.push(l[i]-dr);
		}
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 2796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    string s;
    cin >> s;

    if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, w, h;

struct S{
    int h, w, t;
    //このままソートするとコストの昇順になる。priority_queueだと逆になる
    bool operator<(const S &s) const{
        if(t == s.t) return h * w < s.h * s.w;
        return t < s.t;
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> w >> h;
        if(n + w + h == 0) break;
        vector<int> p(n), s(n);
        rep(i, 0, n){
            cin >> p[i] >> s[i];
            p[i]--;
        }
        vector<S> d;
        d.push_back({h, w, 0}); 
        rep(i, 0, n){
            S now = d[p[i]];
            d[p[i]].t = INF;
            now.t = i;
            S next = now;
            s[i] %= (now.h + now.w);
            if(s[i] <= now.w){
                next.w = now.w - s[i];
                now.w = s[i];
            }else{
                next.h = now.h - (s[i] - now.w);
                now.h = s[i] - now.w;
            }
            d.push_back(now);
            d.push_back(next);
            sort(all(d));        
        }
        vector<int> ans;
        rep(i, 0, d.size()){
            if(d[i].t != INF) ans.push_back(d[i].w * d[i].h);
        }
        sort(all(ans));
        for(int ii = 0; ii < ans.size(); ii++){
            if(ii) cout << ' ';
            cout << ans[ii];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int my_compare(const void *a, const void *b)
{
    int x = *(int*)a;
    int y = *(int*)b;
    return x - y;
}

int main(int argc, void **arg)
{
    long long l, r;
    long long i, j;
    long long min = 2 * 1000000000;

    scanf("%lld %lld", &l, &r);

    if( (r/2019) - (l/2019) > 1 ) {
        puts("0");
        return 0;
    }

    if( ((l % 2019) > (r % 2019)) && (l / 2019) == (r / 2019 + 1) ) {
        puts("0");
        return 0;
    }

    if( l % 2019 == 0 || r % 2019 == 0 ) {
        puts("0");
        return 0;
    }

    for (i = l; i <= r - 1; i++)
    {
        for (j = i + 1; j <= r; j++)
        {
            long long t;
            t = (i * j) % 2019;
            if( min > t ) min = t;
        }
    }

    printf("%lld\n", min);

    return 0;
}


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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

int d[110];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> d[i];

    sort(d, d + N);

    int ans = 0;
    int pre = -1;

    for (int i = 0; i < N; i++)
    {
        if (d[i] > pre)
        {
            ans++;
            pre = d[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long x,a,b;
	cin>>x>>a>>b;
	if(a-b>=0)
	{
		cout<<"delicious"<<endl;
	}else if(a-b >= -x){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	static long ans=0;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long S=sc.nextLong();
		boolean[] b=new boolean[10000000];
		int cnt=1;
		while(true) {
			if(!b[(int)S]) {
				b[(int)S]=true;
				if(S%2==0) {
					S/=2;
				}
				else {
					S=S*3+1;
				}
			}
			else {
				pl(cnt);
				break;
			}
			cnt++;
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 33108
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A = Integer.parseInt(sc.next())
    val B = Integer.parseInt(sc.next())
    
    println(if (B % A == 0) A + B else B - A)
  }
}

Measured memory_bytes: 25544
import itertools
##print(ord("A"))
#n = int(input())
n,k,q = map(int,input().split())
#h = list(map(int,input().split()))	
ans_list=[input() for i in range(q)]
pnt_list = [k-q]*n
#print(pnt_list)
for i in range(q):

    pnt_list[int(ans_list[i])-1]+=1
#print(pnt_list)
for i in range(len(pnt_list)):
    if pnt_list[i]>0:
        print("Yes")
    else:
        print("No")


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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mx 3000
ll n,m;
double dp[3005][3005];
double solve(vector<double>& v,ll i,ll x){
   if(x==0)return 1;
   if(i==0)return 0;
   if(dp[i][x]>-0.9)return dp[i][x];
return dp[i][x]=v[i]*solve(v,i-1,x-1)+(1-v[i])*solve(v,i-1,x);
}
int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ck,k,p,q,r,t,add=0,w,x,y,z;
    double ans;
    cin>>n;
    memset(dp,-1,sizeof dp);
    vector<double>v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    ans=solve(v,n,(n+1)/2);
    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}




Measured memory_bytes: 71040
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>
#include <math.h>
const int MOD = 1000000007;
 
 
ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}
 
 
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	ll s=0,s2=0;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		s=(s+a)%MOD;
		s2=(s2+a*a)%MOD;
	}
	ll ret=((s*s)%MOD+(MOD-s2))%MOD;
	ret = (ret*500000004)%MOD;
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int n;
    char q, prev;
    int kol = 1;
    cin >> n;
    cin >> q;
    prev = q;
    for (int i=0; i<n-1; i++){
        cin >> q;
        if (q != prev){
            kol += 1;
        }
        prev = q;
    }
    cout << kol;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A, B, count;
  cin >> A >> B;
      
   for (;A < B+1 ;A++){
    if(A / 10000 == A % 10 && A % 10000 /1000 == A % 100 / 10){
      count++;
    }
   }
  cout << count <<endl;
}
    

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
cum = [0]*(N)
now = 0
for i in range(N):
  now += A[i]
  cum[i] = now
ans = 0
for i in range(1,N):
  if 2*cum[i-1] < A[i]:
    ans = i
print(N-ans)

Measured memory_bytes: 85924
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    _ = int(input())
    lst = [0 for _ in [0] * (10 ** 5 + 1)]
    sum_lst = 0
    for a in [int(x) for x in input().split()]:
        sum_lst += a
        lst[a] += 1
    Q = int(input())

    for _ in range(Q):
        B, C = map(int, input().split())

        sum_lst += (C - B) * lst[B]
        print(sum_lst)
        lst[C] += lst[B]
        lst[B] = 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 1; i <= n; i++)
int a[200005],s[200005];
int n;
ll ans=0;
int main()
{
  cin >> n;
  rep(i,n){
    cin >> a[i];
    ans+=s[a[i]];
    s[a[i]]++;
  }
  rep(i,n){
    cout << ans-s[a[i]]+1<<endl;
  }
}

Measured memory_bytes: 3712
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    L,R=map(int,input().split())
    L=map(int,bin(L)[2:].zfill(60))
    R=map(int,bin(R)[2:].zfill(60))

    dp=[[[0]*2 for _ in range(2)] for _ in range(2)]
    dp[0][0][0]=1 # dp[msb][mt][lt]

    for l,r in zip(L,R):
        ndp=[[[0]*2 for _ in range(2)] for _ in range(2)]
        for msb,mt,lt,x,y in product(range(2),repeat=5):
            if((not msb) and (x!=y)): continue
            if((not mt) and l>x): continue
            if((not lt) and y>r): continue
            if(x>y): continue
            ndp[max(msb,x*y==1)][max(mt,l<x)][max(lt,y<r)]+=dp[msb][mt][lt]
            ndp[max(msb,x*y==1)][max(mt,l<x)][max(lt,y<r)]%=MOD
        dp=ndp

    print(sum(dp[msb][mt][lt] for msb,mt,lt in product(range(2),repeat=3))%MOD)
resolve()

Measured memory_bytes: 39536
#include <iostream>
using namespace std;
int main(){
	int A,B;
	cin>>A>>B;
	if(A==1&&B!=1)
		cout<<"Alice\n";
	else 
	if(B==1&&A!=1)
	cout <<"Bob\n";
	else {
	
	if (A>B)
	cout<<"Alice\n";
	else if (B>A)
	cout <<"Bob\n";
	else if (A==B)
	cout<<"Draw\n";}
	
}

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::collections::VecDeque;
fn main() {
    input! { k };
    let mut v = (1..10).collect::<VecDeque<_>>();
    let mut x = 0usize;
    for _ in 0..k {
        x = v.pop_front().unwrap();
        let d = x % 10;
        let y = x * 10 + d;
        if d != 0 {
            v.push_back(y - 1);
        }
        v.push_back(y);
        if d != 9 {
            v.push_back(y + 1);
        }
    }
    println!("{}", x);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int64_t MOD=998244353;
//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int64_t n,m,k;
    cin>>n>>m>>k;
    int64_t ans=0;
    COMinit();
    for(int i=0;i<=k;i++){
        ans += (m*modpow(m-1,n-1-i,MOD)%MOD)*((COM(n-1,i))%MOD) % MOD;
        //cout<<ans<<endl;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 27088