akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var x = long.Parse(Console.ReadLine());

        long ans = 0;
        long position = 0;
        while (position < x)
        {
            ans++;
            position = (ans * (ans + 1)) / 2;
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, d, num1, num2, c = 0;
    cin >> n >> d;
    for (int i = 0; i<n; i++){
        cin >>num1 >> num2;
        if(sqrt(pow(num1, 2) + pow(num2, 2)) <= d) c++;
    }
    cout << c;
}



Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int d;
  while(scanf("%d",&d), d){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> v(n+1);
    v[0] = 0; v[n] = d;
    REP(i,n-1) scanf("%d",&v[i+1]);
    sort(ALL(v));
    int ans = 0;
    REP(i,m){
      int pos;
      scanf("%d",&pos);
      vector<int>::iterator it = lower_bound(ALL(v), pos);
      if(*it != pos)
        ans += min(*it - pos, pos - *(it - 1));
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

int n, d, ans=0;

int main() {
    // Input
    cin >> n >> d;
    vector<vector<int> > x(n);
    
    for (int i = 0; i < n; ++i) {
        x.at(i).resize(d);
    
        for (int j = 0; j < d; ++j) {
            cin >> x.at(i).at(j);
        }
    }

    // Solve
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < i; ++j)
        {
            double dis=0;
            for (int k = 0; k < d; ++k) {
                dis+=pow(x.at(i).at(k)-x.at(j).at(k), 2);
            }
            if (ceil(sqrt(dis))==floor(sqrt(dis)))
            {
                ans++;
            }
        }
    }


    // Output
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import Counter


class HuffmanTreeNode:
    def __init__(self, char, freq):
        self.char = char
        self.freq = freq
        self.left = None
        self.right = None
    
    def __lt__(self, other):
        return self.freq < other.freq


def huffman_code_helper(root, code='', codes={}):
    if not root:
        return codes
    
    if not root.left and not root.right:
        codes[root.char] = code if code else '0'
        return codes
    
    huffman_code_helper(root.left, code + '0', codes)
    huffman_code_helper(root.right, code + '1', codes)
    return codes


def huffman_code(text):
    counter = Counter(text)
    heap = []
    for char, freq in counter.items():
        heap.append(HuffmanTreeNode(char, freq))
    heapq.heapify(heap)

    while len(heap) > 1:
        left, right = heapq.heappop(heap), heapq.heappop(heap)
        node = HuffmanTreeNode('', left.freq + right.freq)
        node.left, node.right = left, right
        heapq.heappush(heap, node)
    root = heap[0]

    return huffman_code_helper(root)


def solution():
    text = input()
    codes = huffman_code(text)
    encoded = []
    for char in text:
        encoded.append(codes[char])
    print(len(''.join(encoded)))

solution()


Measured memory_bytes: 7260
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> mp;
  int n; cin >> n;
  for(int i=0;i<n;i++){
    string s; cin >> s;
    mp[s]++;
  }
  int m; cin >> m;
  for(int i=0;i<m;i++){
    string t; cin >> t;
    mp[t]--;
  }
  int ans=0;
  for(auto i:mp){
    if(ans<=i.second) ans = i.second;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  long int A,B;
  cin >> A >> B;
  long int temp,fA,fB;
  if (B>A) {
    fA=B;
    fB=A;
  }else{
    fA=A;
    fB=B;
  }
  while (fA%fB!=0) {
    temp=fB;
    fB =fA%fB;
    fA=temp;
  }
  long int ans;
  ans=A*B/fB;
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
ll n,m,arr[100006];
int main()
{
	ios;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>arr[i];
	}
	ll now=1;
	for(int i=1;i<=n;++i)
	{
		now=lcm(now,arr[i]/2);
		if(now>m)break;
	}
	if(now>m){cout<<0<<'\n';return 0;}
	int flag=1;
	for(int i=1;i<=n;++i)
	{
		int temp=now*2/arr[i];
		if(temp%2==0){flag=0;break;}
	}
	if(flag==0){cout<<0<<'\n';return 0;}
	else
	{
		ll num=m/now;
		if(num&1){cout<<num/2+1<<'\n';}
		else cout<<num/2<<'\n';
	}
}

Measured memory_bytes: 4420
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    
    int cou = 0;
    rep(i, n-1) {
        if(s[i] != s[i+1]) cou++;
    }

    cout << cou << endl;
}

Measured memory_bytes: 512
N=int(input())
A=[int(i) for i in input().split()]
D=dict()
for i in range(N):
    if A[i] in D:
        D[A[i]]+=1
    else:
        D[A[i]]=1
ans=0
for key in D:
    if D[key]<key:
        ans+=D[key]
    else:
        ans+=D[key]-key
