akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int maxn=410;
const int mod=998244353;
inline int ad(int x,int y){return x>=mod-y?x-mod+y:x+y;}
inline int re(int x,int y){return x<y?x-y+mod:x-y;}
inline int mu(int x,int y){return (LL)x*y%mod;}
inline int qp(int x,LL y){if(y==-1)y=mod-2;int r=1;while(y){if(y&1)r=mu(r,x);x=mu(x,x);y>>=1;}return r;}
inline int iv(int x){return qp(x,mod-2);}
inline int dv(int x,int y){return mu(x,qp(y,mod-2));}

int fac[maxn],fac_inv[maxn];
int a[maxn],b[maxn],f[maxn][maxn];
int main()
{
	fac[0]=1;for(int i=1;i<maxn;i++)fac[i]=mu(fac[i-1],i);
	fac_inv[maxn-1]=iv(fac[maxn-1]);
	for(int i=maxn-2;i>=0;i--)fac_inv[i]=mu(fac_inv[i+1],i+1);
	int n,A=0,tA=0,B=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]),A+=a[i],B+=b[i]-1;
	tA=iv(A);
	
	f[0][0]=1;
	for(int s=1,suma=a[1],sumb=b[1]-1;s<=n;s++,suma+=a[s],sumb+=b[s]-1)
		for(int i=suma;i>=a[s];i--)
			for(int j=sumb;j>=0;j--)
				for(int t=0;t<b[s]&&j>=t;t++)
					f[i][j]=ad(f[i][j],mu(mu(re(0,qp(mu(a[s],tA),t)),fac_inv[t]),f[i-a[s]][j-t]));
	
	int ans=0;
	for(int i=1;i<=A;i++)
		for(int j=0;j<=B;j++)
			ans=ad(ans,mu(dv(fac[j],qp(mu(i,tA),j+1)),re(0,f[i][j])));
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;


