akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 1e5;
int k;
int n;
int a[maxn];

bool read() {
  if (scanf("%d%d", &k, &n) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  return true;
}

void solve() {
  multiset<int> m;
  for (int i = 0; i < n; i++) {
    m.insert(a[i]);
  }
  int cnt = 0;
  while (*m.rbegin() > (k - cnt + 1) / 2) {
    int cur = *m.rbegin();
    m.erase(cur);
    cur--;
    m.insert(cur);
    cnt++;
  }
  printf("%d\n", cnt);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define int long long

static const int _MOD = 1e9 + 7, MAX = 2e5 + 5;

int fact[MAX], inv_fact[MAX];

inline int bin_pow(int x, int y)
{
    int ret = 1;
    while (y > 0)
    {
        if (y & 1)
            ret = (ret * x) % _MOD;
        x = (x * x) % _MOD;
        y >>= 1;
    }
    return ret % _MOD;
}

inline int nCr(const int &n, const int &r)
{
    return (((fact[n] * inv_fact[r]) % _MOD) * inv_fact[n - r]) % _MOD;
}

signed main()
{
    // Fast I/O
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(false);

    int m, n, a, b;
    std::cin >> m >> n >> a >> b;

    // Preprocessing
    fact[0] = 1;
    inv_fact[0] = 1;
    for (int i = 1; i <= MAX; ++i)
    {
        fact[i] = (fact[i - 1] * i) % _MOD;
        inv_fact[i] = bin_pow(fact[i], _MOD - 2);
    }

    int ans = 0;
    int y = m - a;
    for (int x = b + 1; x <= n; ++x)
    {
        ans += (nCr(x + y - 2, y - 1) * nCr(n - x + a - 1, a - 1)) % _MOD;
        ans %= _MOD;
    }

    std::cout << ans << '\n';
    return 0;
}

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

int main(){
    long long K,A,B,C;
    cin>>A>>B>>C;
    cin>>K;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            for(int k=0;k<=K;k++){
                if(K<i+j+k)break;
                if((int)(pow(2,i))*A < (int)(pow(2,j))*B && (int)(pow(2,j))*B < (int)(pow(2,k))*C){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

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

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

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

	int jobCount = 0;
	bool completed = false;
	while (true)
	{
		for (int elem : arr)
			if (elem % 2 != 0)
				completed = true;

		if (completed) break;

		for (int i = 0; i < arr.size(); i++)
			arr[i] /= 2;

		jobCount++;
	}

	cout << jobCount << "\n";

	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  char C;
  cin>>C;
  cout<<(char)(((C-'a')+1)%26+'a');
  return 0;
}


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

using namespace std;

int main() {
  string s; cin >> s;
  bool flg = true;
  for(int i = 0; i < (s.size() - 1) / 2; i++) {
    if(s[i] != s[s.size() - 1 - i] || s[i] != s[(s.size() - 1) / 2 - 1 - i]) {
      flg = false; break;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int N, X[2019], M, A[100];
	int i;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &X[i]);
	}
	scanf("%d", &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &A[i]);
	}
	
	for (i = 0; i < M; i++) {
		if (A[i] == N || (X[A[i]] - X[A[i] - 1]) != 1) {
			X[A[i] - 1]++;
		}

		if (X[A[i] - 1] >= 2019) {
			X[A[i] - 1] = 2019;
		}
	}

	for (i = 0; i < N; i++) {
		printf("%d\n", X[i]);
	}

	return 0;
}


Measured memory_bytes: 2104
def printt(x):
  print(x,flush=True)
  i=input()
  if i=="Vacant":exit()
  if i=="Male":return 0
  return 1
n=int(input())
ng=0
ok=n
f=printt(0)
while ng+1!=ok:
  mid=(ok+ng)//2
  if printt(mid)==(f+mid)%2:ng=mid
  else:ok=mid

Measured memory_bytes: 3660
from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

Measured memory_bytes: 9496
unittest
{
	assert( [ "10 2 3", "abccabaabb" ].parse.expand.solve == "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo" );
	assert( [ "12 5 2", "cabbabaacaba" ].parse.expand.solve == "No\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo" );
	assert( [ "5 2 2", "ccccc" ].parse.expand.solve == "No\nNo\nNo\nNo\nNo" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nab = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( nab[ 0 ], nab[ 1 ], nab[ 2 ], s );
}

auto solve( long n, long a, long b, dchar[] s )
{
	auto anss = new string[ n ];
	auto at = 0L;
	auto bt = 0L;
	foreach( ref ans, r; lockstep( anss, s ) )
	{
		final switch( r )
		{
			case 'a':
				if( at + bt < a + b ) ans = "Yes", at++;
				else                  ans = "No";
				break;
			
			case 'b':
				if( at + bt < a + b && bt < b ) ans = "Yes", bt++;
				else                            ans = "No";
				break;
			
			case 'c':
				ans = "No";
				break;
		}
	}
	return anss.join( "\n" );
}


Measured memory_bytes: 4476
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		int b = Integer.parseInt(a);
		String s = sc.nextLine();
		if(s.length()>b) {
		for (int i = 0; i < b; i++) {
		   System.out.print(s.charAt(i));
		}	
			System.out.println("...");
		}else {
			System.out.println(s);
		}
	}

}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



bool solve(int N, int M, vi& a, vi& b){
    vvi nxt(N);
    rep(i,M){
        nxt[a[i]].pb(b[i]);
        nxt[b[i]].pb(a[i]);
    }
    rep(i,N){
        if (nxt[i].size() % 2 != 0) return false;
    }
    return true;
}

int main() {
    int N, M; cin >> N >> M;
    vi a(M), b(M);
    rep(i,M) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
    }
    cout << (solve(N,M,a,b) ? "YES":"NO") << endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    string S;
    cin >> S;
    vector<long> dp(N + 1);
    dp[0] = count(S.begin(), S.end(), '.');
    transform(S.begin(), S.end(), dp.begin() + 1, [](auto c){return c == '.' ? -1 : 1;});
    partial_sum(dp.begin(), dp.end(), dp.begin());
    cout << *min_element(dp.begin(), dp.end());
}

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

int main(void)
{
  int n,i;

  scanf("%d",&n);
  char s[n][11];
   for(i=0; i<n; i++){
       scanf("%s",&s[i]);}
   int sum=1;

  qsort(s,n,11,strcmp);

  for(i=1;i<n;i++){
      if(strcmp(s[i],s[i-1])!=0) 
        sum++;    
  }
   
  printf("%d",sum);
  
  return 0;
}


Measured memory_bytes: 5692
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

char s[MaxN + 5];

int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		int len = strlen(s + 1);
		int ans = inf;
		for(int i = 1; i <= len; i++) {
			if(s[i] != s[i + 1]) {
				ans = min(ans, max(i, len - i));
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
def main():
    h,w=map(int,input().split())
    sx,sy=map(int,input().split())
    sx-=1
    sy-=1
    gx,gy=map(int,input().split())
    gx-=1
    gy-=1
    g=[tuple(input()) for _ in range(h)]
    v=[[0 for j in range(w)] for i in range(h)]
    q=deque([[sx,sy]])
    v[sx][sy]=1
    ans=0
    k=[[0,1],[0,-1],[1,0],[-1,0]]
    while True:
        l=[]
        while q:
            x,y=q.popleft()
            l.append([x,y])
            if x==gx and y==gy:
                print(ans)
                exit()
            for a,b in k:
                nx=x+a
                ny=y+b
                if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0:
                    q.append([nx,ny])
                    v[nx][ny]=1
        if len(l)==0:
            break
        for x,y in l:              
            for a in range(-2,3):
                for b in range(-2,3):
                    if a*b==0 and abs(a+b)<=1:
                        continue
                    nx=x+a
                    ny=y+b
                    if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0:
                        q.append([nx,ny])
                        v[nx][ny]=1
        ans+=1 
    print(-1)
if __name__=='__main__':
    main()

Measured memory_bytes: 190784
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll lg=22;
const ll N=1e5+5;
const ll M=16;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){cin>>a[i];}
    a[0]--;
    for(ll i=1;i<n;i++)
    {
        if(a[i]>a[i-1]){a[i]--;}
        if(a[i]<a[i-1]){cout<<"No"<<endl;exit(0);}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
//TINY_OUNCE911666
// You are not prepared!

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string text1, text2;
	cin >> text1 >> text2;

	const int n = text1.size(), m = text2.size();
	vector<vector<int>> dp(n, vector<int>(m, 0));
	vector<vector<int>> recreate(n, vector<int>(m));

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (text1[i] == text2[j]) {
				recreate[i][j] = 3;
				dp[i][j] = (i-1 >= 0 and j-1 >= 0 ? dp[i-1][j-1] : 0) + 1;
			}
			else {
				int maxi = max((i-1 >= 0 ? dp[i-1][j] : 0), (j-1 >= 0 ? dp[i][j-1] : 0));
				dp[i][j] = maxi;
				
				if (maxi == (i-1 >= 0 ? dp[i-1][j] : 0)) {
					recreate[i][j] = 1;
				}
				else {
					recreate[i][j] = 2;
				}
				//if ((i-1 >= 0 ? dp[i-1][j] : 0) > (j-1 >= 0 ? dp[i][j-1] : 0)) {
				//	dp[i][j] = (i-1 >= 0 ? dp[i-1][j] : 0);
				//	recreate[i][j] = 1;
				//}
				//else {
				//	recreate[i][j] = 2;
				//	dp[i][j] = (j-1 >= 0 ? dp[i][j-1] : 0);
				//}
			}
		}
	}
	
	string ans;
	int row = n-1, col = m-1;
	while (~row and ~col) {
		if (recreate[row][col] == 3) {
			ans += text1[row];
			--row, --col;
		}
		else if (recreate[row][col] == 1) {
			--row;
		}
		else { 
			--col;
		}
	}
	//for (int i = 0; i < n; ++i) {
	//	for (int j = 0; j < m; ++j) {
	//		cout << recreate[i][j] << ' ';
	//	}
	//	cout << '\n';
	//}
	
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smthn instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 70784
#include<stdio.h>
int main()
{
    int N;
    double a,x;
    scanf("%d",&N);
    if(N%2==0)
    {
        x=(double)(N/2)/N;
        printf("%0.10lf",x);

    }
    else if(N%2!=0)
    {
        a=(N+1)/2;
        x=(double)a/N;
        printf("%0.10lf",x);

    }

    return 0;
}


Measured memory_bytes: 128
a=[None]*28
for i in range(28):
    a[i]=input()
a=list(map(int,a))

a.sort()

k=0
m=0
if a[0]==2:
    print(1)
if a[27]==29:
    print(30)
for i in range(27):
    k=a[i+1]-a[i]
    if k==2:
        m=a[i+1]-1
        print(m)



Measured memory_bytes: 5600
n, m = map(int, input().split())
food_dic = {}
for i in range(n):
    k_a = list(input().split())
    foods = k_a[1:]
    for food in foods:
        if food in food_dic:
            food_dic[food] += 1
        else:
            food_dic[food] = 1
count = 0
for food_count in food_dic.values():
    if food_count == n: count += 1

print(count)


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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  if (S.at(A) != '-') {
    cout << "No" << endl;
  }
  else {
    bool ok = true;
    int M = 0;
    for (int i = 0; i < A + B + 1; i++) {
      if (ctoi(S.at(i)) == -1) {
        M++;
      }
    }
    if (M != 1) {
      ok = false;
    }  
    if (ok) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
char co[1010][1010];

int main(){
	int N;read(N);
	if(N<=2){write(-1);return 0;}
	else if(N%4==0){
		for(int i=1;i<=N;i+=4){
			co[i][i]=co[i][i+1]='a';co[i][i+2]=co[i+1][i+2]='b';
			co[i][i+3]=co[i+1][i+3]='c';co[i+1][i]=co[i+1][i+1]='d';
			rep(j,i+2,i+3){
				rep(k,i,i+3)co[j][k]=co[j-2][2*i+3-k];
			}
		}
	}else if(N%4==1){
		co[1][1]=co[1][2]='a';co[1][3]=co[2][3]='b';co[1][5]=co[2][5]='c';
		co[2][4]=co[3][4]='d';co[3][3]=co[4][3]='e';co[3][1]=co[3][2]='f';
		co[5][4]=co[5][5]='g';co[4][4]=co[4][5]='h';co[4][1]=co[5][1]='i';
		co[5][2]=co[5][3]='j';
		for(int i=6;i<=N;i+=4){
			co[i][i]=co[i][i+1]='a';co[i][i+2]=co[i+1][i+2]='b';
			co[i][i+3]=co[i+1][i+3]='c';co[i+1][i]=co[i+1][i+1]='d';
			rep(j,i+2,i+3){
				rep(k,i,i+3)co[j][k]=co[j-2][2*i+3-k];
			}
		}
	}else if(N%4==2){
		/*
		addii
		a c  j
		bbc  j
		k  ehh
		k  e g
 		 llffg
		*/
		co[1][1]=co[2][1]='a';co[3][1]=co[3][2]='b';co[2][3]=co[3][3]='c';
		co[1][2]=co[1][3]='d';co[4][4]=co[5][4]='e';co[6][4]=co[6][5]='f';
		co[5][6]=co[6][6]='g';co[4][5]=co[4][6]='h';co[1][4]=co[1][5]='i';
		co[2][6]=co[3][6]='j';co[4][1]=co[5][1]='k';co[6][2]=co[6][3]='l';
		for(int i=7;i<=N;i+=4){
			co[i][i]=co[i][i+1]='a';co[i][i+2]=co[i+1][i+2]='b';
			co[i][i+3]=co[i+1][i+3]='c';co[i+1][i]=co[i+1][i+1]='d';
			rep(j,i+2,i+3){
				rep(k,i,i+3)co[j][k]=co[j-2][2*i+3-k];
			}
		}
	}else{
		if(N==3){puts("lyy");puts("l.r");puts("ttr");return 0;}
		/*
		a  eedd
		aii  b
		 j   bc
		fj    c
		f   lln
	      mmh n
		ggkkh 
*/
		co[1][1]=co[2][1]='a';co[2][6]=co[3][6]='b';co[3][7]=co[4][7]='c';
		co[1][6]=co[1][7]='d';co[1][4]=co[1][5]='e';co[4][1]=co[5][1]='f';
		co[7][1]=co[7][2]='g';co[6][5]=co[7][5]='h';co[2][2]=co[2][3]='i';
		co[3][2]=co[4][2]='j';co[7][3]=co[7][4]='k';co[5][5]=co[5][6]='l';
		co[6][3]=co[6][4]='m';co[5][7]=co[6][7]='n'; 
		for(int i=8;i<=N;i+=4){
			co[i][i]=co[i][i+1]='a';co[i][i+2]=co[i+1][i+2]='b';
			co[i][i+3]=co[i+1][i+3]='c';co[i+1][i]=co[i+1][i+1]='d';
			rep(j,i+2,i+3){
				rep(k,i,i+3)co[j][k]=co[j-2][2*i+3-k];
			}
		}
	}
	rep(i,1,N){
		rep(j,1,N)putchar((!co[i][j])?'.':co[i][j]);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n,m,k;
    cin>>n>>m>>k;
    set<int> s;
    for(int i=0;i<=n;i++){
        s.insert(i*m);
    }
    for(int i=0;i<=m;i++){
        s.insert(i*n);
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            int num=i*m+j*n-2*i*j;
            s.insert(num);
        }
    }
    if(s.count(k)==0)fin("No");
    else fin("Yes");
    
}

Measured memory_bytes: 13056
def hamming(n)
  [2,3,5].each{ |m| n /= m while (n%m).zero? } 
  return (n == 1 ? true : false)
end

loop do
  m, n = gets.split.map(&:to_i)
  break if m.zero?
  count = 0
  m.upto(n){|num| count += 1 if hamming(num) }
  puts count
end

Measured memory_bytes: 6096
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {  

   int a,b;
   int i=0;
   cin >> a >> b;

   while(1){
    if(a * i - i + 1 >= b){
       break;
     } 
       i++;
   }

   cout << i << endl;

}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] g = new long[n];
    for (int i=0;i<n;i++){
      g[i] = scan.nextLong();
    }
    Arrays.sort(g);
    long t = (long) (g[n-1]+1)/2;
    int p = search(g,t);

    if ((g[p+1]-t) < (t-g[p])){
      p+=1;
    }
    System.out.print(g[n-1] + " " + g[p]);
  }

  static int search(long[] a, long n){
    long ret = 0;
    int l = 0;
    int r = a.length-1;
    while (l<r){
      int mid = (int) (l+r+1)/2;
      if (a[mid] == n){
        return mid;
      }
      if (a[mid] < n){
        l = mid;
      }
      else{
        r = mid-1;
      }
    }

    return l;
  }

}


