akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s; cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}







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

void solve() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && B != C) || (A != B && B == C) || (A == C && B != C)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 256
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

    tmp = 0
    for i in range(N):
        if i%2==0:
            tmp+=A[i]
        else:
            tmp-=A[i]

    ans = [tmp]
    for i in range(N-1):
        tmp = (A[i]-tmp//2)*2
        ans.append(tmp)

    print(*ans)
        
if __name__=='__main__':
    main()

Measured memory_bytes: 95076
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define Max(_A,_B) (_A>_B?_A:_B)
#define Min(_A,_B) (_A<_B?_A:_B)
#define ll long long
inline int read(){
    int s = 0;bool f = 1;char c = getchar();
    while(c > '9' || c < '0'){if(c == '-') f = 0; c = getchar();}
    while(c >= '0' && c <= '9') {
        s = s * 10 + c - '0';
        c = getchar();
    }
    return f == 1 ? s : -s;
}

const int md = 1e9 + 7, maxn = 41; 
ll ksm(int b){
    ll res = 1, tmp = 10; while(b){if(b&1) res = res * tmp % md; tmp = tmp * tmp % md; b >>= 1;}return res;
}
int n, x, y, z;
ll S, tot, t;
ll ck, f[maxn][1<<17];
/*
特殊的状压： 1 -> 1 10 -> 2  100 ->3 1000->4 10000->5
5 + 7 + 5 == 17 
*/
int main(){
   /// freopen("haiku.in", "r", stdin);
    ///freopen("haiku.out", "w", stdout);
    n = read(), x = read(), y = read(), z = read();
    //仅有当状态先凑满x后才能继续进一步枚举y y满了 以后继续j
    //反着来 求所有非法的状态
    ck = ((((1 << x) | 1) << y ) | 1) << (z - 1);
    y += x; z += y;
    S = 1 << z; tot = ksm(n);
    //printf("%lld\n", tot);
    f[0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < S; j++) {
            for (int k = 1; k <= 10; k++) {
                t = (j << k) | (1 << (k - 1));
                t &= (S - 1);
                if ((t & ck) != ck) f[i][t] = (f[i][t] + f[i - 1][j]) % md;
            }   
        }
    }
    for (int i = 0; i < S; i++) {
        tot = (tot - f[n][i] + md) % md;
    }
    printf ("%lld\n", tot);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())


int alti(int H, int cx, int cy, int x, int y){
    return max(H - abs(x-cx) - abs(y-cy), 0);
}

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

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

    int idx1=N+1, idx2=N+1;
    for (int i = 0; i < N; i++) {
        if (posh[i][2] != 0) {
            if (idx1 == N+1) {
                idx1 = i;
            }
            if (idx1 != N+1 && idx2 == N+1) {
                idx2 = i;
                break;
            }
        }
    }

    int diffh = posh[idx1][2] - posh[idx2][2];
    int x1 = posh[idx1][0], y1 = posh[idx1][1];
    int x2 = posh[idx2][0], y2 = posh[idx2][1];
    int cx=10000, cy=10000;
    int H=0;
    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            if (diffh == -abs(x1-Cx)-abs(y1-Cy)+abs(x2-Cx)+abs(y2-Cy)) {
                cx = Cx;
                cy = Cy;
                bool truth=true;
                H = posh[idx1][2]+abs(x1-cx)+abs(y1-cy);
                for (int i = 0; i < N; i++) {
                    if (posh[i][2] != alti(H, cx, cy, posh[i][0], posh[i][1])) {
                        truth = false;
                        break;
                    }
                }
                if (truth) {
                    cout << cx << " " << cy << " " << H << endl;
                    return;
                }
            }
        }
    }

    cout << cx << " " << cy << " " << posh[idx1][2]+abs(x1-cx)+abs(y1-cy) << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