print(ans)


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

string s;
int q;
int main(){
	cin >> s;
	cin >> q;
	vector<char> v(all(s));
	int flag = 0;
	rep(i,0,q){
		int t;
		cin >> t;
		if(t == 1){
			if(flag == 0)flag = 1;
			else flag = 0;
		}
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == 1 and flag == 0)v.insert(v.begin(), c);
			else if(f == 1 and flag == 1) v.push_back(c);
			else if(f == 2 and flag == 0) v.push_back(c);
			else if(f == 2 and flag == 1) v.insert(v.begin(), c);
		}
	}
	if(flag == 1)reverse(all(v));
	for(int i = 0; i < v.size(); i++)cout << v[i];
	cout << endl;


}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  int ans = 0;
  int now = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    // cerr << "now: " << now << " tmp: " << tmp << " ans: " << ans << endl;
    if(i == 0){
      ans = tmp;
      now = tmp;
    } else { 
      if(now > tmp){
        now = tmp;
      } else {
        ans += tmp - now; 
        now = tmp;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
p=[list(map(int, input().split())) for _ in range(N)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for i in range(101):
  for j in range(101):
    center=[i,j,ah+abs(ax-i)+abs(ay-j)]
    if all(t[2]==max(center[2]-abs(t[0]-center[0])-abs(t[1]-center[1]),0) for t in p) :
      print(center[0],center[1],center[2])


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

int main() {

  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;

  for(int i = 1; i < n; i++) {
    int t = i - 1;

    if(s.at(t) == '1') {

      if(s.at(i) == '0') {
      }
      else if(s.at(i) == '1'){
        s.at(i) = '0';
        ans++;
      }
    }else if(s.at(t) == '0') {

      if(s.at(t) == '1'){
      }else if(s.at(i) == '0'){
        s.at(i) = '1';
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

string cipher(int&);

char letter(int& i) {
	// cerr << "letter " << i << endl;
	char c;
	if (S[i] == '+') {
		++i;
		c = letter(i);
		if (c != '?') {
			++c;
			if (c > 'Z') c = 'A';
		}
	} else if (S[i] == '-') {
		++i;
		c = letter(i);
		if (c != '?') {
			--c;
			if (c < 'A') c = 'Z';
		}
	} else {
		c = S[i];
		++i;
	}
	return c;
}

string str(int& i) {
	// cerr << "str " << i << endl;
	string ret;
	if (S[i] == '[') {
		++i;
		ret = cipher(i);
		assert(S[i] == ']');
		++i;
		reverse(ret.begin(), ret.end());
	} else {
		char c = letter(i);
		if (c == '?') c = 'A';
		ret = string(1, c);
	}
	return ret;
}

string cipher(int& i) {
	// cerr << "cipher " << i << endl;
	string ret = str(i);
	if (i < S.length() && S[i] != ']') {
		ret += cipher(i);
	}
	return ret;
}

bool solve() {
	cin >> S;
	if (S == ".") return false;

	int i = 0;
	cout << cipher(i) << endl;
	return true;
}

int main(){
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3160
import math

cnt = 0
n = int(input())

for i in range(n):
    flg = 1
    x = int(input())
    if x == 2: cnt += 1
    elif x % 2 != 0:
        rx = int(math.sqrt(x))
        for i in range(3, rx+1):
            if x % i == 0:
                flg = 0
                break
        if flg == 1: cnt += 1

print(cnt)


Measured memory_bytes: 5668
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long

int main(){
  int n;
  scanf("%d",&n);
  if((n<800 && n>=700) || (n%100>=70 && n%100<80) || n%10==7){
    printf("Yes");
    return 0;
  }
  else{
    printf("No");
  }
  return 0;
}

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

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

int main() {

	int X;
	cin >> X;

	int a = 0, b = 0;

	a = X / 500;
	b = (X - 500 * a) / 5;

	cout << 1000 * a + 5 * b << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long K = sc.nextLong();
    if(N < K){
      long A = K -N;
      if(A >= N){
        System.out.println(N); 
      }else{
        System.out.println(A); 
      }
    }else{
      long B = N % K;
      long A = K - B;
      if(A >= B){
        System.out.println(B); 
      }else{
        System.out.println(A); 
      }
    }
    return;
  }
}



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

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

	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2) {
			if (++cnt >= 3) {
				cout << "Yes" << "\n";
				return 0;
			}
		} else {
			cnt = 0;
		}
	}
	cout << "No" << "\n";
	return 0;
}


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

ll a, b, n, maxi=0;
bool cal(ll x){
  ll tmp = a*x/b - a*(x/b);
  maxi = max(tmp, maxi);
  return maxi<=tmp;
}


int main(){
  cin >> a >> b >> n;
  ll lb=-1, ub=n+1;

  while(ub-lb>1){
    ll mid = (lb+ub)/2;
    if(cal(mid)) lb=mid;
    else ub=mid;
  }
  cout << maxi << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e4 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define al(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define IOS ios::sync_with_stdio(0);
#define sb(x) ((x)*(x))
map<int, int>mp;
void init() {
	for (int x = 1; x <= 99; ++x) {
		for (int y = 1; y <= 99; ++y) {
			for (int z = 1; z <= 99; ++z) {
				int k = sb(x + y) + sb(x + z) + sb(y + z);
				if (k & 1) continue;
				mp[k / 2]++;
			}
		}
	}
}
int main() {
	init();
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		if (mp.count(i)) printf("%d\n", mp[i]);
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main() {
  string s;
  cin >> s;
  int n=s.size();
//  cout << n << endl;
  int ans=0;
  int cnt=0;

  rep(i,0,n){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') cnt++;
    else {
      ans=max(ans,cnt);
      cnt=0;
    }
  }
  ans=max(ans,cnt);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
    char line[11];
    int i,t;
    for(;t=10,scanf("%s",line)!=EOF;){
        while(t--,t!=0){
            for(i=0;i<t;i++){
                line[i]=line[i]+line[i+1];
                if(t==9)
                    line[i]-=6;
                line[i]%=10;
            }
        }
        printf("%d\n",line[0]);
    }
    return 0;
}

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

const int maxn = 1e6 + 100;
int a[maxn],n,vis[maxn];

int gcd(int x,int y){
    return !y ? x : gcd(y,x%y);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(vis,0,sizeof(vis));
    cin >> n;
    for(int i = 1;i <= n;i++) cin >> a[i],vis[a[i]]++;
    bool F = false;
    for(int i = 2;i < maxn;i++){
        int cnt = 0;
        for(int j = i;j < maxn;j += i) cnt += vis[j];
        if(cnt > 1){
            F = true;break;
        }
    }
    if(!F) {
        printf("pairwise coprime\n");return 0;
    }
    int x = a[1];
    for(int i = 2;i <= n;i++) x = gcd(x,a[i]);
    printf("%s\n",x == 1 ? "setwise coprime" : "not coprime");
    return 0;
}

Measured memory_bytes: 11400
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
    h, w, k = map(int,input().split())
    C = [input() for _ in range(h)]
    comb_list = list(product([False, True], repeat = h + w))
    ans = 0
    for comb in comb_list:
        cunt = 0
        for i in range(h):
            if not comb[i]:
                continue
            for j in range(w):
                if not comb[h+j]:
                    continue
                if C[i][j] == '#':
                    cunt += 1
        if cunt == k:
            ans += 1
    print(ans)



if __name__=='__main__':
    main()

Measured memory_bytes: 74504
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> H(N);
	for(int i=0;i<N;i++)cin>>H[i];
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<M;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		bool f = true;
		for(int j=0;j<E[i].size();j++){
			if(H[i]<=H[E[i][j]]){
				f=false;
				break;
			}
		}
		if(f)ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 8808
import sys
import bisect
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
color = [a[n-1]]
for i in range(n-2,-1,-1):
    if a[i]>=color[-1]:
        color.append(a[i])
    else:
        x = bisect.bisect_right(color,a[i])
        color[x] = a[i]
print(len(color))

Measured memory_bytes: 49628
N = int(input())
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
A = factorization(N)
 
def func(x):
    import math
    return int((-1+math.sqrt(1+8*x))/2)
 
ans = 0
for i in range (len(A)):
    ans = ans + func(A[i][1])
    
if N != 1:
  print(ans)
else:
  print(0)

Measured memory_bytes: 9496
from collections import defaultdict
from collections import deque
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
field=[[float('inf') for i in range(w)] for j in range(h)]

q=deque()
q.append((0,0))
field[0][0]=0

dx=[0,1,0,-1]
dy=[1,0,-1,0]

while q:
    y,x=q.popleft()
    
    for i in range(4):
        nx=x+dx[i]
        ny=y+dy[i]
        if 0<=nx<w and 0<=ny<h and field[ny][nx]==float('inf') and s[ny][nx]!='#':
            field[ny][nx]=field[y][x]+1
            q.append((ny,nx))
check=field[h-1][w-1]

shiro=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            shiro+=1
ans=shiro-check-1

print(ans if check!=float('inf') else -1)



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

public class Main 
{
	static long[] mask = new long[12];
	static int n, m; //n books
	static long x; //target mastery
	static long[] price;
	static long[][] mast;
	static long best = -1;
	static void go(long c)
	{
		boolean[] book = new boolean[n];
		long[] skill = new long[m];
		long pay = 0;
		for(int i = 0; i < n; i++)
		{
			book[i] = (c & mask[i]) > 0;
			
			if(book[i])
			{
				for(int j = 0; j < m; j++)
				{
					skill[j] += mast[i][j];
				}
				pay += price[i];
			}
		}
		
		int count = 0;
		for(int i = 0; i < m; i++)
		{
			if(skill[i] >= x)
			{
				count++;
			}
		}
		
//		System.out.println(count + " " + x + Arrays.toString(skill) + " " + pay + " " + m);
		if(count == m)
		{
			if(best < 0 || best > pay)best=pay;
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		
		n = sc.nextInt();
		m = sc.nextInt();
		x = sc.nextLong();
		price = new long[n];
		mast = new long[n][m];
		
		for(int i = 0; i < n; i++)
		{
			price[i] = sc.nextLong();
			//each algo
			for(int j = 0; j < m; j++)
				mast[i][j] = sc.nextLong();
		}
		
		long curm = 1;
		for(int i = 0; i < n; i++)
		{
			mask[i] = curm;
			curm*= 2;
		}
		
		for(long c = 0; c <= curm-1; c++)
		{
			go(c);
//			System.out.println(Long.toString(c,2));
		}
		System.out.println(best);
	}

}


Measured memory_bytes: 28804
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define orz return printf("-1\n"),0;
#define qwq return printf("%lld\n",l),0;
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
using namespace std;
using namespace __gnu_pbds;
const int neko=100010;
int n,m;
typedef long long ll;
ll l;
char S[neko],T[neko];
gp_hash_table<ll,char>ht;
int main()
{
	scanf("%d%d",&n,&m);l=1ll*n*m/__gcd(n,m);
	scanf("%s%s",S+1,T+1);
	int len=n;
	f(i,1,len)
	{
		if(ht[1+1ll*(i-1)*l/n]&&ht[1+1ll*(i-1)*l/n]^S[i])orz;
		ht[1+1ll*(i-1)*l/n]=S[i];
	}
	len=m;
	f(i,1,len)
	{
		if(ht[1+1ll*(i-1)*l/m]&&ht[1+1ll*(i-1)*l/m]^T[i])orz;
		ht[1+1ll*(i-1)*l/m]=T[i];
	}
	qwq;
}

Measured memory_bytes: 18924
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

bool isOdd2(ull n){
    for(ull i=3;i*i<=n;i+=2){
        if(n % i == 0 && (n / i + 1) % 2 == 0){
            return true;
        }
    }
    return false;
}

int main(){
    int N;
    std::cin >> N;

    int res = 0;
    REP(i, N){
        ull k;
        std::cin >> k;
        
        k = 2*k+1;
        if(!isOdd2(k)){
            res++;
        }
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,v1,v2,num1,num2,num3;
int main()
{
	scanf("%d",&n);
	scanf("%d%d",&v1,&v2);
	while(n--)
	{
		int v;
		scanf("%d",&v);
		if(v<=v1)num1++;
		else if(v<=v2)num2++;
		else num3++;
	}
	printf("%d\n",min(num1,min(num2,num3)));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int arr[105];

int main() {
    string s;
    cin>>s;
    for(int i=0;i<s.size();++i) {
        arr[s[i]-'a']++;
    }

    int ok = 1;
    for(int i=0;i<26;++i) {
        if(arr[i]%2) {
            ok = 0; break;
        }
    }
    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	long long A, B, K;
	cin >> A >> B >> K;
	if (A <= K) {
		K -= A;
		A = 0;
		if (B <= K) {
			B = 0;
		}
		else {
			B -= K;
		}
	}
	else {
		A -= K;
	}
	cout << A  << " " << B << endl;	
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int gcd(int a, int b){
    while(b != 0){
        int tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int ans = a[0];
    for(int i=1; i<n; ++i)
        ans = gcd(ans, a[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
	cin>>n;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]-'A'+n>=26)
		cout<<char('A'+(int)(s[i]-'A'+n)%26);
		else
		cout<<char(s[i]+n);
	}
	return 0;
}

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

struct Node {
    int d, v;
};

int main() {
    int n;
    cin >> n;
    vector<int> es[n + 1];
    bool used[n + 1];
    fill(used, used + n + 1, false);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        es[a].push_back(b);
        es[b].push_back(a);
    }
    queue<Node> que;
    que.push(Node {0, 1});
    int start;

    while (!que.empty()) {
        auto t = que.front();
        que.pop();
        if (used[t.v])
            continue;
        used[t.v] = true;
        start = t.v;
        for (int x: es[t.v]) {
            que.push(Node {t.d + 1, x});
        }
    }

    que.push(Node {0, start});
    int diameter = 0;
    fill(used, used + n + 1, false);
    while (!que.empty()) {
        auto t = que.front();
        que.pop();
        if (used[t.v])
            continue;
        used[t.v] = true;
        diameter = max(diameter, t.d);
        for (int x: es[t.v]) {
            que.push(Node {t.d + 1, x});
        }
    }
    cout << ((diameter % 3 == 1) ? "Second" : "First") << endl;
    return 0;
}


Measured memory_bytes: 13812
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define fi first
#define sec second
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;
void solve()
{
    string s,t;
    cin>>s>>t;
    ll cnt=0;
    fo(i,0,s.size())
    {
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>
     
    int main(void)
    {
    	int a,b;
    	scanf("%d %d",&a,&b);
    	
    	if(a%3==0 || b%3==0 ||(a+b)%3==0){
    		printf("Possible\n");
    	} else{
    		printf("Impossible\n");
    	}
     
    return 0;
    }

Measured memory_bytes: 128
// Shift-JIS（シフトジス）

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

int main()
{
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    int stones;
    bool flag1 = true, flag2 = true;

    stones = 0;
    for (int i = A; i < C - 1; i++)
    {
        if (S[i] == '#')
        {
            stones++;
        }
        else
        {
            stones = 0;
        }
        if (stones > 1)
        {
            flag2 = false;
        }
    }

    stones = 0;
    for (int i = B; i < D - 1; i++)
    {
        if (S[i] == '#')
        {
            stones++;
        }
        else
        {
            stones = 0;
        }
        if (stones > 1)
        {
            flag1 = false;
        }
    }

    if (flag1 && flag2)
    {
        if (C > D)
        {
            int count = 0;
            for (int i = B - 2; i < D + 1; i++)
            {
                if (S[i] == '.')
                {
                    count++;
                }
                else
                {
                    count = 0;
                }
                if (count > 2)
                {
                    break;
                }
            }
            if (count < 3)
            {
                flag2 = false;
            }
        }
    }

    if (flag1 && flag2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
from collections import defaultdict
MOD = 10**9+7
n = int(input())


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for p in range(2, int(n**.5)+1):
        if res[p] < p:
            continue
        for q in range(p**2, n, p):
            if res[q] == q:
                res[q] = p
    return res


U = 10**3
min_factor = sieve(U)
pf = defaultdict(lambda: 0)


def prime_factor(n):
    while 1 < n:
        pf[min_factor[n]] += 1
        n //= min_factor[n]


for i in range(1, n+1):
    prime_factor(i)

ans = 1
for v in pf.values():
    ans *= v+1
    ans %= MOD
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
const int MOD = 1e9 + 7 ;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int32_t main(){
   IOS
   int n;
   cin>>n;
   vector<int>arr(n);
   for (int &x : arr)
       cin>>x;

   vector<int>dp(n,INT_MAX);
   dp[0]=0;
    for (int i = 0; i < n; ++i) {
        for( int j : {i+1,i+2}){
                if(j<n) dp[j] = min(dp[j],dp[i] + abs(arr[i]-arr[j]));
        }
    }
   cout<<dp[n-1]<<endl;


    return 0;
}
// CHECK FOR CORNER CASES LIKE 0,1 etc.


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

ll get(ll a, ll b) {
  ll res = 1ll;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1ll;
    a = (a * a) % MOD;
  }
  return res;
}

ll f[N];
ll inv[N];

ll ncr(ll n, ll r) {
  if(n < r or n < 0 or r < 0) return 0;
  ll cur = f[n];
  cur = (cur * inv[n - r]) % MOD;
  cur = (cur * inv[r]) % MOD;
  return cur;
}

int main() {
  f[0] = 1;
  inv[0] = 1;
  for(ll i = 1; i < N; i++) {
    f[i] = (f[i - 1] * i) % MOD;
    inv[i] = get(f[i], MOD - 2);
  }
  ll n, m;
  cin >> n >> m;
  if(n < m) swap(n, m);
  if(n - m > 1) {
    print(0);
    return 0;
  }
  ll cur = (f[n] * f[m]) % MOD;
  if(n == m) cur = (2 * cur) % MOD;
  print(cur);
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<pair<double, double>> data(N);
    REP(i, N) cin >> data[i].first >> data[i].second;

    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    double totalDist = 0;
    int cnt = 0;
    do {
        double dist = 0;
        for (int i = 0; i < N-1; i++) {
            auto a = data[v[i]];
            auto b = data[v[i+1]];
            double tmp = 0;
            tmp += pow(abs(a.first - b.first), 2);
            tmp += pow(abs(a.second - b.second), 2);
            dist += sqrt(double(tmp));
        }
        totalDist += dist;
        cnt++;
    } while(next_permutation(v.begin(), v.end()));

    double ans = totalDist / cnt;
    cout << setprecision(20) << ans << endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

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


int main(int argc, char**argv){
    int a, b;
    cin >> a >> b;

    if (a >= 13){
        cout << b << endl;
    }else if (6 <= a && a <= 12){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return  0;
}



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

int main(){
    vector<vector<int>> c(3, vector<int>(3, 0));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c.at(i).at(j);
        }
    }
    
    vector<int> a(3), b(3);
    a.at(0) = 0;
    b.at(0) = c.at(0).at(0);
    b.at(1) = c.at(0).at(1);
    b.at(2) = c.at(0).at(2);
    a.at(1) = c.at(1).at(0) - b.at(0);
    a.at(2) = c.at(2).at(0) - b.at(0);
    vector<vector<int>> c2(3, vector<int>(3, 0));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            c2.at(i).at(j) = a.at(i) + b.at(j);
        }
        
    }
    if(c == c2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    int n;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1;i<=n;++i){
        int a;cin>>a;
        v[a]=i;
    }
    for(int i=1;i<=n;++i){
        cout << v[i];if(i)cout << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
  double x, y;
  vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
  vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
  vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
  vec operator * (const double& t) const {return vec(x*t, y*t);}
  vec operator / (const double& t) const {return vec(x/t, y/t);}
  const double len2 () const {return x*x + y*y;}
  const double len () const {return sqrt(len2());}
  vec norm() const {return *this/len();}
  vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
  double t = crs(p1-p0, v1) / crs(v0, v1);
  return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
  return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
  //freopen("a.in", "r", stdin);
 // freopen("a.out", "w", stdout);
  scanf("%d", &n);
  for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
  random_shuffle(pot+1, pot+n+1);
  vec o;
  double r2 = 0;
  for(int i=1; i<=n; i++)
    {
      if((pot[i]-o).len2() > r2)
        {
          o = pot[i], r2 = 0;
          for(int j=1; j<i; j++)
            {
              if((pot[j]-o).len2() > r2)
                {
                  o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                  for(int k=1; k<j; k++)
                    {
                      if((pot[k]-o).len2() > r2)
                        {
                          o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
  printf("%.10lf\n", sqrt(r2));
  return 0;
}


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

public class Program{
  public static void Main(){
    var n = uint.Parse(Console.ReadLine());
    var gcd = ulong.Parse(Console.ReadLine());
    ulong gcm = gcd;
    for(var i=1; i<n; i++){
      var x = ulong.Parse(Console.ReadLine());
      var a = Math.Max(gcm, x);
      var b = Math.Min(gcm, x);
      while(b!=0){
        var tmp = b;
        b = a%b;
        a = tmp;
      }
      gcd = a;
      gcm = (x/gcd)*gcm;
    }
    Console.WriteLine(gcm.ToString());
  }
}


Measured memory_bytes: 11092
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=100000;
mt19937 mt;

int D,c[26],s[200000][26],t[200000],T[200000],v,V,l[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		t[i]=uniform_int_distribution<int>(0,25)(mt);
	}
	for(int i=0;i<26;i++){
		l[i]=-1;
	}
	for(int i=0;i<D;i++){
		l[t[i]]=i;
		v+=s[i][t[i]];
		for(int j=0;j<26;j++){
			v-=c[j]*(i-l[j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			if(uniform_int_distribution<int>(0,N*10)(mt)<=N-i){
				T[j]=uniform_int_distribution<int>(0,25)(mt);
			}
			else{
				T[j]=t[j];
			}
		}
		for(int j=0;j<26;j++){
			l[j]=-1;
		}
		V=0;
		for(int j=0;j<D;j++){
			V-=c[T[j]]*(j-l[T[j]]-1)*(j-l[T[j]])/2;
			l[T[j]]=j;
			V+=s[j][T[j]];
		}
		for(int j=0;j<26;j++){
			V-=c[j]*(D-l[j]-1)*(D-l[j])/2;
		}
		if(V>v){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


Measured memory_bytes: 3868
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] data = new int[5];
		int max = 0;
		int sum = 0;

		for (int i = 0;i<5 ;i++ ) {
			data[i] = sc.nextInt();
			if (data[i]%10>0) {
				max = Math.max(max,10-data[i]%10);
			}
		}
		for (int i = 0;i<5 ;i++ ) {
			if (10-data[i]%10==max) {
				sum+=data[i];
				data[i] = 0;
				break;
			}
		}

		for (int i = 0;i<5 ;i++ ) {
		 if (data[i]%10==0) {
				sum+=data[i];
			}else{
				sum +=data[i]+10-data[i]%10;
			}
		}

		System.out.println(sum);


	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 10;
int a[maxn];
int num[4] , id = 0 , cnt = 0 , v = -1;
int main(){
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> a[i];
	if(n % 3 != 0){
		for(int i = 1 ; i <= n ; ++ i)
			if(a[i] != 0){
				cout << "No" << endl;
				return 0;
			}
		cout << "Yes" << endl;
		return 0;
	}
	sort(a + 1 , a + n + 1);
	for(int i = 1 ; i <= n ; ++ i){
		if(a[i] != v){
			cnt = 1;
			v = a[i];
		}
		else
			cnt ++;
		if(cnt == n / 3){
			num[++ id] = v;
			cnt = 0;
		}
	}
	if(id != 3){
		cout << "No" << endl;
	}
	else if((num[1] ^ num[2] ^ num[3]) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

int get_int5(int *a1, int *a2, int *a3, int *a4, int *a5) {
  scanf("%d %d %d %d %d", a1, a2, a3, a4, a5);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}
#define NUM_MAX 200000

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);

    int i;
    for(i = 0; i < num; i++) {
        arr[i] -= i;
    }
    qsort(arr, num, sizeof(int), asc);
    int mid = arr[num/2];
#ifdef DEBUG
    printf("mid: %d\n", mid);
#endif

    int64_t ans = 0;
    for(i = 0; i < num; i++) {
        ans += abs(arr[i]-mid);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
using namespace std;

#define int long long

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

int modpow(int x, int y, int z) { int a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

const int M = 998244353;
int d[90310];
int e[90310];

signed main() {
  int n;
  scanf("%lld", &n);
  int sum = 0;
  d[0] = 1;
  e[0] = 1;
  REP(i, n) {
    int a;
    scanf("%lld", &a);
    RREP(t, sum + 1) {
      (d[t + a] += d[t]) %= M;
      (d[t] *= 2) %= M;
      (e[t + a] += e[t]) %= M;
    }
    sum += a;
  }
  int ans = modpow(3, n, M);
  FOR(t, (sum + 1) / 2, sum + 1) {
    ans = (ans - d[t] * 3) % M;
  }
  if (sum % 2 == 0) {
    ans = (ans + e[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%lld", ans);
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        int X = 0;
        int Y = 0;
        int dis = 0;
        int dif = t[0];
        for (int i = 0; i < n; i++) {
            dis = Math.abs(X - x[i]) + Math.abs(Y - y[i]);
            X = x[i];
            Y = y[i];
            if (dif < dis) {
                System.out.println("No");
                System.exit(0);
            } else {
                if (dif % 2 == dis % 2)
                    ;
                else {
                    System.out.println("No");
                    System.exit(0);
                }
            }
            try {
                dif = t[i + 1] - t[i];
            } catch (Exception e) {

            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 88884
n, k = map(int, input().split())
one_to_nine = set([0,1,2,3,4,5,6,7,8,9])
a = set(list(map(int, input().split())))
a = one_to_nine - a
a = list(a)

for i in range(n, 100001):
    x = list(str(i))
    flag = True
    for j in x:
        if int(j) in a:
            continue
        else:
            flag = False
            break
    if flag is True:
        print(i)
        exit()




Measured memory_bytes: 3060
import math
while True :
    n = int(input())
    if n == 0 :
        break
    
    s = list(map(int, input().split()))
    m = sum(s) / len(s)
    
    a = 0
    for i in range(n) :
        a += (s[i] - m) ** 2
    a /= n
    a = math.sqrt(a)
    print(a)


Measured memory_bytes: 5700
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  if (N%2) {
    cout << 0 << endl;
    return 0;
  }

  N/=2;
  uint64_t N5 = N;

  uint64_t prime5 = 0;
  
  while (N5) {
    prime5 += (N5/5);
    N5 /= 5;
  }

  uint64_t N2 = N;
  uint64_t prime2 = 0;

  while(N2 && prime2 <= prime5) {
    prime2 += (N2/2);
    N2 /= 2;
  }

  cout << min(prime2, prime5) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(), sum=0;
		for(int i=1; i<=t; ++i) sum+=i;
		System.out.println(sum);
		sc.close(); 
	}

}


Measured memory_bytes: 35620
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
    // Your code here!
    int h,w,syo=0,nx,ny,x,y;
    cin>>h>>w;
    char maze[h][w];
    int t[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            t[i][j]=-1;
        }
    }
    t[0][0]=0;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            maze[i][j]=s[j];
            if(s[j]=='#')syo++;
        }
    }
    queue<P> que;
    que.push(P(0,0));
    while (que.size()){
        auto xx=que.front();
        que.pop();
        x=xx.first;
        y=xx.second;
        for(int i=0;i<4;i++){
            nx=x+dx[i];
            ny=y+dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && t[nx][ny]==-1 && maze[nx][ny]=='.'){
                t[nx][ny]=t[x][y]+1;
                que.push(P(nx,ny));
            }
        }
    }
    if(t[h-1][w-1]!=-1){
        cout<<h*w-syo-t[h-1][w-1]-1<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/apc001/submissions/8886443

#include <bits/stdc++.h>

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> par(N, -1);
   for (int i = 1; i < N; ++i) {
      cin >> par[i];
   }
   vector<int> A(N);
   for (int i = 0; i < N; ++i) {
      cin >> A[i];
   }
   vector<vector<bool>> anc(N, vector<bool>(N));
   for (int i = 0; i < N; ++i) {
      int v = i;
      while (v >= 0) {
         anc[v][i] = true;
         v = par[v];
      }
   }
   vector<int> dist(N);
   for (int i = 1; i < N; ++i) {
      dist[i] = dist[par[i]] + 1;
   }
   vector<int> ans;
   while (true) {
      int v = 0;
      for (int i = 0; i < N; ++i) {
         if (anc[A[0]][i] && (dist[A[i]] < dist[A[0]] || !anc[A[i]][i])) {
            if (dist[i] > dist[v]) {
               v = i;
            }
         }
      }
      if (v == 0) break;
      ans.emplace_back(v);
      while (v >= 0) {
         swap(A[v], A[0]);
         v = par[v];
      }
   }
   cout << int(ans.size()) << "\n";
   for (int v : ans) {
      cout << v << "\n";
   }
}


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

int main(){
    ll n,x,p;
    cin>>x>>n;
    map<int,int>mp;
    for(int i=0; i<n; i++){
        cin>>p;
        mp[p]++;
    }
    ll mn=x;
    while(1){
        if(mp[mn]==0){
            break;
        }
        mn++;
    }
    ll mn1=x;
    while(1){
        if(mp[mn1]==0){
            break;
        }
        mn1--;
    }
    ll res1=abs(x-mn);
    ll res2=abs(x-mn1);
    if(res1<res2)
        cout<<mn<<endl;
    else if(res2>res1)
        cout<<mn1<<endl;
    else
        cout<<min(mn,mn1)<<endl;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void) {
  string s, t;
  cin >> s >> t;
  int n = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i]) n++;

  cout << n << endl;
  return 0;
}


Measured memory_bytes: 764
# A - Double Helix

# A,C,G,Tのいずれかの入力に対し、対となる文字を返す
# A=T, C=G


b = str(input())

if b == 'A':
    print('T')

elif b == 'T':
    print('A')

elif b == 'C':
    print('G')

elif b == 'G':
    print('C')


Measured memory_bytes: 8928
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    AGC002BBoxandBall solver = new AGC002BBoxandBall();
    solver.solve(1, in, out);
    out.close();
  }

  static class AGC002BBoxandBall {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      int m = in.nextInt();
      int[] ar = new int[n];
      boolean[] red = new boolean[n];
      for (int i = 0; i < n; i++) {
        ar[i] = 1;
        red[i] = false;
      }
      red[0] = true;
      for (int i = 0; i < m; i++) {
        int a = in.nextInt() - 1;
        int b = in.nextInt() - 1;
        if (red[a]) {
          red[b] = true;
        }
        ar[a]--;
        ar[b]++;
        if (ar[a] == 0) {
          red[a] = false;
        }
      }
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (red[i]) {
          cnt++;
        }
      }
      out.println(cnt);
    }

  }
}



Measured memory_bytes: 65536
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  if (s[1] == 'B')
    s[1] = 'R';
  else
    s[1] = 'B';

  cout << s << en;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++) {
    cin >> B[i];
  }
  
  int ans = B[0];
  
  if (N > 2) {
    for (int i = 0; i < N-2; i++) {
      ans += min(B[i],B[i+1]);
    }
  }
	
  ans += B[N-2];
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
{ loop 1
}

loop :: Int -> IO ()
loop i = do
{ [x] <- getInts
  ; if x == 0 then done
    else do
    { putStrLn ("Case " ++ show i ++ ": " ++ show x)
      ; loop (i+1)
    }
}

getInts :: IO [Int]
getInts = map read . words <$> getLine

done :: IO ()
done = return ()

Measured memory_bytes: 4104