int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int x = n - 1;
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i + 1 < n; ++i) {
    if (a[i + 1] <= i + 1) {
      x = i;
      break;
    }
  }
  int cnt = 0;
  for (int i = x + 1; i < n; ++i) {
    if (a[i] > x) {
      ++cnt;
    }
  }
  if ((a[x] - x - 1) % 2 == 0 && cnt % 2 == 0) {
    cout << "Second\n";
  } else {
    cout << "First\n";
  }
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#define maxn 110
using namespace std;
int n;
long long s0[maxn],s1[maxn],s2[maxn],s3[maxn];
int l0,l1,l2,l3;
long long ans,mv0[maxn],mv1[maxn],mv2[maxn],mv3[maxn];
long long INF = (1LL)<<31,w,w1;
bool cmp(long long a,long long b) {
	return a>b;
}
int main() {
	scanf("%d %d",&n,&w);
	l0=l1=l2=l3=0;
	int x,y;
	scanf("%d %d",&w1,&y);
	l0++; s0[l0]=y;
	for (int i=2;i<=n;i++) {
		scanf("%d %d",&x,&y);
		if (x==w1) {
			l0++; s0[l0]=(long long)y;
		}
		else if (x==w1+1) {
			l1++; s1[l1]=(long long)y;
		}
		else if (x==w1+2) {
			l2++; s2[l2]=(long long)y;
		}
		else {
			l3++; s3[l3]=(long long)y;
		}
	}
	sort(s0+1,s0+(l0+1),cmp);
	sort(s1+1,s1+(l1+1),cmp);
	sort(s2+1,s2+(l2+1),cmp);
	sort(s3+1,s3+(l3+1),cmp);
	for (int i=1;i<=n;i++)
		mv0[i]=mv1[i]=mv2[i]=mv3[i]=0LL;
	for (int i=1;i<=l0;i++) {
		mv0[i]=mv0[i-1]+s0[i];
	}
	for (int i=1;i<=l1;i++) {
		mv1[i]=mv1[i-1]+s1[i];
	}
	for (int i=1;i<=l2;i++) {
		mv2[i]=mv2[i-1]+s2[i];
	}
	for (int i=1;i<=l3;i++) {
		mv3[i]=mv3[i-1]+s3[i];
	}
	ans=0LL;
	for (int i=0;i<=n;i++) {
		for (int j=0;j<=n;j++) {
			for (int k=0;k<=n;k++) {
				for (int l=0;l<=n;l++) {
					if (w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l<=w) {
						ans=max(ans,mv0[i]+mv1[j]+mv2[k]+mv3[l]);
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int64_t lucas_num(int n, vector<int64_t> &vec) {
  int64_t n1 = 0, n2 = 0;
  if (vec.at(n) != 0) {
    return vec.at(n);
  } else {
    int64_t result = lucas_num(n - 1, vec) + lucas_num(n - 2, vec);;
    vec.at(n) = result;
    return result;
  }
}

int main() {
  int num;
  cin >> num;
  
  vector<int64_t> vec(100);
  vec.at(0) = 2;
  vec.at(1) = 1;
  
  cout << lucas_num(num, vec) << endl;
}

Measured memory_bytes: 3620
using System;

namespace atcoderbc138
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            string str = Console.ReadLine();
            if(a >= 3200)
                Console.WriteLine(str);
            else
                Console.WriteLine("red");
        }
    }
}


Measured memory_bytes: 11220
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  rep(i, n) {
    cin >> p[i + 1];
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }

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

Measured memory_bytes: 3708
taroScore = 0
hanakoScore = 0
num = int(input())
for i in range(num):
        list = input().split()
        taroStr = list[0]
        hanakoStr = list[1]
        if taroStr > hanakoStr:
                taroScore += 3
        elif taroStr < hanakoStr:
                hanakoScore += 3
        else:
                taroScore += 1
                hanakoScore += 1

print(taroScore, hanakoScore)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;
		cin>>n;
		vll A(n);
		forn(i,n)
			cin>>A[i];
		ll ans=0;
		forn(i,n)
		{
			if(i&1^1&&A[i]&1)
			{
				ans++;
			}

		}
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 3616
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	q := nextInt(sc)
	a := make([]int, 0)
	ans := make([]int, 0)
	for i := 0; i < q; i++ {
		t := nextInt(sc)
		if t == 2 {
			a = a[:len(a)-1]
		} else {
			p := nextInt(sc)
			if t == 0 {
				a = append(a, p)
			} else {
				ans = append(ans, a[p])
			}
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(wtr, ans[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ms(a, n) memset(a, n, sizeof(a))
#define Size(Array) sizeof(Array)/sizeof(Array[0])
#define pb push_back
#define ed endl
#define en cout << endl
#define it(A) A.begin(), A.end()
#define mod (ll)(1e9 + 7)
#define f(i, a, b) for(ll i = a; i < b; i++)
#define cin(a, n) for(ll i = 0; i < n; i++) cin >> a[i]
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 200005


using namespace std;


void solve()
{
    ll a, b, n;
    cin >> a >> b >> n;
    if(b==1)
    {
        cout << 0 << endl;
        return;
    }

    ll x = min(b-1, n);
    ll p = (a*x)/b;
    ll q = a*(x/b);

    cout << p-q << endl;


    return;
}

int main()
{
    FAST;

    ll t = 1;
    while(t--)
        solve();


    return 0;
}



Measured memory_bytes: 3616
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    int A[5001]={0},B[5001]={0};
    cin>>N>>M;
    int ans=0;
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<M;i++)cin>>B[i];
    for(int i=0;i<M;i++){
        int BB=i,karians=0;
        for(int j=0;j<N;j++){
            if(A[j]==B[BB])karians++,BB++;
        }
        ans=max(ans,karians);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>


#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;



int main()
{
	int n;
	while (cin >> n, n){
		string a;
		cin >> a;
		REP(i, n){
			vector<char> a_a(a.begin(), a.end());

			string b;
			auto it = a_a.begin();
			int num(1);

			while (it != a_a.end()){
				while (it + 1 != a_a.end() && *it == *(it + 1)){
					++num;
					++it;
				}
				b += to_string(num);
				b += *it;
				num = 1;
				++it;
			}
			a.clear();
			a = b;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;

int V,E,s,t;
int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V;
    vector<int> dp(V+2,INF),h(V);
    for(int i = 0; i < V;++i) cin >> h[i];
    dp[0] = 0;
    for(int i = 0; i < V;++i){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
    }
    cout << dp[V-1] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

double dp[3][3][16];
int n, s, t, b;

int toIndex(char l){
    return l - 'A';
}

double rec(int x, int y, int battery){
    if(dp[y][x][battery] > -1e-6){return dp[y][x][battery];}
    if(x == t % 3 && y == t / 3 && battery == n){return 1.0;}
    if(battery >= n){return 0.0;}

    double res = 0.0;
    REP(i, 4){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < 3 &&
           0 <= ny && ny < 3 &&
           !(nx == b % 3 && ny == b / 3)){
            res += 0.25 * rec(nx, ny, battery+1);
        }else{
            res += 0.25 * rec(x, y, battery+1);
        }
    }

    return dp[y][x][battery] = res;
}

int main(){
    while(std::cin >> n, n){
        std::fill(dp[0][0], dp[0][0]+3*3*16, -1.0);

        char sl, tl, bl;
        std::cin >> sl >> tl >> bl;

        s = toIndex(sl), t = toIndex(tl), b = toIndex(bl);

        printf("%.7f\n", rec(s%3, s/3, 0));
    }
}

Measured memory_bytes: 1188
#include <stdio.h>
int main(){
	int in;
	int i,asum=0,bsum=0;
	for(i=0;i<4;i++){
		scanf("%d",&in);
		asum+=in;
	}
	for(i=0;i<4;i++){
		scanf("%d",&in);
		bsum+=in;
	}
	printf("%d\n",asum>bsum?asum:bsum);
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,t;string str[1000000];
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for(;t<n;t++)
    {
        cin>>str[t];
    }
    if(!is_sorted(str,str+n))   sort(str,str+n);
    cout<<unique(str,str+n)-str<<'\n';
    return 0;
}

Measured memory_bytes: 34924
#入力受付
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])

if a == 5 and b == 7 and c == 5:
    print("YES")
elif a == 7 and b == 5 and c == 5:
    print("YES")
elif a == 5 and b == 5 and c == 7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class TheKingsArmyDiv2
{
public:
	int getNumber(vector <string> state)
	{

	}
};
*/




int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double s, t;
	
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF)
	{
		s = ((xp - x1) * (y3 - y1) - (yp - y1) * (x3 - x1)) /
			((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1));
		t = ((xp - x1) * (y2 - y1) - (yp - y1) * (x2 - x1)) /
			((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1));
		
		if (s > 0 && t > 0 && s + t < 1)
		{
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<cstdio>
using namespace std;
int a[101]={},b[101]={},c[101]={},d,e,f,g,h,k[1000]={},aa[1000]={},bb[1000]={},cc[1000]={},l,p,i,n,j,m,x,y,z;
int main(){
	while(1){
	for(i=1;i<=100;i++){
		a[i]=2;
		b[i]=2;
		c[i]=2;
	}
	scanf("%d%d%d",&d,&e,&f);
	if(d==0) break;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&aa[i],&bb[i],&cc[i],&k[i]);
		if(k[i]==1) {
			a[aa[i]]=1;
			b[bb[i]-d]=1;
			c[cc[i]-e-d]=1;
		}
	}
	
	for(x=0;x<n;x++){
		if(k[x]==0){
             if(a[aa[x]]==1 && b[bb[x]-d]==1){
		c[cc[x]-e-d]=0;
	}
	if(a[aa[x]]==1 && c[cc[x]-e-d]==1){
		b[bb[x]-d]=0; 
	}
	if(b[bb[x]-d]==1 && c[cc[x]-e-d]==1){
		a[aa[x]]=0; 
	}
		}}
	for(i=1;i<=d;i++){
		printf("%d\n",a[i]);
	}
	for(i=1;i<=e;i++){
		printf("%d\n",b[i]);
	}
	for(i=1;i<=f;i++){
		printf("%d\n",c[i]);
	}}
	return 0;
}

Measured memory_bytes: 1044
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

bool isPrime[10000001];

int main(){

	fill((bool*)isPrime,(bool*)isPrime+10000001,true);
	isPrime[0] = isPrime[1] = false;
	
	for(int i=2;i*i<=10000000;i++){
		if(isPrime[i]){
			for(int j=i+i;j<=10000000;j+=i){
				isPrime[j] = false;
			}
		}
	}

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int res=-1;
		for(int i=n;i-6>=0;i--){
			if(isPrime[i] && isPrime[i-2] 
			&& isPrime[i-6] && isPrime[i-8]){
				res = i;
				break;
			}
		}

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

	}
}

Measured memory_bytes: 10000
from itertools import *
n, m, q = map(int, input().split())

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i], b[i] = a[i] - 1, b[i] - 1

p_tmp = [0] * m
for i in range(m):
    p_tmp[i] = i

p = combinations_with_replacement(p_tmp, n)

ans = 0
for x in p:
    score = 0
    for i in range(q):
        if x[b[i]] - x[a[i]] == c[i]:
            score += d[i]

    ans = max(ans, score)

print(ans)

Measured memory_bytes: 73588
#include <bits/stdc++.h>
#define MAXN 110
#define MAXC 30
using namespace std;

int n, now, ans;
char s[MAXN];
bool vis_x[MAXC], vis_y[MAXC];

int main() {
  scanf("%d%s", &n, s + 1);
  for (register int pos = 1; pos <= n; ++pos) {
    now = 0; memset(vis_x, 0, sizeof(vis_x)); memset(vis_y, 0, sizeof(vis_y));
    for (register int i = 1; i <= pos; ++i)
      !vis_x[s[i] - 'a'] && (vis_x[s[i] - 'a'] = 1);
    for (register int i = pos + 1; i <= n; ++i)
      !vis_y[s[i] - 'a'] && (vis_y[s[i] - 'a'] = 1);
    for (register int i = 0; i < 26; ++i)
      (vis_x[i] && vis_y[i]) && ++now;
    ans < now && (ans = now);
  }
  printf("%d", ans);
  return 0;
}


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

 using namespace std;
  char Arr[10][10];
  int main(){
   int H,W;
   scanf("%d%d",&H,&W);
   for(int i=0;i<H;i++){
    scanf("%s",Arr[i]);
   }
   int Count = 0;
  for(int i =0;i<H;i++){
    for(int j=0;j<W;j++){
        if(Arr[i][j]=='#')Count++;
    }
  }
  int m=0,n=0;
  int Found = 1;
  while(m<H&&n<W){
    if(m==H-1&&n==W-1)break;
    if(Arr[m][n+1]=='#'){
        n++;
        Found++;
    }
    else if(Arr[m+1][n]=='#'){
        m++;
        Found++;
    }else{
//    printf("%d %d %d %d",m,n,Found,Count);
     printf("Impossible");
     return 0;
    }
  }
//  printf("%d %d\n",Found,Count);
  if(Found==Count)printf("Possible");
  else printf("Impossible");
  }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
long long N, X, MX1, MX2, X1, X2;
vector<long long> cnt1(1000000), cnt2(1000000);
void solve() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X;
        if (i % 2 == 0) {
            cnt1[X]++;
            if (MX1 < cnt1[X]) {
                MX1 = cnt1[X];
                X1 = X;
            }
        } else {
            cnt2[X]++;
            if (MX2 < cnt2[X]) {
                MX2 = cnt2[X];
                X2 = X;
            }
        }
    }
    sort(cnt1.begin(), cnt1.end());
    sort(cnt2.begin(), cnt2.end());
    if (X1 != X2) {
            cout << N - MX1 - MX2 << endl;
        } else {
            cout << N - max(MX1 + cnt2[cnt2.size() - 2], MX2 + cnt1[cnt1.size() -2]) << endl;
    }
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 15872
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, a: "List[int]"):
    a_num = np.array(a)
    min_value = np.min(a_num)
    max_value = np.max(a_num)

    answer = 10**7
    for i in range(min_value,max_value+1):
        goal = np.full(N,i)
        dif = a_num-goal
        nijo = dif**2
        answer = min(answer,np.sum(nijo))
    print(int(answer))
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;


int main() {
  
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==b && b!=c) ||(a==c && c!=b) ||(c==b && b!=a) )
       printf("Yes");
       
    else
      printf("No");
	return 0;
}

