akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int sum_digit(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int digit(int n){
    while( n >= 10 ) n = sum_digit(n);
    return n;
}


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

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

bool prime_judge(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    double sqrtN = sqrt(n);
    for (int i = 3; i <= sqrtN; i += 2) if (n % i == 0) return false;
    return true;
}

int binary_search(vi a,int key){
    int n = a.size();
    int left = 0, right = n;
    while(left < right){
        int mid = (left + right) / 2;
        if(a[mid] == key) return mid;
        else if(a[mid] > key) right = mid;
        else left = mid + 1;
    }
    return -1;
}

vi ITV(int bit, int n){
   vi S;
   Srep(n){
       if(bit & (1<<i)){
           S.push_back(i);
       }
   }
   return S;
}

int main(){
	int r,d,x,ans;
    cin>>r>>d>>x;
  	ans=x;
  	for(int i=0;i<10;i++){
    	ans=ans*r-d;
      	cout<<ans<<endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<long long> A(N+2,0);
  vector<long long> B(N+1,0);
  for(int i=1; i<N+2; i++){
    long long a; cin>>a;
    A[i]=a;
  }
  for(int i=1; i<N+1; i++){
    long long b; cin>>b;
    B[i]=b;
  }
  long long count=0;
  for(int i=1; i<N+1; i++){
    if(B[i]<=A[i]){
      count+=B[i];
    }
    else{
      count+=A[i];
      B[i]=B[i]-A[i];
      if(A[i+1]-B[i]<0){
	count+=A[i+1];
	A[i+1]=0;
      }
      else{
	count+=B[i];
	A[i+1]-=B[i];
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPopularVote solver = new BPopularVote();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPopularVote {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int m = in.readInt();

            int[] a = new int[n];
            double sum = 0.0;
            for (int i = 0; i < n; i++) {
                a[i] = in.readInt();
                sum += a[i];
            }

            int sel = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] >= sum * 1.0 / (4 * m))
                    sel++;
            }
            System.out.println(sel >= m ? "Yes" : "No");

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22612
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    val y = readLine()!!.toInt()
    val z = readLine()!!.toInt()
    val s = readLine()!!.toInt()
    var a = 0
    for(xx in 0..x) for(yy in 0..y) for(zz in 0..z) if (500 * xx + 100 * yy + 50 * zz == s) a += 1
    println(a)
}

Measured memory_bytes: 31536
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define N 2*10e5
#define pi  3.141592
using namespace std;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	ll r;
	cin>>r;
	float c = 2*pi*r;
	cout<<fixed<<setprecision(3)<<c;
}



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

int main(){
    int n;
    vector<int> a;
    int temp;
    cin>> n;
    for(int i = 0; i < n; i++){
        cin>>temp;
        a.push_back(temp);
    }
//    cout<<"入力完了"<<endl;

    int count = 0;
    int loop = 1;
    while(loop == 1){
        for(int i = 0; i < a.size(); i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
//                cout<<"a[i]"<<a[i]<<endl;
            }else {
                loop = 0;
                break;       
            } 
        }
        if(loop == 1)count++;
    }
    cout<<count<<endl;
}

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

bool dp[20000];

int main(){
    int N;
    cin>>N;
    int s[110];
    for(int i=0;i<N;i++){
        cin>>s[i];
    }
    dp[0]=true;
    for(int i=0;i<N;i++){
        for(int j=10000;j>=0;j--){
            if(dp[j])dp[j+s[i]]=true;
        }
    }
    int max=0;
    for(int i=0;i<=10000;i++){
        if(dp[i]==true&&i>max&&i%10!=0)max=i;
    }
    cout<<max<<endl;
    return 0;
}

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



int main() {
  ll a,b,x;
  cin >> a >>b >>x;
  if(a==0){cout << b/x+1 << endl; return 0;}
  cout << b/x-(a-1)/x << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	char s[4+2];

	while(scanf("%4[A-Z]\n", s)==1)
	{
		int c[26]={};

		for(int i=0;i<4;i++)
		{
			c[s[i]-'A']++;
		}

		int c2=0;
		for(int i=0;i<26;i++)
		{
			if(c[i]==2) c2++;
		}
		printf("%s\n", c2==2?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}

ll D;


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

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

	e = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			a = 0;

			for (int k = 0; k < D; k++) {
				b = C[i][k] - C[j][k];
				a += b * b;
			}


			for (ll k = 0; k < 200000; k++) {
				if (k * k == a) {
					e++;
					break;
				}
			}

		}
	}

	cout << e << endl;
	
	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

#define N_MAX 100002
#define V_MAX 100002

using namespace std;

const int INF = 1e9+1;

int n, W;

int w[N_MAX], v[N_MAX];

int dp[V_MAX];

int main()
{
    cin >> n >> W;
    int sumv = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        sumv += v[i];
    }
    for(int i = 1; i <= sumv; i++)
        dp[i] = INF;
    for(int i = 1; i <= n; i++)
        for(int j = sumv; j >= v[i]; j--)
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    int ans = 0;
    for(int i = 1; i <= sumv; i++)
        if(dp[i] <= W)
            ans = i;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
import sys
f = sys.stdin

_, w, h = map(int, f.readline().split())
xyw = [list(map(int, line.split())) for line in f]

from operator import itemgetter
def check(xyw, i, size):
    xyw.sort(key=itemgetter(i))
    p = 0
    for xywi in xyw:
        if xywi[i] - xywi[2] <= p:
            p = max(p, xywi[i] + xywi[2])
    return size <= p

print('Yes' if check(xyw,0,w) or check(xyw,1,h) else 'No')

Measured memory_bytes: 36596
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 100010
#define M 110
using namespace std;
bool dp[N];
int n,k,a[M];
int main(){
	int i,j;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	memset(dp,false,sizeof(dp));
	for(i=0;i<=k;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i>=a[j])
			{
				dp[i]|=(!dp[i-a[j]]);
			}
		}
	}
	if(dp[k])
	{
		cout<<"First"<<endl;
	}
	else
	{
		cout<<"Second"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C && A == C){
		cout << "No" << endl;
	}
	else if (A != B && B != C && A != C)
	{ cout << "No" << endl; }
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[405][405],a[405],pref_cost[405];
const ll inf = 1e18+10;

