akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if (h == 0 & w == 0) {
				break;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (i % 2 == 0 & j % 2 == 0) {
						System.out.print("#");
					} else if (i % 2 == 0 & j % 2 != 0) {
						System.out.print(".");
					} else if (i % 2 != 0 & j % 2 == 0) {
						System.out.print(".");
					} else if (i % 2 != 0 & j % 2 != 0) {
						System.out.print("#");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 31312
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	while(cin>>n)
	{
		int c=n/4;
		int flag=0;
		
		if(n%4==0||n%7==0)
		{
			cout<<"Yes"<<endl;
			continue;
		}
		
		for(int i=1;i<=c;i++)
		{
			for(int j=1;j<=(n-4*i)/7;j++)
			{
				if(4*i+7*j==n)
				{
					cout<<"Yes"<<endl;
					flag=1;
					break;
				}
			}
			if(flag)
				break;
		}
		
		if(!flag)
			cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import copy

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

As = [copy.copy(Bs[0])]
As.extend(copy.copy(Bs))

#print(Bs)
#print(As)

for index, B in enumerate(Bs):
#    print(Bs)
#    print(As)
    if B < As[index]:
        As[index] = B

#print(As)
print(sum(As))



Measured memory_bytes: 3444
N = int(input())
A = list(map(int, input().split()))
A.insert(0,0)
A.append(0)
s = 0
for i in range(N+1):
  s += abs(A[i]-A[i+1])
for i in range(N):
  print(s + abs(A[i]-A[i+2]) - abs(A[i]-A[i+1]) - abs(A[i+1]-A[i+2]))

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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	printf("Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 100010
#define MAX_A 1000010

vi adj[SIZE];
int rem[SIZE] = {0};

void reduce(int v, int idx, int p) {
	if (v != p && adj[v].size() == 2) {
		rem[v] = 1;
		int t = ((adj[v][0] == p || rem[adj[v][0]]) ? adj[v][1] : adj[v][0]);
		reduce(t, idx, p);
		return;
	}
	if (p != v) adj[p][idx] = v;
	for (int i = 0 ; i < adj[v].size() ; ++i) {
		int t = adj[v][i];
		if (t == p || rem[t]) continue;
		reduce(t, i, v);
	}
}

int dfs(int v, int p) {
	int s, leaf = 0, sum = 0;
	if (v != p && adj[v].size() == 1) return 1;
	for (auto t: adj[v]) {
		if (t == p || rem[t]) continue;
		sum += dfs(t ,v);
		leaf |= (adj[t].size() == 1);
	}
	return sum - leaf;
}

int main() {
	start = clock();

	int n;
	scanf("%d", &n);
	int vv = -1;

	for (int i = 1 ; i < n ; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].PB(v);
		adj[v].PB(u);
		if (vv == -1) {
			if (adj[v].size() == 3) vv = v;
			else if (adj[u].size() == 3) vv = u;
		}
	}
	if (vv == -1) {
		printf("1\n");
		return 0;
	}

	reduce(vv, 0, vv);
	printf("%d\n", dfs(vv, vv));

	Time(false);
	return 0;
}

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

int main(){
  int N;
  vector<int> C(510), S(510), F(510);

  cin >> N;
  for(int i=0; i<N-1; i++) cin >> C[i] >> S[i] >> F[i];

  for(int j=0; j<N; j++){
    int t = 0;
    for(int i=j; i<N-1; i++){
      if(t < S[i]){
       t = S[i];
     } else {
       while(t % F[i] != 0) t++;
      }
     t += C[i];
    }

    cout << t << endl;
  }
}
  
  

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

int main(){
    string S;
    int n=4;
    int ans=0;
    cin >> S;
    
    for(int i=0;i<n;i++){
        if(S[i]=='+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (S == U) --A;
  if (T == U) --B;
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 3176
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]

ans=[]
for i in s:
    cnt=0
    for j in range(n):
        if i==s[j]:
            cnt+=1
    for k in range(m):
        if i==t[k]:
            cnt-=1
    ans.append(cnt)

if max(ans)<0:
    print('0')
else:
    print(max(ans))

Measured memory_bytes: 9116
#include <iostream>
using namespace std;
int dp[100001][3];
int arr[100001][3];
int findMinValue(int n,int state,int i){
        if(i==n) return 0;
        
        int ans=0;
       for(int j=0;j<3;++j){
           int value;
           if(state!=j){
               if(dp[i][j]!=-1)   value=dp[i][j];
                else value=arr[i][j]+findMinValue(n,j,i+1);
           dp[i][j]=value;
           ans=max(ans,value);
           }
      }
    
      return ans;
}
int main() {
     int n;
    cin>>n;
    
    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j){
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j){
           dp[i][j]=-1;
        }
    }
    
    for(int i=0;i<3;++i){
        dp[n-1][i]=arr[n-1][i];
    }
    

    cout<<findMinValue(n,-1,0)<<endl;

}


Measured memory_bytes: 13676
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n)){
		if(n==0)
		break;
		int temp,cnt=1;
		int dice[6];
		char com[6];
		dice[0]=5;
		dice[1]=3;
		dice[2]=2;
		dice[3]=4;
		dice[4]=1;
		dice[5]=6;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%s",com);
			if(com[0]=='N'){
				temp=dice[0];
				dice[0]=dice[4];
				dice[4]=dice[2];
				dice[2]=dice[5];
				dice[5]=temp;
				cnt+=dice[4];
			}
			else if(com[0]=='E'){
				temp=dice[1];
				dice[1]=dice[4];
				dice[4]=dice[3];
				dice[3]=dice[5];
				dice[5]=temp;
				cnt+=dice[4];
			}
			else if(com[0]=='W'){
				temp=dice[3];
				dice[3]=dice[4];
				dice[4]=dice[1];
				dice[1]=dice[5];
				dice[5]=temp;
				cnt+=dice[4];
			}
			else if(com[0]=='S'){
				temp=dice[2];
				dice[2]=dice[4];
				dice[4]=dice[0];
				dice[0]=dice[5];
				dice[5]=temp;
				cnt+=dice[4];
			}
			else if(com[0]=='R'){
				temp=dice[2];
				dice[2]=dice[1];
				dice[1]=dice[0];
				dice[0]=dice[3];
				dice[3]=temp;
				cnt+=dice[4];
			}
			else if(com[0]=='L'){
				temp=dice[2];
				dice[2]=dice[3];
				dice[3]=dice[0];
				dice[0]=dice[1];
				dice[1]=temp;
				cnt+=dice[4];
			}
		}
		printf("%d\n",cnt);
	}
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vi Plus, Minus;
	REP(i, N) {
		int a;
		cin >> a;
		if (a < 0)Minus.push_back(abs(a));
		else if (a > 0)Plus.push_back(a);
		else K--;
	}
	if (K == 0) {
		cout << 0 << endl;
		return 0;
	}
	rev(Minus);
	int ans = INT_MAX;
	REP(i, K + 1) {//正の方向にあるろうそくを消す数
		int j = K - i;//負の〃
		int now = 0;
		if (i > SZ(Plus))continue;
		if (j > SZ(Minus))continue;
		int move = INT_MAX;;
		if (i != 0) {
			now += Plus[i - 1];
			move = Plus[i - 1];
		}
		if (j != 0) {
			now += Minus[j - 1];
			move = min(move, Minus[j - 1]);
		}
		if(i != 0 && j != 0)now += move;
		ans = min(ans, now);
	}
	cout << ans << endl;
	PAU;
	return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 200001

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    vii ed;
    ll m = ((n-1) * (n-2))/2;
    if (m < k) {
        cout << -1 << endl;
        return 0;
    }
    REP(i, 2, n+1)
        ed.pb({1, i});
    ll r = m - k, i = n-2;
    while (r) {
        if (r >= i) {
            r -= i;
            REP(j, 2, i+2)
                ed.pb({j, i+2});
        }
        i--;
    }
    cout << ed.size() << endl;
    REP(i, 0, ed.size())
        cout << ed[i].first << " " << ed[i].second << endl;
    return 0;
}