Measured memory_bytes: 256
a, b = map(int,input().split(' '))
s = input()
nums = ['0','1','2','3','4','5','6','7','8','9']

flg = 0

for i in range(a):
    if s[i] in nums:
#        print(i)
        pass
    else:
        flg = 1

if s[a] != '-':
    flg = 1

for i in range(a+1,a+b+1):
#    print("b")
#    print(i)
    if s[i] in nums:
        pass
    else:
        flg = 1

if flg == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if A + B <= K:
        print(0, 0)
        return

    a = A - K
    if a < 0:
        ans_b = B + a
    else:
        ans_b = B
    print(max(a, 0), ans_b)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
const int Maxn=1e5+5;
int n,f[Maxn],pos1,pos2,cnt;
long long ans;
struct Point
{
	int pos,id;
}x[Maxn],y[Maxn];
struct Edge
{
	int u,v,val;
}xz[Maxn],yz[Maxn];
bool cmp1(Point a,Point b)
{
	return a.pos<b.pos;
}
bool cmp2(Edge a,Edge b)
{
	return a.val<b.val;
}
int findfa(int u)
{
	return f[u]==u?u:f[u]=findfa(f[u]);
}
int main()
{
	//freopen("std.in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i].pos>>y[i].pos;
		x[i].id=i;y[i].id=i;
		f[i]=i;
	}
	sort(x+1,x+n+1,cmp1);
	sort(y+1,y+n+1,cmp1);
	for(int i=1;i<n;i++)
	{
		xz[i].u=x[i].id;
		xz[i].v=x[i+1].id;
		xz[i].val=x[i+1].pos-x[i].pos;
	}
	for(int i=1;i<n;i++)
	{
		yz[i].u=y[i].id;
		yz[i].v=y[i+1].id;
		yz[i].val=y[i+1].pos-y[i].pos;
	}
	sort(xz+1,xz+n+1,cmp2);
	sort(yz+1,yz+n+1,cmp2);
	pos1=pos2=1;
	while(cnt<n-1)
	{
		if(xz[pos1].val<yz[pos2].val)
		{
			if(findfa(xz[pos1].u)!=findfa(xz[pos1].v))
			{
				f[findfa(xz[pos1].v)]=findfa(xz[pos1].u);
				cnt++;
				ans+=xz[pos1].val;
			}
			pos1++;
		}
		else
		{
			if(findfa(yz[pos2].u)!=findfa(yz[pos2].v))
			{
				f[findfa(yz[pos2].v)]=findfa(yz[pos2].u);
				cnt++;
				ans+=yz[pos2].val;
			}
			pos2++;
		}
	}
	cout<<ans;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string s;
