akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
    long long t;
    double a, b, n;
    while (cin >> a >> b >> n) {
        double p = a / b - (int)(a / b);
        t = (long long)(p * pow(10.0, n));
        long long res = 0;
        for (int i = (int)n; i > 0; i--) {
            res += t % 10;
            t /= 10;
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1264
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A = sorted(A)
F = sorted(F, reverse=True)
mul = [A[i]*F[i] for i in range(N)]

if K >= sum(A):
    print(0)
    exit()

ma = 2**40
mi = 0
while 1:
    tgt = mi + (ma - mi)//2
    num = 0
    for i in range(N):
        tmp = (mul[i] - tgt + F[i] - 1) // F[i]
        if tmp <= 0:
            continue
        num += tmp
    if ma == mi:
        print(ma)
        exit()
    if num <= K:
        ma = mi + (ma - mi)//2
    else:
        mi = mi + (ma - mi)//2+1


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

#define MAX_VAL 200000000000000

int main()
{
    int n;
    long long int sum = 0;
    vector<long long int> v;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        sum += t;
        v.push_back(t);
    }

    long long int val = MAX_VAL;
    long long int tsum = 0;
    for(int i = 0; i < n-1; ++i)
    {
        tsum += v.at(i);
        sum -= v.at(i);
        if(abs(sum - tsum) < val)
        {
            //cout << sum << " " << tsum << endl;
            val = abs(sum - tsum);
        }
    }
    cout << val << endl;
}

Measured memory_bytes: 2420
//#include </Users/piyush/Desktop/nodejs/first-app/CP/bits/stdc++.h>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<long long,long long> pll;



#define F first
#define S second
#define print(x) for(auto iuiuiuiuiui:x){ cout<<iuiuiuiuiui<<" ";}br;
#define print_array(array,size) for(ll i=0;i<size;i++){ cout<<array[i]<<" ";}br;
#define br cout<<"\n"
#define max_val 1000100
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(asd,fgh) make_pair(asd,fgh)
#define all(c) c.begin(),c.end()
#define check_ cout<<"yo";

#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);

#define N_INF LONG_LONG_MIN


#pragma GCC target("popcnt")



vector<ll> parent,ranking;

ll find_set(ll a){
    if(a==parent[a]){
        return a;
    }
    else
        return parent[a]=find_set(parent[a]);
}

void union_set(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (ranking[a] < ranking[b])
            swap(a, b);
        parent[b] = a;
        if (ranking[a] == ranking[b])
            ranking[a]++;
    }
}


const int INF=1e9+5;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int test;
     test=1;

    while (test--) {

        ll n;
        cin>>n;

        vector<ll> arr(n),dp(n,INF);

        dp[0]=0;
        for(ll i=0;i<n;i++){
            cin>>arr[i];
        }

        for(ll i=1;i<n;i++){
            if(i==1){
                dp[i]=min(dp[i],dp[i-1]+abs(arr[i]-arr[i-1]));
            }else{
                dp[i]=min({dp[i],dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2])});
            }
        }

        cout<<dp[n-1];br;



    }
}

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

bool is_valid(string S){
    if (S[0] != 'A') return false;
    int cnt_C = 0;
    for (int i = 2; i < S.size() - 1; ++i){
        if (S[i] == 'C') ++cnt_C;
    }
    if (cnt_C != 1) return false;
    int cnt = 0;
    for (auto &c : S){
        if (c <= 'Z') ++cnt;
    }
    return cnt == 2;
}

