akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll ans, mx, sum,temp, mn = 1e14, flag,cnt;

int main(){
	ll n,k;
	cin>>n>>k;
	if((n%k)%2!=0) cout<<1;
	else cout<<0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int a,b,x;
    double s,h,r,Sin;
    scanf("%d %d %d",&a,&b,&x);

    if(x>=a*a*b/2)
    {
    s=(a*a*b)-x;
    h=s*2/(a*a);
    r=sqrt(a*a+h*h);
    Sin=a/r;
    printf("%.10lf",(90-(asin(Sin)*180/M_PI)));
    }
    
    
    else
    {
        h=(double)x*2/(a*b);
        r=sqrt(h*h+b*b);
        Sin=b/r;
        printf("%.10lf",((asin(Sin)*180/M_PI)));
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
/***** MAIN *****/
signed main() {
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  REP(r,N/R + 1) {
    int red_count = r*R;
    REP(g, (N-red_count)/G + 1) {
      int green_count = g*G;
      if((N-red_count-green_count)%B == 0) ++ans;
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

const int maxn = 1e5 + 5, inf = 2e9;
int dp[maxn], h[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i ++)
		cin >> h[i];
	for (int i = n - 2; i >= 0; i --){
		dp[i] = inf;
		for (int j = i + 1; j <= min(i + k, n - 1); j ++){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[0];
}


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

int main(){
int n,k;
cin >> n >> k;
int a[n];
for (int i=0;i<n;i++){
cin >> a[i];
}
sort(a,a+n);
int b[100000];
for (int i=0;i<n;i++){
b[i]=a[i+k-1]-a[i];
}
int ans=1000000000;
for (int i=0;i<n-k+1;i++){
ans=min(b[i],ans);
}
cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	ll n;
	cin>>n;
	string s;
	set<string>st;
	for(ll i=0;i<n;i++){
		cin>>s;
		st.insert(s);
	}cout<<(st.size());
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> l(N);
  rep(i, N) cin >> l[i];

  sort(l.rbegin(), l.rend());

  int ans = 0;
  rep(i, K) ans += l[i];

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;

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

	string s;
	cin >> s;

	int cnt[128] = {};
	for(int i = 0; i < (int)s.size(); ++i)
		++cnt[s[i]];

	cout << min(min(cnt['K'], cnt['U']), min(cnt['P'], cnt['C'])) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <stdio.h>
int main(void) {
	int n, count;
	int a, b, c, d;

	while (scanf("%d", &n) != EOF){
		count = 0;
		a = 9; b = 9; c = 9; d = 9;
		if (n >= 37){
			printf("%d\n", count);
		}
		else{
			if ((9 + 9 + 9 + 9) == n) count++;
			for (d = 8; d >= 0; d--){
				if ((a + b + c + d) == n){
					count++;
				}
			}

			for (c = 8; c >= 0; c--){
				for (d = 9; d >= 0; d--){
					if ((a + b + c + d) == n){
						count++;
					}
				}
			}
			for (b = 8; b >= 0; b--){
				for (c = 9; c >= 0; c--){
					for (d = 9; d >= 0; d--){
						if ((a + b + c + d) == n){
							count++;
						}
					}
				}
			}
			for (a = 8; a >= 0; a--){
				for (b = 9; b >= 0; b--){
					for (c = 9; c >= 0; c--){
						for (d = 9; d >= 0; d--){
							if ((a + b + c + d) == n){
								count++;
							}
						}
					}
				}
			}
			printf("%d\n", count);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e3+10;
char s[maxn][maxn];
int d[maxn][maxn];
struct point{
	int x,y;
};
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int main(){
	int n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	queue<point> q;
	int ans=1;
	REP(i,1,n) REP(j,1,m) if(s[i][j]=='#') d[i][j]=1,q.push((point){i,j});
	while(!q.empty()){
		point u=q.front();q.pop();
		chkmax(ans,d[u.x][u.y]);
		REP(k,0,3){
			int x=u.x+dir[k][0],y=u.y+dir[k][1];
			if(x>n || y>m || y<1 || x<1) continue;
			if(d[x][y]) continue;
			d[x][y]=d[u.x][u.y]+1;
			q.push((point){x,y});
		}
	}
	printf("%d\n",ans-1);
    return 0;
}

Measured memory_bytes: 13456
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll n,m;
	cin >> n >> m;
	vi v(n);
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		v[--a]++,v[--b]++;
	}
	rep(i,n) cout << v[i] << endl;
	return 0;
}  


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        var list = line.Split(' ');

        var sum = long.Parse(list[0]);
        var blue = long.Parse(list[1]);
        var red = long.Parse(list[2]);

        if (blue != 0 || red != 0)
        {
            var perfectSet = sum / (blue + red);

            var ans = perfectSet * blue;

            var allAmari = sum;
            if (perfectSet > 0)
            {
                allAmari = sum % (blue + red);
            }

            if (allAmari > blue)
            {
                ans += blue;
            }
            else
            {
                ans += allAmari;
            }

            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine(0);

        }
    }
}



Measured memory_bytes: 13140
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
		try{
			while(true){
				int n = Integer.valueOf(sc.readLine());
				if(n==0)
					break;
				int[][] map = new int[n+1][n+1];
				for(int i=0; i<n; i++){
					String[] st = sc.readLine().split(" ");
					for(int j=0; j<n; j++){
						map[i][j] = Integer.valueOf(st[j]);
						map[i][n] += map[i][j];
						map[n][j] += map[i][j];
					}
				map[n][n] += map[i][n];
				}
				for(int i=0; i<=n; i++){
					for(int j=0; j<n; j++)
						System.out.printf("%5d", map[i][j]);
					System.out.printf("%5d\n",map[i][n]);
				}
			}
		}catch(Exception e){
			System.out.println("Error");
			}
		}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <queue>
#define MAXN 510
using namespace std;

int n,m;
queue<int> a[MAXN];
int cnt[MAXN];
bool removed[MAXN];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int t;
			scanf("%d",&t);
			a[i].push(t);
		}
	}
	for(int i=1;i<=n;i++) cnt[a[i].front()]++;
	int ans=n;
	for(int i=1;i<=m;i++){
		int res=0;
		int maxj;
		for(int j=1;j<=m;j++)
			if(!removed[j] && cnt[j]>res) res=cnt[j],maxj=j;
		if(res<ans) ans=res;
		removed[maxj]=1;
		for(int i=1;i<=n;i++)
			while(removed[a[i].front()]){
				a[i].pop();
				cnt[a[i].front()]++;
			}
	}
	printf("%d\n",ans);
}


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

int main() {
	string k;
	cin >> k;
	int s[10];
	for (int i = 0; i < k.size(); i++)
		s[i] = k[i] - 48;
	int a[8], min = 1000;
	for (int i = 0; i < k.size() - 2; i++) {
		a[i] = s[i] * 100 + s[i + 1] * 10 + s[i + 2];
		if (min > abs(a[i] - 753))
			min = abs(a[i] - 753);
	}
	cout << min << endl;
	return 0;

}

Measured memory_bytes: 256
n = 1
x =1
while not (n==0 and x==0):
    n , x = map(int, input().split())
    ans = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans+=1
    if not (n==0 and x==0):
        print(ans)



Measured memory_bytes: 5596
#pragma comment(linker, "/STACK:128777216")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
using namespace std;

#define forx(_name,_from, to, value) for (int name = from; name < to; name += value)
#define rforx(_name, from, to, value) for (int name = from; name > to; name -= _value)
#define all(_STL_NAME) _STL_NAME.begin(), _STL_NAME.end()
#define rall(_STL_NAME) _STL_NAME.rbegin(), _STL_NAME.rend()
#define mp(_FIRST,_SECOND) make_pair(_FIRST,_SECOND)

typedef long long ll;
typedef unsigned long long llu;
typedef long double ld;
const ld eps = 1e-12;
mt19937 rndm;

void start() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.precision(20); cout.setf(ios::fixed);
	string FILENAME = "navalny";
	rndm.seed(time(0));
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	//freopen((FILENAME + ".in").c_str(), "rt", stdin);
	//freopen((FILENAME + ".out").c_str(), "wt", stdout);
#endif
}

int main() {
	start();
	int l, r;
	cin >> l >> r;
	if (r - l >= 2019)
		cout << 0;
	else {
		ll ans = 2019;
		for (ll i = l; i <= r; ++i)
			for (ll j = i + 1; j <= r; ++j)
				ans = min(ans, (i*j) % 2019);
		cout << ans;
	}
#ifdef _DEBUG
	cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}

Measured memory_bytes: 256
// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========
fn warshall_floyd(adjm: &mut Vec<Vec<Option<usize>>>) {
    let n = adjm.len();
    // kを経て短くなる辺を全部短くする
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if let (Some(dik), Some(djk)) = (adjm[i][k], adjm[k][j]) {
                    if adjm[i][j].is_none() || adjm[i][j].unwrap() > dik + djk {
                        adjm[i][j] = Some(dik + djk);
                    }
                }
            }
        }
    }
}
fn main() {
    input! {
        h: usize,
        w: usize,
        costs: [[usize;10];10],
        wall: [[i64;w];h]
    }
    let mut adjm: Vec<Vec<Option<usize>>> = vec![vec![None; 10]; 10];
    for i in 0..10 {
        for j in 0..10 {
            adjm[i][j] = Some(costs[i][j]);
        }
    }
    warshall_floyd(&mut adjm);
    // iを家として、最長の時間が最も短いもの
    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            if wall[i][j] != -1 {
                ans += adjm[wall[i][j] as usize][1].unwrap();
            }
        }
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
double pi=3.14159265;

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%10==3 || (i%100)/10==3 || (i%1000)/100==3 || (i%10000)/1000==3) cout << ' ' << i;
    }
    cout << endl;
}


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