Measured memory_bytes: 60776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    for(int i=0; i<N; ++i){
        if(a[i]%2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }

    cout << "second" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C, K; 
  cin >> A >> B >> C >> K;

  if(K%2 == 0){
    cout << A-B << "\n";
  }else{
    cout << B-A << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string S;
    cin >> S;
    bool ye = true;
    for(int i=0;i<S.length();i+=2){
        if(S[i]=='L')ye = false;
    }
    for(int i=1;i<S.length();i+=2){
        if(S[i]=='R')ye = false;
    }
    if(ye)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

if n==1:
    print(1)
    exit()
 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)


Measured memory_bytes: 7668
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v); 
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2040
#include<iostream>
#include<map>
#include<algorithm> // min, max
#include<cctype> // isdigit
#include<cassert> //assert
using namespace std;

string exp;
int pos;
map<char,int>value;

int formula()
{
  if(isdigit(exp[pos])){
    return exp[pos++]-'0';
  }
  if(isalpha(exp[pos])){
    return value[ exp[pos++] ];
  }
  if(exp[pos]=='-'){
    pos++;
    return 2-formula();
  }
  if(exp[pos]=='('){
    pos++;
    int left=formula();
    char op=exp[pos++];
    int right=formula();
    assert(exp[pos++]==')');
    if(op=='*'){
      return min(left,right);
    }
    if(op=='+'){
      return max(left,right);
    }
  }
}

