akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int N;
	long long D;
	int count = 0;

	cin >> N >> D;
	for (int i = 0; i < N; ++i)
	{	
		long long X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D){
			count++;	
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 3572
import std.stdio, std.string;

void main() {
  string s;
  int n;
  int points = 0;
  int out_cnt = 0;
  bool runner[4];;
  readf("%d\n", &n);
  while ((s = readln.chomp), !stdin.eof) {
    switch(s) {
    case "HIT":
      if (runner[3]) points++;
      runner[3] = runner[2];
      runner[2] = runner[1];
      runner[1] = true;
      break;
    case "OUT":
      out_cnt++;
      if (out_cnt == 3) {
        writeln(points);
        out_cnt = 0;
        points = 0;
        foreach(ref r; runner) r = false;
      }
      break;
    case "HOMERUN":
      int p = 0;
      foreach(ref r; runner) {
        if (r) {
          p++;
          r = false;
        }
      }
      points += p + 1;
      break;
    default:
      break;
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<llong> a(n);
  rep(i, n) cin >> a[i];

  vector<llong> x(n);
  rep(i, n) x[0] += a[i];
  for (int i = 1; i < n; i += 2) {
    x[0] -= 2 * a[i];
  }
  for (int i = 1; i < n; i++) {
    x[i] = 2 * a[i - 1] - x[i - 1];
  }
  rep(i, n) cout << x[i] << endl;
  return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
    for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(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 T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {
        s << endl << P[i];
    }
    return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    int ans = 0;
    REP(i, n) {
        cin >> a[i];
        ans += a[i];
        mp[a[i]]++;
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        ans -= mp[b] * b;
        ans += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10056
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,a,b,c=MI()
mn=inf
lis=[I() for i in range(n)]
for i in list(product([0,1,2,3],repeat=n)):
    x=[]
    y=[]
    z=[]
    for j in range(n):
        if i[j]==0:
            x.append(lis[j])
        elif i[j]==1:
            y.append(lis[j])
        elif i[j]==2:
            z.append(lis[j])
    if len(x)==0 or len(y)==0 or len(z)==0:
        ans=inf
    else:
        ans=abs(sum(x)-a)+10*(len(x)-1)+abs(sum(y)-b)+10*(len(y)-1)+abs(sum(z)-c)+10*(len(z)-1)
    #print(ans)
    if ans<mn:
        mn=ans
        X=x
        Y=y
        Z=z
print(mn)
'''print(X)
print(Y)
print(Z)
'''

Measured memory_bytes: 11324
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {

  ll n, k;
  ccin >> n >> k;

  ll1d a(n);
  rep(i, n) ccin >> a[i];

  ll plussum = 0;
  ll1d rsump(n + 1, 0);
  ll1d rsumm(n + 1, 0);
  rep(i, n) {
    if (a[i] > 0) {
      plussum += a[i];
      rsump[i + 1] = rsump[i] + a[i];
      rsumm[i + 1] = rsumm[i];
    } else {
      rsumm[i + 1] = rsumm[i] - a[i];
      rsump[i + 1] = rsump[i];
    }
  }
  ll minus_value = inf;

  rep(i, n - k + 1) {
    ll misum = rsumm[i + k] - rsumm[i];
    ll plsum = rsump[i + k] - rsump[i];

    minus_value = min(min(minus_value, plsum), misum);
  }

  ll ans = plussum - minus_value;

  ccout << ans << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

signed main() {
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << ' ' << x << ' ' << y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
N=int(input())
rinsetu=[[] for j in range(N)]
d=[1000000]*(N)

color=["white"]*N
for i in range(N):
    a=list(map(int,input().split()))
    for j in range(a[1]):
        j1=j*2+2
        j2=j*2+3
        rinsetu[i].append([a[j1],a[j2]])
def hunterhunter():
    d[0]=0
    heap=[]
    heapq.heapify(heap)
    heapq.heappush(heap,[0,0])
    while(heap):
        mincost=heapq.heappop(heap)
        u=mincost[1]
        color[u]="black"
        for  i in rinsetu[u]:
            if color[i[0]]=="white":
                if i[1]+d[u]<d[i[0]]:
                    d[i[0]]=i[1]+d[u]
                    heapq.heappush(heap,[d[i[0]],i[0]])
hunterhunter()
for i,cost in enumerate(d):
    print(i,cost)



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

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		for(int j=0;j<s.size()-i;j++)
		{
			string t=s;
			t.erase(i,j);
			if(t=="keyence")
			{
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout <<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans1=(double)w*(double)h/2;
  int ans2=0;
  if(x*2==w && y*2==h){
    ans2=1;
  }
  printf("%.12lf %d\n",ans1,ans2);
  return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,k;
    cin >> n >> k;
    map<ll,ll> m;
    rep(i,n){
        ll in,num;
        cin >> in >> num;
        m[in] += num;
    }
    for(auto a : m){
        k -= a.second;
        if(k <= 0){
            cout << a.first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_169
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            long max = 1000000000000000000;

            for (int i = 0; i < n; i++)
            {
                if (array[i] == 0)
                {
                    WriteLine(0);
                    return;
                }
            }

            long val = 1;
            for(int i = 0; i < n; i++)
            {
                if (val > max / array[i])
                {
                    WriteLine(-1);
                    return;
                }

                val *= array[i];
            }

            WriteLine(val);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static decimal[] ReadDecimals() { return Array.ConvertAll(Read().Split(), decimal.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N, M;
    vector<ll> A, B, C;
    void input() {
        cin >> N;
        A.clear(); A.resize(N); cin >> A;
        cin >> M;
        B.clear(); B.resize(M); cin >> B;
        C.clear(); C.resize(M); cin >> C;
    }

    void solve() {
        sort(A.begin(), A.end());
        vector<ll> sum(N + 1, 0);
        for (int i = 0; i < N; i++) {
            sum[i + 1] = sum[i] + A[i];
        }
        //cout << sum << endl;
        for (int i = 0; i < M; i++) {
            ll x = B[i];
            int index = upper_bound(A.begin(), A.end(), x) - A.begin();
            //cout << a << " " << index << " -> ";
            cout << (sum[index] >= C[i] ? "Yes" : "No") << endl;
        }
    }
}

int main() {
    input(); solve();
    return 0;
}

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

using namespace std;

#define N 3200

const int mod=1000000007;
int n,m,ans,f[N][N][2];

void upd(int &x,int y){x=(x+y)%mod;}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=0;i<=n;++i) f[0][i][i==0]=1;
	for (int i=1;i<=m;++i)
		for (int j=0;j<=n;++j)
			for (int k=0;k<2;++k){
				if (j>0){
					upd(f[i][j][k||j==1],f[i-1][j][k]);
					upd(f[i][j-1][k||j==1],f[i-1][j][k]);
				}
				if (j<n){
					upd(f[i][j][k],f[i-1][j][k]);
					upd(f[i][j+1][k],f[i-1][j][k]);
				}
			}
	for (int i=0;i<=n;++i) upd(ans,f[m][i][1]);
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 76032
#include<stdio.h>
int main(){
  int h,w,i;
  char s[103][103];
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0&&w==0)break;
    scanf("\n");
    for(i=0;i<h;i++){
      fgets(s[i],102,stdin);
    }
    int x=0,y=0;
    char t;
    while(1){
      t=s[y][x];
      s[y][x]=0;
      if(t=='^')y--;
      if(t=='>')x++;
      if(t=='v')y++;
      if(t=='<')x--;
      if(t=='.')break;
      if(t==0)break;
    }
    if(t==0)printf("LOOP\n");
    else    printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 628
//20190629
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

    int d[n];

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

    sort(d,d+n);

    cout << d[n/2]-d[n/2-1] << endl;

    return 0;
}


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


int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i,n) {
    cin >> w[i];
  }
  int minv = 1e9;
  for (int i = 1;i < n;++i){
    int l = 0, r = 0;
    for(int j = 0;j < i;++j) l += w[j];
    for(int j = i;j < n;++j) r += w[j];
    minv = min(minv, abs(l-r));
  }
  cout << minv << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct TEAM{
  char n;
  int w, l;
};

int main(){
  struct TEAM t[1000];
  int n, r, i, j, max;

  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i){
      getchar();
      scanf("%c", &t[i].n);
      t[i].w = t[i].l = 0;
      for(j = 0; j < n - 1; ++j){
	scanf("%d", &r);
	switch(r){
	case 0: t[i].w++; break;
	case 1: t[i].l++; break;
	}
      }
    }

    for(i = 0; i < n; ++i){
      max = 0;
      for(j = 0; j < n; ++j){
	if(t[max].w < t[j].w) max = j;
	else if(t[max].w == t[j].w && t[max].l > t[j].l) max = j;
      }
      printf("%c\n", t[max].n);
      t[max].w = t[max].l = -1;
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M; cin>>N>>M;
  vector<string> A(N),B(M);
  rep(i,0,N) cin>>A[i];
  rep(i,0,M) cin>>B[i];
  string ans="No";
  REP(i,0,N-M){
    REP(j,0,N-M){
      bool flag=1;
      rep(k,i,i+M){
        rep(l,j,j+M){
          if(A[k][l]!=B[k-i][l-j]){
            flag=0;
            goto X;
          }
        }
      }
      X:
      if(flag){
        ans="Yes";
        goto XYZ;
      }
    }
  }
  XYZ:
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
N, Y = list(map(int, input().split()))

man = Y // 10000
fif = Y // 5000
judge = 0
eg = [-1, -1, -1]
for i in range(man+1):
	for j in range(fif+1):
		if Y - i*10000 - j*5000 < 0 or N - i - j < 0:
			break
		if (N - i - j)*1000 == (Y - i*10000 - j*5000):
			eg = [i,j,N-i-j]
			judge = 1
	if judge == 1:
		break

for i in range(3):
	print(eg[i], end="")
	print(" ", end="")
print("\n")

Measured memory_bytes: 41836
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

#define INF (1e5)
#define MOD 1000000007
typedef long long unsigned int ll;




int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if(abs(a-b)<=k&&abs(a-c)<=k&&abs(a-d)<=k&&abs(a-e)<=k&&abs(b-c)<=k&&abs(b-d)<=k&&abs(b-e)<=k&&abs(c-d)<=k&&abs(c-e)<=k&&abs(d-e)<=k){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
	int N;
	int sosu[168] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
	int yakusu[168];
	int i;
	int loop;
	long long int ans = 1;
	for (loop = 0; loop < 168; loop++)yakusu[loop] = 0;
	cin >> N;

	for (loop = 0; loop < 168; loop++){
		for (i = 1; N / i > 0; i++){
			yakusu[loop] += N / (int)pow(sosu[loop], i);
		}
		ans *= yakusu[loop] + 1;
		ans %= (int)pow(10, 9) + 7;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T, H, W;
char grid[15][1005];
int dp[15][1005];

int main()
{
	int i, j;
	scanf("%d%d%d", &H, &W, &K);
	for (i = 1; i <= H; ++i) {
		scanf("%s", grid[i] + 1);
	}
	for (i = 1; i <= H; ++i) {
		for (j = 1; j <= W; ++j) {
			if (grid[i][j] == '1') dp[i][j] = 1;
			dp[i][j] += dp[i][j - 1];
		}
		for (j = 1; j <= W; ++j) {
			dp[i][j] += dp[i - 1][j];
		}
	}

	int mini = INF;
	int until = (1 << H);
	for (int mask = 0; mask < until; ++mask) {
		vector<int> vec;
		vec.push_back(0);
		int cnt = 1;
		for (i = 0; i < H; ++i) {
			bool bit1 = (mask & (1 << i));
			bool bit2 = (mask & (1 << (i + 1)));
			if (i == H - 1 || bit1 != bit2) {
				vec.push_back(cnt);
				cnt = 1;
			}
			else ++cnt;
		}
		int n = vec.size() - 1;

		for (i = 1; i <= n; ++i) vec[i] += vec[i - 1];
		int cutcnt = n - 1;
		int prej = 0;
		bool flag = true;
		for (j = 1; j <= W; ++j) {
			for (i = 1; i <= n; ++i) {
				int white = dp[vec[i]][j] - dp[vec[i - 1]][j] - dp[vec[i]][prej] + dp[vec[i - 1]][prej];
				if (white > K) break;
			}
			if (i > n) {
				continue;
			}
			else {
				if (prej == j - 1) {
					flag = false;
					break;
				}
				prej = j - 1;
				--j;
				cutcnt++;
			}
		}
		if (flag) mini = min(mini, cutcnt);
	}
	printf("%d", mini);
	return 0;
}

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

int main(){
    
    int n; cin>>n;
    vector<int> pro (n);

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

    sort(pro.begin(),pro.end());

    cout<<pro[n/2] - pro[(n/2) - 1]<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<P> V(M);
    rep(i,0,M){
        int a,b;
        cin >> a >> b;
        V[i] = P(b,a);
    }
    sort(V.begin(), V.end());
    int cnt = 0, idx = -1;
    rep(i,0,M){
        if(V[i].second >= idx){
            idx = V[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main(){
  int N;
  cin >> N;
   
  int x = 0;
  int z = N;
  
  for (int i = 0; i < 8 ; i++){
    x += z % 10;
    z  /= 10;
  }
 
  if (N % x == 0){
   cout << "Yes" << endl;
  }
 
  else{
   cout << "No" << endl;
  }    
}

Measured memory_bytes: 256
#include<stdio.h>
int ss(int A[], int N){
	int i, j, t, sw = 0, miji;
	for(i=0;i<N-1;i++){
		miji = i;
		for(j=i;j<N;j++){
			if(A[j]<A[miji]) miji=j;
		}
		t=A[i]; A[i] = A[miji]; A[miji]=t;
		if(i != miji) sw++;
	}
	return sw;
}
int main(){
	int N;
	int A[100];
	int i, sw;
	
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	sw = ss(A, N);
	for(i=0; i<N; i++){
		if(i>0){
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);
	
	
	return 0;
}

Measured memory_bytes: 604
package main

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

func main() {
	X := sc.nextInt()
	happy := 0
	for {
		if X < 500 {
			break
		}
		X = X - 500

		happy += 1000
	}
	// for {
	// 	if X < 5 {
	// 		break
	// 	}
	// 	X = X - 5

	// 	happy += 5
	// }
	happy += 5 * (X / 5)
	fmt.Println(happy)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
k, n = map(int, input().split())
a = list(map(int, input().split()))
dist = [0] * n
a.append(a[0])
for i in range(n) :
    if i == n-1 :
        dist[i] = a[i] - a[i+1]
    else :
        dist[i]= k - (a[i+1] - a[i])
print(min(dist))


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int count_a=0,count_b=0,foreign=0;
  for(int i=0;i<n;i++){
    if(s[i]=='a'){
      if(count_a+count_b<a+b) {
        cout<< "Yes"<< endl;
        count_a++;
      }
      else cout << "No" << endl;
    }
    else if(s[i] == 'b'){
      foreign++;
      if(count_a+count_b<a+b && foreign<=b){
        cout << "Yes" << endl;
        count_b++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else cout << "No" << endl;
  }
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const int N = 1e3+2;
const int INF = 1e9;
int n, k;
int ar[N];
int memo[N][N];

int dp(int idx, int k)
{
    if (idx == 0)
        return (k == 0 ? 0 : INF);
    if (k == 0)
        return 0;
    if (memo[idx][k] != -1)
        return memo[idx][k];
    return memo[idx][k] = min(dp(idx-1,k-1)+ar[idx], dp(idx-1,k));
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    memset(memo,-1,sizeof(memo));
    cout << dp(n,k) << '\n';
    return 0;
}

Measured memory_bytes: 7596
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const int INF = 1e9;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int dp[MAXN][MAXN][MAXN];
int main() {
	for (int i = 0; i < MAXN; i++)
	for (int j = 0; j < MAXN; j++)
	for (int k = 0; k < MAXN; k++)
		dp[i][j][k] = INF;
	int a, b, c;
	read(a), read(b), read(c);
	dp[a][b][c] = 0;
	for (int i = 0; i < MAXN; i++)
	for (int j = 0; j < MAXN; j++)
	for (int k = 0; k < MAXN; k++) {
		if (i + 2 < MAXN) chkmin(dp[i + 2][j][k], dp[i][j][k] + 1);
		if (j + 2 < MAXN) chkmin(dp[i][j + 2][k], dp[i][j][k] + 1);
		if (k + 2 < MAXN) chkmin(dp[i][j][k + 2], dp[i][j][k] + 1);
		if (i + 1 < MAXN && j + 1 < MAXN) chkmin(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
		if (k + 1 < MAXN && j + 1 < MAXN) chkmin(dp[i][j + 1][k + 1], dp[i][j][k] + 1);
		if (i + 1 < MAXN && k + 1 < MAXN) chkmin(dp[i + 1][j][k + 1], dp[i][j][k] + 1);
	}
	int ans = INF;
	for (int i = 0; i < MAXN; i++)
		chkmin(ans, dp[i][i][i]);
	writeln(ans);
	return 0;
}

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

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

bool solve(long long a, long long b, long long c, long long d) {
    if(a < b) return false;
    if(d < b) return false;
    if(c >= b - 1) return true;

    long long g = GCD(b , d);
    long long m = b + a%g - g;
    if(m > c) return false;
    else return true;
}

int main() {
    int T;
    cin >> T;
    for(int i=0; i<T; ++i) {
        long long a,b,c,d;
        cin >> a >> b >> c >> d;
        if(solve(a,b,c,d)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    string S;
    cin >> S;
    bool ans = true;
    for (int i=0; i<S.size()-1; i++) {
        if (S[i]==S[i+1]) {
            ans=false;
        }
    }
    
    if (ans) {
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
#include <functional>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
			cin >> a[i];
	}
	vector<bool> row(false);
	vector<bool> col(false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}

}

Measured memory_bytes: 256
function Main(input) {
  var s = new Set(input.split("\n")[0]);
  var t = "abcdefghijklmnopqrstuvwxyz"
  for (var i = 0; i < 26; i++) {
    if(!s.has(t[i])) {
      console.log(t[i]);
      return;
    }
  }
  console.log("None");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
int d[101];

int main() {
  cin >> N;
  rep(i, 0, N) { cin >> d[i]; }
  sort(d, d + N);
  int ans = 1;
  rep(i, 0, N - 1) {
    if (d[i + 1] > d[i]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>){
    var (a,b) = readLine()!!.split(' ').map(String::toLong)
    var ans = 1
    var cou = 0L
    for(i in 0 until a)ans *= 100
    for(i in 1 until 1000){
        var tmp = ans * i
        for(j in 0 until a)tmp /= 100
        if(!(tmp % 100 == 0))cou++
        if(cou == b){
            ans *= i
            break
        }
    }
    println(ans)
}


Measured memory_bytes: 38172
#include<iostream>
  
int const MAXA = 100;

int A[3][3], N;

int main() {
  for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) std::cin >> A[i][j];
  std::cin >> N;
  for(int n = 0; n < N; ++n) {
    int b; std::cin >> b;
    for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) if(A[i][j] == b) {
      A[i][j] = 0; break;
    }
  }
  for(int i = 0; i < 3; ++i) {
    if(A[i][0]+A[i][1]+A[i][2] == 0) { std::cout << "Yes" << std::endl; return 0; }
    if(A[0][i]+A[1][i]+A[2][i] == 0) { std::cout << "Yes" << std::endl; return 0; }
  }
  if(A[0][0]+A[1][1]+A[2][2] == 0 ||
     A[0][2]+A[1][1]+A[2][0] == 0) { std::cout << "Yes" << std::endl; return 0; }
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x;
    cin >> x;

    cout << (x ? 0 : 1) << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}
 
// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
int N, M, Q; 
ll ans = 0;


ll a[55],b[55],c[55],d[55];
void dfs(vector<int> v){
  if(v.size() == N){
    ll tmp = 0;
    for(int i=0; i<Q; i++){
      if(v[b[i]] - v[a[i]] == c[i]){
        tmp += d[i];
      }
    }
    ans = max(ans, tmp);
    return;
  }

  for(int i=v[v.size()-1]; i<=M; i++){
    v.push_back(i);
    dfs(v);
    v.pop_back();
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  cin >> N >>M >> Q;
  REP(i,Q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }

  vector<int> v;
  for(int i=1; i<=M; i++){
    v.push_back(i);
    dfs(v);
    v.pop_back();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2 ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;

  int ans = 700;
  rep(i, 3) {
    if (s[i] == 'o') ans += 100;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b, c): (i32, i32, i32) = read();
    let m = max(a, max(b, c));
    let mut ans = (m-a)/2+(m-b)/2+(m-c)/2;
    let (a2, b2, c2, m2) = (a%2, b%2, c%2, m%2);
    let mut eqmod = 0;
    for &a in [a2, b2, c2].iter() {
        if a == m2 {
            eqmod += 1;
        }
    }
    ans += eqmod % 3;
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include "bits/stdc++.h"

#define F first
#define S second
#define pb push_back
#define endl '\n'

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int N = 1e3 + 10;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            for (int l = 0; l <= k; ++l) {
                if ( i + j + l <= k) {
                    if ( c * pow(2, l) > b * pow(2, j) and b * pow(2, j) > a * pow(2, i)) {
                        cout << "Yes\n";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 4016
line = input().split(" ")
a = list(map(int, line))
data = [0] * 90001
ans = 0
for i in range(0, a[0]):
    line = input().split(" ")
    temp = list(map(int, line))
    for j in range(0, a[1]):
        data[temp[j]] = [i, j]

memo = [0] * 90001

for i in range(1, a[0] * a[1]+1):
    if i < a[2]+1:
        memo[i] = 0
    else:
        memo[i] = memo[i - a[2]] + abs(data[i][0] - data[i - a[2]][0]) + abs(data[i][1] - data[i - a[2]][1])
times = int(input())
for i in range(0, times):
    line = list(map(int, input().split(" ")))
    print(memo[line[1]] - memo[line[0]])

Measured memory_bytes: 17084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  #ifdef LOCAL_DEFINE
  freopen ("input.txt", "r", stdin);
  freopen ("output.txt", "w", stdout);
  #endif 
  string a, b;
  cin >> a >> b;
  int dp[a.length() + 1][b.length() + 1];
  for (int i = 0; i <= a.length(); ++i) {
    for (int j = 0; j <= b.length(); ++j) {
      dp[i][j] = 0;
    }
  } 
  for (int i = 1; i <= a.length(); ++i) {
    for (int j = 1; j <= b.length(); ++j) {
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }else{
        dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  stack <char> lcs;
  int i = a.length(), j = b.length();
  while (i > 0 && j > 0) {
    if (a[i - 1] == b[j - 1]) {
      lcs.push (a[i - 1]);
      --i;
      --j;
    }else if (dp[i - 1][j] > dp[i][j - 1]) {
      --i;
    }else{
      --j;
    }
  }
  if (lcs.size() == 0) {
    cout << " ";
  }
  while (lcs.size()) {
    cout << lcs.top();
    lcs.pop();
  }
}

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

using namespace std;

int main() {
    int a, b, c, d, p, x, y;
    cin >> a >> b >> c >> d >> p;
    x = p * a;

    if (p <= c) {
        y = b;
    } else {
        y = b + (p - c) * d;
    }

    cout << min(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3060
n = gets.to_i
sqn = Math.sqrt(n).floor.to_i
ans = 10
for i in 1..sqn
  if n%i == 0
    a = n/i
    count = 0
    while a != 0
      a /= 10
      count += 1
    end
  end
  ans = [ans,count].min
end
puts ans

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;

int main()
{
	int r;cin>>r;
	cout<<r*r<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vector<vector<int>> HW(H + 1, vector<int>(W + 1));

    rep(i, H) {
        rep(j, W) {
            HW[i][j + 1] += HW[i][j] + (S[i][j] == '1' ? 1 : 0);
        }
    }

    ll ans = INF;
    rep(bit, 1 << (H - 1)) {
        vector<int> y;
        y.emplace_back(0);
        rep(i, H - 1) {
            if ((bit >> i) & 1) {
                y.emplace_back(i + 1);
            }
        }
        y.emplace_back(H);
        int bw = 0;
        bool check = true;
        int div = 0;
        repd(j, 1, W + 1) {
            bool flag = true;
            repd(i, 1, y.size()) {
                int cnt = 0;
                repd(k, y[i - 1], y[i]) {
                    cnt += HW[k][j] - HW[k][bw];
                }
                if (cnt > K) {
                    flag = false;
                    break;
                }
            }
            if (!flag) {
                if (bw == j - 1) {
                    check = false;
                    break;
                }
                bw = j - 1;
                j--;
                div++;
            }
        }
        if (check) {
            ll res = div + (int)y.size() - 2;
            chmin(ans, res);
        }
    }

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

Measured memory_bytes: 3704
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

x = [0 for _ in range(N)]

for i in range(N):
    t = T - H[i] * 0.006
    x[i] = abs(t - A)
print(x.index(min(x)) + 1)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

string s;

signed main() {
	int i;
	
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String s = new Scanner(System.in).next();
		char a = 'a';
		while (s.indexOf(String.valueOf(a)) != -1)
			a++;
		System.out.println((a <= 'z')? a : "None");
	}
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll maxn=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    
    int n;
    cin>>n;
    
    int ar[n+1];
    forn(i,n+1){
    	if(i==0) continue;
    	cin>>ar[i];
    }
    int start = n/2;
    // cout<<start<<endl;
    while(start>0){
    	int j = start+start;
    	int sum = 0;
    	while(j<=n){
    		sum+=ar[j];
    		j+=start;
    	}
    	if(sum%2==ar[start]) ar[start] = 0;
    	else ar[start] = 1;
    	start--;
    }
    vector<int> ans;
    forn(i,n+1){
    	if(i==0) continue;
    	if(ar[i]) ans.pb(i); 
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
    	cout<<it<<" ";
    }




  return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n+1, 0);
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int cur = 1, ans = 0;
    vector<int> visit(n+1, 0);
    visit[cur] = 1;
    while(cur != 2) {
        cur = arr[cur];
        ans += 1;
        if (visit[cur] == 1) {
            cout << -1 << endl;
            return 0;
        }
        visit[cur] = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3980