int main() {
    string S;
    cin >> S;
    if (is_valid(S)){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
const int NAX=1e5+5;
int par[NAX],siz[NAX];
int findpar(int x){
    if(par[x]==-1)
        return x;
    return par[x]=findpar(par[x]);
}
void mergeset(int x,int y){
    if(siz[x]<siz[y])
        swap(x,y);
    siz[x]+=siz[y];
    siz[y]=0;
    par[y]=x;
}
int main(){
FASTIO;
int n,m,k,i,x,y;
cin>>n>>m>>k;
for(i=1;i<=n;i++)
    par[i]=-1,siz[i]=1;
vector<vector<int> > friendship(n+1),blockship(n+1);
for(i=0;i<m;i++){
    cin>>x>>y;
    friendship[x].pb(y);
    friendship[y].pb(x);
    int parx=findpar(x);
    int pary=findpar(y);
    if(parx!=pary)
        mergeset(parx,pary);
}
for(i=0;i<k;i++){
    cin>>x>>y;
    blockship[x].pb(y);
    blockship[y].pb(x);
}
for(i=1;i<=n;i++){
    int parx=findpar(i);
    int sizeofx=siz[parx];
    for(auto it:blockship[i]){
        if(findpar(it)==parx)
            sizeofx--;
    }
    sizeofx-=friendship[i].size()+1;
    cout<<sizeofx<<" ";
}
cout<<endl;
}


Measured memory_bytes: 12664
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

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

	class Pair{
		int s;
		int t;
		Pair(int s, int t){
			this.s=s;
			this.t=t;
		}
		@Override
		public String toString() {
			return "Pair [s=" + s + ", t=" + t + "]";
		}
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + s;
			result = prime * result + t;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (s != other.s)
				return false;
			if (t != other.t)
				return false;
			return true;
		}
		private Main getOuterType() {
			return Main.this;
		}

	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int N;
		N=sc.nextInt();
		ArrayList<ArrayList<Integer>> G = new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<N; i++) G.add(new ArrayList<Integer>());
		ArrayList<Pair> vp = new ArrayList<Pair>();


		for(int i=0; i<N-1; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--; b--;
			G.get(a).add(b);
			G.get(b).add(a);
			vp.add(new Pair(a,b));
		}

		int K = 0;
		HashMap<Pair, Integer>I = new HashMap<Pair, Integer>();
		ArrayList<Integer> cs = new ArrayList<>();
		ArrayList<Boolean> used = new ArrayList<>();
		ArrayDeque<Integer> que = new ArrayDeque<Integer>();

		for(int i=0; i<N; i++) {
			cs.add(0);
			used.add(false);
		}

		used.set(0, true);
		que.add(0);
		while(!que.isEmpty()) {
			int v = que.poll();
			if(K < G.get(v).size()) {
				K = G.get(v).size();
			}
			int cur=1;
			for(int u : G.get(v)) {
				if(used.get(u))	continue;
				if(cur == cs.get(v)) cur++;
				cs.set(u, cur);
				I.put(new Pair(u,v), cur);
				I.put(new Pair(v,u), cur);
				cur++;
				used.set(u, true);
				que.add(u);
			}
		}
		System.out.println(K);
		for(Pair p : vp) {
			System.out.println(I.get(p));
		}
		sc.close();
	}


}


Measured memory_bytes: 103248
#include <stdio.h>
#define S 2000000

int main(void)
{
    int i, n;
    int min, diff, N[S];
    
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &N[i]);
    
    min=N[0];
    diff=N[1]-N[0];
    for(i=1; i<n; i++){
            if(min>N[i]) min=N[i];
            else if(diff<N[i]-min) diff=N[i]-min;
        }
    printf("%d\n", diff);
    return 0;
}



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

Measured memory_bytes: 580
S = input()

first = int(S[0:2])
last = int(S[2:4])

if 1 <= first <= 12:
    if 1 <= last <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= last <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
/*
 * @Author: BilyHurington
 * @Date: 2020-03-22 20:30:01
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-03-22 20:52:08
 */
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char ch[11][1010];
int bel[11],tot,sum[11];
int nxt(int x){
    memset(sum,0,sizeof(sum));
    int p=x;
    while(x<=m){
        bool pd=1;
        for(int i=1;i<=n;i++){
            sum[bel[i]]+=ch[i][x]-'0';
            if(sum[bel[i]]>k) pd=0;
        }
        if(!pd) break;
        x++;
    }
    if(p==x) return -1;
    return x;
}
int main(){
    int minn=2e9;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) scanf(" %c",&ch[i][j]);
    }
    for(int i=(1<<(n-1))-1;i>=0;i--){
        bel[1]=tot=1;
        for(int j=2;j<=n;j++){
            if(i&(1<<(j-2))) bel[j]=bel[j-1];
            else bel[j]=++tot;
        }
        int x=1,ans=0;
        while(x!=-1&&x<=m) x=nxt(x),ans++;
        if(x!=-1) minn=min(minn,ans+tot-2);
    }
    printf("%d\n",minn);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i, j, k, H, W;

  for (i=0; ; i++){
    scanf("%d %d", &H, &W);

    if ( !H && !W)
      break;

    if ((H==1) && (W==1)){
      printf("#\n\n");
      continue;
    }
    
    for (j=0; j < W; j++)
      printf("#");
    printf("\n");

    for (k=0; k < H-2; k++){
      printf("#");
      for (j=0; j < W-2; j++)
	printf(".");
      printf("#\n");
    }

    for (j=0; j < W; j++)
      printf("#");
    printf("\n");

    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		int count = 0;
		for (int i = 0; i < n - 2; i++) {
			String tmp = "";
			for (int j = 0; j < 3; j++) {
				tmp += str.charAt(i + j);
			}
			if (tmp.equals("ABC")) {
				++count;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	int n, d, sum = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		double x, y;
		cin >> x >> y;
		double s = sqrt(x*x+y*y);
		if(s <= d) sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3804
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t1 = sc.nextInt();
		int t2 = sc.nextInt();
		int r1 = sc.nextInt();
		int r2 = sc.nextInt();
		if (r1 == -1 || r2 == -1) {
		    r1 = -t1;
		    r2 = -t2;
		}
		if (r1 == r2) {
		    System.out.println("Draw");
		} else if (r1 < r2) {
		    System.out.println("Bob");
		} else {
		    System.out.println("Alice");
		}
	}
}



Measured memory_bytes: 26380
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int x[100][100];
char c[100][100];
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int a, b;
	cin >> a >> b;
	f(i, a) {
		f(j, b) {
			cin >> c[i][j];
			x[i][j] = INF;
		}
	}
	x[0][0] = 0;
	if (c[0][0] == '#')x[0][0] = 1;
	f(i, a) {
		f(j, b) {
			if (i < a - 1) {
				if (c[i + 1][j] != c[i][j] && c[i + 1][j] == '#')x[i + 1][j] = min(x[i + 1][j], x[i][j] + 1);
				else x[i + 1][j] = min(x[i + 1][j], x[i][j]);
			}
			if (j < b - 1) {
				if (c[i][j + 1] != c[i][j] && c[i][j + 1] == '#')x[i][j + 1] = min(x[i][j + 1], x[i][j] + 1);
				else x[i][j + 1] = min(x[i][j + 1], x[i][j]);
			}
		}
	}
	cout << x[a - 1][b - 1] << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		for (int i = 0; i < 9; i++) {
			String name = sc.next();
			int am = sc.nextInt();
			int pm = sc.nextInt();
			
			System.out.println(name + " " + (am + pm) + " " + (am * 200 + pm * 300));
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}

}

