akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N), L(N), R(N), S(N, 0);
	if (N == K) {
		for (int i = 0;i < N;i++)cin >> A[i];
		for (int i = 1;i < N;i++)A[i] += A[i - 1];
		cout << max(0LL, A[N - 1]) << endl;
		return 0;
	}
	for (int i = 0;i < N;i++)
		cin >> A[i];
	L[0] = max(A[0], 0LL);
	for (int i = 1;i < N;i++) {
		if(A[i]>0)L[i] = L[i - 1] + A[i];
		else L[i] = L[i - 1];
	}
	R[N - 1] = max(A[N - 1], 0LL);
	for (int i = N - 2;i >= 0;i--) {
		if(A[i]>0)R[i] = R[i + 1] + A[i];
		else R[i] = R[i + 1];
	}


	ll sum = 0;
	for (int i = 0;i < K;i++) {
		sum += A[i];
	}
	S[K - 1] = sum;
	for (int i = K;i < N;i++) {
		sum += A[i];
		sum -= A[i - K];
		S[i] = sum;
	}

	ll ans = max(max(S[K - 1], 0LL) + R[K], max(S[N - 1], 0LL) + L[N - 1 - K]);
	//cout << R[K] << " " << L[N - 1 - K] << endl;
	for (int i = K;i < N - 1;i++) {
		ans = max(max(S[i], 0LL) + L[i - K] + R[i + 1], ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3328
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B = sc.nextLong()
    val K1 = (A + B) / 2
    val K2 = (- A - B) / 2

    val r = if (A == B) "0"
    else if ((A + B) % 2 == 0) {
      if (Math.abs(A - K1) == Math.abs(B - K1))
        K1.toString
      else if (Math.abs(A - K2) == Math.abs(B - K2))
        K2.toString
      else "IMPOSSIBLE"
    } else "IMPOSSIBLE"
    println(r)
  }

}

Measured memory_bytes: 25664
N=input()
L=input()

L=list(map(int,L.split()))

i=0
j=0

x=L[-1]

while j < len(L):
    if L[j] > x:
        j += 1
        
    else:
        L_i = L[i]
        L_j = L[j]
        if j == len(L)-1:
            L_j='['+str(L_j)+']'
        L[i] = L_j
        L[j] = L_i
        i += 1
        j += 1
         
print(' '.join(map(str,L)))