int main()
{
    int n;
    cin >> n;
    
    for(int i=1;i<=n;++i)
    cin >> a[i];
    
    pref_cost[1]=a[1];
    for(int i=2;i<=n;++i)
    {
        pref_cost[i]+=pref_cost[i-1]+a[i];
    }
    
    for(int i=n;i>=0;--i)
    {
        for(int j=i;j<=n;++j)
        {
            dp[i][j]=inf;
            if(i==j)
            dp[i][j]=0;
            for(int k=i;k<j;++k)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pref_cost[j]-pref_cost[i-1]);
            }
        }
    }
    cout << dp[1][n] << '\n';
    
    return 0;
}

Measured memory_bytes: 4840
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

/*void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;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;
	}
}

int 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 n;
vector<int> a;
int ans;
bool flg=false;

main(){
    cin>>n;
    rep(i,n){
        int tmp;
        cin>>tmp;
        if((i+1)==tmp){
            if(flg){
                a.back()++;
            }else{
                a.pb(1);
                flg=true;
            }
        }else{
            flg=false;
        }
    }
    for(int x:a){
        ans+=(x+1)/2;
    }
    dans;
}


Measured memory_bytes: 892
package main

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

var sc *bufio.Scanner

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	x := make([]float64, n)
	y := make([]float64, n)

	for i := 0; i < n; i++ {
		x[i] = nextFloat()
	}
	d1 := 0.0
	d2 := 0.0
	d3 := 0.0
	dinf := 0.0
	for i := 0; i < n; i++ {
		y[i] = nextFloat()
		a := math.Abs(x[i] - y[i])
		d1 += a
		d2 += math.Pow(a, 2)
		d3 += math.Pow(a, 3)
		if dinf < a {
			dinf = a
		}
	}
	fmt.Println(d1)
	fmt.Println(math.Sqrt(d2))
	fmt.Println(math.Pow(d3, 1.0/3.0))
	fmt.Println(dinf)

}



Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int answer = 0;
		String[] s = sc.next().split("");
		int[] chofukuInfofirst = new int[10];
		int[] chofukuInfosecond = new int[10];
		int[] chofukuInfothird = new int[10];
		for(int i =0;i < n-2;i++) {
			if(chofukuInfofirst[Integer.parseInt(s[i])] ==0) {
				chofukuInfofirst[Integer.parseInt(s[i])]++;
				chofukuInfosecond = new int[10];
			}else {
				continue;
			}

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

				if(chofukuInfosecond[Integer.parseInt(s[j])] ==0) {
					chofukuInfosecond[Integer.parseInt(s[j])]++;
					chofukuInfothird = new int[10];
				}else {
					continue;
				}
				for(int k =j +1;k < n;k++) {
					if(chofukuInfothird[Integer.parseInt(s[k])] ==0) {
						chofukuInfothird[Integer.parseInt(s[k])]++;
						answer++;
					}else {
						continue;
					}

				}
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 29440
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define For_Arr     for(i=0;i<n;i++)
using namespace std;
int main()
{
    ll n,i;
    string s;
    cin>>s;
    bool ok=1;
    for(i=0; s[i]; i++)
    {
        if((i+1)%2&&(s[i]=='R'||s[i]=='U'||s[i]=='D'));
        else if((i+1)%2==0&&(s[i]=='L'||s[i]=='U'||s[i]=='D'));
        else
        {
            ok=0;
            break;
        }
    }
    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}





Measured memory_bytes: 3556
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int )1e5 + 10 ;

int n , a [ N ] , sum [ N ] ; 

int solve ( int t ) {
	int ret = 0 ; 
	if ( t ) {
		sum [ 0 ] = a [ 0 ] ; 
		if ( a [ 0 ] >= 0 ) {
			sum [ 0 ] = -1 ; 
			ret += abs ( a [ 0 ] + 1 ) ; 	
		}
	}
	else {
		sum [ 0 ] = a [ 0 ] ; 
		if ( a [ 0 ] <= 0 ) {
			sum [ 0 ] = +1 ; 
			ret += abs ( a [ 0 ] - 1 ) ; 
		}
	}
	for ( int i = 1 ; i < n ; ++i ) {
		sum [ i ] = sum [ i - 1 ] + a [ i ] ;
		if ( sum [ i ] * sum [ i - 1 ] >= 0 ) {
			if ( sum [ i - 1 ] < 0 ) {
				ret += abs ( sum [ i ] - 1 ) ;
				sum [ i ] = +1;  
			}
			else {
				ret += abs ( sum [ i ] + 1 ) ;
				sum [ i ] = -1 ; 
			}
		}
	}
	return ret ; 
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int i = 0 ; i < n ; ++i )
		cin >> a [ i ] ;
	int res = ( 1LL << 60 ) ; 
	for ( int t = 0 ; t < 2 ; ++t )
		smin ( res , solve ( t ) ) ;
	cout << res << '\n' ; 
}














Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k, l;
  
  ll N, M;
  cin >> N >> M;
  
  ll ans=N*(N-1)/2+M*(M-1)/2;
  pt(ans);
  
  
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define lli int
int const maxlen = 1e6+7;
int cnt[maxlen];
void resolve(int t){

  for(int i=2;i*i<=t;i++){
    if(t%i == 0){
      cnt[i]++;
      while(t%i==0)
        t/=i;
    }
  }
  if(t!=1)
    cnt[t]++;
}
void solve(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    resolve(t);
  }
  bool pairwise = true;
  bool setwise = true;
  for(int i=1;i<=maxlen;i++){
    if(cnt[i]>=2){
      pairwise =false;
    }
    if(cnt[i] == n){
      setwise = false;
    }
  }


  if(pairwise){
    cout<<"pairwise coprime"<<endl;
    return;
  }

  if(setwise){
    cout<<"setwise coprime"<<endl;
    return;
  }

  cout<<"not coprime"<<endl;
}
signed main(){
  // int t;
  // cin>>t;
  // while(t--)
  solve();
}


Measured memory_bytes: 11400
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>

using namespace std;

int main(void)
{
	int N, K;
	long long int res = 1;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		//first
		if (i == 0)
		{
			res *= K;
		}
		//second,third........
		else
		{
			res *= (K - 1);
		}
	}

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

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n and n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=a*b;
    int dfd=c+d;
    if(ans%2==1&&dfd%2==1){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}
//大丈夫だ問題ない
//略して　　大　問　題　だ



Measured memory_bytes: 3092
N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    tmp1 = 0
    for j in range(tmp[0]):
        tmp1 = tmp1 | 2**(tmp[j+1]-1)
    S.append(tmp1)    
        
p = list(map(int, input().split()))

ans = [True] * (2**N)
for i in range(M):
    if p[i] == 0:
        for j in range(2**N):
            if bin(j & S[i]).count("1") % 2 != 0:
                ans[j] = False
    else:
        for j in range(2**N):
            if bin(j & S[i]).count("1") % 2 != 1:
                ans[j] = False
            
print(ans.count(True))

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int levenshtein_distance(const std::string &s,const std::string &t){
    std::vector<std::vector<int>> dp(s.size()+1,vector<int>(t.size()+1,s.size()+t.size()));
    for(int i=0; i<s.size(); ++i) dp[i][0]=i;
    for(int i=0; i<t.size(); ++i) dp[0][i]=i;
    for(int i=1; i<=s.size(); ++i){
        for(int j=1; j<=t.size(); ++j){
            int cost=s[i-1]==t[j-1]?0:1;
            dp[i][j]=min(dp[i-1][j-1]+cost,min(dp[i-1][j],dp[i][j-1])+1);
        }
    }
    return dp[s.size()][t.size()];
}

void solve(){
    string s1,s2;
    cin >> s1 >> s2;
    cout << levenshtein_distance(s1,s2) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 6792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , i , j ;
    cin >> n ;
    double p[n+1] ;
    for(i=1 ; i<=n ; i++){
        cin >> p[i] ;
    }
    double dp[n+1][n+1] = { } ;

    dp[0][0] = 1.0 ;
    for(i=1 ; i<=n ; i++){
        dp[i][0] = dp[i-1][0]*(1 - p[i]) ;
        for(j=1 ; j<=i ; j++){
             dp[i][j] = p[i]*dp[i-1][j-1] + (1 - p[i])*dp[i-1][j] ;
        }
    }

    double ans = 0.0 ;
    for(i=(n+1)/2 ; i<=n ; i++){
        ans+=dp[n][i]  ;
    }
    cout << setprecision(10) << fixed << ans ;
    return 0 ;
}

Measured memory_bytes: 70656
#include<iostream>

using namespace std;

const static int MAX_N = 3 * 100000;
int N;
string S;

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

  int l = 0, r = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'E') r += 1;
  }
  
  int m = 0;
  int minc = MAX_N;
  for (int i = 0; i < N; i++) {
    l += m;
    if (S[i] == 'E') {
      r -= 1;
      m = 0;
    } else {
      m = 1;
    }

    minc = min(minc, l + r);
  }

  cout << minc << endl;
  return 0;

}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

random_device seed_gen;
mt19937 rng(seed_gen());

int d,c[26],a[365][26];

int score[26],last[26],t[365];

int calc_score(){
	return accumulate(score,score+26,0);
}

void update(int x,int t2){
	int t1=t[x];
	t[x]=t2;
	score[t1]=last[t1]=0;
	score[t2]=last[t2]=0;
	rep(i,d){
		if(t[i]==t1 || t[i]==t2){
			score[t[i]]+=a[i][t[i]];
			last[t[i]]=i+1;
		}
		score[t1]-=c[t1]*(i+1-last[t1]);
		score[t2]-=c[t2]*(i+1-last[t2]);
	}
}

int main(){
	scanf("%d",&d);
	rep(j,26) scanf("%d",&c[j]);
	rep(i,d) rep(j,26) scanf("%d",&a[i][j]);

	// greedy
	rep(i,d){
		int j_max=0;
		for(int j=1;j<26;j++) if(a[i][j_max]<a[i][j]) j_max=j;
		t[i]=j_max;
		score[t[i]]+=a[i][t[i]];
		last[t[i]]=i+1;
		rep(j,26) score[j]-=c[j]*(i+1-last[j]);
	}

	int score_curr=calc_score();

	rep(k,10000){
		int x=k%d;
		rep(t2,26) if(t[x]!=t2) {
			int t1=t[x];
			update(x,t2);

			int score_tmp=calc_score();
			if(score_tmp>score_curr){
				score_curr=score_tmp;
				break;
			}
			else{
				update(x,t1);
			}
		}
	}

	rep(i,d) printf("%d\n",t[i]+1);

	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, m;
   cin >> n >> m;
   vector<int> a(n);
   rep(i, 0, m) {
      int k;
      cin >> k;
      rep(j, 0, k) {
         int s;
         cin >> s;
         s--;
         a[s] |= 1 << i;
      }
   }
   int p = 0;
   rep(i, 0, m) {
      int x;
      cin >> x;
      p |= x << i;
   }
   int ans = 0;
   rep(i, 0, 1 << n) {
      int t = 0;
      rep(j, 0, n) {
         if (i >> j & 1) {
            t ^= a[j];
         }
      }
      if (t == p) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n),b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i];

  vector<ll> sa(n+1), sb(m+1);
  REP(i,n) { sa[i+1] = sa[i] + a[i]; }
  REP(i,m) { sb[i+1] = sb[i] + b[i]; }

  ll ap = sa.size()-1, bp = sb.size()-1;
  int ans = 0;
  REP(i, m+1) {
    if (sb[i] > k) break;
    ll diff = k - sb[i];
    auto it = std::upper_bound(sa.begin(), sa.end(), diff);
    int point = it-sa.begin();
    point = max(0, point-1);
    // cout << point << " " << i << " " << sa[point] << " " << sb[i] << endl;
    ans = max(ans, point+i);
  }
  COUT(ans);

/*
  REP(i, n+m) {
    if (sa[ap] + sb[bp] <= k) {
      COUT(n+m-i);
      return 0;
    }
    sa[ap] < sb[bp] ? bp-- : ap--;
  }
  COUT(0);
  */
  return 0;
}


