akhauriyash/Code-Regression huggingface dataset:
// 6:35
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

void dump2(const string& name, const ll value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": " << a << ", " << b << ", " << c << endl;
}

void solve()
{
    ll ans = 0;
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    ll h = ty - sy;
    ll w = tx - sx;

    for1(i,h) {
        cout << "U";
    }
    for1(i,w) {
        cout << "R";
    }
    for1(i,h) {
        cout << "D";
    }
    for1(i,w) {
        cout << "L";
    }

    cout << "L";
    for1(i,h+1) {
        cout << "U";
    }
    for1(i,w+1) {
        cout << "R";
    }
    cout << "D";
    cout << "R";
    for1(i,h+1) {
        cout << "D";
    }
    for1(i,w+1) {
        cout << "L";
    }
    cout << "U";
}

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


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

#define rep(i, a, b) for(lli i  = (lli)(a); i < (lli)(b);i++)
#define REP(i,n) for(lli(i)=0;(i)<(lli)(n);(i)++)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define trace(x) cerr << #x << ": " << x << endl;

typedef long long int lli;
typedef pair<lli, lli> ii;
typedef pair<ii, lli> iii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef double C;

int main(){
	fastio;
	lli sum=0,n; cin>>n;
	vi v,c;
	rep(i,0,n){
		lli num; cin>>num;
		v.pb(num);
	}

	rep(i,0,n){
		lli num; cin>>num;
		c.pb(num);
	}

	rep(i,0,n){
		if(v[i]>c[i]) sum+=v[i]-c[i];
	}cout<<sum;
	return 0;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector <bool> vis (n, false);
    bool ans = false;
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        if (a == 1){
            if(vis[b]){
                ans = true;
            }
            vis [b] = true;
        }else if(b == n){
            if(vis[a]){
                ans = true;
            }
            vis [a] = true;
        }
    }
    if (!ans){
        cout << "IM";
    }
    cout << "POSSIBLE";

    return 0;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	ll  H, W;
	cin >> H>>W;
	if (H == 1 || W == 1) { cout << 1; }
	else if(H%2==1&&W%2==1)cout << (H*W+1)/2;
	else cout << (H * W) / 2;

	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int max_value = -1;
    bool isSame = false;
    for (int i=0; i<n; ++i){
        cin >> a[i];
        max_value = max(max_value, a[i]);
        if(a[i] == k){
            isSame = true;
        }
    }
    if(isSame){
        cout << "POSSIBLE" << endl;
    }
    else if(k > max_value){
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        int ans = a[0];
        for (int i=1; i<n; ++i){
            ans = gcd(ans, a[i]);
        }
        if(k % ans == 0){
            cout << "POSSIBLE" << endl;
        }
        else {
            cout << "IMPOSSIBLE" << endl;
        }
        // cout << ans << endl;
    }
    return 0;
}

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