Measured memory_bytes: 16860
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	string s;
	cin >> s;
	int n = s.size();
	vector<ll> l(n), r(n), ans(n, 0);
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r[i] = i;
		} else {
			r[i] = r[i - 1];
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'L') {
			l[i] = i;
		} else {
			l[i] = l[i + 1];
		}
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			if ((l[i] - i) % 2 == 0) {
				ans[l[i]]++;
			} else {
				ans[l[i] - 1]++;
			}
		} else {
			if ((r[i] - i) % 2 == 0) {
				ans[r[i]]++;
			} else {
				ans[r[i] + 1]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3024
#include<stdio.h>
int main(void)
{
	int e,y;
	char a[5]="MTSH";
	scanf("%d %d",&e,&y);
	if(e==0){
		y=y-1867;
		if(y<45) e=0;
		else if(y<59){
			e=1; y=y-44;
		}
		else if(y<122){
			e=2; y=y-58;
		}
		else{
			e=3; y=y-121;
		}
		printf("%c%d\n",a[e],y);
	}
	else{
		if(e==1) y=1867+y;
		else if(e==2) y=1911+y;
		else if(e==3) y=1925+y;
		else y=1988+y;
		printf("%d\n",y);
	}
	return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n,m,a,b,m1=-1,m2=INT_MAX;;
	cin>>n>>m;
	//vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		//v.push_back({a,b});
		m1=max(m1,a);
		m2=min(m2,b);
	} 
	if(m2-m1+1<0)
		cout<<"0\n";
	else
		cout<<m2-m1+1<<endl;
	return 0;
}

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

using namespace std;

typedef vector< pair< int, int > > T;

const int vy[] = {0, 1, 0, -1, 0}, vx[] = {1, 0, -1, 0, 0};

int tail;
vector< pair< int, int > > vec[1000];

int W, H, N;
string S[16];
short v[16 * 16 * 16 * 16 * 16 * 16];

bool isover(int y, int x)
{
  return (y < 0 || y >= H || x < 0 || x >= W || S[y][x] == '#');
}

void CreateVector(int sz, vector< pair< int, int > > &vs)
{
  if(sz == 0) {
    vec[tail++] = vs;
    return;
  }
  for(int i = 0; i < 5; i++) {
    int ny = vs[sz - 1].first + vy[i];
    int nx = vs[sz - 1].second + vx[i];
    if(isover(ny, nx)) continue;
    vs[sz - 1].first += vy[i];
    vs[sz - 1].second += vx[i];
    CreateVector(sz - 1, vs);
    vs[sz - 1].first -= vy[i];
    vs[sz - 1].second -= vx[i];
  }
}

int hashh(vector< pair< int, int > > &vs)
{
  int ret = 0;
  for(int k = vs.size() - 1; k >= 0; k--) {
    ret *= 16;
    ret += vs[k].second;
    ret *= 16;
    ret += vs[k].first;
  }
  return (ret);
}

vector< pair< int, int > > hashd(int h)
{
  vector< pair< int, int > > vs(N);
  int ret = 0;
  for(auto &k : vs) {
    vs[ret].first = h & 15;
    h >>= 4;
    vs[ret++].second = h & 15;
    h >>= 4;
  }
  return (vs);
}

int main()
{
  while(cin >> W >> H >> N, W) {
    vector< char > nums;
    cin.ignore();

    for(int i = 0; i < H; i++) {
      getline(cin, S[i]);
      for(int j = 0; j < W; j++) {
        if(islower(S[i][j])) nums.push_back(S[i][j]);
      }
    }

    sort(begin(nums), end(nums));

    vector< pair< int, int > > vs(N), ans(N);
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        if(islower(S[i][j])) {
          auto q = lower_bound(begin(nums), end(nums), S[i][j]) - begin(nums);
          vs[q] = {i, j};
        } else if(isupper(S[i][j])) {
          auto q = lower_bound(begin(nums), end(nums), tolower(S[i][j])) - begin(nums);
          ans[q] = {i, j};
        }
      }
    }


    queue< int > que;
    que.emplace(hashh(vs));
    memset(v, -1, sizeof(v));
    v[hashh(vs)] = 0;

    while(!que.empty()) {
      auto ss = que.front();
      int cost = v[ss];
      que.pop();
      auto p = hashd(ss);
      if(p == ans) {
        cout << cost << endl;
        break;
      }

      tail = 0;
      CreateVector(N, p);
      for(int z = 0; z < tail; z++) {
        auto &beet = vec[z];
        bool isok = true;
        for(int i = 0; i < p.size(); i++) {
          for(int j = 0; j < i; j++) {
            isok &= beet[i] != p[j] || beet[j] != p[i];
            isok &= beet[i] != beet[j];
          }
          if(!isok) break;
        }
        int hashed = hashh(beet);
        if(isok && v[hashed] == -1) {
          que.emplace(hashed);
          v[hashed] = cost + 1;
        }
      }
    }

  }

}

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

typedef long long LL;

const int N=1000000,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m;

void into(){
  scanf("%d%d",&n,&m);
}