string t;
int cnt[3];

int main(){
	cin>>s;
  rep(i,s.size()){
    cnt[s[i]-'a']++;
  }
  
  if(abs(cnt[0]-cnt[1])<=1&&abs(cnt[1]-cnt[2])<=1&&abs(cnt[2]-cnt[0])<=1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 512
N,X=map(int,input().split())
*A,=map(int,input().split())
A.sort()

ans=0
i=0
while X and i<N-1:
    X-=A[i]
    if X>=0:
        ans+=1
    else:
        break
    i+=1

if i==N-1 and A[i]==X:
    ans+=1

print(ans)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 5003, M = 10004, mod = 998244353 , mxLog = 20;

bool canBeUsed[10];
int howMany[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int mem[M];
int get_mxLen(int n) {
    if (n == 0)
        return 0;
    if (n < 0)
        return -oo;
    int &ret = mem[n];
    if (~ret)
        return ret;
    ret = -oo;
    for (int i = 9; i > 0; --i) {
        if (canBeUsed[i])
            ret = max(ret, 1 + get_mxLen(n - howMany[i]));
    }
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6), cout << fixed;

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        canBeUsed[x] = 1;
    }

    memset(mem, -1, sizeof mem);
    int mxLen = get_mxLen(n);

    string ans;
    for (int i = 0; i < mxLen; ++i) {
        for (int j = 9; j > 0; --j) {
            if (canBeUsed[j] && get_mxLen(n - howMany[j]) == mxLen - i - 1) {
                ans += j + '0';
                n -= howMany[j];
                break;
            }
        }
    }

//    reverse(ans.begin(), ans.end());

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int K;
	int i = 0;
	cin >> K >> s;
	while (s[i])
	{
		i++;
	}
	if (i>K)
	{
		for (int d = 0; d < K; d++)
		{
			cout << s[d];
		}
		cout << "...";
	}
	else
	{
		cout << s;
	}
}



Measured memory_bytes: 3580
N,Yen=map(int,input().split())

def solver(n,yen):
  for x in range(n+1):
    for y in range(n-x+1):
      z=n-x-y
      if x*10000+y*5000+z*1000 == yen:
        return x,y,z
  return -1,-1,-1
print(*solver(N,Yen))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll S;
    cin >> S;
    auto F=[](ll &n){
        if(n%2==0)return n/2;
        else return 3*n+1;
    };
    vector<ll> vec(1000001);
    vec[0]=S;
    for(ll i=1;i<1000001;++i)vec[i]=F(vec[i-1]);
    Map M;
    for(ll i=0;i<1000001;++i){
        M[vec[i]]++;
        if(M[vec[i]]>1){
            prt(i+1)fl return 0;
        }
    }


    return 0;
}


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