while line = gets() and line != "0 0\n"
	n, m = line.chop.split(" ").map{|num| num.to_i}
	pd = []
	n.times do
		pd << gets.chop.split(" ").map{|num| num.to_i}.reverse
	end
	pd.sort!
	while pd.size > 0 and m >= pd[-1][1]
		m -= pd[-1][1]
		pd.pop
	end
	if pd.size == 0
		p 0
	else
		pd[-1][1] -= m
		result = 0
		for i in 0..pd.size - 1
			result += pd[i][0] * pd[i][1]
		end
		p result
	end
end

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

struct grid{ll to; ll cost;};
vector<vector<grid>> G;
using P = pair<ll, ll>;
	

int main(int argc, char **argv)
{
	ll N; cin >> N;
	G.resize(N);

	REP(i, N-1)
	{
		ll a, b, c; cin >> a >> b >> c;
		--a, --b;
		G[a].push_back(grid{b, c});
		G[b].push_back(grid{a, c});
	}

	ll Q, K; cin >> Q >> K;
	queue<ll> que;
	vector<ll> dist(N, -1);
	dist[K-1] = 0;
	que.push(K-1);

	while (!que.empty())
	{
		ll v = que.front(); que.pop();

		for (auto &nP : G[v])
		{
			ll nv = nP.to;
			ll nc = nP.cost;
			if (dist[nv] != -1) continue;

			dist[nv] = dist[v] + nc;
			que.push(nv);
		}
	}

	REP(i, Q)
	{
		ll x, y; cin >> x >> y;
		--x, --y;
		std::cout << dist[x] + dist[y]<< std::endl;
	}

}