using namespace std;

int main()
{
    #ifdef DEBUG
    //freopen("input.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    if (n / 100 == n % 10){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int n;
    cin >> n;
    int a[100010];
    rep(i,n) cin >> a[i];
    int tmp = a[0];
    reps(i, n - 1){
       tmp ^=  a[i];

    }
    if(!tmp){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 640
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{
	ll n,ctr=0;
	lscf(n);
	
	
    rep(m,1,n+1)
	{
	    if(m%3!=0&&m%5!=0)
	    {
	        ctr+=(m);
	    }
	        
	 
	}

        lprin(ctr);
	
}

Measured memory_bytes: 3724
//尽可能出布 
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int g=0;
	int p=0;
	int sum=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='g')
		{
			if(p<g) p++, sum++;
			else g++;
		}
		else
		{
			if(p<g) p++;
			else g++, sum--;
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<u_int64_t> l(N);

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

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (l[i] == l[j]) continue;
            int ipj = l[i] + l[j];
            for (int k = j+1; k < N; ++k) {
                if (l[i] == l[k] || l[j] == l[k]) continue;
                if (ipj > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) ++cnt;
            }
        }
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.System.*;


public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        out.print((char) (in.read()+1));

    }

}


Measured memory_bytes: 21204
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
  j = input()
  if j == 'AC':
    ac += 1
  elif j == 'WA':
    wa += 1
  elif j == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, m;
    std::cin>>n>>m;
    std::vector<long long> a(n), b(n), c(m), d(m);
    for(int i = 0; i < n;i++){
        std::cin>>a[i]>>b[i];
    }
    for(int i = 0;i < m;i++){
        std::cin>>c[i]>>d[i];
    }

    std::vector<int> ans(n);
    for(int i = 0;i < n;i++){
        std::vector<long long> dist(m);
        for(int j = 0;j < m;j++){
            dist[j] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        }
        //std::cout<<"i:"<<i<<std::endl;
        //for(const auto& x : dist){
        //    std::cout<<x<<std::endl;
        //}

        ans[i] = std::distance(dist.begin(),
                std::min_element(dist.begin(), dist.end()))
            + 1;

    }

    //std::cout<<"---------------"<<std::endl;
    for(const auto& x : ans){
        std::cout<<x<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    _ = input()
    aa = list(map(int, input().split()))
    counts = Counter(aa)
    counts = {k: v for k, v in counts.items() if v >= 2}
    sides = []
    for k in sorted(counts.keys(), reverse=True):
        while counts[k] >= 2:
            counts[k] -= 2
            sides.append(k)
            if len(sides) == 2:
                print(sides[0] * sides[1])
                return
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18600
#!/usr/bin/env python3
n, m = map(int, input().split())
s = [list(map(int, input().split()[1:])) for _ in range(m)]
p = list(map(int, input().split()))
c = 0

from itertools import product
for i in product([0,1], repeat=n):
    if all(
        len([None for t in t if i[t-1]]) % 2 == p[j] for j, t in enumerate(s)
    ):
        c += 1
print(c)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int a;
	int b;
	string c;


	cin >> a;
	cin >> c;
	if (c == "+") {

		cin >> b;
		cout << a + b << endl;
	}
	else {
		cin >> b;
		cout << a - b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative

solve n s =  sqrt (sum (map ((^2) . subtract m) s) / n)
	where
		m = sum s / n 

main = do
	n <- readLn
	if n == 0 then return () else do
		s <- (map read . words) <$> getLine
		print $ solve n s
		main

Measured memory_bytes: 4952
n = int(input().rstrip())
heights = list(map(int, input().rstrip().split(" ")))
ans = 0
for i in range(1, n):
  if heights[i] < heights[i-1]:
    ans += heights[i-1] - heights[i]
    heights[i] = heights[i-1]
print(ans)
  

Measured memory_bytes: 32260
#include<stdio.h>
#include<stdint.h>

int h,w;

int main(void){
    register int i,j;
    int k;
    scanf("%d%d%d",&h,&w,&k);
    char grid[h][w];
    for(i = 0;i < h;i++)for(j = 0;j < w;j++)scanf("%1s",&grid[i][j]);
    uint8_t hbit,wbit;
    int cnt,ans = 0;
    for(hbit = 0;hbit < 1u << h;hbit++)for(wbit = 0;wbit < 1u << w;wbit++){
        cnt = 0;
        for(i = 0;i < h;i++)for(j = 0;j < w;j++){
            if(hbit & (1u << i) || wbit & (1u << j))continue;
            if(grid[i][j] == '#')cnt++;
        }
        if(cnt == k)ans++;
    }
    printf("%d",ans);
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	string s,y[5];
	cin >> s;
	int N=s.size();
	for (int i = 0; i < (1 << N); i++) {
		int ans = s[0]-'0';
		for (int j = 0; j < N-1; j++) {
			if (i &(1<<j)) {
				ans += s[j+1] - '0';
				y[j] = '+';
			}
			else {
				ans -= s[j+1] - '0';
				y[j] = '-';
			}
		}
		if (ans == 7) break;
		
	}
	for (int i = 0; i < N; i++) cout << s[i] << y[i];
	cout << "=7" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

template <typename T>
void printVector(string name, vector<T> vec)
{
    cout << name << ": ";
    rep(i, vec.size())
    {
        cout << vec[i] << " ";
    }
    cout << endl;
}

void Main()
{
    string s;
    cin >> s;

    cout << s.substr(0, 3) << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF INT_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef unsigned long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    ll n,k;cin>>n>>k;
    vi v(n+1); rep1(i,n) cin>>v[i];
    ll tmp=1,c=0;
    map<int,int> m;
    vi ans;
    while(m[tmp]==0){
        m[tmp]=1;
        ans.pb(tmp);
        tmp=v[tmp];
        c++;
        //ans.pb(tmp);
    }
    //print1(tmp);
    //rep(i,ans.size()) cout<<ans[i]<<" \n"[i==ans.size()-1];
    if (k<ans.size()) cout<<ans[k];
    else {
        ll idx=0;
        ll s=ans.size();
        rep(i,s) if(tmp==ans[i]) idx=i;
        //print1(idx);
        ll res=(k-(idx))%(s-idx);
        cout<<ans[idx+res];
    }
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 15348
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int MOD = 998244353;

ll mpow(ll x, ll n, ll mod){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % mod;
        x = x * x % mod;
        n  = n >> 1;
    }
    return ans;
}

vector<ll> initVec(int M, int N){
    vector<ll> ret;
    ll tmp = M;
    ret.push_back(tmp);
    rep(i, N){
        tmp *= M - 1;
        tmp %= MOD;
        ret.push_back(tmp);
    }
    return ret;
}

const int MAX = 510000;
long long fac[MAX], inv[MAX], finv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    inv[0] = inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> table = initVec(M, N);
    COMinit();
    ll ans = 0;
    ll tmpN;
    for(ll k = 0; k <= K; k++){
        tmpN = N - k;
        ans += table[tmpN - 1] * COM(N - 1, k);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16916
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    rep(i, 3001) {
        rep(j, 3001) {
            int remain = N - i * R - j * G;
            if (remain < 0 || remain % B) continue;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

class UnionFind {
public:
  vector<int> data; // sizeとparを同時に管理する
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) {
      if (data[py] < data[px]) swap(px, py);
      data[px] += data[py]; data[py] = px;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -data[find(x)];
  }
};

typedef tuple<int, int, int> pos_t;
typedef tuple<int, int, int> edge_t; // 距離、点、点

int main() {
  int n;
  cin >> n;
  vector<pos_t> lp;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    lp.emplace_back(i, x, y);
  }
  vector<edge_t> edges;
  // xの昇順にsort
  sort(lp.begin(), lp.end(),
       [](pos_t const &lhs, pos_t const &rhs) { 
         return get<1>(lhs) < get<1>(rhs);
       }
  );
  for (int i = 0; i < lp.size()-1; ++i) { 
    int fid, fx, fy;
    int tid, tx, ty;
    tie(fid, fx, fy) = lp[i];
    tie(tid, tx, ty) = lp[i+1];
    edges.emplace_back(tx-fx, fid, tid);
  }
  // yの昇順にsort
  sort(lp.begin(), lp.end(),
       [](pos_t const &lhs, pos_t const &rhs) { 
         return get<2>(lhs) < get<2>(rhs);
       }
  );
  for (int i = 0; i < lp.size()-1; ++i) { 
    int fid, fx, fy;
    int tid, tx, ty;
    tie(fid, fx, fy) = lp[i];
    tie(tid, tx, ty) = lp[i+1];
    edges.emplace_back(ty-fy, fid, tid);
  }
  // 距離の昇順にsort
  sort(edges.begin(), edges.end(),
       [](edge_t const &lhs, edge_t const &rhs) { 
         return get<0>(lhs) < get<0>(rhs);
       }
  );
  UnionFind uf(100000);
  ll ans = 0;
  for (auto e : edges) { 
    int d, fid, tid;
    tie(d, fid, tid) = e;
    if (uf.same(fid, tid)) continue;
    uf.unite(fid, tid);
    ans += d;
  }

  cout << ans << endl;

}

Measured memory_bytes: 5748
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  int data[3],ans=0;
  for(int i=0;i<3;i++){
    cin>>data[i];
  }
  sort(data,data+3);
  ans+=data[2]-data[0];
  cout<<ans<<endl;
}


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

x=[10**9]*n
for i in range(n):
  x[p[i]-1]-=n-i-1
#print(x)

a=[1]
b=[x[0]-a[0]]

for i in range(n-1):
  t=max(a[-1],10**9-b[-1])
  a.append(t+1)
  b.append(x[i+1]-t-1)
print(*a)
print(*b)

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

int main() {
  int H, W;
  cin >> H >> W;

  // ここにプログラムを追記
  // (ここで"試合結果の表"の2次元配列を宣言)
  vector<vector<char>> table(H, vector<char>(W));
  
  vector<char> clear_h(H, 'o');
  vector<char> clear_w(W, 'o');

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  int counter = 0;
  // 行ごと
  for (int i = 0; i < H; i++) {
    int counter = 0;
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '.') {
        counter++;
      }
    }
    if (counter == W) {
      clear_h.at(i) = 'x';
    }
  }
  // 列ごと
  for (int j = 0; j < W; j++) {
    int counter = 0;
    for (int i = 0; i < H; i++) {
      if (table.at(i).at(j) == '.') {
        counter++;
      }
    }
    if (counter == H) {
      clear_w.at(j) = 'x';
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (clear_h.at(i) != 'x' && clear_w.at(j) != 'x') {
        cout << table.at(i).at(j);
      }
    }
    if (clear_h.at(i) != 'x') {
      cout << 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 main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        int s, t;
        cin >> s >> t;
        -- s;
        -- t;
        edges[s].push_back(t);
    }

    vector<double> prob(n, 0.0);
    prob[0] = 1.0;
    for(int a=0; a<n; ++a){
        for(int b : edges[a])
            prob[b] += prob[a] / edges[a].size();
    }

    vector<double> dp(n, 0.0);
    for(int a=n-1; a>=0; --a){
        for(int b : edges[a])
            dp[a] += (dp[b] + 1.0) / edges[a].size();
    }

    double ans = dp[0];
    for(int a=0; a<n; ++a){
        if(edges[a].size() <= 1)
            continue;

        double sum = 0.0;
        for(int b : edges[a])
            sum += dp[b];

        for(int b : edges[a]){
            double tmp = sum - dp[b];
            tmp = sum / edges[a].size() - tmp / (edges[a].size() - 1);
            ans = min(ans, dp[0] - tmp * prob[a]);
        }
    }
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	unordered_set<int> us1, us2, us3;
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		for (auto s2 : us2) {
			us3.insert(s2 * 10 + s[i] - '0');
		}
		for (auto s1 : us1) {
			us2.insert(s1 * 10 + s[i] - '0');
		}
		us1.insert(s[i] - '0');
	}
	cout << us3.size() << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

const int MOD = 1e9+7;
int memo[100005];

int main(){
    int N;
    cin >> N;
    bool flag = true;
    rep(i, N){
        int A;
        cin >> A;
        if(N % 2 == 0){
            if(A % 2 == 1){
                memo[A]++;
            }else{
                flag = false;
            }
        }else{
            if(A % 2 == 0){
                memo[A]++;
            }else{
                flag = false;
            }
        }
    }

    if(!flag){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    if(N % 2 == 1){
        if(memo[0] != 1) flag = false;
        for(int i = 2; i < N; i+=2){
            if(memo[i] == 0) flag = false;
            ans = (ans * memo[i]) % MOD;
        }
    }else{
        for(int i = 1; i < N; i+=2){
            if(memo[i] == 0) flag = false;
            ans = (ans * memo[i]) % MOD;
        }
    }

    if(flag){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d) printf("Left\n");
	else if(a+b<c+d) printf("Right\n");
	else printf("Balanced\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(void){
  int K;
  string S;
  cin >> K;
  cin >> S;
  
  if(S.size() > K){
    S = S.substr(0,K) + "...";
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
	int c;
	while (a != 0) { c = a; a = b%a; b = c; }
	return b;
}
bool f(vector<int> a) {
	if (a[0] == 1) {
		int sum = 0;
		for (int x : a) sum += (x-1) % 2;
		return sum % 2 != 0;
	} else {
		int c_odd = 0, c_even = 0;
		for (int x : a) ++(x % 2 ? c_odd : c_even);
		if (c_even % 2 != 0) {
			return true;
		} else {
			if (c_odd == 0) throw 1;
			if (c_odd >= 2) {
				return false;
			} else {
				auto b = a;
				for (auto& x : b) if (x % 2) {
					--x;
					break;
				}
				int g = b[0];
				for (auto x : b) g = gcd(g, x);
				for (auto& x : b) x /= g;
				return !f(b);
			}
		}
	}
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	sort(A.begin(), A.end());
	cout << (f(A) ? "First" : "Second") << endl;
}
/*
1. A_iが1を含む場合

sum(A_i - 1)の偶奇で決まる

2. A_iが1を含まない場合

A_iの最大公約数は1なので、全て偶数ということはない、
すなわち、少なくとも一つ奇数を含む。
よって、gが偶数になることはないので、gは奇数
gは奇数なので、A_iとA_i/gの偶奇は一致

2.1. A_iのなかに偶数が奇数個あるとき

偶数は一つ以上あるので、偶数を選ぶ
奇数が少なくとも2つある状態で相手に渡る
(元からあるやつと、-1してできたやつ)
相手から戻ってきたら、2.2.1.より、偶数が奇数個ある状態になる
よって先手必勝

2.2. A_iのなかに偶数が偶数個あるとき

2.2.1. 奇数が2つ以上のとき

gは奇数になるので、相手に渡す状態は必ずA_iのなかに偶数が奇数個ある状態になる
よって後手必勝

2.2.2. 奇数がちょうど1つのとき

その奇数を選ばないとgは奇数になるので、相手に渡す状態は必ずA_iのなかに偶数が奇数個ある状態になり、後手必勝
その奇数を選ぶとgは偶数になるが、相手に渡す状態は一意に定まる。
*/


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

int n, m;
bool ok = false;
vector<vector<int>>graph(300000);

void dfs(int now, int time, int p) {
  if (time > 2) return;
  if (now == n) ok = true;

  for (auto next_v : graph[now]) {
    if (next_v == p) continue;
    dfs(next_v, time + 1, now);
  }
}

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  cin >> n >> m;
  rep (i, m) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  dfs(1, 0, 0);

  if (ok) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 17380
#include <bits/stdc++.h>
using namespace std;
string S;
int sums,sumt;
int main(){
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(S[i] == 'S') sums++;
        if((sums)&&(S[i]=='T')){
            sums--;
            sumt+=2;
        }
    }
    cout<<S.size()-sumt<<"\n";
}

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

#define all(x) (x).begin(), (x).end()

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

ll gcd(ll A,ll B){
  return B?gcd(B,A%B):A;
}

int main(){
  ll N,M;
  cin>>N>>M;
  VL A(N);
  rep(i,N) cin>>A[i];
  ll lcm=1;
  ll ans=LLONG_MAX;
  rep(i,N){
    lcm=lcm/gcd(lcm,A[i])*A[i];
    if(lcm>M*2) ans=0;
  }
  rep(i,N) if(lcm/A[i]%2==0 or A[i]%2) ans=0;
  cout<<min(ans,(M/(lcm/2)+1)/2)<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int p[25] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
	int i, j, k;
	int count[25];
	for (i = 0; i < 25; i++)
		count[i] = 0;
	for (i = 0; i < n; i++)
	{
		j = i + 1;
		for (k = 0; k < 25; k++)
		{
			while (j % p[k] == 0)
			{
				count[k]++;
				j /= p[k];
			}
		}
	}
	int ans = 0;
	for (i = 0; i < 25; i++)
		if (count[i] >= 74)
			ans++;
	int c2, c24;
	c2 = c24 = 0;
	for (i = 0; i < 25; i++)
	{
		if (count[i] >= 2)
			c2++;
		if (count[i] >= 24)
			c24++;
	}
	ans += c24 * (c2 - 1);
	int c4, c14;
	c4 = c14 = 0;
	for (i = 0; i < 25; i++)
	{
		if (count[i] >= 4)
			c4++;
		if (count[i] >= 14)
			c14++;
	}
	ans += c14 * (c4 - 1);
	ans += c4 * (c4 - 1) / 2 * (c2 - 2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    b1 = list(map(int, input().split()))
    asum = c
    for j in range(m):
        asum += b[j] * b1[j]
    if asum > 0:
        ans += 1

print(ans)


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

int main()
{
    string s;
    cin >> s;
    rep(i, s.length()) cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll MAXREP = 1000079;
	ll k;
	cin >> k;
	ll x = 7 % k;
	for (int i = 1; i < MAXREP; i++)
	{
		if (x == 0)
		{
			cout << i << endl;
			return 0;
		}
		x *= 10;
		x += 7;
		x %= k;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,ans,tot;
int a[150];
inline void read(int &x){
	int f=1;x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]!=a[i-1])tot=0;
		tot++;
		if(tot==2)ans++,tot=0;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int N = r.i();
        int K = r.i();
        int n = 1;
        for(int i = 0; i < N; i++){
            n = Math.min(n+K, 2*n);
        }
        println(n);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

int ctoi(char c){
    switch(c){
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        case '0': return 0;
    }
    return -1;
}

int main(void){
    string s;
    cin >> s;
    int sum;
    for(int i=0; i<s.size(); i++) sum += ctoi(s[i]);
    if(sum % 9 == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[10];
int use[10];
int y[3];
bool bo[3];
signed main(){
	int n,a,b,c,ans=0,ansans=INT_MAX;
	cin>>n>>a>>b>>c;
	f(i,n){
		cin>>x[i];
	}
	f(i,pow(4,n)){
		int z=i;
		ans=0;y[0]=0;y[1]=0;y[2]=0;
		f(j,3) bo[j]=false;
		f(j,n){
			use[j]=z%4;
			z/=4;
		}
		f(j,n){
			if(use[j]<3){
				y[use[j]]+=x[j];
				if(bo[use[j]]==true)ans+=10;
				bo[use[j]]=true;
			}
		}
		if(bo[0]&&bo[1]&&bo[2]){
			ans+=abs(y[0]-a)+abs(y[1]-b)+abs(y[2]-c);
			ansans=min(ansans,ans);
		}
	}
	cout<<ansans<<endl;
	return 0;
}


Measured memory_bytes: 384
N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
L = [0 for i in range(N)]
for i in range(N):
  L[A[i]-1] +=1

L.sort()

ans = 0
for i in range(N-K):
  ans += L[i]

print(ans)
  

Measured memory_bytes: 24996
let split_on_char sep (s : string) =
    let rec rindex (i: int) =
        if i < 0 then
            None
        else
            if s.[i] = sep then
                Some i
            else
                rindex (i - 1) in
    let rec loop i result =
        match rindex (i - 1) with
          Some ii -> loop ii (String.sub s (ii + 1) (i - 1 - ii) :: result)
        | None -> (String.sub s 0 i) :: result in
    loop (String.length s) []

let ord s = 
    match int_of_string s with
            1 -> 14
        |   n -> n

let main =
    let a = read_line () in
    let x = split_on_char ' ' a in 
      let v = match x with
        [a; b] ->
      (match compare (ord a) (ord b) with
        1 -> "Alice"
        | 0 -> "Draw"
        | -1 -> "Bob" )
        | _ -> "" in 
        print_endline v


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    bool ok = true;
    if(s[0] != 'A')ok = false;
    int cnt = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C')cnt++;
    }
    if(cnt != 1)ok = false;
    rep(i, s.size()){
        if(!islower(s[i]) && s[i] != 'A' && s[i] != 'C')ok = false;
    }
    if(ok)cout << "AC";
    else cout << "WA";
}       


Measured memory_bytes: 256