akhauriyash/Code-Regression huggingface dataset:
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    ll chosen_a = min(a,k);
    k-=chosen_a;
    ll chosen_b = min(b,k);
    k-=chosen_b;
    ll chosen_c = min(c,k);
    k-=chosen_c;
    cout<<chosen_a*1 + chosen_b*0 + chosen_c*(-1);
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll n, k;
    cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];

    rep(i, n)
    {
        if (i < k)
        {
            continue;
        }
        if (a[i] > a[i - k])
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    cout << endl;

    return 0;
}

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

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

    vector<vector<int>> abc(N + 1, vector<int>(3, 0));
    for (int i = 1; i <= N; i++)
    {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }

    vector<vector<int>> ans(N + 1, vector<int>(3, 0));

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 1; k < 3; k++)
            {
                ans[i][j] = max(ans[i][j], ans[i - 1][(j + k) % 3] + abc[i][j]);
            }
        }
    }
    cout << *max_element(ans[N].begin(), ans[N].end()) << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll fac[1100000];
ll finv[1100000];
ll inv[1100000];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000000; 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(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll modpow(ll n, ll p, ll m) {
  if(p==0) return 1LL;
  if(p%2==0) {
    ll t = modpow(n, p/2, m);
    return t * t % m;
  }
  return n * modpow(n, p-1, m) % m;
}

int main() {
  ll x, y;
  cin >> x >> y;
  if((x+y)%3!=0 || x>2*y || y>2*x) {
    cout << 0 << endl;
    return 0;
  }
  ll n = (x+y)/3;
  ll k = 2*n-x;
  COMinit();
  cout << COM(n,k) << endl;
  return 0;
}

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

int main(){
    int N;
    string S;
    map<char, long long> m;
    cin >> N >> S;
    for(const auto &c : S){
        if(m.find(c) == m.end()){
            m[c] = 1;
        }else{
            m[c]++;
        }
    }
    long long x = 1;
    for(auto itr = m.begin(); itr!=m.end(); itr++){
        x *= (itr->second+1)%(1000000000+7);
        x %= 1000000000+7;
    }
    cout << (x-1);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,n,s,f,i,x,cnt;
	cnt=0;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&s,&f);
		if(a<f&&b>s){
			cnt++;
		}
	}
	if(cnt>0){
		printf("%d\n",1);
	}
	else{
		printf("%d\n",0);
	}
	return 0;
}



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

using namespace std;

#define pb push_back

const int maxi=1000;
long long a[maxi][maxi];
vector<int> v[maxi];
int n;

const long long inf=1e18;
long long d[1000][1000];
pair<long long, pair<int, int> > b[10000000];

int main()
{
    cin>>n;

   int cnt=0;

   for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
        if (i!=j)
      d[i][j]=inf;

    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
         {
             scanf("%lld",&a[i][j]);
             if (i<j)
             {
                 b[cnt]={a[i][j],{i,j}};
                 cnt++;
             }
         }

     sort(b,b+cnt);
     long long sum=0;

     for (int i=0;i<cnt;i++)
        if (d[b[i].second.first][b[i].second.second]<b[i].first)
        {
            printf("-1\n");
            return 0;
        } else
        if (d[b[i].second.first][b[i].second.second]>b[i].first)
        {

            int nd1=b[i].second.first;
            int nd2=b[i].second.second;
            //cout<<nd1<<" "<<nd2<<" "<<b[i].first<<" "<<d[nd1][nd2]<<"\n";
             sum+=b[i].first;
             d[nd1][nd2]=b[i].first;
             d[nd2][nd1]=b[i].first;

            for (int k=1;k<=n;k++)
                for (int l=k+1;l<=n;l++)
                 {
                     d[k][l]=min(d[k][l],min(d[k][nd1]+d[l][nd2],d[k][nd2]+d[l][nd1])+b[i].first);
                     d[l][k]=d[k][l];
                 }
        }

        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
        if (d[i][j]!=a[i][j]) {printf("-1\n"); return 0;}

   printf("%lld\n",sum);
   return 0;
}