ll choose2(ll n) {
  return n*(n-1)/2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;
  ll tot = 0;
  rep(i,n) {
    tot += choose2(cnt[i]);
  }
  rep(i,n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()
    dic = {399:0, 799:0, 1199:0, 1599:0, 1999:0, 2399:0, 2799:0, 3199:0}
    cnt = 0
    for i in a:
        if i < 400:
            dic[399] = 1
        elif i < 800:
            dic[799] = 1
        elif i < 1200:
            dic[1199] = 1
        elif i < 1600:
            dic[1599] = 1
        elif i < 2000:
            dic[1999] = 1
        elif i < 2400:
            dic[2399] = 1
        elif i < 2800:
            dic[2799] = 1
        elif i < 3200:
            dic[3199] = 1
        else:
            cnt += 1
    c = sum(list(dic.values()))
    if c == 0:
        print(1, cnt)
    else:
        print(c, c+cnt)





if __name__=="__main__":
    main()


Measured memory_bytes: 65536
# https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b

n = int(input())
X = []
L = []
for _ in range(n):
    x, l = map(int, input().split())
    X.append(x)
    L.append(l)

areas = [(x - l, x + l) for x, l in zip(X, L)]
areas = sorted(areas, key=lambda x:x[-1])

# print(areas)

ok = [areas[0]]
for area in areas[1:]:
    if ok[-1][-1] <= area[0]:
        ok.append(area)

# print(ok)
print(len(ok))

Measured memory_bytes: 26972
#include <stdio.h>

int main(void)
{
    int N, M;
    scanf("%d", &N); scanf("%d", &M);
    int n , m;
    n = N * (N - 1) / 2;
    m = M * (M - 1) / 2;
    int a;
    a = n + m;
    printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

Graph G;

vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if (e.first == p) continue;
        if(e.second & 1) dfs(e.first, v, 1 - c);
        else dfs(e.first, v, c);
    }
}
int main() {
    int N;
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const LL MAXN = 1010;
const LL INF = 0x3f3f3f3f;
LL n,m,k,l,an[1001000],bn[1001000],i,x,y,t;
int main()
{
    scanf("%lld %lld",&n,&t);
    LL mi=INF,ma=0;
    for(i=1;i<=n;i++)
    {
     scanf("%lld",&an[i]);
     mi=min(an[i],mi);
     bn[i]=an[i]-mi;
     if(bn[i]==ma) x++;
     if(bn[i]>ma) {ma=bn[i];y=i;x=1;}

    }
    printf("%lld\n",x);
    return 0;
}


Measured memory_bytes: 5120
function f(b,n)
	t=n
	c=0
	while t>0
		c+=t%b
		t=div(t,b)
	end
	c
end
n,s=map(x->parse(x),readlines())
i=1
ans=n+s
while i*i<=n
	if i>1&&f(i,n)==s&&ans>i
		ans=i
	end
	if div(n,i)>1
		t=f(div(n,i),n)
		if t<=s&&(s-t)%i==0
			b=div(n,i)-div(s-t,i)
			if b>1&&f(b,n)==s&&ans>b
				ans=b
			end
		end
	end
	i+=1
end
println(n==s?n+1:ans==n+s?-1:ans)


Measured memory_bytes: 151160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  cin >> b;
  int x;
  x = a + b;
  double y;
  y = x/2.0 - x/2;
  cout << x/2.0 + y << endl;
}
  

Measured memory_bytes: 256
from collections import Counter as ct
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
c = ct(a)

if c[0] == n:
    print("Yes")
elif len(c) == 2 and c[0] * 3 == n:
    print("Yes")
elif len(c) == 3 and len(set(c.values())) == 1:
    a, b, c = c.keys()
    if (a ^ b ^ c) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

const int N = 2e5+5;
vector<int> adj[N];
int n;
vector<ll> arr(N);
set<ll> sz[N];
vector<ll> res(N);
set<ll> ans;

void dp(int node, int par){
	for(auto i : adj[node]){
		if( i != par ){
			if( arr[i] > *prev(ans.end()) ){
				ans.insert(arr[i]);
				res[i] = ans.size();
				dp(i, node);
				ans.erase(arr[i]);
			}else{
				auto get = ans.lower_bound(arr[i]);
				ll val = *get;
				ans.erase(get);
				ans.insert(arr[i]);
				res[i] = ans.size();
				dp(i, node);
				ans.erase(arr[i]);
				ans.insert(val);
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>arr[i];
	}
	for(int i=0; i<n-1; ++i){
		int u,v;
		cin>>u>>v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ans.insert(arr[0]);
	res[0] = 1;
	dp(0, -1);
	for(int i=0; i<n; ++i){
		cout<<res[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 46656
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

char b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> b;
	if(b == 'A') cout << "T\n";
	else if(b == 'T') cout << "A\n";
	else if(b == 'C') cout << "G\n";
	else cout << "C\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] arr = new int[n];
		for(int i =0 ;i<n;i++)
			arr[i] = s.nextInt();

		Arrays.sort(arr);
		long suma =0 ,sumb =0 ;
		int flag =0 ;
		for(int j = n-1 ;j>=0;j--)
		{
			if(flag ==0 )
			{
				suma+=arr[j];
				flag = 1;
			}
			else
			{
				flag =0 ;
				sumb+=arr[j];
			}
		}
		System.out.println(suma-sumb);
	}
}


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

int main()
{
    int N, ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,K;
main()
{
	cin>>N>>K;
	if((N-1)*(N-2)/2<K)
	{
		cout<<-1<<endl;
		return 0;
	}
	K=(N-1)*(N-2)/2-K;
	cout<<K+N-1<<endl;
	for(int i=2;i<=N;i++)cout<<1<<" "<<i<<endl;
	int u=2,v=3;
	while(K)
	{
		cout<<u<<" "<<v<<endl;
		K--;
		v++;
		if(v>N)u++,v=u+1;
	}
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			int n = scan.nextInt();
			BigInteger b = BigInteger.valueOf(1);
			for(int i = n; i > 0; i--){
				b = b.multiply(BigInteger.valueOf(i));
			}
			System.out.printf("%s\n", b.toString());
		}
	}
}

Measured memory_bytes: 26016
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int	A, B;
	cin >> A >> B;
	cout << max(A + B, max(A - B, A*B)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    vector<string> name(N);
    for(int i = 0; i < N; i++) cin >> name[i];
    map<char, ll> count;
    for(int i = 0; i < N; i++){
        if(name[i][0] == 'M' or name[i][0] == 'A' or name[i][0] == 'R' or name[i][0] == 'C' or name[i][0] == 'H'){
            count[name[i][0]]++;
        }
    }
    ull sum = 0;
    sum += count['M'] * count['A'] * count['R'];
    sum += count['M'] * count['A'] * count['C'];
    sum += count['M'] * count['A'] * count['H'];
    sum += count['M'] * count['R'] * count['C'];
    sum += count['M'] * count['R'] * count['H'];
    sum += count['M'] * count['C'] * count['H'];
    sum += count['A'] * count['R'] * count['C'];
    sum += count['A'] * count['R'] * count['H'];
    sum += count['A'] * count['C'] * count['H'];
    sum += count['R'] * count['C'] * count['H'];

    cout << sum << endl;
}

Measured memory_bytes: 5760
import std.stdio,std.string;
void main(){
	auto args = readstd!(int);
	args.sort.reverse;
	writeln( args[0] );
	writeln( args[1] );
	writeln( args[2] );
}
T[] readstd(T)(){
	import std.conv:to;
	T[] args;
	while(1){
		string arg = chomp(readln());
		if(arg){	args ~= to!T(arg);	}else{	break;	}
	}
	return args;
}

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

char check_s(string s, int num) {
    char ans{};
    if (s[num] == 'a') {
        ans = 'a';
    } else if (s[num] == 'b') {
        ans = 'b';
    } else if (s[num] == 'c') {
        ans = 'c';
    }
    return ans;
}

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int i{0};
    int j{0};
    int k{0};

    char lead;
    lead = sa[0];
    i++;
    while ((sa.length() != i && lead == 'a') ||
           (sb.length() != j && lead == 'b') ||
           (sc.length() != k && lead == 'c')) {
        if (lead == 'a') {
            lead = check_s(sa, i);
            i++;
        } else if (lead == 'b') {
            lead = check_s(sb, j);
            j++;
        } else if (lead == 'c') {
            lead = check_s(sc, k);
            k++;
        }
    }
    switch (lead) {
        case 'a':
            cout << 'A' << endl;
            break;
        case 'b':
            cout << 'B' << endl;
            break;
        case 'c':
            cout << 'C' << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

ll combination2(ll num){
	if(num <= 1) return 0;
	return num*(num-1)/2;
}

int main()
{
	int n;
	cin>>n;
	map<string,int> strList;
	rep(i,n){
		string str;
		cin>>str;
		vector<int> localVec(str.size());
		for(int i = 0; i < str.size(); i++){
			localVec[i] = (int)str[i];
		}
		sort(localVec.begin(),localVec.end());
		for(int i = 0; i < str.size(); i++){
			str[i] = (char)localVec[i];
		}
		if( strList.count(str) == 0){
			strList.insert(make_pair(str,1));
		}else{
			strList[str] += 1;
		}
	}
	ll ans = 0;
	for(auto iter = strList.begin();iter != strList.end(); iter++){
		ll num = iter->second;
		ans += combination2(num);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10972
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    if (X >= 30) {
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 35664
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n = int(input())
  *a, = map(int,input().split())
  *b, = map(int,input().split())
  *c, = map(int,input().split())
  
  ans = sum(b)
  for i in range(1,n):
    if a[i]-a[i-1]==1:
      ans += c[a[i-1]-1]

  print(ans)


if __name__ == '__main__':
  solve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 1000000000;

int N,A,B,C;
vector<int> l;

int dfs(int n, int na, int a, int nb, int b, int nc, int c){
  if(n==N){
    if(na==0 || nb==0 || nc==0) return INF;
    return abs(A-a)+abs(B-b)+abs(C-c)+10*(na+nb+nc-3);
  }

  int tmp1,tmp2,tmp3,tmp4;
  tmp1=dfs(n+1,na+1,a+l[n],nb,b,nc,c);
  tmp2=dfs(n+1,na,a,nb+1,b+l[n],nc,c);
  tmp3=dfs(n+1,na,a,nb,b,nc+1,c+l[n]);
  tmp4=dfs(n+1,na,a,nb,b,nc,c);
  int ans;
  ans=min(tmp1,tmp2);
  ans=min(ans,tmp3);
  ans=min(ans,tmp4);
  return ans;
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++){
    int temp;
    cin >> temp;
    l.push_back(temp);
  }

  cout << dfs(0,0,0,0,0,0,0) << endl;
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;

const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 1e5+10;
bool imp = false;

void solve() {

    ll x,n;cin>>x>>n;

    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        vis[a[i]] = 1;
    }
    ll d = INT_MAX;
    ll ans = -1;
    for(ll i=0;i<=300;i++){
        if(d > (abs(i-x)) and vis[i] == 0){
            d = abs(i-x);
            ans = i;
        }
    }
    cout<<ans<<endl;



}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }

}


Measured memory_bytes: 3660
#include <stdio.h>
main(){
   
  int a,b,c,x,y,z;
   
  scanf("%d %d %d",&a,&b,&c);
   
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
   
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
   
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
   
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \                               
  ios_base::sync_with_stdio(false); \                                      
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll k,a,b;cin>>k>>a>>b;
	ll m =1;
	ll f=0;
	while(true){
		if(k*m>b) break;
		if(k*m >=a && k*m<=b) {f=1;break;}
		m++;
	}
	if(f==1) cout<<"OK";
	else cout<<"NG";
	
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;



void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    if(c-a>=0 && b-c>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define M_PI 3.141592653589793
#pragma warning(disable:4996)
int main(){
	double x = 0,y = 0;
	int a,b,c=90;

	while(true){
		scanf("%d,%d",&a,&b);
		if(a == 0 && b == 0)break;
		x += a*cos(c*M_PI/180);
		y += a*sin(c*M_PI/180);
		c -= b;
	}
	printf("%d\n%d\n",(int)x,(int)y);
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
static const ll LL_MAX = (ll)1 << 55;

int main()
{
	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);

	ll ans = 0;
	ll x[100001] = {};
	scanf("%lld", &x[1]);
	repe(i, 2, n) {
		scanf("%lld", &x[i]);
		ans += min((x[i] - x[i - 1])*a, b);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1024
n,m,l = map(int,raw_input().split())

A = []
B = []
AB = [[]for i in range(n)]
for i in range(n):
    A.append(map(int,raw_input().split()))
for j in range(m):
    B.append(map(int,raw_input().split()))

for i in range(n):
    for k in range(l):
        sum = 0
        for j in range(m):
            sum += A[i][j]* B[j][k]
        AB[i].append(sum)
for i in range(n):
    print ("{}".format(AB[i]).replace("[","").replace(",","").replace("]",""))

        

Measured memory_bytes: 6996
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main(){
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    ans += min(A+B, 2*C) * min(X, Y);
    if(X>Y){
        ans += (X-Y) * min(A, 2*C);
    }else{
        ans += (Y-X) * min(B, 2*C);
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int a;
  for (auto i = 0; i != m; ++i) {
    cin >> a;
    n -= a;
    if (n < 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << (n >= 0 ? n : -1) << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

string x[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    rep(i, 4) {
        reverse(x[i].begin(), x[i].end());
    }

    int flag1 = 1;
    for(int i = 0; i < s.size(); ) {
        int flag2 = 0;
        rep(j, 4) {
            string u = x[j];
            if(s.substr(i, u.size()) == u) {
                flag2 = 1;
                i += u.size();
            }
        }
        if(!flag2) {
            flag1 = 0;
            break;
        }
    }

    if(flag1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int ans = 0;
	vector<int> v;
	for(int i=1;i<=N;i++){
		ans += i;
		v.push_back(i);
		if(ans>=N)break;
	}
	for(int i=0;i<v.size();i++){
		if(ans-N==v[i])continue;
		else cout << v[i] << endl;
	}
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

#define MAX_N 100
#define MAX_M 100
#define MAX_P 100

int N, M, P;
int X[MAX_N];

vector<int> ans_list;

int main(){

	while (true){
		cin >> N >> M >> P;
		if (N == 0 && M == 0 && P == 0)
			break;

		int sum = 0;

		for (int i = 0; i < N; i++){
			cin >> X[i];
			sum += X[i];
		}

		double money = 100 * sum;

		money = money * (100 - P) / 100;

		if (X[M - 1] != 0)
			ans_list.push_back(money / X[M - 1]);
		else
			ans_list.push_back(0);

	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	a=abs(a-c);
	b=abs(b-d);
	if(a>b)swap(a,b);
	ll r=gcd(a,b);
	a/=r,b/=r;
	cout<<(a==0?0:(a+b-1)*r)<<endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations

N = int(input())

adj = [list() for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

parent = [None]*N
visited = [False]*N
visited[0] = True
def rec(u):
    for v in adj[u]:
        if not visited[v]:
            parent[v] = u
            visited[v] = True
            rec(v)
rec(0)
del adj

M = int(input())


# edge_id to crucial query_id
tasks = []

for q in range(M):
    u,v = map(int,input().split())
    u,v = u-1,v-1
    u2r = []
    v2r = []
    while u is not None:
        u2r.append(u)
        u = parent[u]
    while v is not None:
        v2r.append(v)
        v = parent[v]
    
    for i,(a,b) in enumerate(zip(reversed(u2r), reversed(v2r))):
        if a != b:
            break
    else:
        i += 1
    # path = u2r[:-i] + [u2r[-i]] + list(reversed(v2r[:-i]))
    tasks.append(u2r[:-i]+v2r[:-i])

cnt = 0
sign = 1

for n in range(1,M+1):
    sub = 0
    for p in combinations(range(M),n):
        sub += 2**(N-1-len(set().union(*(tasks[i] for i in p))))
    cnt += sign*sub
    sign *= -1
print(2**(N-1)-cnt)


Measured memory_bytes: 42396
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    while(true){
      int H=sc.nextInt();
      int W=sc.nextInt();
      if(H==0 && W==0) break;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if((i+j)%2==0){
            System.out.print("#");
          }else{
            System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}



Measured memory_bytes: 34940
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 1000000007
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int gcd(int x,int y){//最大公約数
  if(y>x) swap(x,y);
  int r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
int Lcm(int x,int y){//最小公倍数
  int t=x*y;
  return t/gcd(x,y);
}
lol a,b,c,d,e,g,h,ans=0;
lol dp[111111];
lol i[111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a>>b>>c;
  if(a%c==0) cout <<b/c-a/c+1<<'\n';
  else 
      cout <<b/c-(a-1)/c<<'\n';
  return (0);
}


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

int main() {
  string x;
  cin >> x;
  if (x == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (x == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int dp[200000];
signed main(){
    int h,n,a[1000],b[1000];
    cin>>h>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<200000;i++)
        dp[i]=mod;
    for(int i=0;i<100000;i++)
        for(int j=0;j<n;j++)
            dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
    int ans=mod;
    for(int i=h;i<200000;i++)
        ans=min(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
n = int(input())
p = list(map(float, input().split()))
#dp[i][j] := i枚目のコインを投げ、表がj枚の確率 
#遷移式は、今回のコインが表が出るか、裏が出るかのみ考えればよい
dp = [[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 1.0
for i in range(1,n+1):
    k = p[i-1]
    for j in range(i+1):
        #さっきj枚達成してたら、裏じゃなきゃいけない
        #さっきはj-1しか達成できてないなら、今回は表
        if j > 0:
            dp[i][j] += (dp[i-1][j-1] * k) + (dp[i-1][j] * (1 - k))
        else:
            dp[i][j] += dp[i-1][j] * (1 - k)
ans = 0
for i in range(n+1):
    if (n - i) < i:
        ans += dp[-1][i]
print(ans)

Measured memory_bytes: 261768
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

template<class T>
using vec=vector<T>;
template<class T>
using prq=priority_queue<T>;
template<class T>
using rpq=priority_queue<T,vector<T>,greater<T>>;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int main()
{
    int n,w;
    scanf("%d%d",&n,&w);
    const int m=1e5;
    const ll inf=1e18;
    vec<ll> dp(m+1,inf);
    dp[0]=0;
    while(n--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        for(int i=m;i>=b;--i)
            dp[i]=min(dp[i],dp[i-b]+a);
    }
    int res=0;
    for(int i=1;i<=m;++i)
        if(dp[i]<=w)
            res=i;
    printf("%d\n",res);
}



Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include <algorithm>
using namespace std;
int main(){
  int n, l;
  cin>>n>>l;
  string a[101];
  for(int i = 0; i < n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i = 0; i < n; i++){
    cout<<a[i];
  }
  return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m,a;
int line[1001][101];

int main(){
	while(1){
		cin>>n>>m>>a;
		if(n==0&&m==0&&a==0)break;
		REP(i,1001){
			REP(j,101){
				line[i][j]=-1;
			}
		}
		REP(i,m){
			int h,p,q;
			cin>>h>>p>>q;
			line[h][p]=q;
			line[h][q]=p;
		}
		for(int i=1000;i>=1;i--){
			if(line[i][a]!=-1){
				a=line[i][a];
			}
		}
		cout<<a<<endl;
	}
	return 0;
}
	


Measured memory_bytes: 3492
import java.util.*;

public class Main {
	
	static int[] bambooLengths;
	static int N;
	static int A;
	static int B;
	static int C;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		A = sc.nextInt();
		B = sc.nextInt();
		
		if (B%A == 0) {
			System.out.println(A+B);
		} else {
			System.out.println(B-A);
		}
		
	}
  
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int dx[9]={1,1,1,0,0,0,-1,-1,-1};
const int dy[9]={1,0,-1,1,0,-1,1,0,-1};

const int T = 44;
bool vis[20][20][T][1<<5]={};

struct State{
    int y,x,t,mask;
};

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

    pi s;
    cin >>s.se >>s.fi;
    --s.fi;
    --s.se;

    set<pi> bomb;
    vector<vector<pi>> l(n);
    rep(i,n){
        int L;
        cin >>L;
        rep(j,L){
            int x,y;
            cin >>x >>y;
            --x;
            --y;
            l[i].pb({y,x});
        }
        bomb.insert(l[i][L-1]);
    }

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    queue<State> que;
    vis[s.fi][s.se][0][0] = true;
    que.push({s.fi,s.se,0,0});
    while(!que.empty()){
        State c = que.front();
        que.pop();
        if(c.t==T-1) break;

        int nmask = c.mask;
        rep(i,n){
            int L = l[i].size();
            if(c.t<L && l[i][c.t] == pi(c.y,c.x)) nmask |= (1<<i);
        }
        if(!vis[c.y][c.x][c.t][nmask]){
            vis[c.y][c.x][c.t][nmask] = true;
            que.push({c.y,c.x,c.t,nmask});
        }

        rep(d,9){
            int ny = c.y+dy[d], nx = c.x+dx[d];
            if(IN(ny,nx) && !bomb.count({ny,nx}) && !vis[ny][nx][c.t+1][c.mask]){
                vis[ny][nx][c.t+1][c.mask] = true;
                que.push({ny,nx,c.t+1,c.mask});
            }
        }
    }

    rep(i,T){
        rep(y,h)rep(x,w){
            if(vis[y][x][i][(1<<n)-1]) return i;
        }
    }
    return -1;
}

int main(){
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char str[25];
int main() {
	scanf("%s", str);
	printf("%c%c%c\n", str[0], str[1], str[2]);
}


Measured memory_bytes: 3792
mod = 1000000007

n, m = map(int, input().split())
s = [0] * (n + 2)
for _ in range(m):
    a = int(input())
    s[a] = -1

s[0] = 1
for i in range(0, n):
    if s[i] < 0:
        continue
    if s[i + 1] >= 0:
        s[i + 1] = (s[i + 1] + s[i]) % mod
    if s[i + 2] >= 0:
        s[i + 2] = (s[i + 2] + s[i]) % mod

print (s[n])


Measured memory_bytes: 75712
use std::io::*;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
fn gcd_array(a: &Vec<u64>) -> u64 {
    let mut res = a[0];
    for i in 1..a.len() {
        res = gcd(res, a[i]);
    }
    res
}
fn lcm_array(a: &Vec<u64>) -> u64 {
    let mut res = a[0];
    for i in 1..a.len() {
        res = lcm(res, a[i]);
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: u64 = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let l = lcm_array(&a);
    let g = gcd_array(&a);

    for i in 0..n {
        if a[i] / g % 2 == 0 {
            println!("0");
            return;
        }
    }

    // a_k / 2 * (2 * p + 1) = lcm/2 * i (lcm * i <= M)
    // あるkに関して、仮にa_kとlcmの2の約数の数が違うなら、2 * p + 1が奇数であるため、そのようなpは存在しない。
    // 存在する場合、lcm / 2の奇数倍を求めれば良い。

    println!("{}", (m / (l / 2) + 1) / 2);
}


Measured memory_bytes: 6396
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  
  cout<<min(b/a,c)<<endl;
  
}

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

class Program
{
    static void Main(string[] args)
    {
        var tmp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var A = tmp[0];
        var B = tmp[1];

        int n;

        var flag = ((B - 1) % (A - 1)) == 0;

        if (flag)
        {
            n = (B - 1) / (A - 1);
        }
        else
        {
            n = (B - 1) / (A - 1) + 1;
        }

        Console.WriteLine(n);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

bool cmp(string a, string b) {
	if (a.length() != b.length()) return a.length() > b.length();
	for (int i = 0; i < a.length(); i++) {
		if (a.at(i) != b.at(i)) return a.at(i) > b.at(i);
	}
	return false;
}
int main()
{
	int n, m;
	int count[9] = { 2,5,5,4,5,6,3,7,6 };
	cin >> n >> m;
	vector<int> arr(m, 0);
	for (int i = 0; i < m; i++) {
		cin >> arr[i];
	}
	vector<string> dp(n + 1, "0");
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			char first = arr[j] + '0';
			int sticks = count[arr[j] - 1];
			if (i >= sticks) {
				string cur = "0";
				if (dp[i-sticks] != "0") cur = first + dp[i - sticks];
				else if (dp[i - sticks] == "0" && i == sticks) {
					cur = first;
				}
				if (cmp(cur, dp[i])) {
					dp[i] = cur;
				}
			}
		}
	}
	cout << dp[n] << endl;
	//for (int i = 0; i <= n; i++) cout << i << ": " << dp[i] << " ";
	//cout << endl;
	// dp[i] = max{num[j]*10^wei[j] + dp[i-count[j]]} | j=arr_0->arr_m ;
	// wei[i] = wei[j] + 1;
	return 0;
}

Measured memory_bytes: 32384
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

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

int main() {
    int n = ri();
    int a[n];
    INPUT(a);
    
    int sum = abs(a[0]);
    FROMTO(i,1,n-1) {
        sum += abs(a[i]-a[i-1]);
    }
    sum += abs(a[n-1]);
    
    int chg[n];
    chg[0] = abs(a[0])+abs(a[1]-a[0])-abs(a[1]);
    FROMTO(i,1,n-2) {
        chg[i] = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1]);
    }
    chg[n-1] = abs(a[n-1]) + abs(a[n-2]-a[n-1]) - abs(a[n-2]);
    
    FOR(i,n) {
        cout << sum-chg[i] << endl;
    }
    
 return 0;
}


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

using namespace std;
mt19937_64 rng(58);

typedef long long ll;

string name(ll n) {
    if (n == 0) return "";
    return name((n - 1) / 26ll) + char('a' + (n - 1ll) % 26ll);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin >> n;
    cout << name(n) << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final long MAX = 1000000000000000000L;
        final int N = sc.nextInt();
        long[] a = new long[N];
        boolean flag = true;
        for(int i=0;i<N;i++){
            a[i] = sc.nextLong();
            if(a[i] == 0){
                flag = false;
                System.out.println(0);
                break;
            }
        }
        if(flag) {
            long ans = 1;
            for (int i = 0; i < N; i++) {
                if (ans < MAX / a[i]+1) {
                    ans *= a[i];
                } else {
                    flag = false;
                    System.out.println(-1);
                    break;
                }
                if (ans > MAX) {
                    flag = false;
                    System.out.println(-1);
                    break;
                }
            }
            if (flag) {
                System.out.println(ans);
            }
        }
    }

}


Measured memory_bytes: 50116
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
inline istream &operator>>(istream &in, vector<T> &a)
{
    for (auto &x : a)
        in >> x;
    return in;
}

template <typename T>
inline ostream &operator<<(ostream &out, vector<T> &a)
{
    for (auto &x : a)
        out << x << " ";
    return out;
}

void solve()
{
    int x;
    cin >> x;
    if (x >= 400 && x <= 599)
    {
        cout << 8;
    }
    else if (x >= 600 && x <= 799)
    {
        cout << 7;
    }
    else if (x >= 800 && x <= 999)
    {
        cout << 6;
    }
    else if (x >= 1000 && x <= 1199)
    {
        cout << 5;
    }
    else if (x >= 1200 && x <= 1399)
    {
        cout << 4;
    }
    else if (x >= 1400 && x <= 1599)
    {
        cout << 3;
    }
    else if (x >= 1600 && x <= 1799)
    {
        cout << 2;
    }
    else if (x >= 1800 && x <= 1999)
    {
        cout << 1;
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 3652