int main(){
  int i,j,can;
  char str[11],prev,now;
  for(i = 0 ; i < 1000 ; i++){
    scanf("%s",str);
    can = 1;
    for(j = 1 ; j < strlen(str) ; j++){
      prev = str[j-1];
      now = str[j];
      if(prev == 'A' && now == 'B'){ continue; }
      if(prev == 'A' && now == 'D'){ continue; }
      if(prev == 'B' && now == 'A'){ continue; }
      if(prev == 'B' && now == 'C'){ continue; }
      if(prev == 'B' && now == 'E'){ continue; }
      if(prev == 'C' && now == 'B'){ continue; }
      if(prev == 'C' && now == 'F'){ continue; }
      if(prev == 'D' && now == 'A'){ continue; }
      if(prev == 'D' && now == 'E'){ continue; }
      if(prev == 'D' && now == 'G'){ continue; }
      if(prev == 'E' && now == 'B'){ continue; }
      if(prev == 'E' && now == 'D'){ continue; }
      if(prev == 'E' && now == 'F'){ continue; }
      if(prev == 'E' && now == 'H'){ continue; }
      if(prev == 'F' && now == 'C'){ continue; }
      if(prev == 'F' && now == 'E'){ continue; }
      if(prev == 'F' && now == 'I'){ continue; }
      if(prev == 'G' && now == 'D'){ continue; }
      if(prev == 'G' && now == 'H'){ continue; }
      if(prev == 'H' && now == 'E'){ continue; }
      if(prev == 'H' && now == 'G'){ continue; }
      if(prev == 'H' && now == 'I'){ continue; }
      if(prev == 'I' && now == 'F'){ continue; }
      if(prev == 'I' && now == 'H'){ continue; }
      can = 0; break;
    }
    if(can){
      printf("%s\n",str);
    }
  }
  return 0;
}