int32_t  main() {

	IOS;

	int K;

	cin >> K;
	
	int num = K;	
	
	int ans = 0;
	for (int i = 1; i <= num; i++) {

		for (int j = 1; j <= num; j++) {

			for (int k = 1; k <= num; k++) {

				ans += gcd(i, gcd(j, k));
			}

		}  
	}

	cout << ans << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    ll n;
    cin >> n;
    ll odd = 1;

    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) odd *= 2;
    }

    cout << (ll) pow(3, n) - odd << endl;

    return 0;
}



Measured memory_bytes: 512
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(x[N-1])

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

namespace ABC159
{
    class A
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            Console.WriteLine((n * (n - 1) / 2) + (m * (m - 1) / 2));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)
#define MOD 1000000007

int n;
long long memo[105][6][6][6];
long long func(int i, int p1, int p2, int p3){
	//cout<<" "<<p1<<" "<<p2<<" "<<p3<<endl;
	if(i>=n) return 1;
	if(memo[i][p1][p2][p3]!=-1) return memo[i][p1][p2][p3];
	long long p=0, q=0, r=0, s=0;
	p=func(i+1, 1, p1, p2)%MOD;
	if(!((p2==1 && p1==3) || (p3==1 && p2==3) || (p3==1 && p1==3) || (p2==3 && p1==1))) q=func(i+1, 2, p1, p2)%MOD;
	if(!(p2==1 && p1==2)) r=func(i+1, 3, p1, p2)%MOD;
	s=func(i+1, 4, p1, p2)%MOD;
	return memo[i][p1][p2][p3]=(p+q+r+s)%MOD;
}



int main(){
	cin>>n;
	memset(memo, -1, sizeof memo);
	long long ans = func(0, 0, 0, 0);
	cout<<ans<<endl;
	return 0;
}

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

static const LL INF = 1<<50;
static const LL mod = 100000;
typedef pair<int,int> pii;

LL N,M,place=1,ans;
LL a[100010];
LL day[100010];
LL k[100010];