Measured memory_bytes: 9216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = input()

num_s = 0
num_t = 0

ans = 0
for x in X:
	if x == "T" and num_s:
		ans += 1
		num_s -= 1
	if x == "S":
		num_s += 1
print(len(X)-2*ans)


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
char a[10000];
int main()
{
    int c=0;
    gets(a);
    int len=strlen(a);
    for(int i=0;i<len;i++)
    {
        if(a[i]=='C')
            c=1;
        if(c==1&&a[i]=='F')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (500*i + 100*j + 50*k) == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
N=int(input())
*A,=map(int,input().split())
mod = 10**9+7

cum=[0]
for i in range(N):
  cum.append(cum[-1]+A[i])
  
ans = 0
for i in range(N-1):
  ans += A[i]*(cum[-1]-cum[i+1])
  ans %= mod
  
print(ans)

Measured memory_bytes: 31752
#include <iostream>

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

int main() {
    int h, w;
    std::cin >> h >> w;

    int cs[26];
    rep(i, 26) cs[i] = 0;
    rep(i, h) rep(j, w) {
        char ch;
        std::cin >> ch;
        cs[ch - 'a']++;
    }

    int s4 = (h / 2) * (w / 2);
    int s2 = (h / 2) * (w % 2) + (h % 2) * (w / 2);
    int s1 = (h % 2) * (w % 2);

    bool flag = false;
    [&]() {
        rep(s, s4) {
            bool f = false;
            rep(i, 26) if (cs[i] >= 4) {
                cs[i] -= 4;
                f = true;
                break;
            }
            if (!f) return;
        }
        rep(s, s2) {
            bool f = false;
            rep(i, 26) if (cs[i] >= 2) {
                cs[i] -= 2;
                f = true;
                break;
            }
            if (!f) return;
        }
        rep(s, s1) {
            bool f = false;
            rep(i, 26) if (cs[i]) {
                cs[i]--;
                f = true;
                break;
            }
            if (!f) return;
        }
        flag = true;
    }();

    std::cout << (flag ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d\n", min(n * a, b));
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll tmp1 = max(a*c, b*d);
  ll tmp2 = max(a*d, b*c);
  cout << max(tmp1, tmp2);

  return 0;
}


Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> x(n), y(n), z(n);
  rep(i, n) cin >> x[i] >> y[i] >> z[i];
  ll ans = 0;
  for(int a = -1; a <= 1; a += 2) for(int b = -1; b <= 1; b += 2) for(int c = -1; c <= 1; c += 2){
    vector<ll> v(n);
    for(int i = 0; i < n; i++){
      v[i] = x[i] * a + y[i] * b + z[i] * c;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll tot = 0;
    rep(k, m) tot += v[k];
    ans = tot > ans ? tot : ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    hl=[0]+list(map(int,input().split()))
    #どことも繋がっていない展望台もgoodだから、最後にTrueのままになっているのを数える
    checkl=[True]*n
    for i in range(m):
        a,b=map(int, input().split())
        if hl[a]<hl[b]:
            checkl[a-1]=False
        elif hl[a]>hl[b]:
            checkl[b-1]=False
        else:
            checkl[a-1]=checkl[b-1]=False
    ans=0
    for i in range(n):
        if checkl[i]:
            ans+=1
    print(ans)
resolve()

Measured memory_bytes: 85168
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

map<int,int> dp[80][160]; // [m][i]<x,cost>

int main(){
	int n,m;
	
	while(scanf("%d%d",&n,&m),n|m){
		int ans = INT_MAX;
		vector<pair<int,int> > vp[160];
		rep(i,80)rep(j,160)dp[i][j].clear();
		
		rep(i,n){
			vector<pair<int,int> > tmp;
			int sz; scanf("%d",&sz);
			rep(j,sz){
				int a,b;
				scanf("%d%d",&a,&b);
				//printf("a,b , %d,%d\n",a,b);
				tmp.push_back( make_pair(a,b) );
			}
			vp[i] = tmp;
		}
		
		rep(i,n){
			if( i==0 ){
				rep(j,vp[0].size()){
					dp[0][0][vp[0][j].first] = 0;
				}
				if( n>1 && m>0 ){
					rep(j,vp[1].size()){
						dp[1][1][vp[1][j].first] = 0;
					}
				}
			}else{
				rep(l,m+1){
					rep(j,vp[i-1].size())if( dp[l][i-1].count(vp[i-1][j].first) ){ // src 1step
						rep(k,vp[i].size()){ //dest
							int c = (vp[i-1][j].second+vp[i][k].second) * abs(vp[i-1][j].first-vp[i][k].first);
							if( dp[l][i].count(vp[i][k].first) ){
								dp[l][i][vp[i][k].first] = min(dp[l][i][vp[i][k].first], dp[l][i-1][vp[i-1][j].first]+c);
							}else{
								dp[l][i][vp[i][k].first] = dp[l][i-1][vp[i-1][j].first]+c;
							}
						}
					}
					if( i>1 && l<m ){
						rep(j,vp[i-2].size())if( dp[l][i-2].count(vp[i-2][j].first) ){ // src 2step
							rep(k,vp[i].size()){ //dest
								int c = (vp[i-2][j].second+vp[i][k].second) * abs(vp[i-2][j].first-vp[i][k].first);
								if( dp[l+1][i].count(vp[i][k].first) ){
									dp[l+1][i][vp[i][k].first] = min(dp[l+1][i][vp[i][k].first], dp[l][i-2][vp[i-2][j].first]+c);
								}else{
									dp[l+1][i][vp[i][k].first] = dp[l][i-2][vp[i-2][j].first]+c;
								}
							}
						}
					}
				}
			}
		}
		
		/*
		rep(i,n){
			rep(j,10){
				rep(k,m+1){
					printf("dp[%d][%d][%d] : %d\n",k,i,j,dp[k][i][j]);
				}
			}
		}
		*/
		
		rep(l,m+1){
			rep(i,vp[n-1].size())if( dp[l][n-1].count(vp[n-1][i].first) ){
				ans = min(ans, dp[l][n-1][vp[n-1][i].first]);
			}
			if( n-2>=0 && l<m ){
				rep(i,vp[n-2].size())if( dp[l][n-2].count(vp[n-2][i].first) ){
					ans = min(ans, dp[l][n-2][vp[n-2][i].first]);
				}
			}
		}
		//rep(i,m+1)rep(j,st_sz[n])
		//	ans = min(ans,dp[i][n][j]);
		
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 2976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_1_E
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] number = Console.ReadLine().Split(' ');
            int a = int.Parse(number[0]);
            int b = int.Parse(number[1]);

            if(a>b)
            {
                Console.WriteLine("a > b");
            }
            else if(a<b)
            {
                Console.WriteLine("a < b");
            }
            else
            {
                Console.WriteLine("a == b");
            }

        }
    }
}



Measured memory_bytes: 15960
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll f[1<<16],n,a[16][16],p[1<<16];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				f[i]=f[i-(1<<j)];
				for(int k=0;k<n;k++)
				{
					if(i&(1<<k) && j!=k)
						f[i]+=a[j][k];
				}
			//	cout<<i<<' '<<f[i]<<endl;
			}
		}
	}
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=i;j;j=(j-1)&i)
		{
			f[i]=max(f[i],f[j]+f[i^j]);
		}
	}
	cout<<f[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)