int main()
{
  int ans;
  while(cin>>exp,exp!="."){
    ans=0;
    for(int p=0;p<=2;p++)for(int q=0;q<=2;q++)for(int r=0;r<=2;r++){
      value['P']=p;
      value['Q']=q;
      value['R']=r;
      pos=0;
      if(formula()==2)ans++;
    }
    cout<<ans<<endl;
  }
}

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

using namespace std;

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

  int N, i = 0;
  cin >> N;
  vector<int> P(N);

  while (N--) {
    cin >> P[i++];
  }

  int mn = P[0];
  int count = 1;
  for (i = 1; i < P.size(); i++) {
    if (P[i] <= mn) {
      mn = P[i];
      count++;
    }
  }

  cout << count << endl;

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	double a[2],b[2],c[2];
	double matrix[2][2],ans[2],reverse[2][2],det;
	double r,o[2];
	int n;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];
		b[0] = b[0]-a[0];
		b[1] = b[1]-a[1];
		c[0] = c[0]-a[0];
		c[1] = c[1]-a[1];
		matrix[0][0] = 2*b[0];
		matrix[1][0] = 2*b[1];
		matrix[0][1] = 2*c[0];
		matrix[1][1] = 2*c[1];
		ans[0] = b[0]*b[0]+b[1]*b[1];
		ans[1] = c[0]*c[0]+c[1]*c[1];
		det = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
		reverse[0][0] = matrix[1][1]/det;
		reverse[1][0] = -matrix[1][0]/det;
		reverse[0][1] = -matrix[0][1]/det;
		reverse[1][1] = matrix[0][0]/det;
		o[0] = ans[0]*reverse[0][0]+ans[1]*reverse[1][0];
		o[1] = ans[0]*reverse[0][1]+ans[1]*reverse[1][1];
		r = sqrt(o[0]*o[0]+o[1]*o[1]);
		o[0]+=a[0];
		o[1]+=a[1];
		printf("%.3lf %.3lf %.3lf\n",o[0],o[1],r);
	}
	return 0;
}

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

