akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int mod0 = 0;
        int modn2 = 0;
        for(int i = 1; i <= n; i++){
            if(i % k == 0){
                mod0++;
            }else if(k%2==0 && i%k==k/2){
                modn2++;
            }
        }
        System.out.println((long)Math.pow(mod0,3) + (long)Math.pow(modn2,3));
    }
    public static int nCk(int n,int k,int M) {
        long ret = 1;
        if(n < k)return 0;
        int min = Math.min(k, n-k);
        for(int i=1;i<=min;i++) {
            ret = (ret * pow(i,M-2,M)) % M;
        }
        for(int i=n-min+1;i<=n;i++) {
            ret = (ret * i) % M;
        }
        return (int)ret;
    }

    public static long pow(long a,long b,int M) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1){
                ret = (ret * tmp) % M;
            }
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }
        return ret;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21204
def compute():
    from sys import stdin
    S = stdin.readline().strip()

    wew = []
    for x in S:
        if len(wew)>0 and wew[-1]!=x:
            wew.pop()
        else:
            wew.append(x)

    print(len(S) - len(wew))

if __name__ == "__main__":
    compute()


Measured memory_bytes: 46448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    int ans=0;
    if(a>=500)
    {
        ans+=(a/500)*1000;
        a=a%500;
    }

    if(a<500)
    {
        ans+=(a/5)*5;
    }


    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int A = rei();
	int B = rei();
	cout << min(A,B) << " ";
	cout << max(0,A+B-N) << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using ll = long long;
using ld = long double;
using Graph = vector<vector<ll>>;