Measured memory_bytes: 9532
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#define ll long long
using namespace std;
int main(){
	ll a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3 >= 22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll MOD = 1e9+7;
//modulo arithmetic
inline ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= MOD)
		return res - MOD;
	return res;
}

inline ll mult(ll a, ll b)
{
	ll  res = a;
	res *= b;
	if(res >= MOD)
		return res % MOD;
	return res;
}

inline ll sub(ll a, ll b)
{
	return (a%MOD-b%MOD+MOD)%MOD;
}

ll fstx(ll x)
{
	--x;
	ll ans=x*(x+1);
	return ans/2;
}

ll lstx(ll x,ll n)
{
	return fstx(n+1)-fstx(n+1-x);
}

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,k;
 	cin>>n>>k;
 	ll ans=0;
 	for(ll i=k;i<=n+1;i++)
 	{
 		ans=add(ans,sub(lstx(i,n),fstx(i)));
 		//cout<<i<<" "<<lstx(i,n)<<" "<<fstx(i)<<endl;
 		ans=add(ans,1);
 	}
 	cout<<ans<<endl;
    return 0;
}

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

int main()
{
  string n;
  string m;
  
  cin >> n >> m;
  
  int	iN = atoi(n.c_str());
  int	iM = atoi(m.c_str());
  
  int retVal = 0;

  // 偶数から2個とる場合の数
  if(iN > 1)
  {
    retVal += iN * (iN - 1) / 2;
  }
  // 奇数から2個とる場合の数
  if(iM > 1)
  {
    retVal += iM * (iM - 1) / 2;
  }
  
  cout << retVal << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}

