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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n;
	cin >> n;

	int p[n];
	FOR(i, n){
		cin >> p[i];
	}

	VI v;
	for(int i=0; i<n-2; i++){
		for(int j=i; j<n-2; j=j+3){
			if((p[j] < p[j+1] && p[j+1] < p[j+2]) ||  (p[j] > p[j+1] && p[j+1] > p[j+2])){
				if (find(v.begin(), v.end(), p[j+1]) == v.end()) {
					// cout << p[j+1] << endl;
				 	v.push_back(p[j+1]);
				}
			}
		}
	}

	// int len = v.size();
	// FOR(i, len){
	// 	cout << v[i] << " ";
	// }

	// cout << "\n";
	cout << v.size();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int x, a;
    cin>>x>>a;
    if (x < a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
    return 0;
}


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

int main() {
	long long int H, ans;
	scanf("%lld",&H);
	for (int i = 0;; i++) {
		if ((long long int)pow(2, i) <= H && H < (long long int)pow(2, (double)i + 1)) {
			printf("%lld", (long long int)pow(2, (double)i + 1) - 1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
N, A, B, C = map(int,input().split())
ABC = [0, A,B,C]
L = [int(input()) for _ in range(N)]
import itertools
ans = 100000000
for flags in itertools.product(range(4), repeat=N):
    tmp = [[0, 0] for _ in range(4)]
    for i in range(N):
        tmp[flags[i]][0] += L[i]
        tmp[flags[i]][1] += 1
    mp = 0
    for i in range(1, 4):
        if tmp[i][1] == 0:
            mp = 100000000
            break
        mp += abs(ABC[i] - tmp[i][0])
        mp += (tmp[i][1] - 1) * 10
    if mp < ans:
        ans = mp
print(ans)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($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) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        a:usize,
    }
    let r = a + usize::pow(a, 2) + usize::pow(a, 3);
    r.to_string()
}
test! {
    "2" => "14",
    "10" => "1110",
}


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

LL fastExponentiation(LL base, LL p) {
    if (p == 0)
        return 1;

    LL half = fastExponentiation(base, p/2);
    LL halfhalf = (half * half)%MOD;

    if (p%2 == 0)
        return halfhalf;
    else
        return (halfhalf * base)%MOD;
}

LL C(int n, int k) {
    LL res = 1;
    for (int i = 1; i <= k; i++) {
        res = (res * (n - k + i))%MOD;
        res = (res * fastExponentiation(i, MOD - 2))%MOD;
    }

    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    LL all = (fastExponentiation(2, n) - 1 + MOD)%MOD;
    LL szA = C(n, a);
    LL szB = C(n, b);

    all = (all - szA + MOD)%MOD;
    all = (all - szB + MOD)%MOD;

    cout << all << endl;
}


Measured memory_bytes: 256
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var small = ToInt32(input[0]);
        var big = ToInt32(input[1]);
        var num = big - small;
        WriteLine((double)1 / 2 * num * (num + 1) - big);
    }
}



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

