akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=300000,ans=mzint;
  while(M--){
    int d=rand()%D,q=rand()%26,ans2=ans;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    if(ans2<ans)
      t[d]=q+1;
    else
      ans=ans2;
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3696
W, H, x, y, r = map(int, input().split())

def in_renge(low, high, max):
    return 0 <= low and high <=max
    
if in_renge(x - r, x + r, W) and in_renge(y - r, y + r, H):
    print('Yes')
else:
    print('No')





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

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        Scanner sc = new Scanner(in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x2000 = sc.nextInt();
        int x = x2000;
        for(int i=0; i<10; i++){
            x = r * x - D;
            System.out.println(x);
        }

    }

    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(m==1)
	cout<<"0";
	else if(m<=n)
	cout<<"1";
	else
	{
		int sum=n;
		for(int i=2;i<=30;i++)
		{
			sum=sum+n-1;
			if(sum>=m)
			{
				cout<<i;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#graph implementation
import math
ls=[]
for i in range(3):
    ls.append(list(map(int,input().split())))
ans=[[0,0,0],[0,0,0],[0,0,0]]
n=int(input())
for i in range(n):
    a=int(input())
    for j in range(3):
        for k in range(3):
            if a==ls[j][k]:
                ans[j][k]=1
res=[]
for i in range(3):
    total=0
    for j in range(3):
        total+=ans[i][j]
    res.append(total)
var=0
while var<3:
    total=0
    for i in range(3):
        total+=ans[i][var]
    var+=1
    res.append(total)
res.append(ans[0][0]+ans[1][1]+ans[2][2])
res.append(ans[0][2]+ans[1][1]+ans[2][0])
res.sort()
#print(res)
#print(ans)
if res[len(res)-1]==3:
    print("Yes")
else:
    print("No")

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

const int MOD = 1e9+7;
const int MAXN = 200101;

typedef struct def{
	int a,b,c;

	def(){}
	def(int a2, int b2, int c2){
		a = a2; b = b2; c = c2;
	}
	bool operator < (def comp) const{
		if(a!=comp.a) return a < comp.a;
		else return b < comp.b;
	}
} generico;

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

#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n, w;
int pes[123];
int val[123];

ll memo[123][101010];

int maxval;

ll solve(int at, int V){
	
	if(V == 0) return 0LL;
	if(at >= n || V < 0) return INF;
	
	if(memo[at][V] != -1) return memo[at][V];
	
	return memo[at][V] = min ( solve(at + 1 , V - val[at]) + pes[at] , solve(at + 1 , V) );
}

int main(){
	
	memset(memo, -1, sizeof memo);
	
	scanf("%d %d",&n, &w);
	
	for(int i = 0 ; i < n ; i ++){
		scanf("%d %d", &pes[i] , &val[i]);
		maxval += val[i];
	}
	
	for(int i = maxval ; i >=1 ; i --){ //percorre os possiveis valores pra DP
		
		if( solve(0, i)*1LL <= w ){
			printf("%d\n",i);
			return 0;
		}
	}
	
	return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 4");
            WillReturn.Add("2 1 3");
            WillReturn.Add("3 1 2 3");
            WillReturn.Add("2 3 2");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 5");
            WillReturn.Add("4 2 3 4 5");
            WillReturn.Add("4 1 3 4 5");
            WillReturn.Add("4 1 2 4 5");
            WillReturn.Add("4 1 2 3 5");
            WillReturn.Add("4 1 2 3 4");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 30");
            WillReturn.Add("3 5 10 30");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var AArrList = new List<int[]>();
        foreach (string EachStr in InputList.Skip(1)) {
            int[] wkArr = { };
            Action<string> SplitAct = pStr =>
                wkArr = pStr.Split(' ').Select(X => int.Parse(X)).Skip(1).ToArray();
            SplitAct(EachStr);
            AArrList.Add(wkArr);
        }

        var InterSectArrSet = new HashSet<int>(AArrList[0]);
        for (int I = 1; I <= AArrList.Count - 1; I++) {
            InterSectArrSet.IntersectWith(AArrList[I]);
        }
        Console.WriteLine(InterSectArrSet.Count);
    }
}


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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define vii vector<pair<int, int> >
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

const int N = 3e5 + 10;
int a[N];
int main(){
	boost;
	int n;
	cin >> n;
	n *= 3;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	int m = n / 3;
	ll sum = 0;
	while(m--){
		sum += a[n - 2];
		n -= 2;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1408
s=list(input())
q=int(input())
t1,t2=[],[]
cnt=0
for _ in range(q):
  t=list(input().split())
  if len(t)==1:
    cnt+=1
    t1,t2=t2,t1
  else:
    if int(t[1])==1:
      t1+=[t[2]]
    else:
      t2+=[t[2]]
if cnt%2==1:
  s=s[::-1]
u=t1[::-1]+s+t2
print(''.join(u))

Measured memory_bytes: 9864
from collections import deque
H,W=map(int,input().split())
mp=[['#']*(W+2)]
count=0
for _ in range(H):
    l=list(input())
    mp.append(['#']+l+['#'])
    count+=l.count('.')
mp.append(['#']*(W+2))

dist=[[-1]*(W+2)for _ in range(H+2)]
Q=deque()
Q.append((1,1))
dist[1][1]=1
f=False

while Q:
    y,x=Q.popleft()
    if (y,x)==(H,W):
        f=True
        break
    for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<H+2 and 0<=nx<W+2:
            if mp[ny][nx]=='.' and dist[ny][nx]==-1:
                Q.append((ny,nx))
                dist[ny][nx]=dist[y][x]+1

if f:
    print(count-dist[H][W])
else:
    print(-1)

Measured memory_bytes: 74088
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>

using namespace std;
int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	towns := make([]town, n)
	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d %d", &x, &y)
		towns[i] = town{x: x, y: y, i: i}
	}
	answer := averageLength(towns, n)
	fmt.Println(answer)
}

var sum float64

func averageLength(towns []town, n int) float64 {
	for i := 0; i < n; i++ {
		var others []town
		for j := 0; j < len(towns); j++ {
			if i != j {
				others = append(others, towns[j])
			}
		}
		traced := []town{towns[i]}
		factorialSum(towns[i], others, traced)
	}
	return sum / float64(factorial(n))
}

func factorialSum(prev town, remain []town, traced []town) {
	if len(remain) == 0 {
		for i := 0; i < len(traced)-1; i++ {
			sum += traced[i].distance(traced[i+1])
		}
		return
	}
	for i := 0; i < len(remain); i++ {
		var others []town
		for j := 0; j < len(remain); j++ {
			if i != j {
				others = append(others, remain[j])
			}
		}
		newtraced := append(traced, remain[i])
		factorialSum(remain[i], others, newtraced)
	}
}

func factorial(x int) int {
	if x == 1 {
		return x
	}
	return x * factorial(x-1)
}

type town struct {
	x int
	y int
	i int
}

func (t town) distance(u town) float64 {
	return math.Sqrt(float64((t.x-u.x)*(t.x-u.x) + (t.y-u.y)*(t.y-u.y)))
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
ll func(ll a){
  ll result=0LL;
  if(a%4LL==1LL||a%4LL==2LL)result++;
  for(int i=40;i>0;i--){
    ll bit=1LL<<i;
    if(a>=bit){
      result|=bit*((~a)&1LL);
      a-=bit;
    }
  }
  //cout<<result<<endl;
  return result;
}

int main(){ _;
  ll a,b;cin>>a>>b;
  cout<<(func(a-1)^func(b))<<endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll s,n,m;
ll f(ll b,ll n) {
    if(n<b) return n;
    else return f(b,n/b)+n%b;
}
int main() {
    cin>>n>>s;
    m=sqrt(n)+1;
    if(s>n){
        cout<<"-1"<<endl;
        return 0;
    }
    if(s==n){
        cout<<s+1<<endl;
        return 0;
    }
    for(int  i=2;i<=m;++i){
        if(f(i,n)==s){
            cout<<i<<endl;
            return 0;
        }
    }
    ll b,q,res=1e11;
    n-=s;
    for(ll p=1;p*p<=n;++p){
        if (n%p==0){
            b=n/p+1;
            q=s-p;
            if(q>=0&&b>=2&&q<b&&p<b) res=min(res,b);
        }
    }
    if(res==1e11) cout<<"-1\n";
    else cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
bool vis[105][100005];
int sum[105][100005],cnt[105][100005];
int N,K;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void dfs(int p,int d) {
    if(vis[p][d]) return;
    vis[p][d] = 1;
    if(p == 1) {
	cnt[p][d] = K + 1;sum[p][d] = (mul(2,MOD - d) + (K + 2) * (K - 1) / 2) % MOD;
	return ;
    }
    for(int i = 0 ; i < p ; ++i) {
	if(i > K) break;
	dfs(p - 1,d + (d + i) / p);
	update(cnt[p][d],cnt[p - 1][d + (d + i) / p]);
	update(sum[p][d],inc(sum[p - 1][d + (d + i) / p] ,mul(cnt[p - 1][d + (d + i) / p] ,inc(i, MOD - (d + i) / p))));
    }
    if(p <= K) {
	dfs(p - 1,d + 1 + d / p);
	update(cnt[p][d],cnt[p - 1][d + 1 + d / p]);
	update(sum[p][d],inc(sum[p - 1][d + 1 + d / p], mul(cnt[p - 1][d + 1 + d / p],inc(p, MOD - d / p - 1))));
    }
    for(int i = p + 1 ; i <= K ; ++i) {
	dfs(p - 1,d);
	update(cnt[p][d],cnt[p - 1][d]);
	update(sum[p][d],inc(sum[p - 1][d],mul(cnt[p - 1][d], i)));
    }
}
void Solve() {
    read(N);read(K);
    dfs(N,0);
    out(sum[N][0]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 90368
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long

using namespace std;
const int N=400+10,mod=998244353;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int n,a,pw[N],b,sa,sb,f[2][N][N],fac[N],iac[N];

int main()
{
	fac[0]=1;
	for(int i=1;i<=N-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
	iac[N-5]=ginv(fac[N-5]);
	for(int i=N-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
	n=rd();
	int nw=1,la=0;
	f[la][0][0]=mod-1;
	for(int i=1;i<=n;++i)
	{
		a=rd(),b=rd();
		pw[0]=1;
		for(int j=1;j<b;++j) pw[j]=1ll*pw[j-1]*a%mod;
		for(int j=0;j<=sa;++j)
			for(int k=0;k<=sb;++k)
			{
				if(!f[la][j][k]) continue;
				ad(f[nw][j][k],f[la][j][k]);
				for(int l=0;l<b;++l)
					ad(f[nw][j+a][k+l],mod-1ll*f[la][j][k]*pw[l]%mod*iac[l]%mod);
				f[la][j][k]=0;
			}
		nw^=1,la^=1;
		sa+=a,sb+=b-1;
	}
	int ans=0;
	for(int j=0;j<=sa;++j)
	{
		int w=ginv(j);
		for(int k=0,p=w;k<=sb;++k,p=1ll*p*w%mod)
			ad(ans,1ll*f[la][j][k]*p%mod*fac[k]%mod);
	}
	ans=1ll*ans*sa%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1536
q=int(input())
for _ in range(q):
    a_,b_=map(int,input().split())
    a=min(a_,b_)
    b=max(a_,b_)
    ng=b+1
    ok=1
    while ng-ok>1:
        mid=(ok+ng)//2
        m=-(-(a+mid)//2)
        if m==a:
          m-=1
        if (a+mid-m)*m<a*b:
            ok=mid
        else:
            ng=mid
    print(a+ok-2)

Measured memory_bytes: 9060
#include<stdio.h>
#include<string.h>
int main(void) {
    int n,leng,i=0;
    char s[101];
    scanf("%d\n", &n);
    gets(s);
    leng = strlen(s);
    if (leng<= n) {
        while (s[i] != '\0') {
            printf("%c", s[i]);
            i++;
        }
    }
    else {
        for (i = 0; i < n; i++) {
            printf("%c",s[i]);
        }
        printf("...");
    }
    return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>
int main(void)
{
    int a[110]= {0},i,n,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3&&a[i]%5)
            {
                count=1;
                break;
            }
        }
    }
    if(!count) printf("APPROVED");
    else printf("DENIED");

}


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

int main(){
	int a,cnt=0,di=0;
	cin>>a;
	
	for(int i=1;i<=a;i++){
		int j=i;
		while(j!=0){
			j/=10;
			di++;
		}
		
		if(di%2==1) cnt++;
		di=0;
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, m, q;
  cin >> n >> m >> q;
  int a[n + 1][n + 1];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      a[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    a[l][r]++;
  }
  int sum[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    sum[i][0] = 0;
    for (int j = 1; j <= n; j++) {
      sum[i][j] = sum[i][j - 1] + a[i][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    int count = 0;
    for (int j = l; j <= r; j++) {
      count += sum[j][r] - sum[j][l - 1];
    }
    cout << count << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
  long long N;
  cin >> N;
  for (int i = floor(sqrt(N)); i >= 1; i--) {
    if (N % i == 0) {
      long long ans = i + N / i - 2;
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int Q = GetInt();
		int H = GetInt();
		int S = GetInt();
		int D = GetInt();
		int N = GetInt();

		var tea = new List<Tuple<int, int, double>>();
		tea.Add(Tuple.Create(1, Q, (double)Q));
		tea.Add(Tuple.Create(2, H, (double)H/2.0));
		tea.Add(Tuple.Create(4, S, (double)S/4.0));
		tea.Add(Tuple.Create(8, D, (double)D/8.0));
		tea.Sort((x, y) => (x.Item3.CompareTo(y.Item3)));
		long tmp = (long)N * 4L;
		long ans = 0;
		for(int i = 0; i < 4; i++)
		{
			long num = tmp / (long)tea[i].Item1;
			tmp -= num * (long)tea[i].Item1;
			ans += num * (long)tea[i].Item2;
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var h = long.Parse(inputs[0]);
            var w = long.Parse(inputs[1]);

            for (var i = 0; i < h; i++)
            {
                var s = Console.ReadLine();
                Console.WriteLine(s);
                Console.WriteLine(s);
            }
        }
    }
}


Measured memory_bytes: 27548
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  //vector<vector<int>> water;
  double node = 0;
  pair<int,int> ans;
  for(int i=0;i*a<=f;i++){
    int A = i*a;
    for(int j=0;A+j*b<=f;j++){
      int B = j*b;
      int W = A + B;
      for(int k=0;W+k*c<=f;k++){
        int C = k*c;
        for(int l=0;W+C+l*d<=f;l++){
          int D = l*d;
          if(A+B+C+D == 0) continue;
          double n = 100.0*(double)(C+D)/((double)(C+D)+(double)(A+B));
          //cout << n << endl;
          
          if(100*(C+D) <= e*(A+B) && n >= node){
            //cout << n << endl;
            node = n;
            ans.first = A+B+C+D;
            ans.second = C+D;
          }
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << endl;
}



Measured memory_bytes: 256
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, 0, N) cin >> b[i];

    vector<int> moves;
    while (!b.empty())
    {
        bool erased = false;
        rrep(i, b.size() - 1, 0)
        {
            if (i + 1 == b[i])
            {
                moves.push_back(b[i]);
                b.erase(b.begin() + i);
                erased = true;
                break;
            }
        }
        if (!erased)
        {
            break;
        }
    }
    if (moves.size() == N)
    {
        rrep(i, N - 1, 0)
        {
            cout << moves[i] << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;

	if (N <
		1200) {
		out << "ABC" << endl;
	}
	else if (N < 2800) {
		out << "ARC" << endl;
	}
	else {
		out << "AGC" << endl;
	}

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string s;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> s;

	bool ok = false;
	for (size_t i = 2; i < s.size()-1; i++)
	{
		if (s[i] == 'C') {
			s[i] = 'c';
			ok = true;
			break;
		}
	}
	ok &= s[0] == 'A';

	for (size_t i = 1; i < s.size(); i++)
	{
		if ('a' <= s[i] && s[i] <= 'z') {
		}
		else {
			ok &= false;
		}
	}

	if (ok) {
		out << "AC" << endl;
	}
	else{
		out << "WA" << endl;
	}


	return 0;
}
#endif


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

const int maxn = 2e5 + 10;
int n;
long long A[maxn];

int main(){
    priority_queue<int>Q;

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

    sort(A,A+n);
    Q.push(A[n-1]);
    long long ans = 0;
    for(int i = n - 2;i >= 0;i--){
        ans += Q.top();
        Q.pop();
        Q.push(A[i]);
        Q.push(A[i]);
    }

    cout << ans << endl;
}

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

int main(void){
	int N,Y;
	cin >> N >> Y;
	bool flag=false;
	
	int x=(Y%5000)/1000;
	
	for(int i=0;i<((N+1-x)/5+1);i++){
		int remain_Y=Y-(x+i*5)*1000;
		int remain_N=N-(x+i*5);
		int j=0;
		
		if(((Y%10000)/1000)%10!=(x+i*5)%10){
			j++;
			remain_Y-=5000;
			remain_N--;
		}

		if(remain_Y>=5000*remain_N&&remain_Y<=10000*remain_N){
			j+=(remain_N-remain_Y/10000)*2;
			cout << N-x-i*5-j << " " << j << " " << x+i*5 << endl;
			flag=true;
			return 0;
		}
	}
	if(flag==false){
		cout << "-1 -1 -1" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = gets.split.map &:to_i

x3,y3,x4,y4 = 0

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)

puts [x3, y3, x4, y4].join(" ")

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

int main(void){
    int x, y;
    cin>>x>>y;
    rep(i,x){
        if(i*2+(x-i)*4==y){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3620
from fractions import gcd

a,b = map(int,input().split())
c = gcd(a,b)

ans = 0
i = 2
check = False
while c != 1:
    #print(c,i)
    while c % i == 0:
        #print('a')
        c = c // i
        check = True
    i = i + 1
    if check:
        ans += 1
    check = False
    if i > 1000000:
        print(ans+2)
        exit()
print(ans + 1)


Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

ll N,M,Q;
struct node
{
    ll a,c,d;
};
struct node2
{
	ll a,b,c,d;	
}qq[maxn];
vector<node> adj[maxn]; 
ll A[maxn];
ll res = 0;
int B[maxn],tail = 0;
void dfs(int id,int last = 1){
    if(id > N){
       	ll sum = 0;
       	for(int i = 1;i<=N;i++){
       		if(adj[i].size() == 0) continue;
       		for(auto no:adj[i]){
       			if(A[i] - A[no.a] == no.c) sum += no.d;
       		}
       	}
       	res = max(res,sum);
        return ;
    }
    A[id] = last;
    dfs(id+1,last);
    for(auto no:adj[id]){
        ll cur = A[no.a] + no.c;
        if(cur > M || cur < last) continue;
        else{
            A[id] = cur;
            dfs(id+1,cur);
        }
    }
}

int main(){
    // debug;
    ios;

    cin>>N>>M>>Q;
    for(int i = 1;i<=Q;i++){
        ll a,b,c,d; cin>>a>>b>>c>>d;
        adj[b].pb({a,c,d});
        qq[i] = {a,b,c,d};
    }
    dfs(1);
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 27116
from collections import Counter
n = int(input())
al = list(map(int,input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int,input().split())))

C_al = Counter(al)

wa = sum(al)

for i in range(q):
    dt =  bc[i][1]-bc[i][0]
    wa += C_al[bc[i][0]] * dt
    print(wa)
    C_al[bc[i][1]] += C_al[bc[i][0]]
    C_al[bc[i][0]] = 0


Measured memory_bytes: 40424
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

void io(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (sz(s)) {
    	setIn(s+".in");
    	setOut(s+".out");
    }
}

int N;
bool a,b;
vi v;
vpl todo;

bool ok(pl x, int k) {
    return abs(x.f)+abs(x.s) <= ((1LL<<k)-1);
}

void solve(pl x) {
    if (a) x.f --;
    string ans; F0R(i,31) ans += 'a';
    if (a) ans += 'R';
    F0Rd(i,31) {
        if (ok({x.f-(1<<i),x.s},i)) {
            ans[i] = 'R';
            x.f -= 1<<i;
        } else if (ok({x.f+(1<<i),x.s},i)) {
            ans[i] = 'L';
            x.f += 1<<i;
        } else if (ok({x.f,x.s-(1<<i)},i)) {
            ans[i] = 'U';
            x.s -= 1<<i;
        } else if (ok({x.f,x.s+(1<<i)},i)) {
            ans[i] = 'D';
            x.s += 1<<i;
        }
    } 
    assert(x == mp(0LL,0LL));
    cout << ans << "\n";
}

int main() {
    io();
    cin >> N;
    F0R(i,N) {
        int x,y; cin >> x >> y;
        if ((x+y) % 2 == 0) a = 1;
        else b = 1;
        todo.pb({x,y});
    }
    if (a&b) {
        cout << -1;
        exit(0);
    } 
    F0R(i,31) v.pb(1<<i);
    if (a) v.pb(1);
    cout << sz(v) << "\n";
    for (int i: v) cout << i << " ";
    cout << "\n";
    for (auto x: todo) solve(x);
}

/* 
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	bool flag = false;
	int n,x;
	for (scanf("%d",&n);n--;) {
		scanf("%d",&x);
		if (x&1) flag = true;
	}
	if (!flag) printf("second");
	else printf("first");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Card{ char suit, value; };

void bubble(struct Card A[], int N) {
  for(int i = 0; i<N; i++) {
    for(int j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for(int i=0;i<N;i++) {
    int minj = i;
    for(int j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for(int i=0; i<N; i++) {
    if(i>0) cout << " ";
      cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for(int i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(void) {
  Card C1[100], C2[100];
  int N;

  cin >> N;
  for(int i=0;i<N; i++) {
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    if a>0&&b>0 {println!("Positive")}
    else if a<0&&b<0 {println!("{}",if (a-b)%2==0{"Negative"}else{"Positive"})}
    else {println!("Zero")}
}

Measured memory_bytes: 2084
w,h,X,Y,C,t,b,d[9][9],q[9][9],a[]={-1,0,1,0};
Z(x,y){
	int i=0,s=1;
	if(q[y][x])return 0;
	q[y][x]=1;
	if(d[y][x])return y==Y&&x==X;
	for(;i<4;)s+=Z(x+a[i%4],y+a[i++]);
	return s;
}
B(x,y,c){
	int i=0;
	if(!(c||x-X||y-Y))return 1;
	memset(q,0,324);
	if(d[y][x]||Z(x,y)!=c+(x-X||y-Y))return 0;
	if(b++>120000)return 2;
	for(d[y][x]=1;i<4;)if(t=B(x+a[i%4],y+a[i++],c-1))return t;
	return d[y][x]=0;
}
main(i,j){
	for(;C=b=j=0,memset(d,-1,324),scanf("%d%d\n",&w,&h),h;puts(C<4||B(X,Y,C)-1?"No":"Yes"))
		for(;j++<h;)for(i=0;i++<w;)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
	exit(0);
}

Measured memory_bytes: 388
#include<stdio.h>

main()
{
	int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=(S%3600)/60;
	s=(S%3600)%60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
import java.util.*;
import java.lang.Object;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();

        for(int i = 0;i<10;i++){
            x = r*x - d;
            System.out.println(x);
        }

    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextLong()
    val b = sc.nextDouble()
    val c = Math.round(100 * b)
    println((a * c) / 100)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34592
#include<stdio.h>

int main()
{

  int all,h,w,y,s;
  scanf("%d %d",&h,&w);
  all = h*w;
  scanf("%d %d",&y,&s);

  all = all-y*w;
  all = all-(s*h);
  all = all+y*s;

  printf("%d\n",all);

  return 0;

}


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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > g(N);
    while(M--) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

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

    int ans = 0;
    do {
        if(c[0] != 0) {
            break;
        }
        bool ok = true;
        for(int i=0; i<N-1; i++) {
            if(find(g[c[i]].begin(), g[c[i]].end(), c[i+1]) == g[c[i]].end()) {
                ok = false;
            }
        }
        if(ok) {
            ans++;
        }
    } while(next_permutation(c.begin(), c.end()));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
const int N=1e5+10;
const int mod=1e9+7;
int qmi(int a,int b)
{
    int ans=1;
    while(b){
        if(b&1)ans=(ll)ans*a%mod;
        a=(ll)a*a%mod;
        b>>=1;
    }return ans;
}
ll f[N];
int main()
{
    int n,m;
    cin>>m>>n;
    for(int i=n;i>=1;i--)
    {
        ll sum=0;
        int h=n/i;
        sum=qmi(h,m);
        for(int j=i;j<=n;j+=i)
        {
            sum-=f[j];
        }
        f[i]=sum;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+(ll)f[i]*i%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

typedef long long int_type;
const int MAX_N = 1005;
int_type base = 1007;
int_type mod = 1000000007;
vector<int_type> pow1(MAX_N,1);
void pow_init() {
    for(int i=1;i<MAX_N;++i) {
        pow1[i] = pow1[i-1] * base % mod;
    }
}

struct RollingHash {

    vector<int_type> hash;

    RollingHash(){}

    void init(const string &s) {
        int n=s.size();
        hash.assign(n+1,0);
        for (int i=0;i<n;++i) {
            hash[i+1] = (hash[i]+s[i]) * base % mod;
        }
    }

    int_type get(int l, int r) {
        int_type t = (hash[r] - hash[l] * pow1[r-l] % mod + mod) % mod;
        return t; 
    }

};

int main() {
    pow_init();
    int N; cin >> N;
    vector<string> S(2*N);
    REP(i,N) cin >> S[i];
    REP(i,N) S[i] = S[i] + S[i];
    REP(i,N) S[i+N] = S[i];
    vector<string> T(2*N);
    REP(i,2*N)REP(j,2*N) T[i] += S[j][i];
    vector<RollingHash> yoko(2*N);
    vector<RollingHash> tate(2*N);
    REP(i,2*N) yoko[i].init(S[i]);
    REP(i,2*N) tate[i].init(T[i]);
    int ans = 0;
    REP(i,N)REP(j,N){
        bool flag = true;
        REP(k,N) if(yoko[i+k].get(j,j+N)!=tate[j+k].get(i,i+N)) flag = false;
        if(flag) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9088
#!/usr/bin/env python3
from collections import defaultdict
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    cities = sorted(
        (Yi, Pi, i)
        for i, (Pi, Yi) in enumerate(zip(P, Y))
    )
    ans = [""] * M
    cnt = defaultdict(int)
    for Yi, Pi, i in cities:
        cnt[Pi] += 1
        ans[i] = "%06d%06d" % (Pi, cnt[Pi])

    for ansi in ans:
        print(ansi)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37916
#include<string>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;

void dfs(vector<vector<int>> & Edge, vector<bool>& used, vector<int>& cmp, int n, int c) {
	used[n] = true;
	cmp[n] = c;
	for (int next : Edge[n]) {
		if (!used[next]) {
			dfs(Edge, used, cmp, next, c);
		}
	}
}


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, K, L; cin >> N >> K >> L;
	vector<vector<int>> Edge_road(N + 1);
	vector<vector<int>> Edge_rail(N + 1);
	map<pair<int, int>, int> m;
	vector<int> Ans(N + 1, 1);
	vector<int> cmp1(N + 1, -1),cmp2(N + 1, -1);
	vector<bool> used(N + 1, false);

	for (int i = 0; i < K; i++) {
		int p, q; cin >> p >> q;
		Edge_road[p].emplace_back(q);
		Edge_road[q].emplace_back(p);
	}
	for (int i = 0; i < L;i++) {
		int r, s; cin >> r >> s;
		Edge_rail[r].emplace_back(s);
		Edge_rail[s].emplace_back(r);
	}
	int c = 0;
	for (int i = 1; i <= N; i++) {
		if (!used[i]) {
			dfs(Edge_road, used,cmp1, i, c);
			c++;
		}
	}
	fill(used.begin(), used.end(), false);
	for (int i = 1; i <= N; i++) {
		if (!used[i]) {
			dfs(Edge_rail, used, cmp2, i, c);
			c++;
		}
	}

	for (int i = 1; i <= N;i++) {
		m[make_pair(cmp1[i], cmp2[i])]++;
	}
	for (int i = 1; i <= N;i++) {
		cout << m[make_pair(cmp1[i], cmp2[i])] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 28672
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n_orig = gets.chomp.to_i

if n_orig == 2
  puts 1
  exit
elsif n_orig == 3
  puts 2
  exit
elsif n_orig == 4
  puts 3
  exit
elsif n_orig == 5
  puts 3
  exit
end

de = false

root = Math.sqrt(n_orig).to_i
p ['root', root] if de
div = n_orig - 1

ans = 0
2.upto(root) do |i|
  n = n_orig
  while n % i == 0
    n /= i
  end
  n %= i # =
  if n == 1
    p ['i', i] if de
    ans += 1
    if div % i == 0 && div/i > root
      p ['div', div / i] if de
      ans += 1
    end
  end
end
puts ans + 2

Measured memory_bytes: 2300
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
 
using namespace std;
 
int main(){
    long long N,H;
    cin>>N>>H;
    vector <long long>a(N);
    vector <long long>b(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
        cin>>b[i];
    }
    bool t=true;
    long long a_max=0;
    long long a_m=0;
    long long b_m=0;
    long long ans=0;
    for(long long i=0 ; i<N ; i++){
        if(a[a_max]<a[i]){
            a_max=i;
        }
    }
    a_m=a[a_max];
    b_m=b[a_max];
    //a[a_max]=0;
    b[a_max]=0;
    if(b_m>=H)t=false;
    //sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(long long i=N-1 ; i>0 ; i--){
        if(a_m<b[i]){
            H-=b[i];
            ans+=1;
        }
        if(H<=0){
            break;
        }
        if(H<=b_m){
            ans+=1;
            H=0;
            break;
        }
    }
    if(H>0){
        while(1){
            if(H<=b_m){
                ans+=1;
                break;
            }
            ans+=1;
            H-=a_m;
            if(H<=0)break;
        }
    }
    if(t)cout<<ans<<endl;
    else cout<<1<<endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL gcd(LL x, LL y){
  if(y == 0) return x;
  return gcd(y, x%y);
}

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

  LL N, X;
  cin >> N >> X;
  VL xs(N);
  cin >> xs;

  LL g = 0;
  for(auto x: xs){
	LL y = abs(x - X);
	g = gcd(y, g);
  }
  cout << g << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
N, L = map(int, input().split())
ajiList = []
absList = []
for i in range(N):
    ajiList.append(i + L)
    absList.append(abs(i + L))
s = sum(ajiList)
m = min(absList)
if s > 0:
    ans = s - min(absList)
else:
    ans = s + min(absList)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main (void)

{  

   int a,b,c,i,count=0;  

   scanf("%d %d %d",&a,&b,&c);  

   for(i=a;i<=b;i++)

   {   

         if(c%i == 0)

         {    

            count++;   

         }  

   }  

   printf("%d\n",count);  

   return 0;  

}

Measured memory_bytes: 596
fun main(args: Array<String>){
    val (K, N) = readLine()!!.split(" ").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toInt()}
    
    var ans = A[N-1] - A[0]
    for(i in 1 until N){
        ans = Math.min(ans, K - A[i] + A[i-1])
    }
    println(ans)
}

Measured memory_bytes: 83208
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long x;
long long a[200003];
long long n,l,r,ans;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
}
ans=n;
r=1LL;
for(l=1;l<=n;l++)
{
	x^=a[l-1];
	r=max(r,l);
	long long ans1=0LL;
	while((r<=n)&&((x^a[r])==(x+a[r])))
	{
//		cout<<(x^a[r])<<" "<<(x+a[r])<<endl;
		x^=a[r];
		r++;
		ans1++;
	}
//	cout<<ans1<<endl;
	ans+=r-l-1;
//	ans+=ans1;
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222




ll num[MAX], dist[MAX], idx[MAX];
ll start[MAX];
bool b[MAX];


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



  cin >> n >> m;
  vll a(n), v;
  rep(i, n) cin >> a[i];
  rrep(i, n) {
    idx[a[i]] = i + n;
  }
  rrep(i, n) {
    dist[i] = idx[a[i]] - i;
    idx[a[i]] = i;
  }
  num[0]++;
  ll cur = 0;
  while (num[0] < 2) {
    cur += dist[cur%n] + 1;
    num[cur%n]++;
    start[cur / n] = cur % n;
  }
  cur = m % (cur / n);
  cur = cur - 1;
  if (cur < 0) cur = 0;
  else cur = start[cur];
  while (cur != n) {
    if (b[a[cur]]) {
      tmp = v.size();
      rrep(i, tmp) {
        if (v[i] == a[cur]) {
          b[v[i]] = false;
          v.pop_back();
          break;
        }
        else {
          b[v[i]] = false;
          v.pop_back();
        }
      }
    }
    else {
      v.pb(a[cur]);
      b[a[cur]] = true;
    }
    cur++;
  }
  rep(i, v.size()) cout << v[i] << " ";
  cout << endl;


  return 0;
}


Measured memory_bytes: 11632
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n;
int a[maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
}

void solve()
{
    int all = 0;
    for(int i = 1; i <= n; i += 2)
        all ^= (a[i] ^ a[i + 1]);
    for(int i = 1; i <= n; ++i)
        cout << (all ^ a[i]) << ' ';
    cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 4380
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B = nl()

if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long

using namespace std;
int32_t main()
{
    unsigned int a, b, c=1;
    double l;
    cin >> a;
    while(a--)
    {
      cin >> b;
      c *= b;
      if(b==0) cout<<0<<endl,exit(0);
      l += log10((double) b); 
    }
    if(l>18.00 || c > 1000000000000000000L) cout<<-1<<endl, exit(0);
    cout<<c<<endl;
}

Measured memory_bytes: 3944