void go(ll n , ll k){
    ll mi = INF;
    REP(i,3){
        mi = min(mi, abs(n-k));
        n = abs(n-k);
    }

    cout << mi <<endl;
    
    return  ;


}
int main(){
    int n;
    cin >> n;

    vector<int> a(100005),b(100005);
    int sum =0 , vl = 0;
    for(int i=1; i<=n; i++){
        cin >> b[i];
        sum += b[i];
        b[i] *= 2;
    }

    for(int i=1; i<n; i += 2){
        vl += b[i];
    }
    a[n] = sum - vl;

    for(int i=n-1;i>=1;i--){
        a[i] = b[i] - a[i+1];
    }
    for(int i=1; i<=n; i++){
        cout << a[i] <<" " ;
    }
    cout << endl;


}





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

int main(void){
    int n, h;
    cin >> n >> h;

    vector<int> a(n), b(n);
    int maxa = 0, maxp = 0;
    for(int i=0; i<n; i++){
        cin >> a.at(i) >> b.at(i);
        if(a.at(i) > maxa){
            maxa = a.at(i);
            maxp = i;
        }
    }
    int maxb = b.at(maxp);
    b.erase(b.begin() + maxp);
    sort(b.begin(), b.end());

    int ans = 0;

    while(h > 0){
        if(h <= maxb){
            h -= maxb;
            ans++;
        }else if(b.size() > 0 && b.back() >= maxa){
            h -= b.back();
            b.pop_back();
            ans++;
        }else{
            h -= maxb;
            ans++;
            int q = h/maxa, r = h%maxa;
            ans += q + (r>0);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
mod = 998244353
x = [list(map(int, input().split())) for _ in range(k)]
x.sort()
dp = [0] * (n + 1)
dpsum = [0] * (n + 1)
dp[1], dpsum[1] = 1, 1
for i in range(2, n + 1):
    cnt = 0
    for j in range(k):
        cnt += (dpsum[max(0, i - x[j][0])] - dpsum[max(0, i - x[j][1] - 1)])
        cnt %= mod
        if i - x[j][1] < 0:
            break
    dp[i] = cnt
    dpsum[i] = dp[i] + dpsum[i - 1]
ans = dp[n]
print(ans)

Measured memory_bytes: 77728
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    p = [(p_i+1)/2 for p_i in p]
    ans = 0
    for i in range(N-K+1):
        if i == 0:
            sum_ = sum(p[i:i+K])
        else:
            sum_ = sum_ + p[i+K-1] - p[i-1]
        ans = max(ans, sum_)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int dp[1000001];
int pre[1000001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			pre[i]=-1;
		}
		else
		{
			if(i>0&&pre[i-1]>=0) pre[i]=pre[i-1];
			else pre[i]=i;
		}
	}
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
		dp[i]=dp[i-1];
		if(i>=2&&s[i]=='1'&&s[i-2]=='1'&&s[i-1]=='0')
		{
			int z = pre[i-2];
			//take [z,i-2]
			int cost = i - 2 - z + 1;
			if(z-1>=0) cost+=dp[z-1];
			dp[i]=max(dp[i],cost);
			if(z<i-2)
			{
				cost = i - 2 - z;
				if(z>=0) cost += dp[z];
				dp[i] = max(dp[i],cost);
			}
		}
		if(s[i]=='1')
		{
			int z=pre[i];
			if(z>=2&&s[z]=='1'&&s[z-2]=='1'&&s[z-1]=='0')
			{
				//[z, i]
				int cost = i - z + 1;
				if(z>=3) cost += dp[z-3];
				dp[i]=max(dp[i],cost);
			}
		}
		//cerr<<i<<' '<<dp[i]<<'\n';
	}
	cout<<dp[n-1]<<'\n';
}