using namespace std;

const long long INF = 1ll << 60;

int main(){
  int N, M;
  long long X;
  cin >> N >> M >> X;
  
  vector<long long> C(N);
  vector<vector<long long>> A(N, vector<long long>(M));
  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  
  long long min_cost = INF;
  
  for(int b = 0; b < (1 << N); b++){
    vector<long long> master(M, 0);
    long long cost = 0;
    for(int i = 0; i < N; i++){
      if(b & (1 << i)){
        cost += C[i];
        for(int j = 0; j < M; j++){
          master[j] += A[i][j];
        }
      }
    }
    
    bool mastered = true;
    for(int j = 0; j < M; j++){
      if(master[j] < X){
        mastered = false;
        break;
      }
    }
    
    if(mastered){
      min_cost = min(cost, min_cost);
    }
  }
  
  if(min_cost != INF) cout << min_cost << endl;
  else cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    h,w=MI()
    ss=[SI() for _ in range(h)]
    cc=[[0]*w for _ in range(h)]
    if ss[0][0]=="#":cc[0][0]=1
    for i in range(h):
        for j in range(w):
            if (i,j)==(0,0):continue
            u=l=inf
            if i-1>=0:
                u=cc[i-1][j]
                if ss[i][j]=="#" and ss[i-1][j]==".":u+=1
            if j-1>=0:
                l=cc[i][j-1]
                if ss[i][j]=="#" and ss[i][j-1]==".":l+=1
            cc[i][j]=min(u,l)
    print(cc[h-1][w-1])

main()

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

int main(){
  int N = 0;
  int a = 0;
  int amax = 0;
  int max = 0;
  cin >> N;
  int counter = 0;
  for(int i = 1; i <= N; i++){
    a = i;
    while(a >= 1){
       if(a % 2 != 0) break;
       a /= 2;
       counter++;
    }
    if (max <= counter){
      max = counter;
      amax = i;
    }
    counter = 0;
  }
  cout << amax;
}

Measured memory_bytes: 256
f=[0]*45
f[0]=f[1]=1

def fib(n):
    if n ==0 or n==1:
        return 1
    else:
        if f[n] == 0:
            f[n] = fib(n-1)+fib(n-2)
            return f[n]
        else:
            return f[n-1]+f[n-2]
n = int(input())
print(fib(n))


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

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  a.push_back(-1);
  
  int cnt = 0,eve=0,kind=0;
  rep(i,n){
    cnt++;
    if(a[i+1]!=a[i]){
      if(cnt>=2){
        if(cnt%2==0)eve++;
      }
      cnt = 0;
      kind++;
    }
  }
  int ans;
  if(eve%2==0)ans=kind;
  else ans=kind-1;
  cout << ans << endl;
}



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