int main(void)
{
    ll k,a,b;
    cin >> k;
    cin >> a >> b;
    bool judge=false;
    for(int x=a/k;x*k<=b;x++)
    {
        if(x*k>=a && x*k<=b)
        {
            judge=true;
        }
    }
    if(judge)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100010;
int given[MAXN], visited[MAXN], lb[MAXN], ub[MAXN], res[MAXN];

int n, k, a, b;

VVI adj;

void combine(int u, int v) {
    if (lb[v] == -INF) {  // child not initialized
        return;
    }
    else if (lb[v] == INF) {
        lb[u] = INF;
    }
    else if (lb[u] == -INF) {  // self not initialized
        lb[u] = lb[v] - 1;
        ub[u] = ub[v] + 1;
    }
    else if (lb[u] == INF || (abs(lb[u] - lb[v]) % 2 != 1)) {  // not valid
        lb[u] = INF;
    }
    else if (lb[v] - 1 > ub[u] || ub[v] + 1 < lb[u]) {  // no overlap
        lb[u] = INF;
    }
    else {
        lb[u] = max(lb[u], lb[v] - 1);
        ub[u] = min(ub[u], ub[v] + 1);
    }
}

void dfs(int u) {
    visited[u] = 1; lb[u] = -INF; ub[u] = INF;

    for (auto& v : adj[u]) {
        if (!visited[v]) {
            dfs(v);
            combine(u, v);
        }
    }

    if (given[u] >= 0) { 
        if (lb[u] == -INF || (given[u] >= lb[u] && given[u] <= ub[u] && (given[u] - lb[u]) % 2 == 0)) {
            lb[u] = ub[u] = given[u];
        }
        else {
            lb[u] = INF;
        }
    }

//    DEBUG(u);
//    DEBUG(lb[u]);
//    DEBUG(ub[u]);
}

void dfs2(int u, int p) {
    visited[u] = 1;

    if (u == 1) {
        res[1] = (lb[1] == -INF) ? 0 : lb[1];
    }
    else if (res[p] - 1 >= lb[u] && res[p] - 1 <= ub[u]) {
        res[u] = res[p] - 1;
    }
    else {
        res[u] = res[p] + 1;
    }
    
    for (auto& v : adj[u]) {
        if (!visited[v]) {
            dfs2(v, u);
        }
    }
}

int main() {
    GI(n); adj.resize(n+1);

    FORN(i, n-1) {
        GI(a); GI(b);
        adj[a].PB(b);
        adj[b].PB(a);
    }

    GI(k); memset(given, -1, sizeof given);

    FORN(i, k) {
        int v; int p; GI(v); GI(p);
        given[v] = p;
    }

    memset(visited, 0, sizeof visited);
    dfs(1);

    if (lb[1] == INF) {
        printf("No\n");
        return 0;
    }

    memset(visited, 0, sizeof visited);
    dfs2(1, 1);

    printf("Yes\n");
    FOR1(i, n) printf("%d\n", res[i]);

    return 0;
}

Measured memory_bytes: 13056
while True:
 n = input()
 if n == 0:
  break
 s = [0]*2
 for i in xrange(n):
  r = [int(c) for c in raw_input().split()]
  if r[0] == r[1]:
   s[0]+=r[0];s[1]+=r[1]
  elif r[0] > r[1]:
   s[0]+=sum(r)
  else:
   s[1]+=sum(r)
 print s[0],s[1]

Measured memory_bytes: 6456
MOD = 1000000007

def h(m,n):
	if n == 1:
		return m % MOD
	temp = h(m, n//2)**2
	temp *= m if n%2==1 else 1
	return temp % MOD

def main():
	m,n = map(int, input().split())
	print(h(m,n))
	return

main()



Measured memory_bytes: 5600
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	vector<pair<double, double>> wow;
	REP(i, 3) {
		double a, b;
		cin >> a >> b;
		wow.push_back(make_pair(a, b));
	}
	wow.push_back(wow[0]);
	vector<double> lines;
	for (int i = 0;i < 3;++i) {
		lines.push_back(sqrt((wow[i].first - wow[i + 1].first) * (wow[i].first - wow[i + 1].first) + (wow[i].second - wow[i + 1].second) * (wow[i].second - wow[i + 1].second)));
	}
	double s = (lines[0] + lines[1] + lines[2]) / 2.0;
	double r = s;
	for (int i = 0;i < 3;++i) {
		r *= (s - lines[i]);
	}
	r = sqrt(r);
	r = (2 * r) / (lines[0]+lines[1]+lines[2]);
	double maximu = max({ lines[0],lines[1],lines[2] });
	cout <<fixed << setprecision(10) << (maximu * r) / (maximu + 2 * r) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e6+2;
int add(int a,int b)
{
      a+=b;
      if(a>=MOD) a-=MOD;
      return a;
}
int sub(int a,int b)
{
      a-=b;
      if(a<0) a+=MOD;
      return a;
}
int mul(int a,int b)
{     
      return ((long long)a*b)%MOD;
}
int rev(int a)
{
	return mpow(a,MOD-2);
}
int fac[N];
int nck(int n,int k)
{
	// cout<<fac[n+k-1]<<" ";
	int ans=mul(rev(fac[k]),mul(fac[n],rev(fac[n-k])));
	return ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,k;
	cin>>n>>k;
	fac[0]=1;
	for(int i=1;i<N;i++)
	{
		fac[i]=mul(fac[i-1],i);
	}
	if(k>=n)
		cout<<nck(n+n-1,n-1);
	else{
		int left=n-k;
		// n-=left;
		int ans=0;
		for(int i=0;i<=k;i++)
		{
			// cout<<n-i-1<<" ";
			// cout<<n-i<<" ";
			ans+=mul(nck(n,i),nck(n-1,n-i-1));
			ans%=MOD;
		}
		cout<<ans;
	}
} 
// I never lose. I either win or I learn

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+5;
const long long mod = 1000000007;
long long Hash[maxn];
long long ans[maxn];
int dir[9][2]={-2,-2,-2,-1,-2,0,-1,-2,-1,-1,-1,0,0,-2,0,-1,0,0};
int t;
int main(){
	long long H,W,N;
	cin>>H>>W>>N;
	long long Ans=(long long)(H-2)*(long long)(W-2);
	for(int i=1;i<=N;i++){
		int x,y;
		cin>>x>>y;
		for(int j=0;j<=8;j++){
			int xx=x+dir[j][0];
			int yy=y+dir[j][1];
			if(xx>=1 && xx<=H-2 && yy>=1 && yy<=W-2){
				Hash[t++]=xx*mod+yy;
			}
		}
	}
	sort(Hash,Hash+t);
	int num=1;
	for(int i=0;i<t;i++){
		if(Hash[i]==Hash[i+1]) num++;
		else{
			ans[num]++;
			num=1;
			Ans--;
		}
	}
	cout<<Ans<<endl;
	for(int i=1;i<=9;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 8960
#include <stdio.h>
#include <string.h>


int main(void) {

	char str[100000];
	int flag = 0;
	int size;
	int i;
	int count = 0;
	int judge = 0;
	char tmp;
	char* adr;

	scanf("%s", str);

	size = strlen(str);

	
	for ( i = 0; i < size / 2; i++)
	{
		tmp = str[i];
		str[i] = str[size - i - 1];
		str[size - i - 1] = tmp;
	}
	

	do
	{
		adr = strstr(str, "remaerd"); 
		if (adr && (adr - str) == count) 
        {
			strncpy(adr, "0000000", 7);
			count += 7; 
			judge = count;
			continue;
		}

		adr = strstr(str, "resare");
		if (adr && (adr - str) == count)
		{
			strncpy(adr, "000000", 6);
			count += 6;
			judge = count;
			continue;
		}

		adr = strstr(str, "maerd");
		if (adr && (adr - str) == count)
		{
			strncpy(adr, "00000", 5);
			count += 5;
			judge = count;
			continue;
		}

		adr = strstr(str, "esare");
		if (adr && (adr - str) == count)
		{
			strncpy(adr, "00000", 5);
			count += 5;
			judge = count;
			continue;
		}

		if (judge == count) break;

	} while (adr);

	adr = str;

	for ( i = 0; i < size; i++)
	{
		if (*adr != 48) {
			flag = 1;
			break;
		}
		adr++;
	}
	

	if (flag) printf("NO");
	else printf("YES");


	return 0;

}

Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {

    int n,m;
    cin >> n >> m;

    int a[m];
    for(int i=0; i<m; i++) cin >> a[i];
    
    int total = 0;
    
    for(int i=0; i<m; i++){
        total += a[i];
    }
    
    int judge = n-total; //夏休みの日数から宿題のトータル日数をマイナス
    
    if(judge<0) //はたして高橋君は宿題を終えることができるのか。。
        cout << "-1" << endl;
    else
        cout << judge << endl;
    
    return 0;
    
}


Measured memory_bytes: 3644
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	long a, b, c;
	cin >> a >> b >> c;
	long A, B, C;
	long result = 0;
	for (int i = 0; i < 100000000; i++) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << result << endl;
			return 0;
		}
		A = a / 2;
		B = b / 2;
		C = c / 2;
		a = B + C;
		b = A + C;
		c = A + B;
		result++;
	}
	cout << "-1" << endl;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
import numpy as np
 
N = int(readline())
XY = np.array(read().split(),np.int64)
 
X = XY[::2]; Y = XY[1::2]
 
dx = X[:,None] - X[None,:]
dy = Y[:,None] - Y[None,:]
 
dist_mat = (dx * dx + dy * dy) ** .5
 
answer = dist_mat.sum() / N
print(answer)

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

int main(void){
  int n;
  string s;
  cin >> n >> s;
  
  string ans;
  if (n % 2 == 1){
    ans = "No";
  } else{
    int h = n / 2;
    if(s.substr(0, h) == s.substr(h, n)){
      ans = "Yes";
    } else{
      ans = "No";
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n=I()
lis=list(SI())
orig=0
for i in range(n):
    if lis[i]=="0":
        lis[i]=0
    else:
        lis[i]=1
orcount=sum(lis)
m1=0
m3=0
if orcount==1:
    for i in range(n):
        if lis[i]==1:
            m3=(m3+pow(2,n-i-1,orcount+1))
elif orcount>1:
    for i in range(n):
        if lis[i]==1:
            m1=(m1+pow(2,n-i-1,orcount-1))
            m3=(m3+pow(2,n-i-1,orcount+1))
        
        
m1=m1
m3=m3
#print(m1)
#print(m3)
#print(orig)
dp=[0 for i in range(n+1)]
dp[1]=1
for i in range(1,n):
    #u=count1(i+1)
    count=0
    j=0
    while pow(2,j)<=i+1:
        if ((i+1)>>j) %2==1:
            count+=1
        j+=1
    z=1
    dp[i+1]=z+dp[(i+1)%count]
#print(dp)
for i in range(n):
    if lis[i]==0:
        #num=orig+pow(2,n-i-1)
        pr=orcount+1
        num=m3+pow(2,n-i-1,pr)
    else:
        #num=orig-pow(2,n-i-1)
        pr=orcount-1
        if pr!=0:
            num=m1-pow(2,n-i-1,pr)
    #print(num,pr)
    if pr==0:
        print(0)
    else:
        print(1+dp[num%pr])


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

namespace ABC143C
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputInt = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            //var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();



            int ans = 1;
            char lastChar = S[0];
            for(int i = 1; i < S.Length; i++)
            {
                if (S[i] != lastChar)
                {
                    ans++;
                    lastChar = S[i];
                }
            }

            //string ans = "";

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
/* Code by pedroslrey *
 *     march 7        *
 *    Starurday       */

#include <bits/stdc++.h>

using namespace std;

using lli = long long int;

const int INF = 1000000007;
const lli LLINF = 9223372036854775800;

#define debug(args...) fprintf(stderr, args)
#define show(x) fprintf(stderr, "[DEBUG] -> %d\n", x)

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int i = 0; i <= 10010; ++i) {
		if ((int)(((float)i)*0.08) == a && (int)(((float)i)*0.1) == b) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,sum,minus,mix;
    cin>>A>>B;
    
    sum=A+B;
    minus=A-B;
    mix=A*B;
    
    
    int num=sum;
    
    if(minus>num){
        num=minus;
    }
    if(mix>num){
        num=mix;
    }
    
    cout<<num<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N=int(input())
Participant=[int(i) for i in input().split()]
Point=[0,399,799,1199,1599,1999,2399,2799,3199]
n=0
Colors=0
Any_Colors=0
while n<=len(Point)-2:
  for i in Participant:
    if Point[n]<i<=Point[n+1]:
      Colors+=1
      break
  n+=1
for i in Participant:
  if Point[len(Point)-1]<i:
    Any_Colors+=1
max_Colors=Colors+Any_Colors
if Colors==0 and Any_Colors>0:
  min_Colors=1
elif Colors>0:
  min_Colors=Colors
print(min_Colors,max_Colors)
  



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

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

int main(){
  long long x;
  cin >> x;

  int y=0;
  int64_t yokin = 100;

  while(yokin<x){
    yokin = yokin * 1.01;
    y++;
  }

  cout << y;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int n;
    scanf("%d",&n);
    int a = 2;
    while(a <= n){
        a *= 2;
    }
    if(a > n)
        a /= 2;
    printf("%d\n",a);
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static final int MOD = 998244353;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        Combination comb = new Combination((int)(1e5*4.1), MOD);
        
        long ans = 0;
        for(int i=0; i<=k; i++){
            long tmp = m * comb.mod_pow(m-1, n-1-i, MOD) % MOD;
            long z = comb.c(n-1, i);
            //System.out.println(z);
            tmp = tmp * z % MOD;
            ans += tmp;
            ans %= MOD;
        }
        
        System.out.println(ans);
        
    }
    
    
}

class Combination{
    int mod;
    long[] fact;
    long[] rfact;
    
    public Combination(int max, int mod){
        this.mod = mod;
        fact = new long[max];
        rfact = new long[max];
        fact[0] = 1;
        rfact[0] = 1;
        for(int i=1; i<max; i++){
            fact[i] = (fact[i-1]*i)%mod;
            rfact[i] = mod_inverse(fact[i], mod);
        }
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    public static long mod_inverse(long a, long m){
        return mod_pow(a, m-2, m);
    }
    
    public long p(int n, int r){
        if(r < 0 || n < r) return 0;
        return fact[n] * rfact[r]%mod;
    }
    
    public long c(int n, int r){
        if(r < 0 || n < r) return 0;
        return fact[n] * rfact[r]%mod * rfact[n-r]%mod;
    }
    
    public long h(int n, int r){
        if(n < 0 || r < 0) return 0;
        return r==0 ? 1 : c(n+r-1, r);
    }
}


Measured memory_bytes: 33628
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int X = stdIn.nextInt();
        int Y = stdIn.nextInt();
        int Z = stdIn.nextInt();
        stdIn.close();

        int A = 0;
        int B = 0;

        A = X;
        X = Y;
        Y = A;

        B = X;
        X = Z;
        Z = B;

        System.out.printf("%d %d %d", X, Y, Z);
    }
}

Measured memory_bytes: 21972
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N, L;
	cin >> N >> L;
	vector<string>str;
	string s;
	for (int i = 0;i < N;i++) {
		cin >> s;
		str.push_back(s);
	}
	sort(str.begin(), str.end());
	for (int i = 0;i < N;i++)cout << str[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >> A >> B;
    cout <<max(A-2*B,0) << endl;



}


Measured memory_bytes: 256
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
    
def knapsack(wts,P,N,W):
    if N==0 or W == 0:
        return 0
    dp = list2d(100,100001,1e10) #dp[item][val] = weight
    dp[0][0] = 0
    dp[0][P[0]] = wts[0]
    ##we have to minimize the weight
    for i in range(1,N):
        dp[i][0] = 0
        for j in range(1,100000+1):
            dp[i][j] = dp[i-1][j] # discarding current
            if P[i] <= j:
                dp[i][j] = min(wts[i] + dp[i-1][j - P[i]] , dp[i][j])
            
    #minimum weight
    for val in range(100000,-1,-1):
        if dp[N-1][val] <= W:
            return val #returning the val at maximum weight
    

N,W = ilele()
P = []
A = []
for i in range(N):
    a,b =ilele()
    A.append(a)
    P.append(b)
print(knapsack(A,P,N,W))
    

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

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

    cin>>s;
    int ok =1;
    int ans = 0;
    int i = 0,j = s.length()-1;
    while(i < j){
        if(s[i]==s[j]){
            i++; j--;
        }
        else{
            if(s[i]=='x'){
                ans++;
                i++;
            }
            else if(s[j]=='x'){
                ans++;
                j--;
            }
            else{
                cout<<-1;
                ok = 0;
                break;
            }
        }
    }
    if(ok) cout<<ans<<endl;

    return 0;
}

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

int tanku[5] = {5, 7, 5, 7, 7};

int main(){
    
    for(int n; cin >> n, n;){
        vector<int>v(n);
        for(int i = 0; i < n; i++){
            string s;
            cin >> s;
            v[i] = s.size();
        }
        for(int i = 0; i < n; i++){
            int flg = 0;
            int x = 0, y = 0;
            for(int j = i; j < n; j++){
                x += v[j];
                if(x > tanku[y])break;
                if(x == tanku[y]){
                    x = 0;
                    y++;
                }
                if(y == 5){
                    flg = 1;
                    break;
                }
            }
            if(flg){
                cout << i + 1 << endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max( a,max(b,c) )-min( a,min(b,c) ) << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k,i;
        cin>>n;
        if(n==1)
        {
            cout<<0<<endl;
        }
        else if(n==0)
        {
            cout<<1<<endl;
        }

    }

}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextLine()) {
			int row = scan.nextInt();
			int col = scan.nextInt();
			
			if(row == 0 && col == 0) break;
			
			for(int i=0; i<row; i++) {
				for(int j=0; j<col; j++) {
					if((i+j)%2==0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
						
			System.out.println();
		}
	}
}






Measured memory_bytes: 34596
#include<cstdio>
int n,k,i,j,l,a[300005];int main(){scanf("%d%d",&k,&n);if(k&1){while(j<n)a[j++]=k+1>>1;for(j=n;i<n-1;i+=2)if(--a[--j])while(++j<n)a[j]=k;while(l<j)printf("%d ",a[l++]);}else{for(;i<n;i++)printf("%d ",k/(1+!i));}}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll d=a-b;
  c=max(0LL,c-d);
  pr(c);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;
int x, d;
int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>x>>k>>d;
	x = abs(x);
	int qtd = min(k, x/d);
	x -= qtd*d;
	k -= qtd;

	// cout<<"X = "<<x<<" "<<qtd<<" "<<k<<"\n";
	if(k % 2 == 0) cout<<x<<"\n";
	else cout<<abs(x - d)<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

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

int main() {
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    int dist=K-A.at(N-1)+A.at(0),maxdist=K-A.at(N-1)+A.at(0);
    for(int i=1;i<N;i++){
        dist+=A.at(i)-A.at(i-1);
        if(maxdist<A.at(i)-A.at(i-1)){
            maxdist=A.at(i)-A.at(i-1);
        }
    }
    cout << dist-maxdist << endl;
    
}


Measured memory_bytes: 1024
# マイナスが大きいものの開催頻度をあげる
d=int(input())
c= list(map(int, input().split()))
D= [list(map(int, input().split())) for i in range(d)]
cc=[0]*26
for i in range(26):
    cc[i]=[c[i],i+1]
cc.sort(reverse=True)

ans=[0]*d
# 最後にどの試験がいつ行われたか？
PL=[0]*26

for i in range(d):
    cnt=0
    cntt=-10**9
    x=1
    for k in range(len(c)):
        v=PL[:]
        cnt = D[i][cc[k][1]-1]
        v[cc[k][1]-1] = i+1
        for j in range(len(c)):
            cnt-=(i+1-v[j])*c[j]
        if cnt>cntt+10:
            x=cc[k][1]
            cntt=max(cnt,cntt)
    ans[i]=x
    PL[x-1]=i


for i in range(d):
    print(ans[i])

Measured memory_bytes: 68496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<ll>;
using VVI = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll n,t, sum=0;
    cin >> n >> t;

    ll bef, aft;
    cin >> aft; // = 0
    rep(i,n-1){
        bef = aft;
        cin >> aft;
        if(aft-bef < t) sum += aft - bef;
        else sum += t;
    }
    sum += t;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string sa, sb;
    cin >> sa >> sb;
    string sc = sa + sb;

    int c = 0;
    for (int i = 0; i < (int) sc.size(); i++) {
        c = c * 10 + (sc[i] - '0');
    }
    // printf("c: %d\n", c);

    bool is_heiho = false;
    for (int i = 1; i <= 1000; i++) {
        if (i * i == c) {
            is_heiho = true;
        }
    }

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

    return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==7){
    if(B == 5 && C == 5){
      cout << "YES" << endl ;
      return 0;
    }
  }
  if(B==7){
    if(A == 5 && C == 5){
      cout << "YES" << endl ;
      return 0;
    }
  }
  
  if(C==7){
    if(B == 5 && A == 5){
      cout << "YES" << endl ;
      return 0;
    }
  }
  cout << "NO" << endl ;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int n; cin >> n;
	vector<int> freq(n + 1, 0);
	for (int i = 2; i <= n; i++) {
		int a; cin >> a;
		freq[a]++;
	}

	for (int i = 1; i <= n; i++) cout << freq[i] << "\n";

	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define MAX 100000000

int n;
int minFunc(int v[102], int k){
	int i;
	for(i = 0;i < n;i++){
		if(v[i] > k)break;
	}
	return i;
}

int main(){
	int a[102], b[102];
	while(cin >> n, n){
		for(int i = 0;i < n;i++)cin >> a[i];
		sort(a, a+n);
		int r = 0, l = 0;
		for(int i = 1;i <= 2*n;i++){
			if(a[l] != i)b[r++] = i;
			else l++;
		}
		
		/*for(int i = 0;i < n;i++)cout << a[i] << " ";
		cout << endl;
		for(int i = 0;i < n;i++)cout << b[i] << " ";
		cout << endl;*/
		int p = 0, f = 1, x, y;
		while(r && l){
			p = 0;
			int rr = 1, ll = 1;
			while(rr || ll){
				if(f){
					x = minFunc(a, p);
					//cout << a[x] << "+";
					if(x != n) p = a[x], r--, a[x] = 0;
					else rr = 0;
					f = 0;
				}
				if(!r)break;
				if(x == n)p = 0;
				if(!f){
					x = minFunc(b, p);
					//cout << b[x] << "-";
					if(x != n) p = b[x], l--, b[x] = 0;
					else ll = 0;
					f = 1;
				}
				if(!l || x == n)break;
				/*for(int i = 0;i < n;i++)cout << a[i] << " ";
				cout << endl;
				for(int i = 0;i < n;i++)cout << b[i] << " ";
				cout << endl << r << endl;*/
			}
		}
		cout << l << endl << r << endl;
		/*for(int i = 0;i < n;i++)cout << a[i] << " ";
		cout << endl;
		for(int i = 0;i < n;i++)cout << b[i] << " ";*/
	}
	return 0;
}

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

int n, S[10000], q, T[500];

int main(){
	int c = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (S[j] == T[i]) {
				c++;
				break;
			}
		}
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3080
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n= ii()
a= li()

ans=1
a.sort()
a.reverse()

if a[-1] == 0:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
    elif a[i] == 0:
        print(0)
        exit()
print(ans)


Measured memory_bytes: 22712
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

const int N = 505;

int a[N], b[N], n, k;

bool good(int g) {
    fr(i, 1, n) {
        b[i] = a[i] % g;
    }
    sort(b + 1, b + n + 1);
    fr(i, 1, n) {
        int s1 = 0, s2 = 0;
        fr(j, 1, i) {
            s1 += b[j];
        }
        fr(j, i + 1, n) {
            s2 += g - b[j];
        }
        if(s1 == s2 && s1 <= k) return 1;
    }
    return 0;
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    int s = 0;
    fr(i, 1, n) {
        cin >> a[i];
        s += a[i];
    }
    int ans = 0;
    for(int g = 1; g * g <= s; g++) {
        if(s % g == 0) {
            if(good(g))
                ans = max(ans, g);
            if(good(s / g)) ans = max(ans, s / g);
        }
    }
    cout << ans;
    return 0;
}

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

int main()
{
    ll n, ans = 0;
    cin >> n;
    ll p[n];
    rep(i, n) cin >> p[i];

    for (ll i = 1; i <= n - 2; i++)
    {
        if (p[i - 1] < p[i] && p[i] < p[i + 1])
            ans++;
        if (p[i + 1] < p[i] && p[i] < p[i - 1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
# coding: utf-8

s = raw_input()

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            e = s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3]
            if eval(e) == 7:
                print e + "=7"
                exit(0)


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll n;
	cin>>n;
	ll notes = ceil(n/1000.0);
	ll change = (notes*1000)-n;
	cout<<change<<"\n";
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  printf("%lf\n",sqrt(((a-c)*(a-c)+(b-d)*(b-d))));
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    int N, M, A, B;
    cin >> N >> M >> A >> B;

    if (2*(A+B) > N*M) {
        cout << "NO" << endl;
        return 0;
    }

    vector<char> gridrow(M, '.');
    vector<vector<char>> grid(N, gridrow);

    bool extra = false;

    if (N % 2 == 1 && M % 2 == 1) {
        extra = true;
        for (int x=0;x<min(M/2, A);x++) {
            grid[N-1][1 + 2*x] = '<';
            grid[N-1][1 + 2*x + 1] = '>';
        }
        A-= min(M/2, A);

        for (int y=0;y<min(N/2, B);y++) {
            grid[2*y][M-1] = '^';
            grid[2*y + 1][M-1] = 'v';
        }
        B-= min(N/2, B);
    } else if (N%2 == 1 && M % 2 == 0) {
        for (int x=0;x<min(M/2, A);x++) {
            grid[N-1][2*x] = '<';
            grid[N-1][2*x + 1] = '>';
        }
        A-= min(M/2, A);
    } else if (M%2 == 1 && N%2 == 0){
        for (int y=0;y<min(N/2, B);y++) {
            grid[2*y][M-1] = '^';
            grid[2*y + 1][M-1] = 'v';
        }
        B-= min(N/2, B);
    }


    bool used = false;
    if (extra && (A % 2) == 1 && (B%2) == 1) {
        grid[N-3][0] = '<';
        grid[N-3][1] = '>';
        grid[N-2][0] = '^';
        grid[N-1][0] = 'v';
        used = true;
        A--; B--;
    }

    for (int x=0; x<M/2;x++) {
        for (int y=0;y<N/2;y++) {
            if (used && x == 0 && (y+1) == N/2) continue;
            if (A > 0) {
                grid[2*y][2*x] = '<';
                grid[2*y][2*x+1] = '>';
                A--;
                if (A > 0) {
                    grid[2*y + 1][2*x] = '<';
                    grid[2*y + 1][2*x+1] = '>';
                    A--;
                }
            } else if (B > 0) {
                grid[2*y][2*x] = '^';
                grid[2*y+1][2*x] = 'v';
                B--;
                if (B > 0) {
                    grid[2*y][2*x + 1] = '^';
                    grid[2*y + 1][2*x+1] = 'v';
                    B--;
                }
            }
        }
    }

    if (A > 0 || B > 0) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
    for (int y=0;y<N;y++) {
        for (int x=0;x<M;x++) {
            cout << grid[y][x];
        }
        cout << endl;
    }

}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<pair<int, int>> vp(n);
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        vp[i] = {x, y};
    }
    
    vector<int> perm_list(n);
    for (int i=0; i<n; i++) perm_list[i] = i;
    
    long double ans = 0;
    int divNum = 0;
    do{
        long double dist_sum = 0;
        for (int i=0; i<n-1; i++){
            int xdist = (vp[perm_list[i]].first - vp[perm_list[i+1]].first);
            int ydist = (vp[perm_list[i]].second - vp[perm_list[i+1]].second);
            dist_sum += sqrt(xdist * xdist + ydist * ydist);
        }
        divNum++;
        ans += dist_sum;
    }while(next_permutation(perm_list.begin(), perm_list.end()));
    
    cout << fixed << setprecision(10) << (long double)(ans / divNum) << endl;
}


Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;

string solve(string str){
	string tmp="";
	int alp[200]={};
	for(int i=0;i<10;i++){
		alp[str[i]]++;
	}
	for(int i='a';i<='z';i++){
		while(alp[i]!=0){
			tmp.push_back(i);
			alp[i]--;
		}
	}
	//cout<<tmp<<endl;
	return tmp;
}

long long int n,k,a[2000],sum=0,now=1,up=0,down=0,res=0;

    string str[200005],str2;
int main() {
    long long int count=0;
	
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
	for(int i=0;i<n;i++){
		cin>>str[i];
		str[i]=solve(str[i]);
	}
	sort(str,str+n);
	str[n]="..........";
	for(int i=1;i<=n;i++){
		if(str[i]==str[i-1]){
			now++;
		}else{
			res+=now*(now-1)/2;
			now=1;
		}
	}
	cout<<res;
} 


Measured memory_bytes: 8064