Measured memory_bytes: 6940
import collections
N,K,Q = list(map(int,input().split()))
point = [0 for i in range(N)]
bor = Q - K + 1
A = []
for i in range(Q):
    A.append(int(input()))
for i in A:
    point[i-1] += 1
for i in point:
    if i >= bor:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 56224
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int r,c,z;
  cin>>r>>c>>z;

  vector<string> p(r);
  rep(i,r){
    cin>>p[i];
  }

  //——————————————bit全探索——————————————
  ll ans=0;
  rep(i,(1<<r)){
    rep(j,(1<<c)){
    ll sum=0;
      rep(k,r){
        rep(l,c){
          if( (i & (1<<k)) && (j & (1<<l)) ){
          sum+=(p[k][l]=='#');
          }
        }
      }
    if(sum==z) ans++;
    }
  }

  cout << ans << endl;

  //——————————————————————————————————————


}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    ll tmp = 0;
    rrep(i, n){
        a[i] += tmp;
        ll res;
        if (a[i] % b[i] != 0) res = b[i] - a[i] % b[i];
        else res = 0;
        tmp += res;
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    for (int i = 1; i < N + 1; i++) {
        ll a;
        cin >> a;
        A[i] = a;
    }

    rep(i, N) { A[i + 1] += A[i]; }

    ll ans = INF;
    for (int i = 1; i < N; i++) {
        ll sunuke = A[i];
        ll arai = A[N] - A[i];
        ll diff = abs(sunuke - arai);
        ans = min(ans, diff);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
use proconio::{fastout, input};
use proconio::marker::*;

const INF: usize = 1001001001001001001;

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n],
      uv: [(Usize1, Usize1); n-1]
   }

   let mut to = vec![vec![]; n];
   for (u, v) in uv {
      to[u].push(v);
      to[v].push(u);
   }

   let mut lis = vec![INF; n+1];
   let mut ans = vec![0;n];
   dfs(0, 0, &mut lis, &mut ans, &to, &a);
   for x in ans {
      println!("{}", x);
   }
}