int N;
long A[100001];
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
	cin >> N;
	rep(i,N) cin >> A[i];
	long s = 0;
	rep(i,N){
		if (i!=0){
			if (A[i-1] > 0 && A[i] > 0){
				int x = min(A[i],A[i-1]);
				s += x;
				A[i] -= x;
			}
		}
		int x = A[i]/2;
		s += x;
		A[i] -= x*2;
	}
	cout << s << endl;

    return 0;
}




Measured memory_bytes: 1024
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
#N=int(input())
#S=[list(map(int,input().split())) for i in range(N)]
N=int(input())
X=list(map(int,input().split()))
lastX=X.pop()
mod=10**9+7
ferumaC=10**5+1
fac=[1,1]
for i in range(2,ferumaC):
    fac.append(fac[i-1]*i%mod)
ipow=[pow(i,mod-2,mod) for i in range(ferumaC+1)]

ruiipow=[0,ipow[2]*ipow[1]%mod]

for i in range(2,ferumaC):
    ruiipow.append((ruiipow[i-1]+ipow[i+1]*ipow[i])%mod)

count=0
"""for i in range(1,len(X)):
    count2=0
    for n in range(min(i,len(X)-i)):
        a=((len(X)-1)//i)*i+n
        if a>len(X)-1:
            a-=i
        #print(n,a,i)
        count2+=X[a]-X[n]
    count=(count+ipow[i+1]*ipow[i]*count2)%mod"""