int main()
{
    int n, t;
    stack<int> s;

    cin >> n;
    while (n--) {
        cin >> t;
        s.push(t);
    }

    cout << s.top();
    s.pop();

    while (!s.empty()) {
        cout << " " << s.top();
        s.pop();
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K,X,Y = map(int,read().split())

if K%2 == 0 and (X+Y)%2 != 0:
    print(-1)
    exit()

def next_vec(x,y):
    # 原点からx,yを目指すとき
    if x < 0:
        dx,dy = next_vec(-x,y)
        return -dx,dy
    if y < 0:
        dx,dy = next_vec(x,-y)
        return dx,-dy
    if x < y:
        dx,dy = next_vec(y,x)
        return dy,dx
    # 1手
    if x+y == K:
        return x,y
    # 2手
    if x+y <= K+K and (x+y)%2 == 0:
        return (x+y)//2,(x+y)//2-K            
    # 3手以上
    return K,0

x,y = 0,0
answer = []
while (x,y) != (X,Y):
    dx,dy = next_vec(X-x,Y-y)
    x += dx; y += dy
    answer.append('{} {}'.format(x,y))

print(len(answer))
print('\n'.join(answer))

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

ll gcd(ll x, ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}



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





Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
mod = 10 ** 9 + 7
e = dd(list)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)

vis = [0] * (N + 1)
dp = [[1] * 2 for _ in range(N + 1)]
order = []
parent = [0] * (N + 1)
s = [1]
while len(s):
  x = s.pop()
  vis[x] = 1
  order.append(x)
  for y in e[x]:
    if vis[y]: continue
    s.append(y)
    parent[y] = x
order.reverse()
for x in order:
  y = parent[x]
  dp[y][0] *= dp[x][0] + dp[x][1]
  dp[y][0] %= mod
  dp[y][1] *= dp[x][0]
  dp[y][1] %= mod
print(dp[0][0])

Measured memory_bytes: 85340
function main(input){
  const lines = input.split('\n')
  const N = parseInt(lines.shift());
  const W = lines.shift().split(' ').map(x => parseInt(x));
  var cum_array = [W[0]];
  for(var i=1;i<N;i++){
    cum_array.push(cum_array[i-1]+W[i])
  }
  var result = Infinity;

  for(var i=1;i<N;i++){
    var current_result = Math.abs(cum_array[N-1] - cum_array[i] - cum_array[i])
    if(current_result < result){result = current_result;}
  }

//  console.log(cum_array);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1e5 + 10;

PII t[MR];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	REP(i, N)
		scanf("%d%d", &t[i].first, &t[i].second);
	LL res = 0;
	REP(i, N)
		if ((K&t[i].first) == t[i].first)
			res += t[i].second;

	FORD(i,30,0)
		if (K&(1 << i))
		{
			int mask = (K & (~((1 << (i + 1)) - 1))) + (1 << i) - 1;
			LL tmp = 0;
			REP(j, N)
				if ((mask&t[j].first) == t[j].first)
					tmp += t[j].second;

			res = max(res, tmp);
		}

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

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

using namespace std;

int main(){
    char c;
    scanf("%c", &c);
    switch(c){
        case 'S':
        printf("Cloudy\n");
        break;
        case 'C':
        printf("Rainy\n");
        break;
        case 'R':
        printf("Sunny\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    x, y = read_list(int)
    length = 0
    while x <= y:
        x *= 2
        length += 1
    print(length)


if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
    long long n,p=1,s=0;
    cin >> n;
    long long arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    sort(arr,arr+n);
    for(int i=n-1;i>=1;)
    {
        if(arr[i]==arr[i-1])
        {
            p*=arr[i];
            i=i-2;
            s++;
        }
        else i--;
        if(s==2) break;
    }
    if(s!=2) cout << "0";
    else cout << p;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = list(sorted(list(map(int, input().split())), reverse=True))
    a, b = 0, 0
    for i in range(N):
        if i % 2 == 0:
            a += A[i]
        else:
            b += A[i]
    print(a - b)
    

if __name__ == '__main__':
    main()


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int l = 1, r = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		r = max(r, a[i]);
	}
	while (l < r) {
		int m = (l + r)/2, cuts = 0;
		for (int i = 0; i < n; i++) {
			cuts += (a[i] + m - 1)/m - 1;
		}
		if (cuts <= k) {
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout << r;
}



Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, cnt = 0;
    bool ok = false;
    cin >> N;
    REP(i, N) {
        int D1, D2;
        cin >> D1 >> D2;
        if (D1 == D2) {
            cnt++;
            if (cnt == 3) {
                ok = true;
            }
        } else {
            cnt = 0;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


int main() {
  string s, t; 
  cin >> s >> t;
  for(int i=97;i<=122;++i){
  	if(t == s + (char)i){
    	printf("Yes");
      	return 0;
    }
      
  }
  printf("No");

  return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s,t;
  cin >> s; cin >> t;
  bool ans = true;
  map<char, char> repl1;
  map<char, char> repl2;
  map<char, bool> used;
  int n = s.size();

  for (int i=0; i<26; i++) {
    repl1['a'+i] = '-';
    repl2['a'+i] = '-';
  }

  for (int i=0; i<n; i++) {
    // if (s[i] == t[i]) continue;

    if (repl1[s[i]]=='-') {
      repl1[s[i]] = t[i];
    }

    if(repl2[t[i]]=='-') {
      repl2[t[i]] = s[i];
    }

    if ((repl1[s[i]]!='-' && repl1[s[i]]!=t[i])
        || (repl2[t[i]]!='-' && repl2[t[i]]!=s[i])) {
      ans = false;
      break;
    }
  }

  cout << (ans? "Yes" : "No") << endl;
}

/*
abc
aaa

b → c
c → a

b ← a
c ← a
*/

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main(){
	int n, x,flo,fle,fno,fne,length,i;
	int slo,sle,sno,sne;

	vector<int> O,E;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> x;
		O.push_back(x);
		i++;
		cin >> x;
		E.push_back(x);
	}
		
	sort(O.begin(),O.end());
	sort(E.begin(),E.end());

	flo = 0;fno = 0;
	fle = 0;fle = 0;

	i=0;
	while(i<n/2){
		length = 1;
		while(O[i] == O[i+length]){
			length++;
		}
		if(flo < length){
			flo = length;
			fno = O[i];
		}
		i=i+length;
	}

	i=0;
	while(i<n/2){
		length = 1;
		while(E[i] == E[i+length]){
			length++;
		}
		if(fle < length){
			fle = length;
			fne = E[i];
		}
		i=i+length;
	}

	if(fno != fne){
		cout << n - fle - flo << endl;
		return 0;
	}

	
	slo = 0;sno = 0;
	sle = 0;sle = 0;

	i=0;
	while(i<n/2){
		if(O[i] == fno){
			i=i+flo;
		}else{
			length = 1;
			while(O[i] == O[i+length]){
				length++;
			}
			if(slo < length){
				slo = length;
				sno = O[i];
			}
			i=i+length;
		}
	}

	i=0;
	while(i<n/2){
		if(E[i] == fne){
			i=i+fle;
		}else{
			length = 1;
			while(E[i] == E[i+length]){
				length++;
			}
			if(slo < length){
				sle = length;
				sne = E[i];
			}
			i=i+length;
		}
	}

	cout << n - max(flo + sle, fle + slo) << endl;



	return 0;


}

Measured memory_bytes: 892
#include <bits/stdc++.h>
//#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 21, mod = 1e9 + 7;

int n, comp[N][N], dp[N][1 << N];

int go(int id, int taken){
    if(id >= n)
        return 1;
    int &ways = dp[id][taken];
    if(~ways)
        return ways;
    ways = 0;
    for(int i = 0; i < n; i++) if((taken >> i & 1) == 0){
        if(comp[id][i])
            ways = (ways + go(id + 1, taken | (1 << i))) % mod;
    }
    return ways;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
  
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> comp[i][j];
    cout << go(0, 0);
}

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

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

Node * Min(Node *p){
  while(p->left!=NIL) p=p->left;
  return p;
}

Node * find(Node *p,int a){
  while(p!=NIL && a!=p->key){
    if(a<p->key) p=p->left;
    else p=p->right;
  }
  return p;
}

Node * Successor(Node *p){
  if(p->right!=NIL) return Min(p->right);
  Node *q=p->parent;
  while(q!=NIL && p==q->right){
    p=q;
    q=q->parent;
  }
  return q;
}

Node * Delete(Node *p){
  Node *a,*b;

  if(p->left==NIL || p->right==NIL) b=p;
  else b=Successor(p);

  if(b->left!=NIL) a=b->left;
  else a=b->right;

  if(a!=NIL) a->parent=b->parent;
  if(b->parent==NIL) root=a;
  else if(b==b->parent->left) b->parent->left=a;
  else b->parent->right=a;

  if(b!=p) p->key=b->key;

  free(b);
}

void insert(int a){
  Node *y=NIL, *x=root, *z;
  z = (Node *)malloc(sizeof(Node));
  z->key=a;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node *p){
  if(p==NIL) return;
  inorder(p->left);
  cout << " " << p->key;
  inorder(p->right);
}

void preorder(Node *p){
  if(p==NIL) return;
  cout << " " << p->key;
  preorder(p->left);
  preorder(p->right);
}

int main(){
  int n,x;
  string str;
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> str;
    if(str=="find"){
      cin >> x;
      Node *p=find(root,x);
      if(p!=NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    else if(str=="insert"){
      cin >> x;
      insert(x);
    }
    else if(str=="print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
    else if(str=="delete"){
      cin >> x;
      Delete(find(root,x));
    }
  }
  return 0;
}


Measured memory_bytes: 21868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.size()){
        if(s[i]=='1') ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
//Scannerクラスをimport
class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      //Scannerクラスのインスタンスを作成
        int A = sc.nextInt();
        //りんご
        int P = sc.nextInt();
        //りんごの欠片
        System.out.println((3 * A + P) / 2 );
        //計算(頭の中ではわかっているけど、言葉では表せない処理)
    }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n);
    llin(m);
    vllin(a,n);
    map<ll,ll> p;
    ll s=0;
    p[0]++;
    FOR(i,0,n-1){
        s=(s+a[i])%m;
        p[s]++;
    }
    ll k=0;
    for(auto q:p){
        k+=q.se*(q.se-1)/2;
    }
    sal(k)
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n, tmp; cin >> n;
    ll ans = 1LL;
    vector<ll> a(n);

    rep(i,n) {
        cin >> tmp;
        if (tmp == 0) {
            cout << 0 << endl;
            return 0;
        }
        a[i] = tmp;
    }
    rep(i,n) {
        if (ans > (ll)1e18/a[i]) {
            cout <<"-1" << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3648
S = input()
N = len(S)
if N == 2:
  if S[0] == S[1]:
    print(1,2)
    exit(0)
  else:
    print(-1, -1)
    exit(0)
    
for e,c in enumerate(S):
  if e+1 < len(S):
    b = S[e+1]
    if c == b:
      print(e+1, e+2)
      exit(0)
  
  if e+2 < len(S):
    b = S[e+2]
    if c == b:
      print(e+1, e+3)
      exit(0)
print(-1, -1)

Measured memory_bytes: 3188
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, W, dp[110][100010];
signed main() {
    cin >> N >> W;

    const int MAXV = 1000 * N;

    fill(dp[0], dp[N+1], INF);
    dp[0][0] = 0;
    for(int i=0; i<N; i++) {
        int w, v; cin >> w >> v;
        for(int j=0; j<=MAXV; j++) {
            if(dp[i][j] == INF) continue;
            chmin(dp[i+1][j], dp[i][j]);
            if(j+v <= MAXV) chmin(dp[i+1][j+v], dp[i][j] + w);
        }
    }

    int ans = 0;
    for(int i=0; i<=MAXV; i++) {
        if(dp[N][i] <= W) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int t = 1;
    while (t <= n)
    {
        v.push_back(t);
        t *= 6;
    }
    t = 1;
    while (t <= n)
    {
        v.push_back(t);
        t *= 9;
    }
    vector<int> dp(2 * n + 100, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (auto j : v)
        {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<vector<long long>> dp;

const long long inf = 1e+18;

void solve()
{
	int n, w;
	cin >> n >> w;

	int m = 1000 * 100 + 1;
	dp.assign(2, vector<long long>(m, inf));

	long long ans = 0;

	dp[0][0] = 0; dp[1][0] = 0;

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;

		for (int k = 1; k < m; k++)
		{
			
			dp[i & 1][k] = min(dp[i & 1][k], dp[(i + 1) & 1][k]);

			if (k - b >= 0)
			{
				dp[i & 1][k] = min(dp[i & 1][k], dp[(i + 1) & 1][k - b] + a);
			}

			if (dp[i & 1][k] <= w)
			{
				ans = max(ans, (long long)k);
			}
		}
	}
	cout << ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
int n, m, ans = 0;
char W[100][100];

// 通れるようなマスがいくつあるか知りたい
void dfs(int y, int x){
    W[y][x] = '#';
    for(int dx = -1; dx <= 1; dx++){
        for(int dy = -1; dy <= 1; dy++){
            if(dx == dy and dx != 0 and dy != 0) continue;
            else if(dx == -dy) continue;
            int nx = dx + x;
            int ny = dy + y;
            if(W[ny][nx] == '.' and 0 <= nx and nx < n and 0 <= ny and ny < m){
                dfs(ny, nx);
                ans++;
            }
        }
    }
    return ;
}

int main(void){
    while(true){
        ans = 0; // 新しいデータセットの度に初期化
        cin >> n >> m;
        if(n == 0 and m == 0) return 0;
        REP(i, m){
            REP(j, n){
                cin >> W[i][j];
            }
        }

        REP(i, m){
            REP(j, n){
                if(W[i][j] == '@'){
                    ans++;
                    dfs(i, j);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,n) for(i=a;i<n;i++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}


void fun(){
	ll i,j,x;
	cin>>x;
	unsigned long long a,b;
	unsigned long long q=1,cnt=0;
	a=100;
	while(1){
		a=1.01*a;
		cnt++;
		if(a>=x){
			break;
		}
		
	}
	cout<<cnt<<endl;
}
int main(){
	fun();
//    ll t;
//    cin>>t;
//    while(t--){
// 	   fun();
//    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...)
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 2000010

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int main(){
    int j,k,i,T,ca=0,n,K=0,m;
    scanf("%d%d", &n, &K);
    printf("%d\n", n-K+1);
    return 0;
}


Measured memory_bytes: 256
import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = fractions.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = fractions.gcd(mini, X - x[i])
        

print(mini)


Measured memory_bytes: 16240
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000

void dijkstra(void);

int n,A[N][N];

int main()
{
  int i,j,k,c,u,v;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = INF;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d %d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra(void){
  int minv,v,u,i;
  int d[N],color[N];

  for(i = 0; i < n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && A[u][v] != INF){
	if(d[v] > d[u] + A[u][v]){
	  d[v] = d[u] + A[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    printf("%d ",i);
    if(d[i] == INF)printf("-1");
    else printf("%d",d[i]);
    printf("\n");
  }
}



Measured memory_bytes: 2112
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int N, M;
        cin >> N;
        vector<int> time(N + 1);
        for (int i = 0; i < N; i++)
        {
                cin >> time[i];
        }

        cin >> M;

        vector<pair<int, int>> drink(M + 1);
        for (int i = 0; i < M; i++)
        {
                int a, b;
                cin >> a >> b;
                a--;
                drink[i] = make_pair(a, b);
        }

        for (int i = 0; i < M; i++)
        {
                int ans = 0;
                for (int j = 0; j < N; j++)
                {

                        if (j == drink[i].first)
                        {
                                ans += drink[i].second;
                        }
                        else
                        {
                                ans += time[j];
                        }
                }
                cout << ans << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define free -1
#define notfree 1
#define FALSE 2
#define TRUE 3
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];
 
void initialize(void);
void print(void);
void recursive(int);
 
int main(){
  int i,j,k,r,c;
  initialize();
             
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=FALSE;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=TRUE;
  }
  recursive(0);
 
  return 0;
}
 
 
void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=free;
    col[i]=free;
  }
 
  for(i=0;i<2*N-1;i++){
    dpos[i]=free;
    dneg[i]=free;
  }
}
 
void print(){
  int i,j;
  
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(X[i][j] == TRUE){
	if(row[i] != j)return;
      }
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    print();
    return;
  }
  for(j=0;j<N;j++){
    if(notfree==col[j]||notfree==dpos[i+j]||notfree==dneg[i-j+N-1])continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=notfree;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=free;
  }
}



Measured memory_bytes: 2108
const lines = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line) {
  lines.push(line);
});

reader.on("close", function () {
  const cardNum = lines[0] as string;
  const cardArray = (lines[1] as string).split(" ");

  console.log(
    diff(
      makeNumArray(cardArray).sort(function (a, b) {
        return b - a;
      })
    )
  );
});

function diff(cardArray: number[]): number {
  let diff = 0;

  for (let i = 0; i < cardArray.length; i++) {
    if (i % 2 === 0) {
      diff += cardArray[i];
    } else {
      diff -= cardArray[i];
    }
  }

  return diff;
}

function makeNumArray(value: string[]): number[] {
  const numArray = [];

  for (let i = 0; i < value.length; i++) {
    numArray.push(Number(value[i]));
  }
  return numArray;
}


Measured memory_bytes: 7756
N, M = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

ct, x = 0, 0
ABs.sort_by{|a, b| b}.each do |a, b|
  next if a <= x
  ct += 1
  x = b - 1
end
puts ct

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

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

        BigDecimal max = new BigDecimal(Math.pow(10, 18));
        BigDecimal decimal = null;
        boolean overflow = false;

        for (int i = 0; i < n; i++) {
            long val = scanner.nextLong();
            if (val == 0) {
                System.out.println("0");
                System.exit(0);
            }
            if (decimal == null) {
                decimal = new BigDecimal(val);
            } else if (!overflow) {
                decimal = decimal.multiply(new BigDecimal(val));
                if (decimal.compareTo(max) > 0) {
                    overflow = true;
                }
            }
        }

        if (overflow) {
            System.out.println("-1");
        } else {
            System.out.println(decimal);
        }

    }
}

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

int beki(int a,int b){
	int ans=1;
	for(int i=0;i<b;i++){
		ans=ans*a;
	}
	return ans;
}
int main(){
string a;
cin>>a;
int t=a.length();
for(int i=0;i<t-2;i++){
if(a[i]==a[i+1]){cout<<i+1<<" "<<i+2<<endl;return 0;}
if(a[i]==a[i+2]){cout<<i+1<<" "<<i+3<<endl;return 0;}
}
if(a[t-2]==a[t-1]){cout<<t-1<<" "<<t<<endl;return 0;}
cout<<-1<<" "<<-1<<endl;
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n;
ll gcd(ll a, ll b) {
    return (b == 0 ? a : gcd(b, a % b));
}

int main() {
    cin >> n;
    cout << 360 / gcd(360, n) << endl;
}


Measured memory_bytes: 3628
<?php

list($n) = explode(" ", trim(fgets(STDIN)));
list($S) = explode(" ", trim(fgets(STDIN)));

$r=0;
$g=0;
$b=0;
for($i=0;$i<$n;$i++){
  if($S[$i]=="R"){
    $r++;
  }else if($S[$i]=="G"){
    $g++;
  }else{
    $b++;
  }
}

$all = $r*$g*$b;

$ans=0;
$half = intdiv($n, 2);
for($i=0;$i<$n;$i++){
  for($j=$i+1;$j<$n;$j++){
    $k=$j*2-$i;
    if($k>=$n){
      continue;
    } 
//    echo $i." ".$j." ".$k.PHP_EOL;
//    echo $S[$i]." ".$S[$j]." ".$S[$k].PHP_EOL;
    if($S[$i]!=$S[$j] && $S[$i]!=$S[$k] && $S[$j]!=$S[$k]){
      $ans++;
    }
  }
}

$ans=$all-$ans;
echo $ans;

Measured memory_bytes: 16156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }

  int ans = 1;
  int i = 1;
  vector<int> LOG(100010);
  while(1){
    if(binary_search(LOG.begin(), LOG.end(), v.at(i-1))){
      ans = -1; break;
    }else if(v.at(i-1) == 2){
      break;
    }else{
      i = v.at(i-1);
      LOG.at(ans-1) = v.at(i-1);
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool check(int p)
{
	if(p>=1&&p<=9||p>=100&&p<=999||p>=10000&&p<=99999) return true;
	return false;
}
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	if(check(i)) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))

'''
r = 0
b = 0
cnt = 0

while k in range(n):
    for k in range(k):
        if d[k] >= k+1:
            r += 1
        else:
            b += 1

if r == b:
     cnt += 1
print(cnt)
'''

sortedd = sorted(d)
ans = 0
if not sortedd[n//2-1] == sortedd[n//2]:
    ans += sortedd[n//2] - sortedd[n//2-1]
print(ans)

Measured memory_bytes: 14556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, m, x; cin >> n >> m >> x;
    ll a[m]; zep(i, 0, m){cin >> a[i];}

    ll cnt = 0;
    zep(i, 0, m){
        if(a[i] < x){
            cnt++;
        }
    }
    print(min(cnt, m-cnt))
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

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

  bool f = (s[a] == '-');
  s.erase(s.begin() + a);
  f &= all_of(ALL(s), [](int c){return isdigit(c);});

  puts(f ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;



void solve(){

    ll x;
    cin >> x;

    ll t = 100;
    ll ans = 0;
    while(t<x){
        t *= 1.01;
        ans++;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 3640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
        	var result = cin.ReadIntArray(N).Min(intA => {
            	var cnt = 0 ;
              	while(intA % 2 == 0)
                {
                	intA /= 2;
                  	cnt ++ ;
                }
              	return cnt;
            });
          	WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 28448
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    string s;
    cin >> n >> s;
    lint mod = 1e9 + 7;
    lint dp[n][n], dpsum[n][n+1];
    rep(i, n) dpsum[i][0] = 0;
    rep(i, n)rep(j, n) dp[i][j] = dpsum[i][j+1] = 0;
    rep(j, n) dp[0][j] = 1, dpsum[0][j+1] = dpsum[0][j] + dp[0][j];
    For(i, 1, n)rep(j, n-i){
        if(s[i-1] == '<') dp[i][j] = dpsum[i-1][j+1];
        else dp[i][j] = (dpsum[i-1][n-i+1] - dpsum[i-1][j+1] + mod) % mod;
        dpsum[i][j+1] = (dpsum[i][j] + dp[i][j]) % mod;
    }
    printf("%lld\n", dp[n-1][0]);
}

Measured memory_bytes: 140928
#include<cstdio>
#include<cstring>

using namespace std;

int n,m;
int s[1000001],t[1000001],e[1000001];
int l,b[10001],c[10001];
int main(void){	
	scanf("%d%d",&n,&m);
	int in=0;
	while(1){
		scanf("%d%d%d",&s[in],&t[in],&e[in]);
		if(s[in]==0)break;
		in++;
	}
	scanf("%d",&l);
	for(int i=0;i<l;i++){
		memset(c,0,sizeof(c));
		for(int j=0;j<m;j++)scanf("%d",&b[j]);
		for(int j=0;j<in;j++){
			c[s[j]-1]+=b[t[j]-1]*e[j];
		}
		for(int j=0;j<n;j++)printf("%d%c",c[j],j==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 7460
from collections import deque

n,u,v = map(int,input().split())
u -= 1
v -= 1
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

def bfs(x):
    dist = [-1]*n
    dist[x] = 0
    que = deque([x])
    while que:
        now = que.pop()
        for nex in G[now]:
            if dist[nex] != -1:continue
            dist[nex] = dist[now] + 1
            que.appendleft(nex)
    return dist

dist_u = bfs(u)
dist_v = bfs(v)

ans = 0
for i in range(n):
    if dist_u[i] < dist_v[i]:
        ans = max(ans,dist_v[i]-1)

print(ans)

Measured memory_bytes: 29336
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	char c;
	cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n,_,w := scanInt(), scanInt(), scanInt()
	a := scanInts(n)

	if n > 1 {
		fmt.Println(max(abs(w-a[n-1]),abs(a[n-1]-a[n-2])))
	} else {
		fmt.Println(abs(w-a[n-1]))
	}

}

func abs(a int) int {
	if a<0 {
		return -a
	}
	return a
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}



Measured memory_bytes: 640
"""解説から
1. 偶数+偶数=偶数, 奇数+奇数=偶数になる
2. 偶奇が入り混じった配列Aの中にある奇数が偶数個であれば、YESとなる
3. 2の前提が達成されているかを調べるには以下の2通りの方法がある
    ・各Aiを調べ奇数を数える
    ・1の前提から、sum(A)が偶数ならば、Aの中に奇数は偶数個あるといえる
"""
input()
print('YES' if sum(map(int, input().split())) % 2 == 0 else 'NO')


Measured memory_bytes: 11100