int H, W;
vector<vector<int>> cntx, cnty;
vector<string> S;

int dfsX(int h, int w, int n){
    // cout << h << " " << w << " " << n << endl;
    if(w+1>=W || S[h][w+1]=='#'){
        cntx[h][w] = n;
        return n;
    }
    cntx[h][w] = dfsX(h,w+1, n+1);
    return cntx[h][w];
}
int32_t dfsY(int h, int w, int n){
    if(h+1>=H || S[h+1][w]=='#'){
        cnty[h][w] = n;
        return n;
    }
    cnty[h][w] = dfsY(h+1,w, n+1);
    return cnty[h][w];
}

int main(){
    cin >> H >> W;
    S = vector<string>(H);
    for(int i=0; i<H; i++){
        cin >> S[i];
    }

    cntx = vector<vector<int>>(H,vector<int>(W,-1));
    cnty = vector<vector<int>>(H,vector<int>(W,-1));
    for(int h=0; h<H; h++) for(int w=0; w<W; w++){
        if(S[h][w]=='.'){
            if(cntx[h][w]==-1){
                cntx[h][w] = dfsX(h,w,1);
            }
            if(cnty[h][w]==-1){
                cnty[h][w] = dfsY(h,w,1);
            }
        }
    }
    
    int ans = 0;
    for(int h=0; h<H; h++) for(int w=0; w<W; w++){
        ans = max(ans, cntx[h][w] + cnty[h][w] - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, s;
int dp[20][500][1100];
int solve(int i, int sum, int used)
{
	if (dp[i][sum][used] >= 0) return dp[i][sum][used];
	if (i == n + 1 && sum == s) return 1;
	if (i > n || sum > s) return 0;
	int res = 0;
	REP(j, 10)
	{
		if (((used >> j) & 1) == 0&&sum+i*j<=s)
		{
			res += solve(i + 1, sum + i*j, used | (1 << j));
		}
	}
	return dp[i][sum][used] = res;
}

int main()
{
	while (cin >> n >> s)
	{
		MS(dp, -1);
		cout << solve(1, 0, 0) << endl;
	}
	return 0;

}

Measured memory_bytes: 44136
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll x=n/(a+b);
	cout<<x*a+min(a,n%(a+b));	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

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

long long N, M, P, A[1 << 18], B[1 << 18], C[1 << 18];
long long dist[1 << 18], predist[1 << 18];
bool used1[1 << 18], used2[1 << 18];

int main() {
	cin >> N >> M >> P;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		C[i] -= P;
	}
	used1[1] = true;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (used1[A[j]] == true) used1[B[j]] = true;
		}
	}
	used2[N] = true;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (used2[B[j]] == true) used2[A[j]] = true;
		}
	}

	for (int i = 1; i <= N; i++) dist[i] = -(1LL << 60);
	dist[1] = 0;
	for (int i = 1; i <= N * 2; i++) {
		for (int j = 1; j <= N; j++) predist[j] = dist[j];
		for (int j = 1; j <= M; j++) {
			dist[B[j]] = max(dist[B[j]], dist[A[j]] + C[j]);
		}
		bool flag = false;
		for (int j = 1; j <= N; j++) {
			if (used1[j] == true && used2[j] == true && dist[j] != predist[j]) flag = true;
		}
		if (flag == false) break;
		if (i == N * 2) {
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << max(0LL, dist[N]) << endl;
	return 0;
}

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

int main() {
    set<int> s;
    int N;cin>>N;
    for (int i = 0; i < N; i++){
        int a;cin>>a;
        if(s.count(a)){
            cout<<"NO"<<endl;
            return 0;
        }
        s.insert(a);
    }
    cout<<"YES"<<endl;
}

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

using namespace std;

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

    vector<int> c;
    for(int i=0; i<26; i++){
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }
    
    vector<vector<int>>  s(d,vector<int>(26,0));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> s[i].at(j);
        }
    }

    vector<int> t;
    for(int i=0; i<d; i++){
        int tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    
    int m;
    cin >> m;

    vector<int> d_;
    vector<int> q;
    for(int i=0; i<m; i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        d_.push_back(tmp1);
        q.push_back(tmp2);
    }
    /*
    vector<int> last(26,0);
    int ans = 0;
    int i = 0;
    while(i<d){
        int dec = 0;
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        for(int j=0; j<26; j++){
            dec += c[j] * (i+1-last[j]);
        }
        ans -= dec;
        i++;
        cout << ans << endl;
    }
    */
    vector<int> last_(26,0);
    int total;
    for(int k=0; k<m; k++){
        //int tmp3 = t[d_[k]-1];
        t[d_[k]-1] = q[k];
        /*
        for(int l=0;l<d;l++){
            cout << t[l] << " ";
        }
        cout << endl;
        */
        //cout << t[d_[j]-1] << endl;
        //cout << tmp3 << endl;
        int i_ = 0;
        long long ans_ = 0;
        for(int a=0; a<26; a++){
            last_[a] = 0;
        }
        while(i_<d){
            long long dec_ = 0;
            //cout << t[i_] << endl;
            ans_ += s[i_][t[i_]-1];
            last_[t[i_]-1] = i_+1;
            for(int j=0; j<26; j++){
                dec_ += c[j] * (i_+1-last_[j]);
            }
            ans_ -= dec_;
            i_++;
        }
        cout << ans_ << endl;
        //cout << tmp3 << endl;
        //total = max(ans,ans_);
        /*
        if(total == ans){
            t[d_[j]-1] = tmp3;
        }
        */
        //cout << total << endl;
        
    }


    /*
    //デバッグ処理
    for(int i=0; i<26; i++){
        cout << c[i] << " ";
    }
    cout << endl;
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cout << s[i][j] << " ";
        }
        cout << endl;
    }
    for(int i=0; i<d; i++){
        cout << t[i] << " ";
    }
    */
    return 0;
}

