akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

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

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);
int main()
{   
 
    // vector<long long> vec(0);
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t tairyoku;
    uint64_t attack;
    uint64_t result;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    // uint32_t temp, temp2;
    // int32_t i, j, k, l, m, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
 
    cin >> tairyoku >> attack;
    if (tairyoku % attack == 0) {
        result = tairyoku / attack;
    } else {
        result = (tairyoku / attack) + 1;
    }
    

  
    cout << result << endl;

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


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

using namespace std;

int n, q;
bool com[100500];
int x[100500],y[100500];

int P[100500];
void init(int N){
  for(int i = 0; i < N; ++i){
    P[i] = i;
  }
}

int root(int a){
  if(P[a] == a) return a;
  return(P[a] = root(P[a]));
}

bool is_same_set(int a, int b){
  return root(a) == root(b);
}

void unit(int a, int b){
  P[root(a)] = root(b);
}

int main(){
  cin >> n >> q;
  init(n);
  for(int i = 0; i < q; ++i){
    cin >> com[i] >> x[i] >> y[i];
  }
  for(int i = 0; i < q; ++i){
    if(com[i] == 0){
      unit(x[i], y[i]);
    }
    else if(com[i] == 1){
      cout << is_same_set(x[i] ,y[i]) << endl;
      //cout << is_same_set(2, 3) << endl;
    }
  }
}


Measured memory_bytes: 4028
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }

vector<ll> f;
void set_f(int n) { f.resize(n+1); f[0] = 1; for (int i=1; i<= n; i++) { f[i] = (f[i-1] * i) % MOD;} }
ll nod(ll a, ll b) { if (b == 0) { return a; } else { return nod(b, a % b); } }
ll pw(ll x, ll n, ll m=MOD) { if (n == 0) { return 1;} if (n%2 == 0) { return pw((x*x) % m, n/2, m); } return (pw(x, n-1, m) * x) % m; }
ll dv(ll a, ll b) { return (a * pw(b, MOD - 2)) % MOD; }
ll c_n_k(int n, int k) { if (k > n) { return 0; } if (k < 0) { return 0; } return dv(dv(f[n], f[k]), f[n-k]); }

void solve() {
    ll x;
    cin >> x;

    for (ll a=0; a * a * a * a <= x; a++) {
        double y = a * a * a * a * a - x;
        ll sign = 1;
        if (y < 0) {
            sign = -1;
            y = -y;
        }
        ll b = sign * round(pow(y, 0.2));

        //cout << a << ' ' << y << ' ' << b << endl;

        if (a * a * a * a * a - b * b * b * b * b == x) {
            cout << a << ' ' << b;
            return;
        }
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            //cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] ac = new int[n], wa = new int[n];
        int acc = 0, wac = 0;
        for (int i = 0; i < m; i++){
            int p = sc.nextInt() - 1;
            String s = sc.next();
            if (ac[p] == 1) continue;
            if (s.equals("AC")) {
                ac[p] = 1;
            } else {
                wa[p]++;
            }
        }
        for (int i = 0; i < n; i++) {
            acc += ac[i];
            if (ac[i] == 1) wac += wa[i];
        }
        System.out.println("" + acc + " " + wac);
    }
}


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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();
        int M = nextInt();

        int[] input = new int[N];

        int total = 0;
        for (int x=0; x<N; x++) {
            input[x] = nextInt();
            total += input[x];
        }
        
        Arrays.sort(input);

        // read top M
        for (int x=N-1; x>N-1-M; x--) {
            if( input[x] * 4 * M < total){
                System.out.println("No");
                return;
            };
        }

        System.out.println("Yes");

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32880
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$M,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
$B = array_map('intval',explode(" ",trim(fgets(STDIN))));

$a[]=0;
$b[]=0;
for($i=0;$i<$N;$i++) $a[]=$a[$i]+$A[$i];
for($i=0;$i<$M;$i++) $b[]=$b[$i]+$B[$i];

$ans=0;$j=$M;
for($i=0;$i<$N+1;$i++) {
  if ($a[$i]>$K) break;
  while($b[$j]>$K-$a[$i]) {
    $j-=1;
  }
  $ans = max($ans,$i+$j);
}
printf("%d\n",$ans);


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