int inv[N*3+9],fac[N*3+9],ifac[N*3+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2,lim=n+m*2;i<=lim;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int Get_c(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}

int ans;

void Get_ans(){
  for (int i=0;i<=m&&i<=n;++i){
	if (i&1^m&1) continue;
	int t=3*m-i>>1;
	sadd(ans,mul(Get_c(n,i),Get_c(n+t-1,n-1)));
	ssub(ans,mul(n,mul(Get_c(n-1,i),Get_c(n+t-m-2,n-1))));
	ssub(ans,mul(n,mul(Get_c(n-1,i-1),Get_c(n+t-m-1,n-1))));
  }
}

void work(){
  Get_inv();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 27048
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K, ans = 0;
	cin >> N >> K;
	REP(i, N) {
		int a;
		cin >> a;
		if (a >= K)ans++;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
vector<int>vec;
bitset<1001>vis;
const int mod=1000000007,siz=1001;
void sieve() {
    for(int i=2;i*i<siz;i++){
        if(!vis[i]){
            for(int c=i*2;c<siz;c+=i){
                vis[c]=true;
            }
        }
    }
    for(int i=2;i<siz;i++){
        if(!vis[i])
            vec.push_back(i);
    }
}
int legendres(int a,int b){
    int s=0;
    while(a){
        s+=a/b;
        a/=b;
    }
    return s;
}
int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    sieve();
    int x;
    cin>>x;
    ll ans=1;
    for(int i=0;i<vec.size() && vec[i]<=x;i++){
        ans*=(1+legendres(x,vec[i]))%mod;
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
using namespace std;
signed main()
{
	fastio;
	int n;
	cin>>n;
	if(n%1000!=0)
	cout<<1000-(n%1000);
	else
	cout<<0;
	
	
return 0;
}


Measured memory_bytes: 3648
R, C = [int(n) for n in input().split()]
c_sum = [0]*C
for i in range(R):
  r = [int(n) for n in input().split()]
  for j in range(C):
    c_sum[j] += r[j]
  print(*(r + [sum(r)]))
print(*(c_sum + [sum(c_sum)]))



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++){cin>>arr[i];}
	int ans=INT_MAX;
	for(int i=0;i<=200;i++){
		int c=0;
		for(int j=0;j<n;j++){
			c+=((i-arr[j])*(i-arr[j]));
		}
		ans=min(ans,c);
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3644
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if ((mask >> i) & 1):
            ans += str(S[i]) + "+"
        else:
            ans += str(S[i])
    ans += "+"

print(int(eval(ans[:-1])))


Measured memory_bytes: 4140
#include<iostream>
using namespace std;
int main()
{
  int S;
  int h;
  int m;
  int s;

  cin >> S;
  h=S/3600;
  m=(S-h*3600)/60;
  s=(S-m*60-h*3600);
  cout << h << ":" << m << ":" << s<<endl;
  return 0;
}



Measured memory_bytes: 3136
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K
{
	static int[] G => ReadLine().Split().Select(i => int.Parse(i) - 1).ToArray();
	static int N;
	static void Main()
	{
		var I = G;
		N = I[0] + 1;
		WriteLine(ToString(Calc(G, G, I[1])));
	}
	static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
	static int[] Calc(int[] p, int[] q, int K)
	{
		int[] P = Inv(p), Q = Inv(q), x = Pow(Mult(q, P, Q, p), K / 6), y = Inv(x);
		switch (K % 6)
		{
			case 0: return Mult(x, p, y);
			case 1: return Mult(x, q, y);
			case 2: return Mult(x, q, P, y);
			case 3: return Mult(x, q, P, Q, y);
			case 4: return Mult(x, q, P, Q, p, Q, y);
			default: return Mult(x, q, P, Q, p, p, Q, y);
		}
	}
	static int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	static int[] Mult(int[] a, int[] b) { var p = new int[N]; for (var i = 0; i < N; i++) p[i] = a[b[i]]; return p; }
	static int[] Mult(params int[][] a) => a.Aggregate(Mult);
	static int[] Pow(int[] a, int b)
	{
		if (b < 0) return Inv(Pow(a, -b));
		var p = new int[N];
		var f = new bool[N];
		for (var i = 0; i < N; i++)
			if (!f[i])
			{
				var l = new List<int>();
				var x = i;
				while (!f[x]) { l.Add(x); f[x] = true; x = a[x]; }
				var C = l.Count;
				for (var j = 0; j < C; j++) p[l[j]] = l[(j + b) % C];
			}
		return p;
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size();
  int64_t res = 0;
  for (int bit = 0; bit < (1 << (N - 1)); bit++) {
    int64_t cur = S[0] - '0';
    for (int i = 0; i < N - 1; i++) {
      if ((bit >> i) & 1) {
        res += cur;
        cur = 0;
      }
      cur = cur * 10 + (S[i + 1] - '0');
    }
    if (cur > 0) res += cur;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3628
import java.math.BigInteger;
import java.util.*;
public class Main {





public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
		String odd=sc.next();
		String even=sc.next();
		String ans="";
		int j=0;
		int k=0;
		for(int i=1;i<=odd.length()+even.length();i++) {
			if(i%2!=0) {
				ans+=odd.charAt(j);
				j++;
			}else {
				ans+=even.charAt(k);
				k++;
			}
		}
		System.out.println(ans);
}
}

class pair{
	int x,y;
	pair(int x,int y){
		this.x=x;
		this.y=y;
	}
}


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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var dict = new Dictionary<int, int>();

        var nCr = new long[200001];
        for (var i = 1; i <= 200000; i++)
        {
            nCr[i] = CombCount(i, 2);
        }

        for (var i = 0; i < N; i++)
        {
            if (dict.ContainsKey(A[i]))
                dict[A[i]]++;
            else
                dict[A[i]] = 1;
        }

        var total = 0L;
        foreach (var d in dict)
        {
            if (d.Value >= 2)
                total += nCr[d.Value];
        }

        for (var i = 0; i < N; i++)
        {
            //if (dict[A[i]] - 1 >= 2)
                Console.WriteLine(total - (nCr[dict[A[i]]] - nCr[dict[A[i]]-1]));
            //else
            //    Console.WriteLine(0);
        }
    }

    public static long CombCount(int n, int m)
    {
        if (m == 0) return 1;
        if (n == 0) return 0;
        return (n * CombCount(n - 1, m - 1) / m);
    }
}


Measured memory_bytes: 44080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
    int n,a[100000],cnt=0,ans=0;
    cin>>n;
    int s=1;//はじめ
    for(int i=0;i<n;i++,s*=-1){
        cin>>a[i];
        cnt+=a[i];
        if(cnt*s>0)continue;
        ans+=abs(cnt-s);
        cnt+=s*abs(cnt-s);
    }
    cnt=0;
    int res=0;
    s=-1;//はじめ
    for(int i=0;i<n;i++,s*=-1){
        cnt+=a[i];
        if(cnt*s>0)continue;
        res+=abs(cnt-s);
        cnt+=s*abs(cnt-s);
    }
    cout<<min(res,ans)<<endl;
	return 0;
}

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

using namespace std;

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<long long> h(n);
  long long ans = 0;
  if (k >= n) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, 0, n)
  {
    cin >> h[i];
    ans += h[i];
  } 
  sort(h.begin(), h.end());
  for (int i = n-1; i > n-k-1; --i)
  {
    ans -= h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
S = input()[::-1]
N = len(S)
sum_of_mod = [0] * 2019
sum_of_mod[0] += 1
digit = 1
now = 0
for i in range(N):
    now = int(S[i])*digit + now
    now %= 2019
    digit *= 10
    digit %= 2019
    sum_of_mod[now] += 1

ans = 0
for i in range(2019):
    ans += sum_of_mod[i] * (sum_of_mod[i]-1) // 2
print(ans)


Measured memory_bytes: 9400
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    int x = 0;
    for (int i = 1; i <= 1e8; i++) {
        x *= 10;
        x += 7;
        x %= k;
        if (x == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


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

class dice
{
public:
    int F[6];
    int q;
    dice();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
};

dice::dice()
{
    for(int i = 0; i < 6; i++) cin >> F[i];
    q = F[0] * F[5] + F[1] * F[4] + F[2] * F[3]; // invariant.
}

void dice::roll_a()
{
    int i;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    i = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = i;
}

void dice::roll_b()
{
    int i;
    i = F[0]; F[0] = F[5]; F[5] = i;
    i = F[1]; F[1] = F[3]; F[3] = i;
    i = F[2]; F[2] = F[4]; F[4] = i;
}
 
bool dice::check(const dice& d)
{
    int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

int main()
{
    dice d1 = dice();
    dice d2 = dice();
    bool eq;

    if(d1.q != d2.q){
        eq = false;
    }else{
        for(int i = 0; i < 2; i++){
            eq = d1.check(d2);
            if(!eq){ d1.roll_a(); eq = d1.check(d2); }
            if(!eq){ d1.roll_a(); eq = d1.check(d2); }
            if(eq || (i == 1)) break;
            d1.roll_b();
        }
    }

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

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int i;
  int Count[101] = {0};
  int data = 0;
  int MaxCount = 0;
  while(scanf("%d", &data) != EOF){
    Count[data] += 1;
  }
  for(i = 1 ; i <= 100 ; i++){
    if(MaxCount < Count[i]){
      MaxCount = Count[i];
    }
  }
  for(i = 1 ; i <= 100 ; i++){
    if(Count[i] == MaxCount){
      printf("%d\n", i);
    }
  }
  return 0;
}



Measured memory_bytes: 2028
n,m=map(int,input().split())
p=[list(map(int,input().split())) for i in range(n)]
c=[list(map(int,input().split())) for i in range(m)]

for i in p:
    cnt=1
    d=10**9
    for j in c:
        if abs(i[0]-j[0])+abs(i[1]-j[1])<d:
            d=abs(i[0]-j[0])+abs(i[1]-j[1])
            ans=cnt
        cnt+=1
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			double
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

double dist(vector<double>& a, vector<double>& b)
{
	double d = 0.0;
	for (int i = 0; i < a.size(); ++i)
	{
		d +=pow((double)a[i] - (double)b[i], 2);
	}
	return sqrt(d);
}

int main()
{
	int n, d;
	cin >> n >> d;
	int ans = 0;

	vvdef x(n, vdef(d, 0.0));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			double a;
			cin >> a;
			x[i][j] = a;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			double comp = 0.0;
			comp = dist(x[i], x[j]);

			if (comp == (int)comp)
			{
				++ans;
			}
		}
	}

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

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

using namespace std;

template <typename T>
struct bit{
    int n;
    vector<T> data;

    bit(int n_){
        n = 1;
        while(n < n_) n *= 2;
        data = vector<T>(n+1);
        for(int i = 0; i <= n; i++) data[i] = 0;
    }
    
    T sum(int i){
        T ret = 0;
        while(i > 0){
            ret += data[i];
            i -= i&-i;
        }
        return ret;
    }

    void add(int i, T x){
        while(i <= n){
            data[i] += x;
            i += i&-i;
        }
    }
};

vector<int> left_half;
vector<int> right_half;
int p[200001];
int order[200001];

int main(){
    string S;
    vector<int> idx[26];
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        idx[S[i]-'a'].push_back(i);
    }
    int cnt_odd = 0;
    for(int i = 0; i < 26; i++){
        if(idx[i].size()%2 == 1){
            cnt_odd++;
        }
    }
    if(cnt_odd >= 2){
        cout << -1 << endl;
        return 0;
    }
    
    int center = -1;
    for(int i = 0; i < 26; i++){
        if(idx[i].size()%2 == 0){
            for(int j = 0; j < idx[i].size()/2; j++){
                left_half.push_back(idx[i][j]);
            }
            for(int j = idx[i].size()/2; j < idx[i].size(); j++){
                right_half.push_back(idx[i][j]);
                p[idx[i][j]] = idx[i][idx[i].size()-1-j];
            }
        }else{
            for(int j = 0; j < idx[i].size()/2+1; j++){
                left_half.push_back(idx[i][j]);
            }
            center = left_half[left_half.size()-1];

            for(int j = idx[i].size()/2+1; j < idx[i].size(); j++){
                right_half.push_back(idx[i][j]);
                p[idx[i][j]] = idx[i][idx[i].size()-1-j];
            }
        }
    }
    sort(left_half.begin(), left_half.end());
    sort(right_half.begin(), right_half.end());
    long sum = 0;
    
    for(int i = 0; i < left_half.size(); i++){
        sum += left_half[i]+1;
        if(center == left_half[i]){
            int s = left_half.size()-1;
            sum += abs(s-i);
        }
        if(left_half[i] < center) order[left_half[i]] = i+1;
        if(left_half[i] > center) order[left_half[i]] = i;
        if(center == -1) order[left_half[i]]++;
    }
    long ans = sum - ((long)left_half.size()*((long)left_half.size()+1))/2;
    bit<int> btree(right_half.size());
    //cout << ans << endl;
    for(int i = 0; i < right_half.size(); i++){
        //cout << order[p[right_half[i]]] << endl;;
        btree.add(order[p[right_half[i]]], 1);
        ans += (long)(btree.sum(order[p[right_half[i]]])-1);
        //cout << btree.sum(order[p[right_half[i]]])-1 << endl;
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3832
#include<stdio.h>

int main() {
	int n, q, count = 0;
  int S[100000], T[50000];

  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &S[i]);
  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ) scanf("%d", &T[i]);

  for (int i = 0; i < q; i++) {
    int left = 0, right = n;
    while (left < right) {
      int mid = (left+right)/2;
      if (T[i] < S[mid]) {
        right = (left+right)/2;
      } else if (T[i] > S[mid]) {
        left = (left+right)/2+1;
      } else {
        count++;
        break;
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
using namespace std;
typedef long long ll;
int n, m, mes[100010];
ll ans = 0;
int main() {
	scanf("%d%d", &n, &m);
	int cnt = 0;
	ff(i, 1, n) {
		int tmp;
		scanf("%d", &tmp);
		if(tmp == 0)
			m--;
		else
			mes[++cnt] = tmp;
	}
	ll ans = 1e18;
	if(m == 0) {
		printf("0\n");
		return 0;
	}
	n = cnt;
	ff(i, 1, n) {
		int r = i + m - 1;
		if(r <= n);
		else
			break;
		if(mes[r + 1] < 0 && r != n)continue;
		if(mes[r] <= 0)
		ans = min(ans, (ll)0 - mes[i]);
		else if(mes[i] >= 0)
			ans = min(ans, (ll)mes[r]);
		else
		ans = min(ans, (ll)mes[r] - mes[i] + min(-mes[i], mes[r]));
		if(mes[i] > 0)
			break;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// ref: 1. https://img.atcoder.jp/nomura2020/editorial.pdf
//      2. https://atcoder.jp/contests/nomura2020/submissions/13727054

// crux: (try to) think simple!

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi a(n+1);
	for(int i=0;i<n+1;++i)
        cin>>a[i];

	int cur=1,tot=0;

	vi sum(n+1);
	sum[n]=a[n];
	for(int i=n-1;i>=0;--i)
        sum[i]=a[i]+sum[i+1];

	for(int i=0;i<n;++i)
    {
		tot+=cur;

		if(cur<a[i])
		{
			cout<<-1;
			return;
		}

		cur-=a[i];
		if(2*cur<sum[i+1])
			cur=2*cur;
		else if(sum[i+1]<cur)
		{
			cout<<-1;
			return;
		}
		else
            cur=sum[i+1];
	}

	if(cur==a[n])
        tot+=cur;
	else
        tot=-1;

	cout<<tot;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 4712
function main(arg) {
	var btcRate = 380000
	arg = arg.split("\n")

	var N = arg.shift()

	arg = arg.map(e => {
		tmp = e.split(" ")
		tmp[0] = Number(tmp[0])
		return tmp
	})

	var result = 0

	for (var i = 0; i < arg.length; i++) {
		// console.log(arg[i][1]) //JPY
		if (arg[i][1] == "JPY") {
			result += Number(arg[i][0])
		} else if (arg[i][1] == "BTC") {
			result += Number(arg[i][0]) * btcRate
		}
	}

	console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    char number_buffer[100];
    uint8_t lookup[100];

    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;

        if (input_len == 0)
            input_buffer[0] = EOF;
    }

    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template<typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template<typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }

        int length = 0;

        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }

        if (number != 0 || length == 0)
            write_char(number + '0');

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    void init()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);

        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;
	bool a = false, b = false;
	for (auto i : s)
	{
		a |= i == 'A';
		b |= i == 'B';
	}
	if (a && b)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
package main

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

type Tuple struct {
	A int
	B int
	C int
}

func main() {
	sc := NewScanner()
	A, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()
	mp := map[Tuple]bool{}

	count := 0
	for {
		t := Tuple{A: A, B: B, C: C}
		if A%2 == 1 || B%2 == 1 || C%2 == 1 {
			fmt.Println(count)
			return
		}
		if _, ok := mp[t]; ok {
			fmt.Println(-1)
			return
		}
		mp[t] = true
		A, B, C = (B+C)/2, (A+C)/2, (B+C)/2
		count++
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int a, b, fish;
  int th, fif, hun;

  while(1){
    scanf("%d%d", &a, &b);
    if(a==0 && b==0){
      break;
    }
    fish=b-a;
    th=fish/1000;
    fif=(fish%1000)/500;
    hun=((fish%1000)%500)/100;
    printf("%d %d %d\n", hun, fif, th);
  }
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
    IOS;
    int x; cin>>x;
    int y=100;
    int cnt=0;
    while(y<x)
    {
        y=y+y/100;
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	int a, b;
	string str;
	cin >> a >> str >> b;
	if (str == "+") {
		cout << a + b << endl;
	}
	if (str == "-") {
		cout << a - b << endl;
	}
}

Measured memory_bytes: 256
import sys

if __name__ == "__main__":
    (X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
    A = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))
    C = list(map(int, sys.stdin.readline().split()))

    v = []
    for a in A:
        for b in B:
            v.append(a + b)

    v.sort(reverse=True)

    ans = []
    for i in range(min(len(v),3000)):
        for c in C:
            ans.append(v[i] + c)

    ans.sort(reverse=True)

    for i in range(K):
        sys.stdout.write("%d\n" % ans[i])

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

typedef long long ll;
const ll InF = 1e15;

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> x(N);
  ll start = N;
  ll ans = InF;
  bool flag = true;
  for (ll i = 0; i < N; i++) {
    cin>>x[i];
    if (x[i] >= 0 && flag) {
      start = i;
      flag = false;
    }
  }
  ll goal = min(start, N - start);
  if (goal == start) {
    for (ll i = 0; i <= goal; i++) {
      if (start + K - i - 1 >= N) continue;
      ll res;
      if (i == 0) res = x[start + K - 1];
      else res = x[start + K - i - 1] - x[start - i] + min(x[start + K - i - 1], - x[start - i]);
      ans = min(ans,res);
    }
  } else {
    for (ll i = 0; i <= goal; i++) {
      if (start - K + i < 0) continue;
      ll res;
      if (i == 0) res = -x[start - K];
      else res = x[start + i - 1] - x[start - K + i] + min(x[start + i - 1], - x[start - K + i]);
      ans = min(ans,res);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
struct dd
{
    int x;
    int y;
};
struct ddd
{
    int x;
    int y;
    int c;
};
int main()
{
    int n;
    struct dd ball[55] = {};
    struct ddd cand[2000] = {};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &(ball[i].x), &(ball[i].y));
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int x, y;
            x = ball[i].x - ball[j].x;
            y = ball[i].y - ball[j].y;
            if (x < 0)
            {
                x = -x;
                y = -y;
            }
            else if (x == 0 && y < 0)
            {
                y = -y;
            }
            int k = 0;
            for (; cand[k].c != 0; k++)
            {
                if (cand[k].x == x && cand[k].y == y)
                {
                    cand[k].c++;
                    x = 0;
                    y = 0;
                    break;
                }
            }
            if (x != 0 || y != 0)
            {
                cand[k].x = x;
                cand[k].y = y;
                cand[k].c = 1;
            }
        }
    }
    int max = 0;
    for (int k = 0; cand[k].c != 0; k++)
    {
        if (cand[k].c > max)
        {
            max = cand[k].c;
        }
    }
    printf("%d", n - max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack <int> s1;
    stack < pair <int, int> > s2;
    char ch;
    int sum = 0;

    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') s1.push(i);
        else if (ch == '/' && s1.size() > 0) {
            int j = s1.top();
            s1.pop();
            sum += i - j;
            int a = i - j;

            while (s2.size() > 0 && s2.top().first > j) {
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }

    vector<int> ans;

    while (s2.size() > 0) {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

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

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

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

long div(long a, long b, long p) { // a以上b以下の整数のうちpで割り切れる数の個数
    return b / p - (a - 1) / p;
}

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long e = lcm(c, d);
    long n = b - a + 1;
    long p, q, r;
    p = div(a, b, c);
    q = div(a, b, d);
    r = div(a, b, e);
    cout << n - (p + q - r) << endl;
}

Measured memory_bytes: 3612
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a]
v = [-1 for _ in range(n)]
p = 0
x = 0
c = 0
while k > 0 and v[x] < 0:
    v[x] = p+1
    p = v[x]
    x = a[x]
    c += 1
    k -= 1

z = c-v[x]+1
k = k%z

while k > 0:
    k -= 1
    x = a[x]
print(x+1)

Measured memory_bytes: 107272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>

using namespace std;


int main() {

    long long A;
    string B;
    cin >> A >> B;

    long long B1 = (B[0] - '0') * 100 + (B[2] - '0') * 10 + B[3] - '0';
    
    cout << (A * B1) / 100 << endl;

    return 0;
}

Measured memory_bytes: 3620
N,K,Q=map(int,input().split())
L=[0 for i in range(N+1)]
for i in range(Q):
    a=int(input())
    L[a]+=1
for i in range(1,N+1):
    if K-Q+L[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 51104
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
 
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var s = ReadStringArray();
            Console.WriteLine($"{string.Concat(s.Select(v => char.ToUpper(v[0])))}");
        }
    }
 
    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main()
{
  int r,c;
  cin>>r>>c;
  char s;
  long long int a[r+1][c+1];
  for(int i=0;i<=r;i++)
  {
    for(int j=0;j<=c;j++)
    {
      if(i==0 || j==0)
        a[i][j]=-1;
      else
      {
        cin>>s;
        if(s=='.')
          a[i][j]=0;
        else
          a[i][j]=-1;
      }
    }
  }
  for(int i=1;i<=r;i++)
  {
    for(int j=1;j<=c;j++)
    {
      if(i==1 && j==1)
      a[i][j]=1;
      else if(a[i][j]!=-1)
      {
        if(a[i-1][j]==-1 && a[i][j-1]!=-1)
          a[i][j]=a[i][j-1];
        else if(a[i-1][j]!=-1 && a[i][j-1]==-1)
          a[i][j]=a[i-1][j];
        else if(a[i-1][j]!=-1 && a[i][j-1]!=-1)
          a[i][j]=(a[i][j-1]+a[i-1][j])%1000000007;
        else
          a[i][j]=0;
      }
    }
  }
  cout<<a[r][c];
  return 0;
}

Measured memory_bytes: 8064
def digsum(x):
    sum = 0
    while(x != 0):
        sum += x%10
        x //= 10
    return sum
N = int(input())
while(1):
    if N == 10 or N%10 != 0:
        break
    N //= 10
print(digsum(N) if N!= 10 else 10)

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

int main(){
	int min=1000000, max=-1000000, n, tmp,i ;
	long sum=0; 
	
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> tmp;
		
		if (tmp < min){
			min = tmp;
		}
		if (tmp > max){
			max = tmp;
		}
		
		sum += tmp;
	}
		cout << min << " " << max << " " << sum<< endl;

    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int d[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    rep(i, 0, k) d[i] = INF;
    deque<P> dq;
    dq.push_back(P(1, 0));
    d[1] = 0;
    while(dq.size()){
        P p = dq.front(); dq.pop_front();
        if(p.first == 0) break;
        int nxt1 = (p.first + 1) % k;
        // cout << p.first << " " << p.second << endl;
        if(d[nxt1] > p.second + 1){
            d[nxt1] = p.second + 1;
            dq.push_back(P(nxt1, p.second + 1));
        }
        int nxt2 = (p.first * 10) % k;
        if(d[nxt2] > p.second){
            d[nxt2] = p.second;
            dq.push_front(P(nxt2, p.second));
        }
    }
    cout << d[0] + 1 << endl;
}

Measured memory_bytes: 1792
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  string s;
  ll i,n,a=0,b=0,x=0;
  cin >> n >> s;
  for(i=0;i<n;i++){
    if(s[i]=='1'){
      x++;
    }
  }
  reverse(s.begin(),s.end());
  for(i=0;i<n;i++){
    if(x-1==0){
      if(i==0){
        b+=1%(x+1);
      }
      b=b+modpow(2,i,x+1);
      continue;
    }
    if(s[i]=='1'){
      if(i==0){
        a+=1%(x-1);
        b+=1%(x+1);
        continue;
      }
      a=a+modpow(2,i,x-1);
      b=b+modpow(2,i,x+1);
    }
  }
  if(x-1==0){
    b=b%(x+1);
  }
  else{
    a=a%(x-1),b=b%(x+1);
  }
  reverse(s.begin(),s.end());
  for(i=0;i<n;i++){
    ll c,ans=1;
    if(s[i]=='1'){
      if(x-1==0){
        cout << 0 << endl;
        continue;
      }
      c=a-modpow(2,n-i-1,x-1);
      if(c<0){
        c+=(x-1);
      }
    }
    else{
      c=b+modpow(2,n-i-1,x+1);
      c=c%(x+1);
    }
    while(c!=0){
      ans++;
      c=c%__builtin_popcount(c);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3720
module main;
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
  int N = 1000000;
  bool pb[] = new bool[N];
  int p[];
  for(int i = 2; i < N; i++)
  {
    if(pb[i])
      continue;
    p ~= i;
    for(int j = i; j < N; j += i)
      pb[j] = true;
  }
  while(true)
  {
    int n = chomp(readln()).to!int();
    if(!n)
      break;
    writeln(reduce!("a + b")(p[0..n]));
  };
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int m[n];
    int sum = 0;
    int min_m = 1000;
    for (int i = 0; i < n; i++) {
        cin >> m[i];
        sum += m[i];
        min_m = min(min_m, m[i]);
    }
    cout << n + (x - sum) / min_m << endl;
    return 0;
}

Measured memory_bytes: 256