for i in range(len(X)):

    count=(count+(ruiipow[i]-ruiipow[len(X)-i-1])*X[i])%mod
    #print(i,count*fac[N-1]%mod)

for i in range(len(X)):
    count=(count+(lastX-X[i])*ipow[len(X)-i])%mod
count=count*fac[N-1]%mod
print(count)


Measured memory_bytes: 70636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, K;
    cin >> A >> B >> K;
    int minnum = min(A,B);
    int flag = 0;
    int i;
    for(i = minnum; i > 0; i--){
        if(A%i==0 && B%i==0) flag++;
        if(flag == K) break;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a, &b, &c);
	if(a == 5&&b == 5&&c == 7||a == 5&&b == 7 &&c == 5||a == 7&&b == 5&&c == 5)
		printf("YES");
	else
		printf("NO");

		
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def mpow(b: Long, e: Long): Long = {
    def doMpow(r: Long, b: Long, e: Long): Long = {
      if (e == 0) r
      else {
        val r1 = if ((e & 1) == 1) r * b else r
        doMpow(r1, b * b, e >> 1)
      }
    }
    doMpow(1, b, e)
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n, k = s.nextLong
    (k * mpow(k - 1, n - 1)).toString
  }

  val tests = List(
    "2 2" -> "2",
    "1 10" -> "10",
    "10 8" -> "322828856"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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


int main(){
    ll N, A, B;
    ll ans;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0) ans = min((B - A) /2,min(B - 1, N - A));
    else{
        if(A - 1 < N - B){
            ans = min(A + (B - A - 1) / 2, min(B - 1, N - A));
        }else{
            ans = min(N - B + 1 + (B - A - 1) / 2, min(B - 1, N - A));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np

D = int(input())
C = np.array(list(map(int, input().split())))
S = np.array([list(map(int, input().split())) for d in range(D)])

L = np.empty(26, int)
L[:] = -1

score = 0
for d in range(D):
    scores_ = []
    for t in range(26):
        d_bkp = L[t]
        L[t] = d
        scores_.append(score + S[d, t] - np.dot(C, d-L))
        L[t] = d_bkp

    smax = scores_[0]
    tmax = 0
    for t, s in enumerate(scores_):
        if s>smax:
            smax = s
            tmax = t

    L[tmax] = d
    score = smax
    print(tmax+1)


Measured memory_bytes: 27148
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
    int N;
    int ma = 0;
    cin >> N;
    map<string, int> ans{};
    rep(i, N){
        string s;
        cin >> s;
        if(!ans.count(s)){
            ans[s] = 1;
        }else{
            ans[s]++;
        }
        if(ans[s]>ma) ma = ans[s];
    }
    for(auto it=ans.begin(); it!=ans.end(); ++it){
        if(it->second==ma) cout << it->first << endl;
    }
}


Measured memory_bytes: 25216
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	cin >> N;

	string S;
	cin >> S;

	int ans = N;

	int cE = 0;
	int cW = 0;

	int vE = 0;
	int vW = N - 1;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'E') {
			cE += 1;
		}
		else {
			cW += 1;
		}
	}

	vector<int> dE(N, 0);
	vector<int> dW(N, 0);

	if (S[0] == 'E') {
		dE[0] = cE - 1;
		dW[0] = cW;
	}
	else {
		dE[0] = cE;
		dW[0] = cW - 1;
	}

	for (int i = 1; i < N; i++) {
		if (S[i] == 'E') {
			dE[i] = dE[i - 1] - 1;
			dW[i] = dW[i - 1];
		}
		else {
			dE[i] = dE[i - 1];
			dW[i] = dW[i - 1] - 1;
		}
	}

	for (int i = 0; i < N; i++) {
		if (S[i] == 'E') {
			ans = min(abs(vE - (cE - 1 - dE[i])) + abs(vW - dW[i]), ans);
		}
		else {
			ans = min(abs(vE - (cE - dE[i])) + abs(vW - dW[i]), ans);
		}
		vE += 1;
		vW -= 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6148
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int n,m,i,j,x,y;
    char c;
    while(1){
        cin>>n;
        if(n==0)break;
        set<pair<int,int>> s;
        rep(i,n){
            cin>>x>>y;
            s.insert(make_pair(x,y));
        }
        cin>>n;
        x=10;
        y=10;
        rep(j,n){
            cin>>c>>m;
            if(c=='N'){
                rep(i,m){
                    y++;
                    if(s.find(make_pair(x,y))!=s.end()){
                        s.erase(make_pair(x,y));
                    }
                }
            }
            else if(c=='S'){
                rep(i,m){
                    y--;
                    if(s.find(make_pair(x,y))!=s.end()){
                        s.erase(make_pair(x,y));
                    }
                }
            }
            else if(c=='E'){
                rep(i,m){
                    x++;
                    if(s.find(make_pair(x,y))!=s.end()){
                        s.erase(make_pair(x,y));
                    }
                }
            }
            else{
                rep(i,m){
                    x--;
                    if(s.find(make_pair(x,y))!=s.end()){
                        s.erase(make_pair(x,y));
                    }
                }
            }
            // cout<<x<<" "<<y<<endl;
        }
        
        if(s.size()>0)fin("No");
        else cout<<"Yes"<<endl;
    }

//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>

using namespace std;

int main(){
	int n;
	double m;
	cin >> n >> m;
	vector<double> a(n);
	int count = 0;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] >= sum / (m * 4)) {
			count++;
		}
	}
	if (count >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
K = int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

s = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            s += gcd(a,b,c)

print(s)

Measured memory_bytes: 69608
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int ans = c+b-a;
            if(ans < 0)
                Console.WriteLine(0);
            else
                Console.WriteLine(ans);
    
        }
    }

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0037
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int N = int.Parse(s.Split(' ')[0]);
            int L = int.Parse(s.Split(' ')[1]);

            int r = int.MaxValue;
            int dIndex = 0;
            int result = 0;

            for (int i = 1; i <= N; i++)
            {
                if (Math.Abs(L + i - 1) <= r)
                {
                    r = Math.Abs(L + i - 1);
                    dIndex = i;
                }
            }

            for (int i = 1; i <= N; i++)
            {
                if (i != dIndex)
                {
                    result += (L + i - 1);
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27524
n = int(input())
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9+n-99)
elif n < 10000:
    print(909)
elif n < 100000:
    print(909+n-9999)
else:
    print(90909)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll k=1;k<=N;k++){
        ll n = N / k;
        ans += (k + n*k) * n / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
n=[360, 180, 120, 90, 72, 60, 360, 45, 40, 36, 360, 30, 360, 180, 24, 45, 360, 20, 360, 18, 120, 180, 360, 15, 72, 180, 40, 90, 360, 12, 360, 45, 120, 180, 72, 10, 360, 180, 120, 9, 360, 60, 360, 90, 8, 180, 360, 15, 360, 36, 120, 90, 360, 20, 72, 45, 120, 180, 360, 6, 360, 180, 40, 45, 72, 60, 360, 90, 120, 36, 360, 5, 360, 180, 24, 90, 360, 60, 360, 9, 40, 180, 360, 30, 72, 180, 120, 45, 360, 4, 360, 90, 120, 180, 72, 15, 360, 180, 40, 18, 360, 60, 360, 45, 24, 180, 360, 10, 360, 36, 120, 45, 360, 60, 72, 90, 40, 180, 360, 3, 360, 180, 120, 90, 72, 20, 360, 45, 120, 36, 360, 30, 360, 180, 8, 45, 360, 60, 360, 18, 120, 180, 360, 5, 72, 180, 120, 90, 360, 12, 360, 45, 
40, 180, 72, 30, 360, 180, 120, 9, 360, 20, 360, 90, 24, 180, 360, 15, 360, 36, 40, 90, 360, 60, 72, 45, 120, 180, 360]
a=int(input())
print(n[a-1])

Measured memory_bytes: 62012
INF = 10 ** 15


def bellman_ford(v, G):
    ret = [INF] * len(G)
    ret[v] = 0

    for _ in range(len(G) - 1):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[u] == INF and ret[w] > ret[u] + l:
                    ret[w] = ret[u] + l

    for _ in range(len(G)):
        for u, g in enumerate(G):
            for w, l in g:
                if not ret[u] == INF and ret[w] > ret[u] + l:
                    ret[w] = -INF

    return ret


N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    G[a - 1].append((b - 1, -c))

ans = bellman_ford(0, G)[-1]
print('inf' if ans == -INF else -ans)


Measured memory_bytes: 49240
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


string s;
int main() {
	cin >> s;
	REP(i, INF) {
		bool ans = false;
		if (s.size() == 0) break;
		if (s.size() > 4) {			
			if (s.substr(s.size() - 5) == "dream") {
				s.erase(s.size() - 5, 5);
				ans = true;
			}
			else if (s.substr(s.size() - 5) == "erase") {
				s.erase(s.size() - 5, 5);
				ans = true;
			}
			else if (s.size() > 5) {
				if (s.substr(s.size() - 6) == "eraser") {
					s.erase(s.size() - 6, 6);
					ans = true;
				}
				else if (s.size() > 6) {
					if (s.substr(s.size() - 7) == "dreamer") {
						s.erase(s.size() - 7, 7);
						ans = true;
					}
				}
			}
		}
		if (!ans) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}	


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < (int)S.size() / 2; i++) {
    if (S.at(i) != S.at(S.size() - 1 - i)) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << (n / 2) * (n / 2) << endl;
	}
	else {
		cout << (n / 2 + 1) * (n / 2) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    vector <int> nums;
    int num;
    REP(i, n){
        cin >> num;
        nums.push_back(num);
    }
    int d_count = 0;
    stack <int> method;
    while(d_count < n){
        bool deleted = false;
        for(int i=n-d_count-1; i>=0; i--){
            if (nums[i] == i+1){
                method.push(nums[i]);
                nums.erase(nums.begin() + i);
                d_count++;
                deleted = true;
                break;
            }
        }
        if (! deleted){
            break;
        }
    }
    if (d_count == n){
        REP(i, n){
            cout << method.top() << endl;
            method.pop();
        }
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,ans=0;
  cin>>N>>M;
  
  vector<pair<ll,ll>> L;
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    L.PB(MP(b,a));
  }
  SORT(L);
  REVERSE(L);
  
  set<ll> S={-INF};
  ll ANS[M];
  REP(i,M){
    S.insert(i);
    ANS[i]=0;
  }
  S.insert(INF);
  
  REP(i,N){
    auto itr=S.upper_bound(M-L[i].second);
    ll index=*(--itr);
    if(index==-INF) continue;
    ANS[index]=L[i].first;
    S.erase(index);
  }
  
  REP(i,M) ans+=ANS[i];
  co(ans);
  return 0;
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int h,w,white=0;
    cin>>h>>w;
    vector<vector<char>> g(h,vector<char>(w));
    rep(i,0,h){
        rep(j,0,w){
            cin>>g[i][j];
            if(g[i][j]=='.'){white++;}
        }
    }
    int dx[4]={0,1,0,-1};
    int dy[4]={-1,0,1,0};
    vector<vector<int>> cnt(h,vector<int>(w));
    vector<vector<bool>> visited(h,vector<bool>(w));
    queue<pair<int,int>> q;
    int sx=0,sy=0,gx=h-1,gy=w-1;
    q.push(make_pair(sx,sy));
    visited[sx][sy]=true;
    cnt[sx][sy]=0;
    while(!q.empty()){
        pair<int,int> pos=q.front();q.pop();
        for(int i=0;i<4;i++){
            int nx=pos.first+dx[i];
            int ny=pos.second+dy[i];
            if(nx<0||ny<0||nx>=h||ny>=w || g[nx][ny] =='#' || visited[nx][ny])continue;
            visited[nx][ny]=true;
            q.push(make_pair(nx,ny));
            cnt[nx][ny]=cnt[pos.first][pos.second]+1;
        }
    }
    if(cnt[gx][gy]==0)cout<<-1<<endl;
    else    cout<<white-cnt[gx][gy]-1<<endl;    // 白マス-最短経路マス-スタートマス
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, m , k;
    cin >> n >> m >> k;

    int i, j;
    for(i = 0; i <= n; i ++)
    {
        for(j = 0; j <= m; j ++)
        {
            int apas = i * m + j * n - 2 * i * j;

            if(apas == k)
            {
                cout << "Yes\n";

                return 0;
            }
        }
    }

    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    a, b = map(int, open(0).read().split())
    R = []
    if (a < b):
        for i in range(b):
            R.append(str(a))
    else:
        for i in range(a):
            R.append(str(b))
    print(''.join(R))


main()

Measured memory_bytes: 2940
#include <iostream>
#include <queue>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
map<long long,long long> dis;
long long d[3] = {0,1,-1};
long long x;
long long bfs(){
    queue<long long> que;
    que.push(0);
    while(!que.empty()){
        long long q = que.front();
        que.pop();
        if(q==x){
            return dis[x];
        }
        for(int i=0;i<3;i++){
            long long nx = q + dis[q]*(d[i]+1);
            if(dis[nx]==0||nx==0){
                if(nx>=0&&nx<=x){
                    que.push(nx);
                    dis[nx] = dis[q]+1;
                }
            }
        }
    }
    return dis[x];
}
int main(){
    scanf("%lld",&x);
    long long a = (-1+sqrt(1+2*4*x))/2;
    //long long b = (-1-sqrt(1+2*4*x))/2;
    if(a*(1+a)<2*x){
        a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
use strict;
my ($N,$M,$K) = split(/ /,<>);
my $s = <>; chomp $s;
my @DBA = split(/ /,$s);
my $t = <>; chomp $t;
my @DBB = split(/ /,$t);

my @TA;
my $maxa=0;
my $ttime=0;
my $A=0;
$TA[0]=0;
for(my $i=0;$i<=$#DBA;$i++){
    $TA[$i+1] = $TA[$i] + $DBA[$i];
    if($TA[$i+1] >$K ){
        last;
    }
    $maxa++;
}
my $maxb =0;
my @TB;
$TB[0]=0;

my $j=0;

my $ans= $maxa;
for(my $i=0;$i<=$#DBB;$i++){
    $TB[$i+1] = $TB[$i] + $DBB[$i];
    if($TB[$i+1] >$K ){
        last;
    }
    while(){
        if( $TA[$maxa-$j] + $TB[$i+1] <= $K ){last;}
        if($j>$N){last;}
        $j++;
    }
    
    if($ans < ($maxa-$j+$i+1) ){ $ans = ($maxa-$j+$i+1);}
    $maxb++;
}
print "$ans";

Measured memory_bytes: 60788
#include<iostream>
#include<queue>

using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int i;
  priority_queue<int> b;
  for(i=0;i<n;i++){
    cin >> a[i];
    b.push(a[i]);
  }
  
  for(i=0;i<n;i++){
    if(b.top() == a[i]){
      int tmp = b.top();
      b.pop();
      cout << b.top() << endl;
      b.push(tmp);
    }else
      cout << b.top() << endl;
  }
}

Measured memory_bytes: 3316
adj = Hash.new
n = gets.to_i
n.times do
  l = gets.split.map(&:to_i)
  adj[l.shift] = l[1..-1]
end
adj.sort.transpose[1].each do |v|
  arr = Array.new(n,0)
  v.each{|i| arr[i-1]=1} if v
  puts arr.join(" ")
end

Measured memory_bytes: 8892
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  long long ans = ruizyou(2,n) - 1;
  long long bunsi = n-a+1;
  for(long long i=n-a+2;i<=n;i++)bunsi = bunsi * i % MOD;
  long long bunbo = kaizyou(a);
  ans -= bunsi * ruizyou(bunbo,MOD-2) % MOD;
  bunsi = n-b+1;
  for(long long i=n-b+2;i<=n;i++)bunsi = bunsi * i % MOD;
  bunbo = kaizyou(b);
  ans -= bunsi * ruizyou(bunbo,MOD-2) % MOD;
  ans %= MOD;
  if(ans<0)ans+=MOD;
  cout << ans << endl;
}

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

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(s == u){
		a--;
	}else if(t == u){
		b--;
	}
	cout << a << " " << b << endl;
	return 0;
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;

int a, b;


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

    cin >> a >> b;

    cout << max(0, a-2*b) << endl;
    


    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
   int n,k;
   cin >> n >> k;

   cout << n%k << endl;
   return 0;

}


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

int dp[301][301][901];
struct exc {
	int a;
	int b;
	int c;
	int d;
};
int main() { 
	int N; cin >> N;
	int X, Y; cin >> X >> Y;
	for (int i = 0; i < 301; ++i) {
		for (int j = 0; j < 301; ++j) {
			for (int k = 0; k < 901; ++k) {
				dp[i][j][k] = -1e9;
			}
		}
	}
	dp[0][X][Y + 300] = 0;
	vector<exc>es;
	for (int i = 0; i < N; ++i) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		es.push_back(exc{ a,b,c,d });
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 301; ++j) {
			for (int k = 0; k < 901; ++k) {
				exc ex(es[i]);
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				{
					int nj = j - ex.a;
					int nk = k+ex.b;
					if (nj < 0) {

					}
					else {
						if (nk > 900)nk = 900;
						dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk], dp[i][j][k]);
					}
				}
				{
					int nk = k - ex.c;
					if (nk < 0) {

					}
					else {
						dp[i + 1][j][nk] = max(dp[i + 1][j][nk], dp[i][j][k] + ex.d);
					}
				}
			}
		}
	}
	int ans = 0;
	for (int j = 0; j <= 300; ++j) {
		for (int k = 300; k <= 900; ++k) {
			ans = max(ans, dp[N][j][k]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 322028
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    using P = pair<int, int>;
    int N;
    cin >> N;
    vector<P> X(N);
    cin >> X;
    vector<P> S(N);
    REP(i, N) {
        S[i] = { X[i].first + X[i].second, X[i].first - X[i].second };
    }
    SORT(S);
    int ans = 0;
    int m = -INF;
    REP(i, N) {
        if (S[i].second >= m) {
            m = S[i].first;
            ans++;
        }
    }

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


Measured memory_bytes: 1920
<?php

while(true){
    
    $inputs = explode(" ", trim(fgets(STDIN)));
    $h = $inputs[0];
    $w = $inputs[1];

    if ( $h == 0 && $w == 0 ) break;

    for ($i = 0; $i < $h; $i++) {
        if ($i % 2 == 0) {
            for ($j = 0; $j < $w; $j++) {
                if ($j % 2 == 0) { echo "#"; }else { echo ".";}
            }
        } else {
            for ($j = 0; $j < $w; $j++) {
                if ($j % 2 == 0) { echo "."; }else { echo "#";}
            }
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15328
# 2019/06/01
# M-SOLUTIONS プロコンオープン - B

# Input
s = input()

cnt = 0
for i in range(len(s)):
    if s[i] == "o":
        cnt += 1

cnt += 15 - len(s)

if cnt >= 8:
    ans = "YES"
else:
    ans = "NO"

# Output
print(ans)


Measured memory_bytes: 2940