int main(){
  int l,r;
  int n;
  while(cin>>n,n!=0){
    l=r=false;
    int ans = 0;
    bool on = false;
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      if(s=="lu"){
        l = true;
      }else if(s=="ru"){
        r = true;
      }else if(s=="ld"){
        l = false;
      }else if(s=="rd"){
        r = false;
      }
      if(!on){
        if(l==true&&r==true){
          on = true;
          ans++;
        }
      }else{
        if(l==false&&r==false){
          on = false;
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int i = 1;
		while(true){
			int x = s.nextInt();
			if(x == 0){
				break;
			}
			System.out.println("Case " + i + ": " + x);
			i++;
		}

	}

}

Measured memory_bytes: 41544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll n,p[200005],inv[200005],sz[200005],dp[200005],val,hell=pow(10,9)+7;
ll exp(ll x,ll y){
  ll res=1;
  x%=hell;
  while(y>0){
    if(y&1)
      res=(res*x)%hell;
    y>>=1;
    x=(x*x)%hell;
  }
  return res;
}
void dfs0(ll i,ll par,vector<vector<ll>> &v){
  sz[i]=dp[i]=1;
  for(ll j=0;j<v[i].size();j++)
    if(v[i][j]!=par){
      dfs0(v[i][j],i,v);
      dp[i]*=dp[v[i][j]];
      dp[i]%=hell;
      sz[i]+=sz[v[i][j]];
    }
  dp[i]*=p[sz[i]-1];
  dp[i]%=hell;
  for(ll j=0;j<v[i].size();j++)
    if(v[i][j]!=par){
      dp[i]*=inv[sz[v[i][j]]];
      dp[i]%=hell;
    }
}
void dfs1(ll i,ll par,vector<vector<ll>> &v){
  for(ll j=0;j<v[i].size();j++)
    if(v[i][j]!=par){
      ll val=(dp[i]*p[n-sz[v[i][j]]-1])%hell;
      val*=(p[sz[v[i][j]]]*inv[sz[v[i][j]]-1])%hell;
      val%=hell;
      val*=(inv[n-sz[v[i][j]]]*exp(dp[v[i][j]],hell-2))%hell;
      val%=hell;
      dp[v[i][j]]*=val;
      dp[v[i][j]]%=hell;
    }
  for(ll j=0;j<v[i].size();j++)
    if(v[i][j]!=par)
      dfs1(v[i][j],i,v);
}
void solve(){
  p[0]=inv[0]=1;
  for(ll i=1;i<200005;i++){
    p[i]=(i*p[i-1])%hell;
    inv[i]=exp(p[i],hell-2);
  }
  cin>>n;
  vector<vector<ll>> v(n+1);
  for(ll i=0;i<n-1;i++){
    ll a,b;
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs0(1,1,v);
  dfs1(1,1,v);
  for(ll i=1;i<=n;i++)
    cout<<dp[i]<<endl;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

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

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

	ll N,M;
	cin>>N>>M;

	ll sum = 0;

	ll A;

	for(ll i = 0;i<M;i++)
	{
		cin>>A;
		sum += A;
	}

	// cout<<sum<<endl;

	ll diff = N - sum;

	if(diff>=0)
		cout<<diff<<endl;
	else
		cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 3652
using System.Linq;using System.Collections.Generic;using static System.Console;class Z{static void Main()=>new K();}class K{long M=1000000007;int[]G=>ReadLine().Split().Select(int.Parse).ToArray();long N,A,D;long[]j,k,l,m;bool[]z;List<E>[]g;public K(){var I=G;N=I[0];int Q=I[1],s=(I=G)[0]-1,t=I[1]-1,a,b,c;g=new List<E>[N];for(var i=0;i<N;i++)g[i]=new List<E>();while(Q-->0){I=G;g[a=I[0]-1].Add(new E(b=I[1]-1,c=I[2]));g[b].Add(new E(a,c));}C(s,ref j,ref l);C(t,ref k,ref m);A=S(l[t]);D=j[t];z=new bool[N];B(t);WriteLine((A%=M)<0?A+M:A);}long S(long x)=>x*x%M;void B(long u){if(!z[u]){z[u]=true;if(2*j[u]==D)A-=S(l[u]*m[u]%M);foreach(var e in g[u])if(j[e.V]+e.D==j[u]){if(2*j[u]>D&&2*j[e.V]<D)A-=S(m[u]*l[e.V]%M);B(e.V);}}}void C(int u,ref long[]d,ref long[]c){d=new long[N];c=new long[N];for(var v=0;v<N;v++)d[v]=M*M;var q=new Q();d[u]=0;c[u]=1;q.E(new E(u,0));while(q.C>0){var p=q.D();var v=p.V;if(d[v]<p.D)continue;foreach(var e in g[v]){var t=d[v]+e.D;if(d[e.V]>t){q.E(new E(e.V,d[e.V]=t));c[e.V]=c[v];}else if(d[e.V]==t)c[e.V]=(c[e.V]+c[v])%M;}}}}struct E{public long V,D;public E(long v,long d){V=v;D=d;}public long C(E e)=>D-e.D;}class Q{List<E>a=new List<E>();public int C;public void E(E x){var i=C++;a.Add(x);while(i>0){var p=(i-1)/2;if(a[p].C(x)<=0)break;a[i]=a[p];i=p;}a[i]=x;}public E D(){var v=a[0];var x=a[--C];a.RemoveAt(C);if(C==0)return v;var i=0;while(i*2+1<C){int l=2*i+1,r=l+1;if(r<C&&a[r].C(a[l])<0)l=r;if(a[l].C(x)>=0)break;a[i]=a[l];i=l;}a[i]=x;return v;}}

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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
#define ld long double
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}



ld getSqrtl(ld x1,ld y1,ld x2,ld y2){
    ld x = x1 - x2;
    ld y = y1 - y2;
    ld ans = (ld)sqrtl( x*x + y*y );
    return ans;
}

int main() {
    ld A,B,H,M;
    //              時間  分
    cin >> A >> B >> H >> M;

    ld do2 = (ld)360.0 * ((ld)M/(ld)60.0);
    ld ra2 = do2 * ((ld)M_PI/(ld)180.0);
    ld x2 = B * cosl(ra2);
    ld y2 = B * sinl(ra2);

    ld do1 = (ld)360.0 * ((ld)H/(ld)12.0) + ((ld)30.0*((ld)M/(ld)60.0));
    ld ra1 = do1 * ((ld)M_PI/(ld)180.0);
    ld x1 = A * cosl(ra1);
    ld y1 = A * sinl(ra1);

    cout << fixed << setprecision(20) << getSqrtl(x1,y1,x2,y2) << endl;

}



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

int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    rep(i, N) cin >> A[i];

    double res = 0;
    rep(i, N) {
        res += 1.0/A[i];
    }
    res = 1.0/res;

    cout << fixed;
    cout << setprecision(10) << endl;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>  
using namespace std;
 
int main(){
  int N;
  cin >> N;
  map<int,int> Mochi;
  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
   Mochi[tmp];
  }
  cout << Mochi.size() << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let k:i64 = read();
    let f = k / 2 + k % 2;
    println!("{}",f * (k / 2));

}

Measured memory_bytes: 2092
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String a = sc.next();
		String x = sc.next();
		String b = sc.next();
		
		// 計算
		String result = "";
		result = "A" + x.charAt(0) + "C";
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

int main()
{
	int n;
	while(cin >> n, n) {
		int res = -1;
		char c, rc;
		vector<int> hyo(26, 0);
		for (int i = 0; i < n; i++) {
			cin >> c;
			hyo[c - 'A']++;
			if (res != -1) continue;
			for (int k = 0; k < 26; k++) {
				bool flag = true;
				for (int j = 0; j < 26; j++) {
					if (j != k && hyo[j] + n - i - 1 >= hyo[k]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					res = i + 1;
					rc = k + 'A';
					break;
				}
			}
		}
		if (res == -1) {
			cout << "TIE" << endl;
		}
		else {
			cout << rc << ' ' << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2996
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <malloc.h>

#define char_max 200000
#define Nmax 100000

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);





int main()
{
	int n = 0;
	int ans = 0;
	int* v = (int*)calloc(Nmax, sizeof(int));

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}

	int* v1 = (int*)calloc(Nmax, sizeof(int));
	int* v2 = (int*)calloc(Nmax, sizeof(int));

	for (int i = 0; i < n / 2; i++) {
		v1[v[2 * i]]++;
	}

	for (int i = 0; i < n / 2; i++) {
		v2[v[2 * i + 1]]++;
	}
	
	//printf("v1: ");
	//for (int i = 0; i < 10; i++) {
	//	printf("%d, ", v1[i]);
	//}
	//printf("\n");

	//printf("v2: ");
	//for (int i = 0; i < 10; i++) {
	//	printf("%d, ", v2[i]);
	//}
	//printf("\n");

	int maxv1 = Max(v1, Nmax);
	int maxv2 = Max(v2, Nmax);

	int nmaxv1 = 0;
	int nmaxv2 = 0;

	for (int i = 0; i < Nmax; i++) {
		if (v1[i] == maxv1) {
			nmaxv1 = i;
			break;
		}
	}

	for (int i = 0; i < Nmax; i++) {
		if (v2[i] == maxv1) {
			nmaxv2 = i;
			break;
		}
	}

	
	
	if (nmaxv1 == nmaxv2) {
		v1[nmaxv1] = 0;
		v2[nmaxv2] = 0;
		int amaxv1 = Max(v1, Nmax);
		int amaxv2 = Max(v2, Nmax);
		if (maxv1 + amaxv2 < amaxv1 + maxv2) {
			ans = n - amaxv1 - maxv2;
		}else {
			ans = n - maxv1 - amaxv2;
		}

	}else {
		ans = n - maxv1 - maxv2;
	}
	

	printf("%d", ans);


	return 0;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

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

	return sum;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define N 100005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define pll pair<ll,ll>
#define fr first
#define sd second
using namespace std;

pll a[N];
ll ansx=0,ansy=1,sum[N],S=0;
bool cmp(const pll &a,const pll &b){ return a.fr>b.fr; }
ll calc(int x,int y){ return y<=x?sum[x]-a[y].fr:sum[x]; }
ll gcd(ll x,ll y){ return x%y?gcd(y,x%y):y; }

int main(){
	int n; scanf("%d",&n);
	For(i,1,n){
		scanf("%lld%lld",&a[i].fr,&a[i].sd);
		S+=a[i].fr;
		a[i].fr=max(a[i].fr,a[i].sd);
	}
	sort(a+1,a+n+1,cmp);
	For(i,1,n) sum[i]=sum[i-1]+a[i].fr;
	For(i,1,n){
		int l=0,r=n,num=-1;
		while(l<=r){
			int mid=(l+r)>>1;
			if(calc(mid,i)>=S-a[i].sd) num=mid,r=mid-1;
			else l=mid+1;
		}
		if(num<0) continue;
		if(calc(num,i)>=S) continue;
		ll nowx=1ll*(1ll*n-(num-(i<=num)))*a[i].sd-S+calc(num,i),nowy=1ll*n*a[i].sd;
		ll p=gcd(nowx,nowy);nowx/=p,nowy/=p;
		if(1.0*nowx*ansy>1.0*nowy*ansx) ansx=nowx,ansy=nowy;		
	}
	printf("%lld %lld\n",ansx,ansy);
}


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

#define ll long long int
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair

int main()
{
    ll n;
    cin>>n;
    ll h[n+1];
    for(ll i=1;i<=n;cin>>h[i++]);

    ll c[n+1];
    c[1] = 0;
    c[2] = abs(h[1]-h[2]);

    for(ll i=3;i<=n;i++)
    {
        c[i] = min(c[i-1] + abs(h[i-1]-h[i]),c[i-2] + abs(h[i-2]-h[i]));
    }

    cout<<c[n];
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int myfind(int a, vector<int>& v) {
	if (v[a] == a) return a;
	int res = myfind(v[a], v);
	v[a] = res;
	return res;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vp;
	vector<int> vr(n + 1, 0);
	vector<long long int> vw(n + 1, 1);
	for (int i = 1; i <= n; i++) vr[i] = i;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vp.push_back(make_pair(a, b));
	}
	vector<long long int> res(1, 0);
	for (int i = m - 1; i >= 0; i--) {
		int ra = myfind(vp[i].first, vr);
		int rb = myfind(vp[i].second, vr);

		if (ra == rb) {
			res.push_back(res.back());
			continue;
		}

		long long int now = (vw[ra] - 1) * vw[ra] / 2 + (vw[rb] - 1) * vw[rb] / 2;
		long long int after = (vw[ra] + vw[rb] - 1) * (vw[ra] + vw[rb]) / 2;
		res.push_back(after - now + res.back());
		// myunion(ra, rb, vr);
		vr[ra] = rb;
		vw[rb] += vw[ra];
	}
	reverse(res.begin(), res.end());
	for (int i = 1; i <= m; i++) {
		cout << (long long int)n * (n - 1) / 2 - res[i] << endl;
	}
}


Measured memory_bytes: 6956
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    int a[12] = {};
    if (n >= 357)
    {
        a[0] = 7;
        a[1] = 5;
        a[2] = 3;
        long long int  A;
        A = 357;
        int i, j;
        int p, q, r;
        while (A <= n)
        {
            p = q = r = 0;
            for (i = 0; i < 12; i++)
            {
                if (a[i] == 3)p = 1;
                else if (a[i] == 5)q = 1;
                else if (a[i] == 7)r = 1;
            }
            if (p + q + r == 3)
                ans++;
            i = 0;
            while (a[i] == 7)
                i++;
            if (a[i] == 3)a[i] = 5;
            else if (a[i] == 5)a[i] = 7;
            else a[i] = 3;
            if (i > 0)
                for (j = 0; j < i; j++)
                    a[j] = 3;
            A = 0;
            for (i = 0; i < 12; i++)
                A += a[i] * (long long int)pow(10, i);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>

typedef long long int llint;

int main(void){
  int n, m;
  std::cin >> n >> m;

  std::priority_queue<int> pq;

  for(int i=0; i<n; i++){
    int a;
    std::cin >> a;
    pq.push(a);
  }

  for(int i=0; i<m; i++){
    int b = pq.top();
    pq.pop();
    pq.push(b/2);
  }

  llint total = 0;
  for(int i=0; i<n; i++){
    int b = pq.top();
    pq.pop();
    total += b;
  }

  std::cout << total << std::endl;
  
  return 0;
}


Measured memory_bytes: 892
import numpy as np

D=int(input())
*c,=map(int,input().split())
c=np.array(c,dtype=int)
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

s=np.array(s,dtype=int).reshape((D,26))
dt=[]
cnt=np.array([0]*26)

for d in range(D):
    x=s[d]-c*(d-cnt)
    y=np.argmax(x)
    cnt[y]=d+1
    dt.append(y+1)

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

v0=score(dt)
newt=dt+[]

import random

for _ in range(1):
    for d in range(D):
        q=0
        while True:
            q=random.randint(1,26)
            if q!=newt[d]: break
        newt[d]=q
        v=score(newt)
        if v>v0:
            dt=newt
            v0=v
        else:
            newt=dt+[]
for i in dt:
    print(i)

Measured memory_bytes: 27504
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	boolean isPrime[];
	int MAX = 1000000;
	void run() {
		isPrime = new boolean[MAX];
		isPrime[0] = isPrime[1] = true;
		er();
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int a = sc.nextInt();
			int d = sc.nextInt();
			int n = sc.nextInt();
			if((a|d|n) == 0) break;
			for(int i=0;i<n;a+=d) {
				if(!isPrime[a]) i++;
			}
			System.out.println(a-d);
		}
		
	}
	
	void er() {
		for(int i=2;i<MAX;i++) {
			if(!isPrime[i])
				for(int j=i*2;j<MAX;j+=i) isPrime[j] = true;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Type{
	not_visited,
	visited,
};

struct Info{
	Info(int arg_node_id,ll arg_sum_dist,ll arg_v,Type arg_type){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
		v = arg_v;
		type = arg_type;
	}
	bool operator<(const struct Info &arg) const{
		return sum_dist > arg.sum_dist;
	};
	int node_id;
	ll sum_dist,v;
	Type type;
};

struct Data{
	Data(int arg_to,ll arg_time){
		to = arg_to;
		time = arg_time;
	}
	int to;
	ll time;
};

int N,M;
ll A,B,C;
ll min_dist[2][500][50];

ll calc_V(ll pre_v){
	return (A*pre_v+B)%C;
}

int main(){

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

	vector<Data> V[N];

	int from,to;
	ll time;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %lld",&from,&to,&time);
		from--;
		to--;
		V[from].push_back(Data(to,time));
		V[to].push_back(Data(from,time));
	}

	ll first_v;
	scanf("%lld",&first_v);
	scanf("%lld %lld %lld",&A,&B,&C);

	for(int a = 0; a < 2; a++){
		for(int b = 0; b < N; b++){
			for(int c = 0; c < 50; c++)min_dist[a][b][c] = 999999999999999;
		}
	}

	priority_queue<Info> Q;
	min_dist[not_visited][0][first_v] = 0;
	Q.push(Info(0,0,first_v,not_visited));

	ll ans = 999999999999999;
	int next_node;
	ll next_v;

	while(!Q.empty()){

		if(Q.top().node_id == 0 && Q.top().type == visited){
			ans = min(ans,Q.top().sum_dist);
			Q.pop();
		}else if(Q.top().sum_dist > min_dist[Q.top().type][Q.top().node_id][Q.top().v]){
			Q.pop();
		}else{
			next_v = calc_V(Q.top().v);

			for(int i = 0; i < V[Q.top().node_id].size(); i++){
				next_node = V[Q.top().node_id][i].to;

				if(next_node != N-1){
					if(min_dist[Q.top().type][next_node][next_v] > Q.top().sum_dist+Q.top().v*V[Q.top().node_id][i].time){
						min_dist[Q.top().type][next_node][next_v] = Q.top().sum_dist+Q.top().v*V[Q.top().node_id][i].time;
						Q.push(Info(next_node,min_dist[Q.top().type][next_node][next_v],next_v,Q.top().type));
					}
				}else{ //next_node == N-1
					if(min_dist[visited][next_node][next_v] > Q.top().sum_dist+Q.top().v*V[Q.top().node_id][i].time){
						min_dist[visited][next_node][next_v] = Q.top().sum_dist+Q.top().v*V[Q.top().node_id][i].time;
						Q.push(Info(next_node,min_dist[visited][next_node][next_v],next_v,visited));
					}
				}
			}
			Q.pop();
		}
	}

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

	return 0;
}

Measured memory_bytes: 11536
// Author: Zark84010 (Aditya Ranjan)

#include <bits/stdc++.h>
 
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
 
#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define tr(c, it) for (auto it = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
 
const int INF = 9e18;
// const int N = 1e9 + 7;
const int N = 998244353;
const double eps = 1e-9;
 
const auto start_time = std::chrono::high_resolution_clock::now();
 
void zark() {
  #ifdef ZARK
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}
 
#ifdef ZARK
  #include "/home/aranjan/Desktop/CP/header.h"
  #else
  #define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

// bool cmp(pair<string, int> p1, pair<string, int> p2) {
// 	if(p1.S < p2.S) return ;
// 	else if(p1.S > p2.S) return false;

// }

bool okk(string s) {
	int n = sz(s);
	int ss = 0;
	fo(i, n) {
		if(s[i] == '(') ss++;
		else ss--;
		if(ss < 0) return false;
	}
	return ss == 0;
}

string reduce(string s) {
	string ans;
	int n = sz(s);
	fo(i, n) {
		if(sz(ans) > 0 && ans.back() == '(' && s[i] == ')') {
			ans.pop_back();
		}
		else ans.pb(s[i]);
	}
	return ans;
}

void solve() {
	int n;
	cin >> n;
	vector<string> v(n);
	fo(i, n) cin >> v[i], v[i] = reduce(v[i]);
	string pre, suf;
	vpii a(n, {-INF, -INF});
	int ss=0;
	fo(i, n) {
		int aa=0, b=0;
		tr(v[i], it) aa+=*it=='(', b+= *it==')';
		dbg(i, aa, b);
		if(b == 0) pre += v[i];
		else if(aa == 0) suf += v[i];
		else a[i].F = aa-b, a[i].S = i, ss++;
	}
	dbg(v);
	sort(a.rbegin(), a.rend());
	string ans;
	fo(i, ss) ans += v[a[i].S];
	ans = pre + ans + suf;
	if(okk(ans)) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif
 
  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);
 
  solve();
  zark();
  return 0;
}

Measured memory_bytes: 53376
#include <iostream>
using namespace std;
int main(){
    while(1){
        int a,b;
        cin >> a >> b;
        if(a==0 && b==0)break;
        for(int i=0; i<a; i++) {
            for(int j=0; j<b; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
  long long A, B; 
  cin >> A >> B; 
  if(A % 2 != B % 2) { 
    cout << "IMPOSSIBLE" << endl; 
  } else { 
    cout << (A + B) / 2 << endl; 
  } 
  return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k, x;
    cin >> k >> x;
    cout << (k * 500 >= x ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include<iostream>

int main() {
  int sum, num_sum;
  std::cin >> num_sum >> sum;
  int count = 0;
  for (int i=0; i < num_sum+1; i++) {
    for (int j=0; j < num_sum+1; j++) {
      if (sum -(i + j) < num_sum+1 && sum -(i+j) > -1) {
        count++;
      }
    }
  }
  std::cout << count << std::endl;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	A = list(map(int, input().split()))

	is_increasing = True
	is_first = True
	ans = 1

	for i in range(1, N):
		if is_first == True:
			if A[i - 1] < A[i]:
				is_increasing = True
				is_first = False
			elif A[i - 1] > A[i]:
				is_increasing = False
				is_first = False
		else:
			if is_increasing == True and A[i - 1] > A[i]:
				ans += 1
				is_first = True
			elif is_increasing == False and A[i - 1] < A[i]:
				ans += 1
				is_first = True

	print(ans)



 
if __name__ == "__main__":
  	main()

Measured memory_bytes: 20516
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        double [] x = new double[n];
        double [] y = new double[n];
        for(int a = 0; a < n; a++){
            x[a] = scan.nextDouble();
        }
        for(int a = 0; a < n; a++){
            y[a] = scan.nextDouble();
        }
        System.out.printf("%.6f\n", distance(x,y,1,n));
        System.out.printf("%.6f\n", distance(x,y,2,n));
        System.out.printf("%.6f\n", distance(x,y,3,n));
        System.out.printf("%.6f\n", distance(x,y,4,n));
    }
    public static double distance(double x[], double y[], int p, int n){
        double answer = 0;
        if(p == 4){
            double max = 0;
            for (int a = 0; a < n; a++){
                if(Math.abs(x[a] - y[a]) > max){
                    max = Math.abs(x[a] - y[a]);
                }
            }
            answer = max;

        }
        else if(p == 3){
            for (int a = 0; a < n; a++){
                answer = answer + Math.pow(Math.abs(x[a] - y[a]), p);
            }
            answer = Math.cbrt(answer);
        }
        else if(p == 2){
            for (int a = 0; a < n; a++){
                answer = answer + Math.pow(Math.abs(x[a] - y[a]), p);
            }
            answer = Math.sqrt(answer);

        }
        else{
            for (int a = 0; a < n; a++){
                answer = answer + Math.pow(Math.abs(x[a] - y[a]), p);
            }
            answer = Math.pow(answer, (1/p));
        }
        return answer;
    }
}


Measured memory_bytes: 29156
#include <bits/stdc++.h>
using namespace std;int main(){size_t n,a,b;cin>>n>>a>>b;size_t ave=(a+b)/2;if(ave * 2 == a + b)cout <<  ave - a << endl;else cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  int n,m;
  cin >> n >> m;
  int a[n],sum=0;
  rep(i,n) {
    R a[i];
    sum+=a[i];
  }
  if(sum<=m) {
    pr(1);
    return 0;
  }
  sort(a,a+n,greater<int>());
  ll dp[10001];
  memset(dp,0,sizeof(dp));
  dp[0]=1;
  ll ans=0;
  rep(i,n) {
    sum-=a[i];
    REP(j,max(0,m-sum-a[i]+1),m-sum+1) {
      ans+=dp[j];
      ans%=MAX;
    }
    rrep(j,m-a[i]+1) {
      dp[j+a[i]]+=dp[j];
      dp[j+a[i]]%=MAX;
    }
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 1260
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  if(s == "ABC") printf("ARC\n");
  else printf("ABC\n");

  return 0;
}


Measured memory_bytes: 3592
// Problem : D - Disjoint Set of Common Divisors
// Contest : AtCoder - AtCoder Beginner Contest 142
// URL : https://atcoder.jp/contests/abc142/tasks/abc142_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
vl a,b;
void printDivisors(int n) 
{ 
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                printf("%d ", i); 
  
            else // Otherwise print both 
                printf("%d %d ", i, n/i); 
        } 
    } 
} 

 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll A,B;
	cin>>A>>B;
	if(A>B)swap(A,B);
	if(A==1)
	{
		cout<<1<<endl;
		return 0;
	}
	for(ll x=1;x<=sqrt(A);x++)
	{
		if(A%x==0)
		{
			if(A%x==x)
				a.pb(x);
			else
				a.pb(x),a.pb(A/x);
		}
	}
	for(ll x=1;x<=sqrt(B);x++)
	{
		if(B%x==0)
		{
			if(B%x==x)
				b.pb(x);
			else
				b.pb(x),b.pb(B/x);
		}
	}
	sort(all(a));
	sort(all(b));
	vl v;
	F0R(x,sz(a))
	{
		if(binary_search(all(b),a[x]))
			v.pb(a[x]);//,bug(a[x]);
	}
	vi res;
	FOR(x,1,sz(v))
	{
		bool flag=true;
		F0R(y,sz(res))
		{
			if(v[x]%res[y]==0)
			{
				flag=false;
				break;
			}
		}
		if(flag)
			res.pb(v[x]);//,bug(v[x]);
	}
	cout<<sz(res)+1<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

signed main(){
  int n,data[5];
  scanf("%lld", &n);
  for (int i=0;i<5;i++){
    cin >> data[i];
  }
  int bottle_neck_i,bottle_neck_value=(long long)10e15;
  for (int i=0;i<5;i++){
    if (bottle_neck_value > data[i]){
      bottle_neck_value = data[i];
      bottle_neck_i     = i;
    }
  }

  int time = (n%bottle_neck_value==0)?n/bottle_neck_value:(n/bottle_neck_value+1);
  cout << 4+time << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

  int ans = INF;
  // iは最初に使う色(0 or 1)
  rep(i,2) {
    // iを最初に使ったときに変えなければならないタイルの数
    int cnt = 0;
    rep(j,s.size()) {
      // (j%2,i) = (0,0), (1,1)のときtrue
      if ((j%2 == 0) ^ (s[j] != (char)(i+'0'))) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3732
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    X, Y = map(int, input().split())

    if X % Y == 0:
        print(-1)
        exit()

    for i in range(1, 10**8):
        num = X * i
        if num % Y != 0:
            print(num)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 61908
#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(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans=n/x;
    if(n%x!=0) ans++;
    cout << ans*t << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<pair<int, int> >adj[MAX];

void dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int d[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    
    d[0]=0;
    PQ.push(make_pair(0, 0));
    color[0]=GRAY;

    
    while (!PQ.empty()) {
        pair<int, int> f=PQ.top(); PQ.pop();
        int u=f.second;
        color[u] = BLACK;
        if ( d[u]<f.first *(-1))continue;
        
        
        for(int j=0;j<adj[u].size(); j++){
            int v=adj[u][j].first;
            if(color[v]==BLACK)  
                        continue;
            if(d[v] >d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
            }
        }
    
    
    for(int i=0;i<n;i++){
      cout<<i<< " "<<(d[i]==INFTY ?-1:d[i])<<endl;
    }
}



int main(){
    int k, u, v, c;
    
    cin>>n;
    
    for(int i=0;i<n;i++){
         cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
             adj[u].push_back(make_pair(v, c));
        }
    }
  
    dijkstra();
    return 0;
    
    
}




Measured memory_bytes: 8032
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    let ab = get!(usize, usize; n);

    let ab = ab.into_iter().filter(|&(a,_)| a<=k).collect::<Vec<_>>();

    let mut mx = 0;
    for &(a,b) in &ab {
        if a|k==k {
            mx += b;
        }
    }
    for i in 0..31 {
        if (k>>i)%2 == 0 {
            continue;
        }
        let kr = (k | ((1<<i)-1)) & !(1<<i);
        let mut sum = 0;
        for &(a,b) in &ab {
            if a|kr==kr {
                sum += b;
            }
        }
        mx = max!(mx, sum);
    }
    println!("{}", mx);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}

int main(){
  string s;
  cin >> s;
  ll len = s.size();
  bool can = true;
  rep(i,len){
    if(i % 2 == 0){
      if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){

      }else{
        can = false;
      }
    }else{
      if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){

      }else{
        can = false;
      }
    }

  }
  if(can){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n; i++) {
			int num = sc.nextInt();
			a[num-1] = i+1;
		}
		for(int i = 0; i < n; i++) {
			System.out.printf("%d ",a[i]);
		}

		sc.close();

	}

}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
typedef long long ll;
typedef unsigned long long ull;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int a,b;
    cin>>a>>b;
    if(a+b>=10){
        cout<<"error"<<endl;
    }else{
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
peaks = [1]*n # 0としないことで一本の道を使って辿り着ける展望台が存在しない場合に対応
hs = [int(h) for h in input().split()]
for _ in range(m):
    a, b = map(int, input().split())
    # aとbを比較して負けていれば0をセットする
    if hs[a-1] > hs[b-1]:
        peaks[b-1] = 0
    elif hs[a-1] == hs[b-1]:
        peaks[a-1] = 0
        peaks[b-1] = 0
    else:
        peaks[a-1] = 0
print(sum(peaks))

Measured memory_bytes: 20768
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	map<int, int> mp;
	
	int a, maxi = 0;
	while(cin >> a){
		mp[a]++;
		maxi = max(maxi, mp[a]);
	}
	for(auto it : mp){
		if(maxi == it.second) cout << it.first << endl;
	}

	
	return 0;
}

Measured memory_bytes: 2940
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += i
        if not cnt % 2 == A[i]:
            B[i] = 1
        else:
            B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 128872