Measured memory_bytes: 948
n,a[100],dp[1<<17];
i,j,l;
main(k)
{
	for(scanf("%d%d",&n,&k);~scanf("%d",a+j++););
	for(;i++<k;)
	{
		for(j=0;j<n&&a[j]<=i;j++)dp[i]|=!dp[i-a[j]];
	}
	puts(dp[k]?"First":"Second");
}

Measured memory_bytes: 512
// copied from https://atcoder.jp/contests/abc110/submissions/8089381

#include<bits/stdc++.h>

using namespace std;

#define MAX_COMB_F 100100 

long long MOD = pow(10,9)+7;
long long comb[MAX_COMB_F][50];

main(){
  long long n, m, temp;
  //n=100000;
  //m=536870912;
  cin>>n>>m;
  vector<long long> p;
  temp=m;

  for(int i=2;i<MAX_COMB_F;i++){
    long long count=0;
    while (temp%i==0){
      temp /= i;
      count++;
    }
    p.push_back(count);
  }

  // for(int i=0;i<MAX_COMB_F;i++){
  //   cout<<p[i]<<' ';
  // }
  // cout<<endl;
  // cout<<endl;
  // cout<<endl;

  if(temp!=1){p.push_back(1);}

  for(int i=0;i<MAX_COMB_F;i++){
    comb[i][0]=1;
//    if(i<50) comb[i][i]=1;
  }
  comb[1][1]=1;

  for(int i=2;i<MAX_COMB_F;i++){
    for(int j=1;j<50;j++){
      comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
      comb[i][j] %= MOD;
    }
  }

  long long ans = 1;
  for(int i=0;i<p.size();i++){
    long long m;
    m=p[i];
    if(n-1+m>MAX_COMB_F){

      cout<<n<<endl;
      cout<<m<<endl;
      cout<<(n-1+m)<<endl;
    }
    ans *= comb[n-1+m][m];
    ans %= MOD;
  }

  cout << ans << endl;

}