Measured memory_bytes: 4324
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, A, B = lr()
list1 = '0' * (W-A) + '1' * A
for i in range(H-B):
    print(list1)

list2 = '1' * (W-A) + '0' * A
for i in range(B):
    print(list2)

# 40

Measured memory_bytes: 3956
#include<iostream>
using namespace std;
int main()
{
	int A, B;
	cin >> A >> B;
	if ((A >= 0 && A <= 100) && (B >= 2 && B <= 1000) && (B % 2 == 0))
	{
		if (A < 6)
			cout << 0 << endl;
		else if (A >= 6 && A < 13)
			cout << B / 2 << endl;
		else
			cout << B << endl;
	}
	else
		cout << "Wrong inputs" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll>v(N + 1, -Q + K);
    rep1(i, Q){
        ll a;
        cin >> a;
        v[a]++;
    }
    rep1(i, N){
        // cout << v[i] << " : ";
        if(v[i] <= 0)cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}

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

bool is_prime(ll x){
  if(x==1) return false;
  else{
    for(int i=2;i*i<=x;i++){
      if(x%i==0) return false;
    }
  return x!=1;
  }
}

int main() {
  ll X;cin>>X;
  
  for(int i=X;i<=100003;i++){
    if(is_prime(i)){
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

main(){
	long long x,y,n=0;
	cin>>x>>y;
	long long a=x%y;
	long long b=y;
	while(a !=0){
		x=y;
		y=a;
		a=x%y;
		b=y;
	}
	printf("%d\n",b);
}


Measured memory_bytes: 3208
#include<stdio.h>

int main()
{
    int n, l, s = 0, m = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &l);
        if (l > m) m = l;
        s += l;
    }
    printf("%s", ((m*2 < s) ? "Yes" : "No"));
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    int ansArray[n];
    string ans = "Yes";

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

    for(int i = 0; i < n; i++){
        if(i > 0){
            if(h[i] < h[i-1]){
                if(h[i]+1 < h[i-1]){
                    cout << "No";
                    return 0;
                }else if(h[i]+1 == h[i-1]){
                    h[i] = h[i] + 1;
                }
            }
        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len=s.size();
    string s1,s2;
    s1=s.substr(0,(len-1)/2);
    //cout<<s1;
    s2=s.substr((len+3)/2-1,-1);
    //cout<<s2;
    string r1=s1,r2=s2,r=s;
    reverse(r1.begin(),r1.end());
    reverse(r2.begin(),r2.end());
    reverse(r.begin(),r.end());
    if(r==s&&r1==s1&&r2==s2)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
#define PI 3.14159265359
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int N, K;
	cin >> N >> K;
	vector<int>V;
	REP(i, N) {
		int h; cin >> h;
		V.push_back(h);
	}
	sort(V.begin(), V.end(), greater<int>());
	ll ans = 0;
	int cnt = 0;
	REP(i, N) {
		if (cnt < K) {
			cnt++;
		}
		else {
			ans += V[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<16;i++){
    string a="",b="",c="",d="";
    if(i&1){
      a='A';
    }
    if(i>>1&1){
      b='A';
    }
    if(i>>2&1){
      c='A';
    }
    if(i>>3&1){
      d='A';
    }
    string t=a+"KIH"+b+"B"+c+"R"+d;
    if(t==s){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0154 Sum of Cards

#include <stdio.h>
#include <string.h>

int now[1001], prev[1001];


void dp(int a, int b)
{
    int i, j;
    
    memcpy(prev, now, sizeof(now));
    
    for (i = 1; i <= 1000; i++){
        if (prev[i] > 0){
            for (j = 1; j <= b; j++){
                if (i + a * j <= 1000){
                    now[i + a * j] += prev[i];
                }
            }
        }
    }
    for (j = 1; j <= b; j++){
        now[a * j]++;
    }
}


int main(void)
{
    int m;
    int a, b;
    int g;
    int n;
    int i, j;
    
    while (1){
        scanf("%d", &m);
        if (m == 0){
            break;
        }

        memset(now, 0, sizeof(now));
        memset(prev, 0, sizeof(prev));
        
        for (i = 0; i < m; i++){
            scanf("%d%d", &a, &b);
            dp(a, b);
        }
        
       
        scanf("%d", &g);
        for (i = 0; i < g; i++){
            scanf("%d", &n);
            printf("%d\n", now[n]);
        }
    }
    
    return (0);
}

Measured memory_bytes: 0