fn dfs(v: usize, p: usize, lis: &mut [usize], ans: &mut [usize], to: &[Vec<usize>], a: &[usize]) {
   let pos = lis.lower_bound(&a[v]);
   let res = lis[pos];
   lis[pos] = a[v];
   ans[v] = lis.lower_bound(&INF);
   for u in to[v].iter().copied() {
      if u == p {
         continue;
      }
      dfs(u, v, lis, ans, to, a);
   }
   lis[pos] = res;
}

use std::cmp::Ordering;
/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
   fn lower_bound(&self, x: &T) -> usize;
   fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
   fn lower_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            Ordering::Less => {
               low = mid + 1;
            }
            Ordering::Equal | Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
   fn upper_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            Ordering::Less | Ordering::Equal => {
               low = mid + 1;
            }
            Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
}


Measured memory_bytes: 46824
n=int(input())
a=[0]*n
a=list(map(int,input().split()))
flag=0
num=0
for i in range(100):
  for j in range(n):
    if (a[j]%2==0):
      a[j]=a[j]//2
    else:
      flag=1
      break
  if (flag==1):
    break
  num+=1
print(num)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

from heapq import heappush, heappop

n, m = map(int, input().split())

# A日後、報酬B
workList = {}
for i in range(n):
    a, b = map(int, input().split())
    if a not in workList:
        workList[a] = [-b]
    else:
        workList[a].append(-b)