Measured memory_bytes: 40308
#include <iostream>

using namespace std;
const long long MAXN = 2e5+5;
long long arr[MAXN];
long long pref[MAXN];
long long ans=1e18;
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
        pref[i] = pref[i-1]+arr[i];
    }
    long long suff = 0;
    for(long long i=n;i>=2;i--){
        suff+=arr[i];
        ans = min(ans,abs(suff-pref[i-1]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	string s[50] = {}, t[50] = {};
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	bool f = 0;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m;j++) {
			bool g = 1;
			for (int k = j; k <= j + m - 1;k++) {
				if (t[k-j] != s[k].substr(i, m)) {
					g = 0;
					break;
				}
			}
			if (g) {
				f = 1;
				break;
			}
		}
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,m,ans=0;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  for(int i=0;i<m;++i){
    cin >> l[i] >> r[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  sort(r.begin(),r.end());
  if(r[0]-l[0]<0){
    cout << 0 << endl;
  }else{
    cout << r[0]-l[0]+1 << endl;
  }
}


Measured memory_bytes: 4092
#include "bits/stdc++.h"
using namespace std;

typedef long long lli;
typedef pair<int,int> pii;
#define rep(i,n) for(lli i=0;i<(lli)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int pass[200][200];


int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        
        rep(i,200)rep(j,200)pass[i][j]=INF;
        
        rep(i,m){
            int a,b,c;
            cin>>a>>b>>c;
            pass[a][b]=c;
            pass[b][a]=c;
        }
        
        bool used[200];
        int mincost[200];
        rep(i,200)mincost[i]=INF;
        rep(i,200)used[i]=false;
        
        int res=0;
        mincost[0]=0;

        while(1){
            int v=-1;
            rep(i,n){
                if( !used[i]&&(v==-1||mincost[v]>mincost[i]) )v=i;
            }
            
            if(v==-1)break;
            
            used[v]=true;
            res+=mincost[v];
            
            rep(i,n){
                mincost[i] = min( mincost[i] , pass[v][i] );
            }
        }
        cout<<res<<endl;
    }
}

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

main () {
 int a, b, c, d;
 cin >> a >> b >> c >> d;
 if(a>=c&&a-c<=d||a<c&&c-a<=d)
  cout << "Yes" <<endl;
 else if(a>=b&&a-b<=d||a<b&&b-a<=d)
  if(b>=c&&b-c<=d||b<c&&c-b<=d) {
   cout << "Yes" <<endl;
  }
   else cout << "No" <<endl;
 else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (n, k) = get!(usize, usize);

    if (n + 1) / 2 >= k {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 8572
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	int i;
	cin>>s;
	for(i=0;i<7;i++){
		if(s.substr(0,i)+s.substr(s.length()-7+i)=="keyence"){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

int main() {
	int S;
	int W;
	cin >> S >> W;
	string str;
	str = (S > W) ? "safe" : "unsafe";
	cout << str << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int kazu,i,tmp[111]={0};
  int num[111]={0},cou=0,count=0,max;
  while(scanf("%d",&kazu) != EOF){
    tmp[kazu-1]++;
  }
  for(i=0;i<100;i++){
    num[i] = tmp[i];
  }
  max = 0;
  for(i=1;i<100;i++){
    if(num[i]>max){
      max = num[i];
    }
  }
  for(i=0;i<100;i++){
    if(num[i]==max){
      printf("%d\n",i+1);
    }
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll calc(ll n) {
    ll ret = 0;
    while (n != 0 && n % 2 == 0) {
        n /= 2;
        ret++;
    }
    return ret;
}

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

    ll ans = 0;
    for (auto v: a) {
        ans += calc(v);
    }

    cout << ans << endl;
}

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

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}

public class Main {
  private static long solve(long[] a, long[] b) {
    long answer = 0;
    for (int i = a.length - 1; i >= 0; i--) {
      long mod = (a[i] + answer) % b[i];
      if (mod > 0) {
        answer += b[i] - mod;
      }
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = reader.nextLong();
      b[i] = reader.nextLong();
    }
    out.println(solve(a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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


void solve(long long A, long long B, long long C, long long K){
  long long mymax = max(A, max(B, C));
  long long acc = A + B + C;

  cout << ((acc - mymax) + mymax * pow(2, K)) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long K;
  scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 4292
def resolve():
    m1,d1=map(int, input().split())
    m2,d2=map(int, input().split())
    if m2==m1+1 and d2==1:
        print('1')
    elif m1==12 and m2==1 and d2==1:
        print('1')
    else:
        print('0')
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}

int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}

/*--------Library Zone!--------*/

int H, W, N, ans[15];
map<P, int>mp;
signed main() {
	cin >> H >> W >> N;
	rep(i, N) {
		int A, B;
		cin >> A >> B;
		mp[{A, B}]++;
		mp[{A, B + 1}]++;
		mp[{A, B - 1}]++;
		mp[{A + 1, B}]++;
		mp[{A + 1, B + 1}]++;
		mp[{A + 1, B - 1}]++;
		mp[{A - 1, B}]++;
		mp[{A - 1, B + 1}]++;
		mp[{A - 1, B - 1}]++;
	}
	int sum = 0;
	for (auto p : mp) {
		if (p.first.first > 1 && p.first.first < H && p.first.second > 1 && p.first.second < W) {
			ans[p.second]++;
			sum++;
		}
	}
	rep(i, 10) {
		if (i)cout << ans[i] << endl;
		else cout << (H - 2)*(W - 2) - sum << endl;
	}
	endre;
}


Measured memory_bytes: 56448
#include <stdio.h>

int absol(int a,int b)
{
  if(a>b)
    return a-b;
  else
    return b-a;
}

int main(void)
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  if(absol(a,x)<absol(b,x))
  {
    printf("A\n");
  }
  else
  {
    printf("B\n");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
vn = list(map(int, input().split()))

vn.sort()

sum = (vn[0] + vn[1]) / 2
for i in range(2, N):
    sum = (sum + vn[i]) / 2
print(sum)


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<a+b+1;i++){
        if(i==a && s[i]!='-'){cout<<"No"<<endl;return 0;}
        else if(i!=a&&(s[i]-'0'<0||s[i]-'0'>9)){cout<<"No"<<endl;;return 0;}
        
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

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






Measured memory_bytes: 3688