Measured memory_bytes: 9984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int a,b;
   char op;scanf("%d %c %d",&a,&op,&b);
   if(op == '+')printf("%ld",a+b);
   else printf("%d",a-b);
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	var d []int
	var count int

	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		d = append(d, tmp)
	}

	for j:=1; j<=100; j++{
		for i:=0; i<n; i++ {
			if d[i] == j {
				count += 1
				break
			}
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
/* 
   AOJ 2582
   Step Aerobics
   2015.4.27
 */

#include<stdio.h>
#include<string.h>
int count_steps(int num)
{
  int i, up = 0, down = 1, prev_state = down, lu = 0, ru = 0, ld = 1, rd = 1, count = 0;
  char input_str[10];
  for(i = 0; i < num; i++)
    {
      scanf("%s", input_str);
      if(strcmp(input_str, "lu") == 0)
	{
	  lu = 1;
	  ld = 0;
	  if(prev_state == down && lu * ru == 1)
	    {
	      prev_state = up;
	      count++;
	    }
	}
      else if(strcmp(input_str, "ru") == 0)
	{
	  ru = 1;
	  rd = 0;
	  if(prev_state == down && lu * ru == 1)
	    {
	      prev_state = up;
	      count++;
	    }
	}
      else if(strcmp(input_str, "ld") == 0)
	{
	  ld = 1;
	  lu = 0;
	  if(prev_state == up && ld * rd == 1)
	    {
	      prev_state = down;
	      count++;
	    }
	}
      else
	{
	  rd = 1;
	  ru = 0;
	  if(prev_state == up && ld * rd == 1)
	    {
	      prev_state = down;
	      count++;
	    }
	}
    }
  return count;
}

int main(void)
{
  int n, count;
  while(1)
    {
      scanf("%d", &n);
      if(n == 0)
	{
	  break;
	}
      
      count = count_steps(n);
      printf("%d\n", count);
    }
  return 0;
}

Measured memory_bytes: 604
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s;
  cin >> s;
  int count = 0;
  for (auto&&c: s) count += c == '1';
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

H = int(input())
W = int(input())
N = int(input())

if H>=W:
    t = N%H
    if t==0:
        print(N//H)
    else:
        print(N//H+1)
else:
    t = N%W
    if t==0:
        print(N//W)
    else:
        print(N//W+1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pair pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    int black = 0;
    vector<vector<char>>v(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0;j < w; j++)
        {
            cin >> v[i][j];
            if (v[i][j] == '#')
                black++;
        }
    }
    int x = 1 << h;
    int y = 1 << w;
    int ans = 0;
    for (int i = 0; i < x; i++)
    {
        int p = i;
        vector<bool>hb(h, false);
        for(int hl=0;hl<h;hl++)
        {
            if (p & (1 << hl))
                hb[hl] = true;
        }
         for (int j = 0; j < y; j++)
         {
             int count = 0;
             int pj = j;
             vector<bool>wb(w, false);
             for (int wl = 0; wl < w; wl++)
             {
                 if (pj & (1 << wl))
                     wb[wl] = true;
             }
             for (int y = 0; y < h; y++)
             {
                 for (int z = 0; z < w; z++)
                 {
                     if (v[y][z] == '#' && (hb[y] == true || wb[z] == true))
                         count++;
                 }
             }
             if (black-count == k)
                 ans++;
         }
        
    }
    cout << ans << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3664
use proconio::input;

fn main() {
    input!{
        n: usize,
        d: i64,
        xy: [(i64, i64); n],
    }

    let mut cnt = 0;
    for (x, y) in xy{
        if x * x + y * y <= d * d {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 7812
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 K = 0;
	SINT32 ans = 1;


	cin >> N;
	cin >> K;
	
	rep(i,0,N) {
		if (ans < K) {
			ans += ans;
		} else {
			ans += K;
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
import sys

p = [0] * 51
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

for i in sys.stdin:
    print(p[int(i)])

Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, a, b, v[55], dp[55][55]{}, cnt[55][55]{};
    cin >> n >> a >> b;
    REP(i,n){
        cin >> v[i];
    }
    cnt[0][0] = 1;
    REP(i,n){
        REP(j,n){
            if(dp[i+1][j+1] < dp[i][j] + v[i]){
                dp[i+1][j+1] = dp[i][j] + v[i];
                cnt[i+1][j+1] = cnt[i][j];
            }
            else if(dp[i+1][j+1] == dp[i][j] + v[i]){
                cnt[i+1][j+1] += cnt[i][j];
            }
            if(dp[i+1][j] < dp[i][j]){
                dp[i+1][j] = dp[i][j];
                cnt[i+1][j] = cnt[i][j];
            }
            else if(dp[i+1][j] == dp[i][j]){
                cnt[i+1][j] += cnt[i][j];
            }
        }
    }
    ll ans = 0, vma=0, kma=1;
    for(int i=a;i<=b;i++){
        if(vma*i < dp[n][i]*kma){
            vma = dp[n][i];
            kma = i;
            ans = cnt[n][i];
        }
        else if(vma*i == dp[n][i]*kma){
            ans += cnt[n][i];
        }
    }
    printf("%.7lf\n",double(vma)/kma);
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(void) {

	ll N;
	string S;
	cin >> N;
	cin >> S;
	vector<int> S_flag(N);

	REP(i, N) S_flag[i] = 0;

	REP(i, 50) {
		REP(j, N) {

			if (S_flag[j] == 0) {
				if (S[j] == '(') {
					FOR(k, j, N) {
						if (S_flag[k] == false) {
							if (S[k] == ')') {
								S_flag[j] = 1;
								S_flag[k] = 1;
								break;
							}
						}
					}
				}
			}

		}
	}

	string Answer;
	Answer = S;

	REP(j, N) {

		if (S_flag[j] == false) {
			if (S[j] == '(') {
				Answer = Answer + ')';
				S_flag[j] = true;
			}
			else if (S[j] == ')') {
				Answer = '(' + Answer;
				S_flag[j] = true;
			}
		}
	}


	cout << Answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

typedef int INT;
set <INT> S;
const int SIZE = 16777216;
bool HA[SIZE];

inline INT get( char c ) {
    char T[5] = "ACGT";
    for ( INT i = 0; i < 4; ++ i ) {
        if ( c == T[i] ) return i + 1;
    }
    return 0;
}

inline INT get( char *s ) {
    INT n = strlen( s );
    INT sum = 0;
    INT t = 1;
    for ( INT i = 0; i < n; ++ i ) {
        sum += get( s[i] ) * t;
        t *= 4;
    }
    return sum;
}

inline void insert( char *s ) {
    S.insert( get( s ) );
}

inline bool find( char *s ) {
    return S.count( get( s ) ) > 0;
}

int main() {
    INT n, sum, t, c;
    while ( scanf("%d", &n) != EOF ) {
        memset( HA, false, sizeof(HA) );
        while ( getchar() != '\n' );
        S.clear();
        for ( register INT i = 0; i < n; ++ i ) {
            sum = 0;
            t = 1;
            bool flag = getchar() == 'i';
            while ( ( c = getchar() ) != ' ' );
            while ( ( c = get( getchar() ) ) != 0 ) {
                sum += c * t;
                t *= 4;
            }
            if ( flag ) {
                S.insert( sum );
            } else {
                puts( S.count( sum ) ? "yes" : "no" );
            }
        }
    }
    return 0;
}

Measured memory_bytes: 23000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

	typedef set<string>::iterator Iter;

	string s;
	cin >> s;
	int k;
	cin >> k;

	// kが異常に小さい

	// 高々K文字が最大
	set<string> se;
	rep(i, s.size()) {
		string tempS = "";
		rep(j, 5) {
			if (i + j + 1 <= s.size()) {
				tempS += s[i + j];
				//cout << tempS << endl;
				se.insert(tempS);
			}
		}
	}

	//sort(allof(se));
	int cnt = 1;
	for (Iter iter = se.begin(); iter != se.end(); ++iter) {
		//cout << cnt << " " << *iter << endl;
		if (cnt == k) {
			cout << *iter << endl;
			break;
		}
		cnt++;
	}

	return 0;
}

Measured memory_bytes: 1664
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))

#print(a)

nl = 0
nu = 0
for i in range(m):
    if a[i] < x:
        nl += 1
    elif a[i] > x:
        nu += 1
if nl <= nu:
    print(nl)
else:
    print(nu)

Measured memory_bytes: 3060
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

for i in range(n-1, -1, -1):
  ans[i] = sum(ans[i+i+1:n:i+1]) % 2 != a[i]

print(sum(ans))
for i in range(n):
  if ans[i] == 1:
    print(i+1)

Measured memory_bytes: 8380
# coding: utf-8

num, time = map(int, input().split())
count = 0
ans = 10000
for i in range(num):
    cost, tm = map(int, input().split())
    if tm <= time:
        if cost < ans:
            ans = cost
            max = ans
            count = 1
if count == 0:
    print("TLE")
else:
    print(ans)

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

#define ll long long
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define all(a) (a).begin(), (a).end()

using namespace std;

const int maxn = 2e5 + 10;
const double eps = 1e-9;

void solve() {
	int n;
	cin >> n;
	vi v;
	int sum = 0;
	for( int i = 0;i < n;i++ ) {
		double x;cin >> x;
		v.pb( x );
		sum += x;
	}
	
	int sum1 = sum / n + ( sum % n != 0 );
	sum /= n;
	int ans = 0, ans1 = 0;
	for( int i = 0;i < n;i++ ) {
		ans += ( sum - v[ i ] ) * ( sum - v[ i ] );
		ans1 += ( sum1 - v[ i ] ) * ( sum1 - v[ i ] );
	}
	cout << min( ans, ans1 ) << "\n";
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 2e5 + 100;

int A[N];
vi G[N];
int ans[N];
vector<int> inc;

void dfs(int s , int p){
	if(inc.size() == 0){
		ans[s] = 1;
		inc.pb(A[s]);
		for(auto it : G[s]){
			if(it == p) continue;
			dfs(it , s);
		}
	}
	else{
		int type = 0;
		int idx , val;
		if(A[s] < inc[0]){
			idx = 0;
			val = inc[0];
			inc[0] = A[s];
		}
		else if(A[s] > inc.back()){
			inc.pb(A[s]);
			type = 1;
		}
		else{
			int lo = 0 , hi = inc.size()-1 , ans = lo;
			while(lo <= hi){
				int mid = (lo+hi)>>1;
				if(inc[mid] < A[s]){
					ans = mid;
					lo = mid+1;
				}
				else{
					hi = mid-1;
				}
			}
			idx = ans+1;
			val = inc[ans+1];
			inc[ans+1] = A[s];
		}
		ans[s] = inc.size();
		for(auto it : G[s]){
			if(it == p) continue;
			dfs(it , s);
		}
		if(type == 1){
			inc.pop_back();
		}
		else{
			inc[idx] = val;
		}
	}

}


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n; cin >> n;
	for(int i = 1;i <= n ; ++i)
		cin >> A[i];
	int u , v;
	for(int i= 0;i < n-1 ; ++i){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}	
	// inc.pb(A[1]);
	dfs(1 , -1);
	for(int i =1 ;i <= n ; ++i)
		cout << ans[i] << endl;








	return 0;
}


Measured memory_bytes: 30448
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
string s;
llong dfs(llong i, llong sum, llong a) {
    if (i >= n) return sum + a;

    return dfs(i + 1, sum + a, s[i] - '0') + dfs(i + 1, sum, a * 10 + (s[i] - '0'));
}

int main() {
    cin >> s;
    n = s.size();

    cout << dfs(1, 0, s[0] - '0') << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, c;
    cin >> a >> b >> c;
    int ans = min(b / a, c);
    cout << ans << endl;
}

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

int main() {
    int N, K, A, d;
    int ans = 0;
    cin >> N >> K;
    vector<int> nusuke(N + 1, 0);
    
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> A;
            nusuke.at(A)++;
        }
    }
    for (int i = 1; i <= N; i++) {
        if (nusuke.at(i) == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int64 power_mod(int64 a, int64 n, int p = MOD) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % p;
    a = a * a % p;
  }
  return ret;
}

const int N = 2e3 + 10;
int dp[N][N], pre[N << 1];

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; i + j < n; ++j) {
      if (i == 0) {
        dp[i][j] = i + j == n - m;
      } else {
        add(dp[i][j], pre[i + j - 1]);
      }
      if (i + j == n - 1) add(ret, dp[i][j]);
      add(pre[i + j], dp[i][j]);
    }
  }
  for (int i = 0; i < n - m - 1; ++i) {
    ret = ret * 2 % MOD;
  }
  cout << ret << endl;
  return 0;
}


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

int main() {

	int n; cin >> n;
	int a, b, c, d;	a = b = c = d = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AC") a++;
		else if (s == "WA") b++;
		else if (s == "TLE") c++;
		else if (s == "RE") d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define nax 101010
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int arr[200];
int fix[10];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  int mi = 123456;
  int ma = -1;
  for (int i = 0; i < n; ++i)
  {
    sd(arr[i]);
    mi  = min(mi,arr[i]);
    ma = max(ma,arr[i]);
  }
  cout << ma -mi << '\n';
  return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;


char mcxi[]={'i','x','c','m'};

int main(){
	int n;
	cin>>n;
	for(int l=0;l<n;l++){
		string s[2];
		cin>>s[0]>>s[1];
		int data[4];
		
		for(int i=0;i<4;i++)data[i]=0;
		for(int i=0;i<2;i++){
			int prev=-1;
			for(int j=0;j<s[i].size();j++){
				
				for(int k=0;k<4;k++){
					if(s[i][j]==mcxi[k]){
						if(prev==-1)data[k]+=1;
						else data[k]+=prev;
						break;
						
					}
					
				}
				
				int num=s[i][j]-'0';
				if(num>1 &&num<10)prev=num;
				else prev=-1;
			}
		}
		for(int i=0;i<3;i++){
			if(data[i]>=10){
				data[i+1]+=data[i]/10;
				data[i]%=10;
			}
		}
		for(int i=3;i>=0;i--){
			if(data[i]>0){
				if(data[i]>1)cout<<data[i];
				cout<<mcxi[i];
			}
		}
		cout<<endl;
	}

}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+5;
const ll M=1e2+5;

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll a[N][2],c[M][M];

int main()
{
	memset(c,0,sizeof(c));
	ll n=read(),ans=0;
	for (ll i=1;i<=n;i++)
	{
		double t;
		scanf("%lf",&t);
		ll x=t*1e9+0.1;
		ll c2=-9,c5=-9;
		while (x%2==0)
		{
			x/=2;
			c2++;
		}
		while (x%5==0)
		{
			x/=5;
			c5++;
		}
		a[i][0]=c2;
		a[i][1]=c5;//print(c2,' ');print(c5);
		c2+=50;
		c5+=50;
		c[c2][c5]++;
	}
	for (ll i=100;i>=1;i--)
	for (ll j=100;j>=1;j--) c[i][j]+=c[i][j+1]+c[i+1][j]-c[i+1][j+1];
//	for (ll i=1;i<=n;i++) print(c[50-a[i][0]][50-a[i][1]]-(a[i][0]>=0&&a[i][1]>=0));
	for (ll i=1;i<=n;i++) ans+=c[50-a[i][0]][50-a[i][1]]-(a[i][0]>=0&&a[i][1]>=0);
	print(ans/2);

	return 0;
}

Measured memory_bytes: 6804
fn main() {
    let s = read::<String>();
    let n = s.chars().count();
    let mut nums: Vec<u64> = Vec::new();
    for c in s.chars() {
        nums.push(c as u64 - 48);
    }

    let mut ret = 0;
    for bit in 0..(1 << n - 1) {
        let mut buf = 0;
        for i in 0..n-1 {
            if (bit & (1 << i)) != 0 {
                buf = buf * 10 + nums[i];
            } else {
                ret += buf * 10 + nums[i];
                buf = 0;
            }
        }
        ret += buf * 10 + nums[n-1];
    }
    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a[200010],b[200010],L[200010],R[200010],c=0,j,l,r,k;
  cin>>n;
  fr(i,n){
    cin>>a[i];
    b[a[i]]=i+1;
  }
  fr(i,n+2){
    L[i]=i;
    R[i]=i;
  }
  fr(i,n){
    j=n-i;
    k=b[j];
    l=L[k];
    r=R[k];
    c+=j*(k-l+1)*(r-k+1);
    L[r+1]=l;
    R[l-1]=r;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

struct NODE{
	int x, y;
	NODE(){x = y =0;}
	NODE(int x, int y):x(x), y(y){
	}
};
	

int main() {
	int n;
	while(cin >> n, n){
		vector<NODE> vec(n);
		vector<bool> ok(n);
		rep(i, n){
			int xx, yy;
			cin >> xx >> yy;
			vec[i] = NODE(xx, yy);
		}
		
		int m;
		cin >> m;
		int x = 10, y = 10;
		rep(i, m){
			string way;
			int dis;
			cin >> way >> dis;
			rep(j, dis){
				if(way == "N") y++;
				else if(way == "E") x++;
				else if(way == "W") x--;
				else y--;
				if(DEBUG) cout << x << "\t" << y << endl;
				rep(k, n) if(x == vec[k].x && y == vec[k].y) ok[k] = true;
			}
		}
	
		bool flag = true;
		rep(i, n) flag = (flag & ok[i]);
		
		if(flag) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

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

  int train;
  stack<int> trains;

  while (cin >> train) {
    if (train == 0) {
      cout << trains.top() << endl;
      trains.pop();
    } else {
      trains.push(train);
    }
  }

  return 0;
}

Measured memory_bytes: 1196
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	String t = sc.next();
      	int st = Integer.parseInt(s + t);
      	String ans = "No";
      	for(int i = 1; i <= 400; i++){
        	if(st == i*i){
            	ans = "Yes";
              	break;
            }
        }
      	System.out.println(ans);
    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

double N,K;
double ans=0;


double getprob(double T){
  double P=0;
  reps(i,T-1){
    int j=i;
    double p=0;
    int count =0;
    while(j<K){
      j *= 2;
      count ++;
    }

    p =double(1)/(1<<count);

    P+=p;

  }
  return P;
}

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


  if(N>K){
    ans = (N- K+getprob(K)+1)/N;
  }else{
    ans = getprob(N+1)/N;;
  }


  cout << fixed << setprecision(12)<<ans ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int X1, X2, Y1, Y2;
	cin >> X1 >> Y1 >> X2 >> Y2;
	int cmpX = X2 - X1, cmpY = Y2 - Y1;
	cout << X2 - cmpY << " " << Y2 + cmpX << " " << X2 - cmpY - cmpX << " " << Y2 + cmpX - cmpY << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

ll mod = 1000000007;

ll hoge(ll x) {
  static ll data[100001] = {};
  if (data[x])
    return data[x];
  return data[x] = (x <= 1) ? 1 : (hoge(x-1) + hoge(x-2)) % mod;
}

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

  for (ll i = 0; i < 1e5+1; ++i)
    hoge(i);

  ll cur = 0;
  ll ans = 1;
  for (ll i = 0; i < m; ++i) {
    ll a;
    cin >> a;
    if (cur == a)
      ans = 0;
    ans = ans * hoge(a - 1 - cur) % mod;
    cur = a + 1;
  }
  cout << ans * hoge(n - cur) % mod << endl;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S,T;
  cin>>S>>T;
  
  if(S.size()>T.size()){
    cout<<"GREATER"<<endl;
    return 0;
  }
  else if(S.size()<T.size()){
    cout<<"LESS"<<endl;
    return 0;
  }
  else if(S.size()==T.size()){
    int x=0;
    for(int i=0;i<S.size();i++){
      if(S[i]>T[i]){
        cout<<"GREATER"<<endl;
        return 0;
      }
      else if(S[i]<T[i]){
        cout<<"LESS"<<endl;
        return 0;
      }
      else{
        x++;
      }
    }
    if(x==S.size()){
      cout<<"EQUAL"<<endl;
    }
  }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<max(A*B,C*D);
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

if((x+r>w||x-r<0)||(y+r>h||y-r<0)){
    printf("No\n");
}
else{
    printf("Yes\n");
}

return (0);
}


Measured memory_bytes: 2140
n = int(input())
vec = []
for i in range(n):
    vec += [list(map(int, input().split()))]
vec += [vec[0]]
 
def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]
def ab(a, b):
    c = (b[0]-a[0],b[1]-a[1])
    return c
def dot(a, b):
    n = len(a)
    if n != len(b):
        return None
    ans = 0
    for i, j in zip(a, b):
        ans += i*j
    return ans

def check(a, b):
    if abs(cross(a, b)) < pow(10,-8) and dot(a,b)<pow(10,-8):
        return 1
    else:
        return 0
    
def contain():
    x = 0
    p = list(map(int, input().split()))
    for a,b in zip(vec[:-1],vec[1:]):
        a = ab(p,a)
        b = ab(p,b)
        if check(a, b) == 1:
            print(1)
            return 
        if a[1] > b[1]:
            a, b = b, a
        if a[1] < pow(10,-8) and b[1] > pow(10,-8) and cross(a, b) > 0:
            x += 1 
        
    if x%2==1:print(2)
    else:print(0)
k = int(input()) 
for i in range(k):
    contain()


Measured memory_bytes: 5644
from operator import itemgetter
import itertools

N,M = map(int,input().split())
L = [0]*M
for i in range(M):
  L[i] = list(map(int,input().split()))
P = list(map(int,input().split()))

cnt = 0

for b in list(itertools.product(range(2),repeat = N)):
  flag = 1
  for i in range(M):
    k = L[i][0]
    b_sum = 0
    for j in range(1,k+1):
      b_sum += b[L[i][j]-1]
    if b_sum % 2 != P[i]:
      flag = 0
  if flag == 1:
    cnt += 1
print(cnt)

Measured memory_bytes: 3188
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(i64, i64);
    println!("{}", if K == 1 { 0 } else { N - K })
}


Measured memory_bytes: 4352
import java.util.*;

class Main{

    public Main(){
        int N, M, L;
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        M = scanner.nextInt();
        L = scanner.nextInt();

        if(N == M & M != L){
                System.out.println("Yes");

        } else if(N == L & N != M){
                System.out.println("Yes");

        } else if(M == L & M != N){

                    System.out.println("Yes");
        } else {
                System.out.println("No");

        }

    }

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }
}


Measured memory_bytes: 21972
n,m = map(int, input().split())
ls = []
rs = []
for _ in range(m):
    l,r = map(int, input().split())
    ls.append(l)
    rs.append(r)

ls.sort()
rs.sort()

ans = rs[0] - ls[-1] + 1
ans = max(0,ans)

print(ans)

Measured memory_bytes: 86680
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b,k;cin>>a>>b>>k;
    for(int i=a;i<=b;i++){
        if(i<a+k)cout<<i<<endl;
        else if(i>b-k)cout<<i<<endl;
    }
}



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

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < 0) {
        if (b < 0) {
            if ((b - a) % 2) {
                cout << "Positive\n";
            } else {
                cout << "Negative\n";
            }
        } else {
            cout << "Zero\n";
        }
    } else if (a == 0) {
        cout << "Zero\n";
    } else {
        cout << "Positive\n";
    }
}

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

int main(){
 	int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    long long int c =a[n-1];int k=n-2,h=0;

    for(int i=n-3;i>=0;i--){
        if(h<2){
            c+=a[k];
            h++;
            if(h==2){
                h=0;
                k--;
            }
        }
    }
    cout<<c;



}

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

int main() {
	int ajitama = 0, tyaasyuu = 0, negi = 0;
	string s;

	cin >> s;
	if (s[0] == 'o') ajitama = 1;
	if (s[1] == 'o') tyaasyuu = 1;
	if (s[2] == 'o') negi = 1;

	cout << (700 + (ajitama + tyaasyuu + negi) * 100) << endl;
}


Measured memory_bytes: 256
S = input()

if 1 <= int(S[0:2]) <= 12 and 1<= int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(S[0:2]) <= 12 and 0<= int(S[2:]) <= 99:
    print("MMYY")
elif 0<= int(S[:2]) <= 99 and 1<= int(S[2:]) <= 12:
    print("YYMM")
else:
    print("NA")



Measured memory_bytes: 3060
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]

    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        print 0
        return

    print min((A/2+1) * B * C - (A /2)* B * C,
              (B/2+1) * A * C - A * (B/2) * C,
              (C/2+1) * B * A - A * B * (C/2))


if __name__ == '__main__':
    main()

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

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string S;
  cin >> S;
  int length = S.length();
  reverse(all(S));

  int ans = 0;

  // sum(i) iまで足した時の累積和。
  vector<int> sum(length+1);
  sum[0] = 0;
  int dig = 1;
  const int m = 2019;
  for (int i = 0; i < length; i++) {
    sum[i + 1] = (sum[i] + dig * (S[i] - '0')) % m;
    dig = dig * 10 % m;
    PRINT(sum[i])
    // PRINT(dig)
  }

  rep(i, m) {
    int count = 0;
    rep(j, length+1) {
      if (i == sum[j]) {
        count++;
      }
    }
    if (count == 0) continue;
    ans += count * (count - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4260