Measured memory_bytes: 512
input = raw_input

s = input()
n = len(s)

ok = True
for i in range(n):
    if s[i] != s[n-1-i]:
        ok = False
        break

if ok:
    n1 = (n-1) // 2
    for i in range(n1):
        if s[i] != s[n1-1-i]:
            ok = False
            break
if ok:
    n2 = (n+3) // 2
    i2 = n-1
    for i1 in range(n2-1, n):
        if s[i1] != s[i2]:
            ok = False
            break
        i2 -= 1
if ok:
    out = "Yes"
else:
    out = "No"
print(out)

Measured memory_bytes: 28268
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,i,j,srx[200001],sry,t,p;
int main()
{
   scanf("%d%d",&n,&k);
   for(i=1;i<=n;++i)
   scanf("%d",&t),srx[t]++;
   sort(srx+1,srx+n+1);
   for(i=n;i>n-k;--i)
   sry+=srx[i];
   printf("%d",n-sry);
   return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(){
  int n,h[20],res=1,flag;
  scanf("%d",&n);
  for (int i=0;i<n;i++) scanf("%d",&h[i]);
  for (int i=1;i<n;i++){
    flag=1;
    for (int j=0;j<i;j++){
      if (h[j]>h[i]){
        flag=0;
        break;
      }
    }
    if (flag) res++;
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC target ("avx,avx2,fma")
#pragma GCC optimize ("unroll-loops")

#include <iostream>
#include <vector>

using namespace std;

int upbound;
const int MOD = 1000000007;
vector<int> g, dp;

inline int Solve(int x)
{
	if (x == 0) return 1;
	if (dp[x] != -1) return dp[x];
	int p = __builtin_popcount(x), r = 0;
	for (int y = x & g[p - 1]; y; y &= y - 1)
	{
		r += Solve(x & ~(y & -y));
		if (r >= MOD) r -= MOD;
	}
	dp[x] = r;
	return r;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, r;
	char p;
	cin >> n;
	upbound = (1 << n);
	g = vector<int>(n), dp = vector<int>(upbound, -1);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			cin >> p;
			if (p == '1')
				g[i] |= (1 << j);
		}
	cout << Solve(upbound - 1);
}


Measured memory_bytes: 11304
def hit_blow(str1, str2)
  n, m = 0, 0
  
  4.times do |i|
    n += 1 if str1[i] == str2[i]
    m += 1 if str1.include?(str2[i])
  end
  
  return [n ,m - n]
end

until (str = gets.split) == ["0", "0"]
  h, b = hit_blow(str[0], str[1])
  puts "#{h} #{b}"
end

Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b)
{
   ll res = 1;
   while(b>0)
   {
     if(b&1)
      res = (res*a)%mod;
     a = (a*a)%mod;
     b/=2;
   }
   return res;
}
#define rs resize
int main()
{
   std::ios::sync_with_stdio(false);
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a <= c)
   {
      if(c > b) cout<<0;
      else
        cout<<min(b - c, d - c);
   }
   else
   {
      if(a > d)
       cout<<0;
      else
       cout<<min(d - a,b - a);
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

#define NMAX 10

ll n, m;
ll rec[NMAX][1<<NMAX];
vector<vector<ll>> G;

void init() {
    rep(i, 0, NMAX) {
        rep(j, 0, 1<<NMAX) rec[i][j] = -1;
    }
}

ll dfs(ll cur, ll bit) {
    if(rec[cur][bit] != -1) return rec[cur][bit];
    if(bit == (1<<n)-1) return rec[cur][bit] = 1;
    ll res = 0;
    for(auto g : G[cur]) {
        if(!(bit & (1<<g))) res += dfs(g, bit | (1<<g));
    }
    return rec[cur][bit] = res;
}

int main(){
    init();
    cin >> n >> m;
    G.resize(n);
    rep(i, 0, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << dfs(0, 1) << endl;
    return 0;
}

Measured memory_bytes: 3728
<?php
const MOD = 10 ** 9 + 7;
list($n) = ints();
$a = ints();
$cusum[0] = 0;
for ($i = 0; $i < $n; ++$i) {
    $cusum[$i + 1] = ModAdd($cusum[$i], $a[$i]);
}
$ans = 0;
for ($i = 0; $i < $n - 1; ++$i) {
    $ans = ModAdd($ans, ModMul($a[$i], ModSub($cusum[$n], $cusum[$i + 1])));
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// SUM
function modSum(...$xs)
{
    $res = 0;
    foreach ($xs as $x) $res = modAdd($res, $x);
    return $res;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// PRODUCT
function modProd(...$xs)
{
    $res = 1;
    foreach ($xs as $x) $res = modMul($res, $x);
    return $res;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}


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

bitset<4000000> bs;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	bs[0] = 1;
	int n; cin >> n;
	int s = 0;
	while(n--){
		int x; cin >> x;
		s += x;
		bs |= (bs << x);
	}
	
	s = (s + 1)/2;
	while(!bs[s]) s++;
	cout << s;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n; string s;
const ll mod = 1e9+7;


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

  cin>>s;
  n=s.length();
  vector<ll> dp(13, 0);
  dp[0]=1;
  for (int i=0; i<n; i++) {
    vector<ll> _dp(13);
    set<ll> st;
    if (s[i]=='?') {
      for (int d=0; d<=9; d++) st.insert(d);
    } else {
      st.insert(s[i]-'0');
    }

    for (int d: st) {
      for (int x=0; x<13; x++) {
	(_dp[(x*10+d)%13] += dp[x]) %= mod;
      }
    }

    swap(dp, _dp);
  }

  ll ans = dp[5];
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n, c; cin >> n >> c;
    map<int, int> c_cnt0, c_cnt1, c_cnt2;
    vector<vector<int>> d(550, vector<int>(550, 0));

    for(int i=1; i<=c; ++i) for(int j=1; j<=c; ++j) cin >> d[i][j];

    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            int cc; cin >> cc;
            if((i+j)%3 == 0) c_cnt0[cc]++;
            else if((i+j)%3 == 1) c_cnt1[cc]++;
            else c_cnt2[cc]++;
        }
    }

    int ans = 1<<30;
    for(int c0=1; c0<=c; ++c0){
        for(int c1=1; c1<=c; ++c1){
            for(int c2=1; c2<=c; ++c2){
                if(c0 == c1 || c1 == c2 || c2 == c0) continue;

                int tmp = 0;
                for(int from=1; from<=c; ++from){
                    tmp += d[from][c0]*c_cnt0[from];
                    tmp += d[from][c1]*c_cnt1[from];
                    tmp += d[from][c2]*c_cnt2[from];
                }
                chmin(ans, tmp);
            }
        }
    }
    
    cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K; cin >> N >> K;
  cout << min(abs(N%K), abs(N%K-K)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if ((a + b) % 2 == 0) cout << (a + b) / 2;
	else cout << "IMPOSSIBLE";

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> hig(n+1);
  for(int i=0; i<n; ++i){
    cin >> hig.at(i);
  }
  int ans=0;
  for(int i=0; i<100; ++i){
    for(int j=0; j<n; ++j){
      if(hig.at(j)>0){
        --hig.at(j);
        if(hig.at(j+1)==0) ++ans; 
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//ABC115C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	int diff=0;
	for(int i=0;i<n;i++){
		cin >> h.at(i);
	}
	sort(h.begin(),h.end());
	int ans = h.at(n-1);
	for(int i=0;i<n-k+1;i++){
		diff = h.at(i+k-1) - h.at(i);
		ans = min(ans,diff);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 998244353;


long long mod_pow(long long x, long long n) {
    if (n==0) return 1;
    long long res = mod_pow(x * x % MOD, n/2);
    if (n&1) res = res * x % MOD;
    return res;
}

ll ans;
ll n, m, k;

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

    ll color = m*mod_pow(m-1, n-k-1);
    color %= MOD;

    ll X = 1, Y = 1;
    rep(i, k+1, n) X = (X*i)%MOD;
    rep(i, 2, n-k) Y = (Y*i)%MOD;

    for (int i=k; i>=0; i--) {
      //printf("X:%lld, Y:%lld, color:%lld\n", X, Y, color);
        ans += (((color * mod_pow(Y, MOD-2)) % MOD) * X) % MOD;
        //cout << ans << endl;
        ans %= MOD;
        color = (color*(m-1)) % MOD;
        X *= i;
        X %= MOD;
        Y *= n-i;
        Y %= MOD;
    }

    cout << ans << endl;

    return 0;
}



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


int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    vector<int> dp(n,INT_MAX);
    dp[0]=0;



    for(int i=1;i<n;i++)
    {
        for(int j=i-1 ; j>= i-k && j>=0 ;j--)
            dp[i]= min (dp[i], dp[j]+abs(arr[i]-arr[j]));
    }

    cout<<dp[n-1]<<endl;


}





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

int main() {
	int	N;
	cin >> N;
	int	ans;
	for (int i = 1; i <= N; i += 2)
	{
		int	div;
		div = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i % j == 0)
				div++;
		}
		if (div == 8)
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<int,int> a[100005],b[100005];
int p[100005],vis[100005];
int main(){
	int n,num=0,mi=2e9;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].second;
	}
	for(int i=1;i<=n;i++){
		cin>>a[i].first;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		b[i].first=a[i].second;
		b[i].second=i;
	}
	sort(b+1,b+1+n);
	for(int i=1;i<=n;i++){
		if(b[i].first>a[i].first){
			cout<<"No"<<endl;
			return 0;
		}
		p[i]=b[i].second;
	}
	for(int i=n;i>=1;i--){
		if(mi<=a[i].first){
			cout<<"Yes"<<endl;
			return 0;
		}
		mi=min(mi,b[i].first);
	}
	for(int i=1;i<=n&&num<2;i++){
		if(vis[i])continue;
		int pos=i;
		while(!vis[pos]){
			vis[pos]=1;
			pos=p[pos];
		}
		num++;
	}
	if(num==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

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


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

    string a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    rep(i, n){
        set<char> st;
    
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        if(st.size() == 2){
            ans++;
        }else if(st.size() == 3){
            ans += 2;
        }
    }

    cout << ans << "\n";

    return 0;
}


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

int main() 
{ 	int i,n;
	cin >> n;
	long int a[n],t=0;
	for(i=0;i<n;i++){
		cin >> a[i];
		t=t^a[i];
	}
	
	if(t==0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}


    return 0; 
} 


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

int main() {
  double R;
  cin >> R;
  cout << fixed << setprecision(9) << R * 2 * 3.1416 << endl;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <string.h>
int main(void){
    
    int i=0,a,b;
    char s[200001];
    
    scanf("%s",s);
    
    for(i=0;i<strlen(s);i++){
        if(s[i]=='A'){
            a=i-1;
            break;
        }
    }
    for(i=strlen(s)-1;i>0;i--){
        if(s[i]=='Z'){
            b=i;
            break;
        }
    }
    
    printf("%d\n",b-a);
}

Measured memory_bytes: 384
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         int n,k;
         cin>>n>>k;
         int i,j;
         vector<int> v(n);
         for(i=0;i<n;i++)
         	cin>>v[i];
         int dp[n];
         for(i=0;i<n;i++)
         	dp[i]=1e9;
         dp[0]=0;
         dp[1]=abs(v[1]-v[0]);
         for(i=2;i<n;i++)
         {
         	for(j=1;j<=k;j++)
         	{
         		if((i-j)>=0)
         	   dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
            }
         }
       //  cout<<dp[n-1];


        cout<<dp[n-1];
         
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
const int MAX = 3*1e5;
int h,w,m,x[MAX],y[MAX], r[MAX], c[MAX],mr,sr,mc,sc;
int main() {
  cin >> h >> w >> m;
  rep(i,m) {
    cin >> x[i] >> y[i]; 
    x[i]--; y[i]--;
    r[x[i]]++; c[y[i]]++;
  }

  rep(i,h) {
    if (r[i] > mr) {
      mr = r[i];
      sr = 1;
    } else if (mr == r[i]) sr++;
  } 
  rep(i,w) {
    if (mc < c[i]) {
      mc = c[i];
      sc = 1;
    } else if (mc == c[i]) sc++;
  }

  int s = 0;
  rep(i,m) {
    if (r[x[i]]==mr && c[y[i]]==mc) s++;
  }
  cout << mr + mc - (s==sr*sc) << endl;
  return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    bool ok=true;
    map<ll,ll> mp;
    rep(i,3){
        ll a,b; cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }
    for(auto x:mp) if(x.second>=3) ok=false;
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
    int  c;
    unsigned long int x, sum;
    sum = 100;
    scanf("%lu", &x);
    c = 0;
    while (sum < x)
    {
        sum = sum * 1.01;
        c++;
    }
    printf ("%d\n", c);
    
    return 0;
}

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

int solve(int n, int A[],int m,int i, int num) {
	for (; i < n; i++) {
		if (A[i] == m) {
			return 1;
		}
		if (num + A[i] < m) {
			if (solve(n, A, m, i + 1, num + A[i])) {//m??????????????¨???
				return 1;
			}
		} else if (num + A[i] == m) {
			return 1;
		}

	}
	return 0;
}

int main(void) {
	int n, q, A[2001], m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> q;
	sort(A, A + n);
	reverse(A, A + n);
	
	for (int i = 0; i < q; i++) {
		cin >> m;
		if (solve(n, A, m,0,0)) cout << "yes\n";
		else cout << "no\n";
	}
	return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int top(int num) {
    int digits = log10(num) + 1;
    return num / pow(10, digits - 1);
}

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

    int n;
    cin >> n;

    int cnt[10][10] = {};
    FORE(i, 1, n) { cnt[top(i)][i % 10]++; }

    int sum = 0;
    rep(i, 10) {
        rep(j, 10) { sum += cnt[i][j] * cnt[j][i]; }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a, b;
string s;
cin >> a >> b >> s;
string ans = "Yes";
if(s[a]=='-'){
    rep(i,a+b+1){
        if(i==a)
            continue;
        if(!isdigit(s[i])){
            ans = "No";
        }
    }
}
else{
    ans = "No";
}
cout <<ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] a = new int[N];
		int b = 0;
		long ans = 0;

		for (int i = 0; i < N; i++) {
			a[i] = reader.nextInt() - i - 1;
		}
		Arrays.sort(a);
		if (N % 2 == 0) {
			b = (a[N/2] + a[N/2 - 1])/2;
		} else {
			b = a[N/2];
		}


		for (int i = 0; i < N; i++) {
			ans += Math.abs(a[i]-b);
		}
		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 88292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll a,b;

void init(){
	cin>>a>>b;
}

int main(void){
	init();
	if((a+b)%2==0){
		cout<<(a+b)/2<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author NMouad21
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    FLCS solver = new FLCS();
    solver.solve(1, in, out);
    out.close();
  }

  static class FLCS {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      char[] s = in.nextCharArray();
      char[] t = in.nextCharArray();
      int[][] dp = new int[s.length + 1][t.length + 1];
      for (int i = 0; i <= s.length; i++) {
        for (int j = 0; j <= t.length; j++) {
          if (i == 0 || j == 0) {
            continue;
          }
          if (s[i - 1] == t[j - 1]) {
            dp[i][j] = dp[i - 1][j - 1] + 1;
          } else {
            dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
          }
        }
      }
      int i = s.length, j = t.length;
      StringBuilder sb = new StringBuilder();
      while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
          sb.append(s[i - 1]);
          --i;
          --j;
        } else {
          if (dp[i][j] == dp[i - 1][j]) {
            --i;
          } else {
            --j;
          }
        }
      }
      out.println(sb.reverse().toString());
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final String next() {
      int c;
      while (isSpaceChar(c = this.read())) {}

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

    public final char[] nextCharArray() {
      return next().toCharArray();
    }
  }
}


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

int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> X(n);
    rep(i,0,n){
        ll x,l;
        cin>>x>>l;
        X[i]=make_pair(x+l,x-l);
    }
    sort(X.begin(),X.end());
    ll ans=0,now=-1*(1e9+10);
    rep(i,0,n){
        if(now<=X[i].second){
            ans++;
            now=X[i].first;
        }
    }
    cout<< ans <<endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    lli rec=0;
    lli cnt=0;
    vi p(n);
    rep(i,n){
        cin>>p[i];
    }
    vi cp(n);
    cp=p;
    sort(all(cp));
    rep(i,n){
        if(cp[i]!=p[i]){ 
            cnt++;
        }
    }
    YES(cnt==2||cnt==0);
}

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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

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

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
	double x, y;
	Pos(double x, double y) {
		this->x = x;
		this->y = y;
	}
	Pos() {
		x = 0.0;
		y = 0.0;
	}
};

class Mod {
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
	
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};

inline double distance(Pos p1, Pos p2) {
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
	int ans = 1;
	for (int i = 2; i <= n; ++i) {
		ans *= i;
	}
	return ans;
}

template <typename T>
inline int keta(T num) {
	return to_string(num).length();
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
		cout << endl;
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl;
	}
	try {
		(debug) ? DebugMain() : Main();
	}
	catch (exception& e) {
		cout << e.what() << endl;
	}
	return 0;
}

void recursive_comb(int* indexes, int s, int rest, std::function<void(int*)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, std::function<void(int*)> f) {
	int indexes[3];
	recursive_comb(indexes, n - 1, 3, f);
}

inline bool isInHairetu(vector<string>& v, string& str) {
	if (v.size() == 0) {
		return false;
	}
	for (string& s : v) {
		if (s == str) {
			return true;
		}
	}
	return false;
}

inline void Main(){
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b + c >= 22) {
		cout << "bust";
		return;;
	}
	cout << "win";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int t = n;
	vector<int> data;
	while(t--) {
	    int a;
	    cin >> a;
	    data.push_back(a);
	}
	int count = 0;
	for(int i = 0; i < n; i++) {
	    if(data[i]!=(i+1)) {
	        count += 1;
	    }
	}
	if(count == 0 || count == 2) {
	    cout << "YES" << endl;
	}
	else {
	    cout << "NO" <<endl;
	}
	return 0;
}

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

public class Main {
  private static String solve(String a, String b) {
    if (a.length() > b.length()) {
      return "GREATER";
    } else if (a.length() < b.length()) {
      return "LESS";
    } else if (a.compareTo(b) > 0) {
      return "GREATER";
    } else if (a.compareTo(b) < 0) {
      return "LESS";
    } else {
      return "EQUAL";
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String a = reader.next();
    String b = reader.next();
    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();
  }
}

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 String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22228
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int size = Integer.parseInt(line);
			if(size==0) break;
			int[][] data = new int[size][2];
			for(int n=0; n<size; n++){
				line = in.readLine();
				String[] tmp = line.split(" ");
				data[n][0] = Integer.parseInt(tmp[0]);
				data[n][1] = Integer.parseInt(tmp[1]);
			}
			
			line = in.readLine();
			size = Integer.parseInt(line);
			for(int n=0; n<size; n++){
				line = in.readLine();
				int num = Integer.parseInt(line);
				int[] N = {0};
				count(data, num, N, 0, 0);
				System.out.println(N[0]);
			}
		}
	}
	
	public void count(int[][] data, int ans, int[] N, int current, int depth){
		if(current > ans){
			return;
		}
		if(depth != data.length){
			for(int n=0; n<=data[depth][1]; n++){
				int cost = current + data[depth][0] * n;
				count(data, ans, N, cost, depth+1);
			}
		}
		else{
			if(current == ans){
				N[0]++;
			}
		}
	}
}

Measured memory_bytes: 9632
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Xn := make([]int, N)
	for i := range Xn {
		Xn[i] = nextInt()
	}
	Xcopied := make([]int, N)
	copy(Xcopied, Xn)
	sort.Ints(Xcopied)
	for i := 0; i < N; i++ {
		if Xn[i] >= Xcopied[N/2] {
			fmt.Println(Xcopied[N/2-1])
		} else {
			fmt.Println(Xcopied[N/2])
		}
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 9216