# print(workList)

hq = []
sum = 0
for i in range(1, m + 1):
    if i in workList:
        for w in workList[i]:
            heappush(hq, w)

    val = None
    if len(hq) > 0:
        val = heappop(hq)
    if val is not None:
        sum += -val

print(sum)


Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  repp(i, 0, N - M) {
    repp(j, 0, N - M) {
      bool accord = true;
      rep(ii, M) {
        rep(jj, M) {
          if (A[i + ii][j + jj] != B[ii][jj])
            accord = false;
        }
      }
      if (accord) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
int main(){
	int n,rem,got=0;
  	scanf("%d",&n);
  
  	while(n!=0){
      rem=n%10;
      n=n/10;
      
      if(rem==7){
      	got=1;
        break;
      }
    }
  
  	if(got)
      	printf("Yes\n");
  	else
      	printf("No\n");
}

Measured memory_bytes: 1644
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)
	c := count("0")
	fmt.Println(min(c, len(S)-c) * 2)
}

func count(s string) int {
	var ret int
	for i := 1; i <= len(S); i++ {
		if S[i-1:i] == s {
			ret++
		}
	}
	return ret
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2488
#include <iostream>
#include <vector>
#include <queue>

using lli = long long int;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define rREP(i, n) for(int (i) = (n)-1; (i)>= 0; --(i))


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


std::vector<int> A;
std::vector<lli> P, N;
constexpr lli inf = 2e18+334;


int main(void){
    // 入力
    int n; scanf("%d", &n);

    std::priority_queue<int, std::vector<int>, std::greater<int>> Front;

    lli S1 = 0;
    REP(i, n){ int k; scanf("%d", &k); Front.push(k); S1 += k;}

    A.resize(n);
    REP(i, n) scanf("%d", &A[i]);

    std::priority_queue<int> Back;
    lli S2 = 0;
    REP(i, n){ int k; scanf("%d", &k); Back.push(k); S2 += k; }
  
    // 入力ここまで

    // P[i] := 最初のn要素とその次のi個の要素で作れる数の最大
    P.resize(n+1); P[0] = S1;
    REP(i, n){
        if(Front.top() >= A[i]){ P[i+1] = P[i]; continue; }

        int a = Front.top(); Front.pop(); Front.push(A[i]);
        S1 += (A[i]-a); P[i+1] = S1;
    }

    // Q[i] := 末尾n要素とその手前のn-i個の要素で作れる数の最小
    N.resize(n+1); N[n] = S2;
    rREP(i, n){
        if(Back.top() <= A[i]){ N[i] = N[i+1]; continue; }
        int a = Back.top(); Back.pop(); Back.push(A[i]);
        S2 += (A[i] - a); N[i] = S2;
    }
  
    // 最適の探索
    lli ans = -inf;
    REP(i, n+1){
        lli koho = P[i] - N[i];
        chmax(ans, koho);
    }
    
    // 結果の出力
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long sum;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> k(n);
    for(int i=0; i<n; i++){
      cin >> a[i];
      b[i]=a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++){
        long long x=upper_bound(a.begin(),a.end(),a[i])-lower_bound(a.begin(),a.end(),a[i]);
        k[a[i]]=(x-1);
        sum+=k[a[i]];
    }
    sum/=2;
    for(int i=0; i<n; i++){
        cout << sum-k[b[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 4992