int main(){
    cin>>N>>M;
    for(int i=1;i<N;++i){
        cin>>a[i];
    }
    for(int i=2;i<=N;++i){
        k[i]+=k[i-1]+a[i-1];
    }
    for(int i=1;i<=M;++i){
        cin>>day[i];
        int temp=k[place];
        place+=day[i];
        ans+=abs(k[place]-temp)%mod;
    }
    cout<<ans%mod<<endl;
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    ll cnt = 0;
    for(int i=1;i<=n;++i) {
      ll su = i;
      for(int j=i+1;j<=n;++j) {
        su += j;
        if(su == n) cnt++;
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3036
def main(s):
    sumval = 0
    #2 ** (入力文字列の長さ - 1)が探索範囲
    for i in range(2 ** (len(s) - 1)):
        #数式作成
        t = ""
        for j in range(len(s)):
            t += s[j]
            if (i >> j) & 1:
                t += "+"
        lst = list(map(int, t.split("+")))
        sumval += sum(lst)
    return sumval

s = input()
print(main(s))


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0; int maxnum = 0;
		int second = 0;
		int a = 0;
		for(int i = 0; i < n; i++){
			a = Integer.parseInt(sc.next());
			if(a > second) second = a;
			if(second > max){
			second = max; max = a; maxnum = i;
			}
		}
		for(int i = 0; i < n; i++){
			if(i != maxnum){
				System.out.println(max);
			}else{
				System.out.println(second);
			}
		}
}
}


Measured memory_bytes: 89368
#include <cmath>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
struct state { int pos, val; };
bool operator<(const state& s1, const state& s2) { return s1.val > s2.val; }
int N, K, a, b, c[100009], p[100009]; vector<int> g[100009];
int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b; a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fill(c, c + N, -1);
	fill(p, p + N, -1);
	cin >> K;
	priority_queue<state> que;
	for (int i = 0; i < K; i++) {
		cin >> a >> b, c[--a] = b;
		que.push(state{ a, b }); p[a] = b;
	}
	while (!que.empty()) {
		state u = que.top(); que.pop();
		for (int i : g[u.pos]) {
			if (p[i] == -1 || p[i] > p[u.pos] + 1) {
				p[i] = p[u.pos] + 1;
				que.push(state{ i, p[i] });
			}
		}
	}
	bool f = true;
	for (int i = 0; i < N; i++) {
		if (c[i] != -1 && p[i] != c[i]) f = false;
		for (int j : g[i]) {
			if (abs(p[i] - p[j]) != 1) f = false;
		}
	}
	if (!f) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < N; i++) cout << p[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8308
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int to, from, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
vector<int> makePrimes(int n) {
  vector<int> res, pr(n + 1, 1);
  pr[0] = pr[1] = 0;
  rep(p, 2, sqrt(n) + 2) 
    if (pr[p]) 
    for (int x = p * 2; x <= n; x += p) pr[x] = 0;
  rep(p, 2, n + 1) 
    if (pr[p]) 
      res.push_back(p);
  return res;
}
ll n, p;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  ll ans = 1LL, v = p;
  for (ll i = 2; i * i <= p; ++i) {
    ll s = 0;
    while (v % i == 0) {
      v /= i;
      s++;
    }
    ll cnt = s / n;
    if (cnt >= 1) {
      ans *= (ll)pow(i, cnt);
    }
    if (v <= 1) break;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef double db;
#define mk make_pair
#define pb push_back
#define pa pair<int,int>
using namespace std;

inline int rd() {
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
const int MAXN=1e5+10;
int N;
char s[MAXN];
int rt[MAXN];
int cnt,last;
vector<pa> e;
//main=============================
int main() {
	scanf("%s",s+1);
	N=strlen(s+1);
	if(s[1]=='0'||s[N]=='1') {
		puts("-1"),exit(0);
	} 
	for(int i=1;i<N;++i) if(s[i]!=s[N-i]) puts("-1"),exit(0);
	
	for(int i=1;i<=N;++i) if(s[i]=='1') {
		if(last) {
			e.push_back(mk(i,last));
		}
		for(int j=last+1;j<i;++j) e.push_back(mk(i,j));
		last=i;
	}
	e.push_back(mk(N,N-1));
	for(pa p:e) {
		printf("%d %d\n",p.first,p.second);
	}
	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
    int h,w;
    vector<vector<char> > s(55, vector<char>(55, '#'));
    vector<vector<int> > area(55, vector<int>(55, -1));
    cin >> h >> w;
    int white = 0;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> s[i][j];
            if(s[i][j] == '.') white++;
        }
    }
    queue<pair<int, int> > q;
    q.push(make_pair(1,1));
    area[1][1] = 1;
    int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
    int shotestpath = -1;
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        if(p.first == h && p.second == w){
            shotestpath = area[p.first][p.second];
            break;
        }
        for(int i = 0; i < 4; i++){
            int nextx = p.first + dx[i], nexty = p.second + dy[i];
            if(s[nextx][nexty] == '.' && area[nextx][nexty] == -1){
                area[nextx][nexty] = area[p.first][p.second] + 1;
                q.push(make_pair(nextx, nexty));
            }
        }
    }
    int ans = -1;
    if(shotestpath != -1) ans = white - shotestpath;
    cout << ans << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=["."*(W+2)]+["."+input()+"." for i in range(H)]+["."*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=="#":
            if S[i+1][j]=="." and S[i-1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	h, w, k := sc.getInt3()
	grid := make([][]rune, h)
	for i := range grid {
		grid[i] = sc.getRunes()
	}

	copyGrid := func(s [][]rune) [][]rune {
		ret := make([][]rune, h)
		for i := range ret {
			ret[i] = make([]rune, w)
			copy(ret[i], s[i])
		}
		return ret
	}

	ans := 0
	for bit1 := 0; bit1 < (1 << h); bit1++ {
		for bit2 := 0; bit2 < (1 << w); bit2++ {
			g := copyGrid(grid)
			for i := 0; i < h; i++ {
				if bit1&(1<<i) == 0 {
					continue
				}
				for j := 0; j < w; j++ {
					g[i][j] = 'r'
				}
			}
			for i := 0; i < w; i++ {
				if bit2&(1<<i) == 0 {
					continue
				}
				for j := 0; j < h; j++ {
					g[j][i] = 'r'
				}
			}

			cnt := 0
			for i := 0; i < h; i++ {
				for j := 0; j < w; j++ {
					if g[i][j] == '#' {
						cnt++
					}
				}
			}
			if cnt == k {
				ans++
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


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


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

   long long a;
   int cnt1=0;
   for (int i = 0; i < n; ++i){
      cin>>a;
      if(a%2==1)
         cnt1++;
   }

   int cnt2=n-cnt1;
   
   if(cnt1==0)
      cout<<"second"<<endl;
   else if(cnt2==0)
      cout<<"first"<<endl;
   else
      cout<<"first"<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] A = new int[M];

		for(int i=0;i<M;i++) {
			A[i] = scan.nextInt();
		}

		int homework=0;

		for(int i=0;i<M;i++) {
			homework += A[i];
		}

		if(homework <= N) {
			System.out.println(N-homework);
		}else {
			System.out.println(-1);
		}

		scan.close();
	}

}


Measured memory_bytes: 46544
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    int i;
    for (i = 0; i < n; i += 1000)
        ;
    cout << i - n << endl;
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		
		//n??¨m???????????\?????????int????????°???????´???????
		String s = scan.nextLine();
		String[] ary = s.split(" ");
		int n = Integer.parseInt(ary[0]);
		int m = Integer.parseInt(ary[1]);
		
		//n???????????±???????´???????
		ArrayList<String> array = new ArrayList<String>();
		for(int i = 0; i < n; i++) {
			array.add(scan.nextLine());
		}
		
		//????????????b???????´??????\?????????????´???????
		ArrayList<Integer> data = new ArrayList<Integer>();
		for(int i = 0; i < m; i++) {
			data.add(scan.nextInt());
		}
		
		//n???????????±???int??????????????????2?¬?????????????????´???????
		int [][] intArray = new int[n][m];
		for(int i = 0; i < n; i++) {
			String str = array.get(i);
			String [] strAry = str.split(" ");
			for(int j = 0; j < strAry.length; j++) {
				intArray[i][j] = Integer.parseInt(strAry[j]);
			}
		}
		
		//?¨???????????????????
		int[] sum = new int[n];
		for(int i = 0; i < intArray.length; i++) {
			for(int j = 0; j < intArray[i].length; j++) {
				sum[i] = sum[i] + (intArray[i][j] * data.get(j));
			}
		}
		
		//??¨?????????
		for(int i = 0; i < n; i++) {
			System.out.println(sum[i]);
		}
	}

}

Measured memory_bytes: 30124
n = list(input())
n = [int(i) for i in n]
n.reverse()
l = len(n)
ans = 0
for i in range(l-1):
    if (n[i]==5 and n[i+1]>=5) or n[i]>5:
        n[i+1] += 1
        ans += 10-n[i]
    else:
        ans += n[i]
ans += 11-n[-1] if n[-1]>5 else n[-1]
print(ans)


Measured memory_bytes: 141628
#include<iostream>
#define mod 1000000007
#define N 1000005
using namespace std;
long long a[N],ab[N],abc[N],x[N];
int main() {
	string s;
	cin>>s;
	x[0]=1;
	for(int i=0;i<(int)s.size();++i) {
		if(s[i]>='A'&&s[i]<='C') {
			x[i+1]=x[i],a[i+1]=a[i],ab[i+1]=ab[i],abc[i+1]=abc[i];
			if(s[i]=='A') (a[i+1]+=x[i])%=mod;
			if(s[i]=='B') (ab[i+1]+=a[i])%=mod;
			if(s[i]=='C') (abc[i+1]+=ab[i])%=mod;
		} else {
			x[i+1]=3*x[i]%mod;
			a[i+1]=(3*a[i]+x[i])%mod;
			ab[i+1]=(3*ab[i]+a[i])%mod;
			abc[i+1]=(3*abc[i]+ab[i])%mod;
		}
	}
	cout<<abc[s.size()];
	return 0;
}

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

using i64 = int64_t;

bool dp[100005]={0};

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    for(int i=1;i<=k;++i){
        for(int j=0;j<n;++j){
            if(i - v[j] < 0)continue;
            dp[i] |= !dp[i-v[j]];
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
int32_t main() {
    int n , x;
    cin>>n>>x;
    vector<int>v(n + 1);
    for(int i = 1; i <= n; ++i){
        cin>>v[i];
    }
    int req = 0;
    for(int i = 1 ; i <= n; ++i){
        int b = v[i] + v[i - 1];
        if(b > x){
            req += b - x;
            v[i] = x - v[i - 1];
        }
    }
    cout<<req<<"\n";
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	char Ball = 'A';
	char a,b;
	while(scanf("%c,%c",&a,&b)!=EOF)
	{
		if(a == Ball){
			Ball = b;
		}
		else if(b == Ball){
			Ball = a;
		}
	}
	printf("%c\n",Ball);
	return 0;
}

Measured memory_bytes: 544
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include <queue>
#include <functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    int n;
    cin >> n;
    map<int,int> mp;
    REP(i,n) {
        int tmp;
        cin >> tmp;
        int rate = tmp/400;
        if(rate>=8) rate = 8;
        mp[rate]++;
    }
    int anshigh = 0;
    int anslow = 0;
    
    REP(i,8){
        if(mp[i]>0) anslow++;
    }
    anshigh = anslow + mp[8];
    if(anslow==0) anslow = 1;
    
    cout << anslow << " " << anshigh << ENT;
    
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
using namespace std;

string s;
int alpha[26];

int main(){
    IOS;
    cin >> s;
    for(int i=0; i<s.size(); i++)
        alpha[s[i] - 'a']++;
    bool flag = true;
    for(int i=0; i<26; i++){
        if(!alpha[i]){
            cout << (char)('a' + i);
            flag = false;
            break;
        }
    }
    if(flag) cout << "None";
    cout << endl;
    return 0;
}


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

void listen_hills(std::vector<int> &hills);
void echo_top3(const std::vector<int> &hills);

int main()
{
	using namespace std;
	
	vector<int> hills;
	listen_hills(hills);
	sort(hills.begin(),hills.end(),greater<int>());
	echo_top3(hills);
	
	return 0;
}

void listen_hills(std::vector<int> &hills)
{
	using namespace std;
	int tmp;
	for(int hillCount=0;hillCount<10;hillCount++)
	{
		cin>>tmp;
		hills.push_back(tmp);
	}
}

void echo_top3(const std::vector<int> &hills)
{
	using namespace std;
	vector<int>::const_iterator itr=hills.begin();
	for(int count=0;count<3;count++)
	{
		cout<<*itr++<<endl;
	}
}

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

using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  vector<pair<int,int>> a;
  for(int i = 0; n > i; i++){
    int x;
    cin >> x;
    a.push_back({x,1});
  }
  for(int i = 0; m > i; i++){
    int x,y;
    cin >> x >> y;
    a.push_back({y,x});
  }
  sort(a.begin(),a.end(),greater<pair<int,int>>());
  long long ans = 0, sum = 0;
 
  for(auto itr : a){
    if(sum >= n) break;
    ans += min(n-sum, 1LL*itr.second) * 1LL * itr.first;
  	sum += itr.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
#define MAX 1000
#define VMAX 10000
int w[MAX];
bool done[MAX];

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

    int n, mini = VMAX;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        mp[w[i]] = 0;
        mini = min(mini, w[i]);
    }

    int k = 0;
    for (auto& p : mp) {
        p.second = k++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (done[i]) {
            continue;
        }
        int cnt = 0, cur = i, sum = 0, mi = VMAX;
        while (true) {
            if (done[cur]) {
                break;
            }
            cnt++;
            done[cur] = true;
            mi = min(mi, w[cur]);
            sum += w[cur];
            cur = mp[w[cur]];
        }
        int tmp = sum + (cnt - 2) * mi;
        tmp = min(tmp, sum + mi + mini * (cnt + 1));
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int h,k, c=0;
	cin>>h>>k;
	for(int i = 0 ; i < h ; i++)
	{
		int j; cin>>j;
		if(j>=k)
			c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main () {
	int n,i,c=0;
	cin >> n;
	int a[n],b[n-1];
	for(i=0;i<n;i++){
		cin >> a[i];
		if(i>0) b[i-1]=a[i]-a[i-1];
	}
	int max=b[0];
	for(i=0;i<n-1;i++){
		c+=b[i];
		if(c>max) max=c;
		if(c<=0) c=0;
	}
	cout << max << endl;
}

Measured memory_bytes: 2720
#include<stdio.h>
int main(){
    int i, max = 0, min = 0, sum = 0, n, tmp[1001] = {};
    for(;scanf("%d", &n), n != 0;){
        for( i = 0; i < n; i++ ){
            scanf("%d", &tmp[i]);
            sum += tmp[i];
            if( i == 0 ){
                min = tmp[i];
                max = tmp[i];
            }else if( max < tmp[i] ){
                max = tmp[i];
            }else if( min > tmp[i] ){
                min = tmp[i];
            }
        }
        sum = sum - max - min;
        printf("%d\n", sum / (n - 2));
        sum = 0;
        max = 0;
        min = 0;
    }
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s1>>s2;

	s1=s1+s2;

	k=stoi(s1);

	m=sqrt(k);

	if(m*m==k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int N,K;
    cin >> N >> K;
    int ans = 0;
    for(int i = K+1; i <= N; i++) {
        ans+=N/i*(i-K);
        if(N%i >= K) {
            ans+=N%i-K;
            if(K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi  vector<int>
#define pb  push_back
#define mp  make_pair
#define ALL(x) x.begin(),x.end()
#define M(a,x) memset(a,x,sizeof(a))
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define scs(x) scanf("%s",x);
#define SZ(x) (int)x.size()
#define print(x) printf("%d",x);
#define nl printf("\n")
#define fr first
#define se second
#define printl(x) printf("%lld",x)
#define F(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000LL
#define LL long long

const int N = 1e5+5;

int main() {
  int a,b;
  cin >> a >> b;
  if(a  > 0 )  {
    cout<<"Positive\n";return 0;
  }
  if(a <= 0 && b>=0) {
    cout<<"Zero\n"; return 0;
  }
  int temp = b-a+1;
  if(temp%2 == 0) {
     cout<<"Positive\n";return 0;
  }
  else {
    cout<<"Negative\n";
    return 0;
  }
}


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

using namespace std;

int main() {
	int n, p;
	while ( cin >> n >> p, n || p ) {
		vector<int> v(n, 0);
		int rest = p;
		int pos = 0;
		int ans = 0;
		int t = 0;
		while (++t < 1000001) {
			if (rest > 0) --rest, ++v[pos];
			else rest = v[pos], v[pos] = 0;

 			if (rest == 0 && v[pos] == p) {
				ans = pos;
				break;
			}
			pos = (pos + 1) % n;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
s = str(input())

j = 0
count = len(s)

s = [_ for _ in s]
for i in range(0, len(s)-1):
    if j+1 <= len(s)-1:
        if s[j] == s[j+1]:
            j = j + 3
            count -= 1
        else:
            j = j + 1
            continue

print(count)


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
int k,x;
int main(){
	scanf("%d%d",&k,&x);
	for(int i=max(x-k+1,-1000000);i<=min(1000000,x+k-1);i++){
		printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int i, j = 0;
	
	for ( i = 1; i < 10; i++ ) {
		for ( j = 1; j < 10; j++ ) {
			printf("%dx%d=%d\n", i, j, (i * j));
		}
	}
	
    return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
            char[] c1 = sc.nextLine().toCharArray();
            char[] c2 = sc.nextLine().toCharArray();

            int len = c1.length;
            int counter = 0;

            for (int i = 0; i < len; i++) {
            	if  (c1[i] != c2[i]) counter++;
            }



            System.out.println(counter);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

Measured memory_bytes: 43180
#include<stdio.h>//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10015
#include<stdlib.h>
int main(void){

	int card[4][13]={0},i,maisu,j;//スペード(S)=1,ハート(H)=2,クローバー(C)=3,ダイヤ(D)=4//
	char a[2];

	scanf("%d",&maisu);
	if(maisu>52)
		exit(0);

	for(j=0;j<maisu;j++){
		scanf("%s %d",a,&i);
		if(a[0]=='S'){
			card[0][i-1]=1;
		}else if(a[0]=='H'){
			card[1][i-1]=1;	
		}else if(a[0]=='C'){
			card[2][i-1]=1;	
		}else if(a[0]=='D'){
			card[3][i-1]=1;	
		}
	}
	for(i=0;i<4;i++)
		for(j=0;j<13;j++)
			if(card[i][j]==0){
				if(i==0)
					printf("S %d\n",j+1);
				if(i==1)
					printf("H %d\n",j+1);		
				if(i==2)
					printf("C %d\n",j+1);	
				if(i==3)
					printf("D %d\n",j+1);
			}
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// dp[i][j] := i番目の人まででj個の雨を分けるときの場合の数
// dp[0][0] = 1
// dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + ... + dp[i-1][j-a_{i}]
ll dp[110][101010];
ll dp_sum[110][101010];

const ll mod = 1e9 + 7;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n+1);
    rep(i, n) cin >> a[i+1];

    dp[0][0] = 1;
    for (int j = 0; j <= k; ++j) dp_sum[0][j] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= k; ++j) {
            dp[i][j] = dp_sum[i-1][j];
            if (j-a[i]-1 >= 0) dp[i][j] -= dp_sum[i-1][j-a[i]-1];
            if(j-1 >= 0) dp_sum[i][j] = dp_sum[i][j-1] + dp[i][j];
            else dp_sum[i][j] = dp[i][j];
            dp[i][j] %= mod;
            dp_sum[i][j] %= mod;
        }
    }

    cout << (dp[n][k] + mod) % mod << endl;
}


Measured memory_bytes: 162048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <numeric>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

lli knapsack_dp(vector<lli> &cost, vector<lli> &value, lli capacity){
    vector<lli> dp(capacity+1, 0);
    for(int i=0; i<(int)cost.size(); i++){
        for(int j=0; j<capacity; j++){
            if(j+cost[i] > capacity) break;
            dp[j+cost[i]] = max(dp[j+cost[i]], dp[j]+value[i]);
        }

    }
    return *max_element(dp.begin(), dp.end());
}

int main(){
    lli n,m,w,t;
    cin >> n >> m >> w >> t;
    
    map<string, pair<lli,lli>> s2cv;
    for(int i=0; i<m; i++){
        string s;
        lli c,v;
        cin >> s >> c >> v;
        s2cv[s] = {c, v};
    }
    vector<vector<pair<lli,lli>>> cv(n);
    vector<lli> x(n),y(n);
    for(int i=0; i<n; i++){
        int item;
        cin >> item >> x[i] >> y[i];
        for(int j=0; j<item; j++){
            string name;
            lli price;
            cin >> name >> price;
            auto ret = s2cv[name];
            cv[i].emplace_back(ret.first, ret.second -price);
        }
    }

    vector<lli> mindist(1<<n, inf);
    vector<lli> maxvalue(1<<n, 0);
    for(int i=1; i<(1<<n); i++){
        vector<int> idxs;
        for(int j=0; j<n; j++){
            if(i>>j&1) idxs.push_back(j);
        }
        do{
            lli dist = abs(x[idxs[0]])+abs(y[idxs[0]]) +abs(x[idxs.back()])+abs(y[idxs.back()]);
            for(int j=0; j<(int)idxs.size()-1; j++){
                dist += abs(x[idxs[j]]-x[idxs[j+1]]) +abs(y[idxs[j]]-y[idxs[j+1]]);
            }
            mindist[i] = min(mindist[i], dist);
        }while(next_permutation(idxs.begin(), idxs.end()));

        vector<lli> cost, value;
        for(int j: idxs){
            for(auto &p: cv[j]){
                cost.push_back(p.first);
                value.push_back(p.second);
            }
        }
        maxvalue[i] = knapsack_dp(cost, value, w);
    }

    cout << knapsack_dp(mindist, maxvalue, t) << endl;
    return 0;
}



Measured memory_bytes: 3308
from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def gcd_list(n):
    return reduce(gcd, n)

n, X = map(int, input().split())
x = list(map(int, input().split()))
dx = [abs(X - i) for i in x]
print(gcd_list(dx))

Measured memory_bytes: 14748
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int s,w;
  cin >> s >> w;
  bool hantei = false;
  if(s <= w)hantei = true;
  if(hantei){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
 }


Measured memory_bytes: 3676
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main() {
    int n;
    cin>>n;
    ll ar[n];
    int ans=0,mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    
    }
    sort(ar,ar+n);
    unordered_map<string,int> mp;
    int count=0;
    
    for (int i = 0; i < n-2; i++)
    { 
        for (int j = i + 1; j < n-1; j++)
        { 
            for (int k = j + 1; k < n; k++)
            {
                if (ar[i]!=ar[j] && ar[j]!=ar[k] && ar[k]!=ar[i] && ar[i] + ar[j] > ar[k])
                {
              count++;
                    
                }
                   
        }
        }
    }  
    cout<<count<<"\n";
return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
static const int N = 100;
void selectionSort(int [], int);
void swap(int *, int *);

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

  selectionSort(A, n);
  return 0;
}

void selectionSort(int A[], int n){
  int i, j, mini, count = 0;

  for(i = 0; i < n; i++){
    mini = i;
    for(j = i; j < n; j++){
      if(A[j] < A[mini]) mini = j;
    }
    if(i != mini){
      swap(&A[i], &A[mini]);
      count++;
    }
  }

  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i != n - 1)printf(" ");
  }
  printf("\n%d\n", count);
}

void swap(int *p, int *q){
  int swap;
  swap = *p;
  *p = *q;
  *q = swap;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int a[10];
int use[10];
int ans;

void dfs(int n){
  if(n==9){
    if(a[0]+a[2]+a[5]+10*(a[1]+a[4])+100*a[3]==100*a[6]+10*a[7]+a[8])ans++;
    return;
  }
  if(a[n]!=-1)dfs(n+1);
  else {
    for(int i=1;i<=9;i++){
      if(use[i])continue;
      use[i]++;
      a[n]=i;
      dfs(n+1);
      a[n]=-1;
      use[i]--;
    }
  }
}

int main(){
  for(int i=0;i<9;i++){
    cin>>a[i];
    use[a[i]]++;
  }
  dfs(0);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3092