akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){

	char mark[9];
	int num[9], r_num[9], b_num[9], g_num[9], set, i, j;
	
	scanf("%d", &set);	/* ???????????°?????\??? */
	int ans[set];

	for(i = 0 ; i < 9 ; i++){	/* ????????????????????? */
		r_num[i] = 0;
		g_num[i] = 0;
		b_num[i] = 0;
	}

	for(i = 0 ; i < set ; i++){
		ans[i] = 0;
	}

	for(i = 0 ; i < set ; i++){	/* ???????????°?????°????????? */
		for(j = 0 ; j < 9 ; j++){
			scanf("%d", &num[j]);
		}
			for(j = 0 ; j < 9 ; j++){
				if(j == 9){
					scanf("%c", &mark[j]);
				}
		else{
			scanf(" %c", &mark[j]);
		}
	}

	for(j = 0 ; j < 9 ; j++){		/* ????????¨?????????????????? */
		if(mark[j] == 'R'){
			r_num[j] = num[j];
	}
			else if(mark[j] == 'G'){
				g_num[j] = num[j];
			}
			else if(mark[j] == 'B'){
				b_num[j] = num[j];
			}
		}

	sort(r_num);	/* ??????????????? */
	sort(g_num);	/* ??????????????? */
	sort(b_num);	/* ??????????????? */

		if(judge(r_num) == 1 && judge(g_num) == 1 && judge(b_num) == 1){	/* ???????????? */
			ans[i] = 1;
			}
	else{

		ans[i] = 0;
	}

		for(j = 0 ; j < 9 ; j++){	/* ????????????????????? */
			r_num[j] = 0;
			g_num[j] = 0;
			b_num[j] = 0;
		}
	}

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

void sort(int num[]){

	int p, q, tmp;

	for(p = 0; p < 8; p++){
		for(q = p + 1; q < 9; q++){
			if(num[p] > num[q]){
				tmp = num[p];
				num[p] = num[q];
				num[q] = tmp;
				}
			}
		}   
	}

int judge(int num[]){

	int cnt = 0;
	int i, j, k;

	for(i = 0; i < 9; i++){
		if(num[i] == 0){
			cnt++;			/* ???????????????0?????°??????????????? */
		}
	}
		if(cnt % 3 != 0){		/* 0?????°???3????????°??§???????????°0????????? */
	return 0;
}

	for(i = cnt; i < 9; i++){	/* ???????????¶?????????????????????????????? */
		if(num[i] != 0){
			for(j = cnt; j < 9; j++){
				if(num[j] != 0 && j != i){
					if(num[i] == num[j]){
						for(k = cnt; k < 9; k++){
							if(num[k] != 0 && (k != i && k != j)){
								if(num[i] == num[k]){
									num[i] = 0;
									num[j] = 0;
									num[k] = 0;
								}
							}
						}
					}

					else if(num[j] - num[i] == 1){
						for(k = cnt; k < 9; k++){
							if(num[k] != 0 && (k != i && k != j)){
								if(num[k] - num[j] == 1){
									num[i] = 0;
									num[j] = 0;
									num[k] = 0;
								}
							}
						}
					}
				}
			}
		}
	}
	cnt = 0;
		for(i = 0; i < 9; i++){
			if(num[i] == 0){
				cnt++;
			}
		}
		if(cnt == 9){
			return 1;
		}
		else{
	return 0;
	}
}

Measured memory_bytes: 592
#include <stdio.h>

int main(){
    
    int area;
    int perimeter;
    int a; //length a
    int b; //length b

    scanf("%d %d", &a, &b);

    area = a * b;
    perimeter = 2 * a + 2 * b;

    printf("%d %d\n",area,perimeter);

    return 0;

}

Measured memory_bytes: 1740
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  	
  	int h, w, n;
  	cin >> h >> w >> n;
  	int r, c;
  	cin >> r >> c;
  	string s, t;
  	cin >> s >> t;
  	int l1, r1, u1, d1;
  	int l2, r2, u2, d2;
  	l1 = r1 = u1 = d1 = 0;
  	l2 = r2 = u2 = d2 = 0;
  	for (int i = 0; i < s.size(); i++) {
  		if (s[i] == 'L')
  			l1++;
  		else if (s[i] == 'R')
  			r1++;
  		else if (s[i] == 'U')
  			u1++;
  		else 
  			d1++;

  		if ((d1 > u2 && r + d1 - u2 > h) || (u1 > d2 && r - u1 + d2 <= 0) || (r1 > l2 && c + r1 - l2 > w) || (l1 > r2 && c - l1 + r2 <= 0)) {
  			cout << "NO" << endl;
  			return 0;
  		}

  		if (t[i] == 'L')
  			l2++;
  		else if (t[i] == 'R')
  			r2++;
  		else if (t[i] == 'U')
  			u2++;
  		else
  			d2++;
  		
  		if (r + d2 - u1 > h)
  			d2--;
  		if (r - u2 + d1 <= 0)
  			u2--;
  		if (c + r2 - l1 > w)
  			r2--;
  		if (c - l2 + r1 <= 0)
  			l2--;

  	}
  	cout << "YES" << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
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<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;
    vs s(n+1),t(m+1);
    rep(i,n)cin>>s[i];
    rep(i,m)cin>>t[i];
    vector<vector<mint> > dp(n+10,vector<mint>(m+10,0));
    vector<vector<mint> > sdp(n+10,vector<mint>(m+10,0));
    dp[0][0] = 1;
    sdp[0][0] = 1;
    rep(i,n+1){
        rep(j,m+1){
            if(i == 0 && j == 0)continue;
            if (i-1 >= 0 && j-1 >= 0 && s[i-1] == t[j-1])dp[i+1][j+1] = sdp[i][j] + 1;
            else dp[i+1][j+1] = 0;
            sdp[i+1][j+1] = sdp[i][j+1] + sdp[i+1][j] - sdp[i][j] + dp[i+1][j+1];
        }
    }
    out(sdp[n+1][m+1].x + 1); 
}


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



int main(){

	long long N;
	cin>>N;
	
	long long ans = 0LL;
	
	for(long long i=1;i<N;i++){
		long long ok = 1;
		long long ng = 1000000;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			if(mid*i<N)ok = mid;
			else ng = mid;
		}
		ans += ok;
	}
	
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3640
import collections

list_for_node_count = []

for _ in range(3):
    list_for_node_count.extend(input().split())
    
result_of_node_count = collections.Counter(list_for_node_count)

num_of_node = len(result_of_node_count)
odd_node_count = 0

for x in result_of_node_count.values():
    if int(x)%2 == 1:
        odd_node_count += 1

if odd_node_count == 2 or odd_node_count == 0:
    print('YES')
else:
    print('NO')
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
#define REP(I, N) for (std::decay_t<decltype(N)> I = 0, I##_LEN = (N); I < I##_LEN; ++I)
#define PER(I, N) for (auto I = (N) - 1; 0 <= I; --I)
#define ALLOF(c) begin(c), end(c)
#define MEM0(x) memset((x), 0, sizeof(x))
#define MEMFF(x) memset((x), 0xFF, sizeof(x))
template<class T> const T big_number;
template<> const int big_number<int> = 1 << 30;
template<> const llong big_number<llong> = ((llong) 1) << 60;

void solve() {
    int n, length;
    cin >> n >> length;
    vector<string> ss;
    REP (i, n) {
        string s;
        cin >> s;
        ss.push_back(s);
    }
    // size(s[i]) == length

    sort(ALLOF(ss));

    for (auto&& s : ss) {
        cout << s;
    }
    endl(cout);
}






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



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
dp = [0]*(N+1)
li_A = [0]*(N+1)
for i in range(M):
    li_A[int(input())] = 1

dp[0] = 1
dp[1] = 1
if li_A[1] == 1:
    dp[1] = 0

for i in range(2, N+1):
    if li_A[i-1] == 0:
        dp[i] += dp[i-1]
    if li_A[i-2] == 0:
        dp[i] += dp[i-2]
print(dp[-1]%1000000007)

Measured memory_bytes: 469496
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)

    return divisors
l=make_divisors(N)
if len(l)%2==0:
    A=l[-2]
    B=l[-1]
    a=str(A)
    b=str(B)
    ans=max(len(a),len(b))
else:
    A=l[-1]
    B=l[-1]
    a=str(A)
    ans=len(a)
print(ans)

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

    while(1){
    cin >> n;
    if(n == 0) break;
    int num[10000][2] = {};
    int score[2] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 2; ++j){
            cin >> num[i][j];
        }
        if (num[i][0] > num[i][1])
        {
            score[0] += num[i][0] + num[i][1];
        } else if (num[i][0] == num[i][1])
        {
            score[0] += num[i][0];
            score[1] += num[i][1];
        } else{
            score[1] += num[i][0] + num[i][1];
        }
    }

    cout << score[0] << " " << score[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  uint32_t N;
  int32_t *H;
  cin >> N;

  H = new int32_t[N];

  for (uint32_t i = 0; i < N; ++i) cin >> H[i];

  uint16_t flag = 0;
  int32_t Max = H[0];

  for (uint32_t i = 1; i < N; ++i) {
    if ((H[i] - Max) < -1) {
      flag = 1;
      break;
    }
    if (H[i] > Max) {
      Max = H[i];
    }
  }

  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int x=(n-1)*(n-2)/2;
    if(k>(n-1)*(n-2)/2){cout<<-1<<endl; return 0;}
    vector<P>a;
    for(int i=2; i<=n; ++i)a.push_back(P(1,i));
    for(int i=2; i<=n; ++i)for(int j=i+1; j<=n; ++j){
        if(x==k)break;
        a.push_back(P(i,j));
        x--;
    }
    cout<<a.size()<<endl;
    rep(i,a.size())cout<<a[i].first<<" "<<a[i].second<<endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long double pi = 3.14159265;
const long long mod =1e9+7;


int main(){
    
    int N;
    cin >> N;
    int n1 = N/10;
    int n2 = N%1000;

    if(n1%111==0 || n2%111==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int N, M; cin >> N >> M;
    VVI G(N+1);
    REP(_, M) {
        int A, B; cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    VB visited(N+1,false);
    int cc = 0;
    FOR(i,1,N+1) {
        if (visited[i]) continue;
        cc++;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            if (visited[u]) continue;
            visited[u] = true;
            for (int v : G[u]) {
                if (visited[v]) continue;
                q.push(v);
            }
        }
    }
    int ans = cc - 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8504
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    vector<LL> a(n+1);

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

    LL total = 0;

    for(int i = 1; i < n+1; i++){
        total += a[i];
    }

    
    bool frag = true;

    if(total%((n*(n+1))/2) != 0){
        frag = false;
    }

    total/=(n*(n+1))/2;

    vector<LL> dist;

    for(int i = 1; i < n; i++){
        dist.push_back(a[i+1]-a[i]);
    }
    dist.push_back(a[1]-a[n]);

    for(int i = 0; i < dist.size(); i++){
        dist[i] -= total;
    }


    for(int i = 0; i < dist.size(); i++){
        if(dist[i] > 0 || dist[i]%n != 0){
            frag = false;
        }
    }
    
    cout << (frag?"YES":"NO") << endl;

    return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		List<Integer> nums = new ArrayList<>();
		int t = 1;
		while(t*6<=n) {
			t*=6;
			nums.add(t);
		}
		t = 1;
		while(t*9<=n) {
			t*=9;
			nums.add(t);
		}
		nums.add(1);
		Collections.sort(nums);
		int dp[] = new int[100010];
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0]=0;
		for(int i=1;i<100010;i++) {
			int j = 0;
			while(j<nums.size()&&nums.get(j)<=i) {
				dp[i] = Math.min(dp[i], dp[i-nums.get(j)] + 1);
				j++;
			}
		}
		System.out.println(dp[n]);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 24148
N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))

if N >= M:
    print(0)
    exit()

path_cnt = sorted([X[i + 1] - X[i] for i in range(M - 1)])
if N == 1:
    print(sum(path_cnt))
else:
    print(sum(path_cnt[:-N + 1]))


Measured memory_bytes: 13960
def solve(l):
    if len(l)<2:
        return max(0,l[0])
    m=10**18
    a=0
    for i in range(len(l)):
        if l[i]<1:
            if i+1<len(l):
                a+=solve(l[i+1:])
            else:
                l=l[:i]
            break
        m=min(m,l[i])
    l=l[:i+1]
    for i in range(len(l)):
        l[i]-=m
    return solve(l)+a+m*(m!=10**18)

n=int(input())
*h,=map(int,input().split())
print(solve(h))

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;
int N;
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N][3]; // 最大の幸福度のdp。その日にA,B,Cをしたかどうかで3通り

int solve() {
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    REP(i,1,N) {
        dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
    }
    return max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]);
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,0,N) cin >> a[i] >> b[i] >> c[i];
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(1024);
int n, m, a[N][N];

int main()
{
	n = 1 << read(), m = 1 << read();
	for (int i = 1; i < n; i++)
		for (int j = 1; j < m; j++) a[i][j] = __builtin_popcount(i & j) & 1;
	for (int i = 1; i < n; i++, putchar('\n'))
		for (int j = 1; j < m; j++) putchar('0' + (a[i][j] ^ a[i - 1][j] ^ a[i][j - 1] ^ a[i - 1][j - 1]));
	return 0;
}


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

int main(){
  int i,j,h,w,minh,minw;
  while(1){
    int result;
    int resultmin=100000000;
    
    cin >> h >> w;
    if(h==0 && w==0)break;

    int original = h*h+w*w;
    int original_minh = h;
    int flag = 0;

    for( i = 1;i < 150; i++ ){
      for( j = i+1; j <=150; j++ ){

	result = i*i+j*j;
      	if( result > original && result < resultmin ){
	    resultmin = result;
	    minh=i;
	    minw=j;
	} 
	if( result == original && i > original_minh ){
	  minh=i;
	  minw=j;
	  flag = 1;
	  break;
	}
	
      }
      if( flag == 1 ) break;
    }
    cout << minh << " " << minw << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1164
N,P=map(int,input().split())
S=input()
sn=int(S)

if P==2:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%2==0:
      ans+=N-i+1
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%5==0:
      ans+=N-i+1
  print(ans)
  exit()

amari=[0]*P
amari[0]=1

mod=0
for i in range(1,N+1):
  mod=(mod+int(S[-i])*pow(10,i-1,P))%P
  amari[mod]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)

Measured memory_bytes: 74592
#include<bits/stdc++.h>
using namespace std;
int n,a[100050],ans=0;
bool cmp(int a,int b){return a>b;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)if(i+1>a[i+1])
	{
		for(int j=i+1;a[j]==i;j++)ans^=1;
		ans|=(a[i]-i)&1;
		if(ans)printf("First");
		else printf("Second");
		return 0;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[500001];
int n;
void maxheapify(int i){
    int l=i*2+1,r=i*2+2,mx;
    if(l<n&&a[i]<a[l]) mx=l;
    else mx=i;
    if(r<n&&a[mx]<a[r]) mx=r;
    if(mx!=i){
        swap(a[i],a[mx]);
        maxheapify(mx);
    }
}
int main(){
    cin>>n;
    rep(i,n) cin>>a[i];
    for(int i=(n-1)/2;i>=0;--i){
        maxheapify(i);
    }
    rep(i,n)cout<<" "<<a[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4952
#include<stdio.h>
#define N 100
#include<stdlib.h>


main(){
  
  int top=0;
  int t[N];
  char c[200];
  while(scanf("%s",&c)!=EOF){
    
    if(c[0]=='-'){
      t[top-2] = t[top-2] - t[top-1];
      top--;
    }
    else if(c[0]=='+'){
      t[top-2] = t[top-2] + t[top-1];
      top--;
    }
    else if(c[0]=='*'){
      t[top-2] = t[top-2] * t[top-1];
      top--;
    }
    else{
     
      t[top]=atoi(c);
      top++;
    }
    
  
  }
  printf("%d\n",t[top-1]);
  return 0;
  
}

Measured memory_bytes: 548
W = raw_input().lower()
s = []
ans = 0
while True:
    T = map(str, raw_input().split())
    if(T[0] == "END_OF_TEXT"):
        break
    else:
        for i in range(len(T)):
            if(W == T[i].lower()):
                ans += 1
print(ans)

Measured memory_bytes: 4212
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  int L, R, d;

  scanf("%d%d%d", &L, &R, &d);

  int ans = 0;
  for (int i = L; i <= R; i += 1) {
    if (i % d == 0) {
      ans += 1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N;
  cin >> N;
  for(ll h = 1;h < 3501;h++) {
    for(ll n = h;n < 3501;n++) {
      if(4 * h * n > N * (h + n) && (N*h*n) % (4 * h * n - N * (h + n)) == 0) {
        cout << h << " " << n << " " << (N*h*n) / (4 * h * n - N * (h + n)) << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int n,a[100005],t;
    int ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(i==a[i])
        {
            t=a[i];
            a[i]=a[i+1];
            a[i+1]=t;
            ans++;

        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 4208
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

int main() {

	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	cout << a[n-1] - a[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)(1e9+7)

int main(){
    ll h,w;
    cin >> h >> w;
    char grid[h][w];
    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            cin >> grid[i][j];
        }
    }
    ll dp[h][w];
    memset(dp,-1,sizeof dp);
    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            if(i==0) dp[i][j] = (j)?(dp[i][j-1] & (grid[i][j]=='.')):(grid[i][j] == '.');
            else if(j==0) dp[i][j] = (dp[i-1][j] & (grid[i][j]=='.'));
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1])% mod * (grid[i][j]=='.');
        }
    }
    cout<<dp[h-1][w-1];
}

Measured memory_bytes: 12388
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	double h[4]={0.2,0.6,1.1,30};
	vector<int>r(4);
	vector<int>l(4);
	double a,b;
	while(cin>>a>>b){
		rep(i,4)if(a<h[i]){l[i]++;break;}
		rep(i,4)if(b<h[i]){r[i]++;break;}
	}
	rep(i,4)cout<<l[3-i]<<" "<<r[3-i]<<endl;
}

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

int a[100001],b[100001],c[100001],dp[100001];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	int ax=0;
	long long ans=0;
	for(int i=1;i<=n;i++){
		while(ax<n&&a[ax+1]<b[i]) ax++;
		dp[i]=ax;
	}
	int bx=0;
	long long ans2=0;
	for(int i=1;i<=n;i++){
		while(bx<n&&b[bx+1]<c[i]) bx++,ans2+=(long long)dp[bx];
		ans+=ans2;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
X = int(input())

list = []
for i in range(-119,120):
    list.append(i)
for j in range(len(list)):
    for k in range(len(list)):
        if X == (list[j]) ** 5 - list[k] ** 5:
            A = list[j]
            B = list[k]
            break

print(str(A)+" "+str(B))

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 + 7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll n ;
    cin >> n ;
    ll ans = 0 ;
    for( ll i = 0 ; i < n ; i++){
        ans += (i+1)*(n-i);
    }
    //cout << ans << " " ;
    for( int i = 0 ; i <n-1 ; i++){
        int u , v ;
        cin >> u >> v ;
        if(u>v) swap(u,v);
        ans -= u*(n-v+1);
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}




Measured memory_bytes: 3648
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    char[] s = Console.ReadLine().ToArray();
    int maxCount = 0;
    for (int i = 1; i < N; i++) {
      int count = s.Skip(i).Take(N-1).Distinct().Intersect(s.Take(i).Distinct()).Count();
      maxCount = (count > maxCount) ? count : maxCount;
    }
    Console.WriteLine(maxCount);
  }
}


Measured memory_bytes: 13280
#include <iostream>
#include <vector>

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    int H, W;
    std::cin >> H >> W;
    auto S = Vec<int>(H, W, 0);
    for (auto& s : S) {
        for (auto& c : s) std::cin >> c;
    }

    for (int y = 0; y < W; ++y) {
        for (int x = 0; x < H; ++x) {
            if (S[x][y] == 1) {
                S[x][y] = 0;
            } else {
                S[x][y] = (x > 0 ? S[x - 1][y] : 0) + 1;
            }
        }
    }

    int ans = 0;
    for (auto& h : S) {
        h.push_back(0);

        std::vector<std::pair<int, int>> stack;
        for (int i = 0; i <= W; ++i) {
            int pos = i;
            while (!stack.empty() && stack.back().first > h[i]) {
                auto p = stack.back();
                stack.pop_back();
                ans = std::max(ans, p.first * (i - p.second));
                pos = p.second;
            }
            if (stack.empty() || stack.back().first < h[i]) {
                stack.emplace_back(h[i], pos);
            }
        }
    }

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



Measured memory_bytes: 17108
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

solve :: [Int] -> [Int] -> Int -> Int
solve as bs c | foldr (+) c (zipWith (*) as bs) > 0 = 1
              | otherwise = 0
                  
solveAll :: [[Int]] -> [Int] -> Int -> Int
solveAll ass bs c = foldr (\ as -> (+) (solve as bs c)) 0 ass

main = do
  [n, m, c] <- getIntList
  bs <- getIntList
  ass <- getIntNList n
  print $ solveAll ass bs c

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define inf 0x3f3f3f3fll
#define cases(a, b) for (int a = 1; a <= (b); ++a)
using namespace std;
int h, w;
int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
char e[1005][1005];
struct node {
    int x, y, s;
};
int main() {
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; ++i) {
        scanf("%s", e[i] + 1);
    }
    queue<node> q;
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            if (e[i][j] == '#') q.push({i, j, 0});
    int ans = 0;
    while (!q.empty()) {
        auto cur = q.front();
        q.pop();
        ans = max(ans, cur.s);
        for (int i = 0; i < 4; ++i) {
            int tx = cur.x + dx[i];
            int ty = cur.y + dy[i];
            if (tx >= 1 && tx <= h && ty >= 1 && ty <= w && e[tx][ty] == '.') {
                e[tx][ty] = '#';
                q.push({tx, ty, cur.s + 1});
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define int long long
using namespace std;
void solve();
mt19937 rnd(2007);
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    swap(rng, rnd);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}

void solve() {
    int n; cin >> n;
    vector<string> a(n); forn (i, n) cin >> a[i];
    sort(all(a)); a.resize(unique(all(a)) - a.begin());
    cout << len(a) << endl;
}


Measured memory_bytes: 9576
require 'set'

loop do
  n,h = gets.split.map(&:to_i)
  break if (n|h)==0
  set = Set.new
  h.times do
    s,a,b = gets.split
    1.upto(n) do |i|
      case s
      when "xy"
        set << a+","+b+","+i.to_s
      when "yz"
        set << i.to_s+","+a+","+b
      when "xz"
        set << a+","+i.to_s+","+b
      end
    end
  end
  puts n**3-set.size
end

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

const int mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	vector<vector<ll>> dp(h + 1, vector<ll>(w + 1));
	for(int i = 0; i < h; ++ i) cin >> a[i];
	dp[1][1] = 1;
	for(int i = 1; i <= h; ++ i) {
		for(int j = 1; j <= w; ++ j) {
			if(i == 1 && j == 1) continue;
			if(a[i - 1][j - 1] == '#') continue;
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[h][w] << '\n';
}



Measured memory_bytes: 9216
use proconio::{input, fastout};
// use math::round;
// extern crate math;


#[fastout]
fn main() {
    input!{
        n: i64,
        k: i64
    }

    let x = n%k;
    if x < k-x {
        println!("{}", x);
    } else {
        println!("{}", k-x);
    }
}


Measured memory_bytes: 2156
#include <iomanip>
#include <iostream>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  set<int> st;
  rep(i, N) {
    int a;
    cin >> a;
    if (st.count(a)) {
      cout << "NO" << endl;
      return 0;
    }
    st.emplace(a);
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

i = 1
for p in itertools.permutations([x for x in range(1,N+1)]):
  p = list(p)

  if P == p:
    p_pos = i

  if Q == p:
    q_pos = i
  i += 1
print(abs(p_pos - q_pos))

Measured memory_bytes: 3064
use proconio::input;

#[derive(Debug)]
struct UnionFind {
    // 自身が親ならばその集合に属する頂点数に -1 をかけたもの
    // そうでなければ親のid
    rank: Vec<i32>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            // 各根は最初それぞれ独立なため -1 で初期化される
            rank: vec![-1; n],
        }
    }

    // 根を求める
    fn root(&mut self, x: usize) -> usize {
        if self.rank[x] < 0 { return x }

        let v = self.rank[x] as usize;
        self.rank[x] = self.root(v) as i32;
        self.rank[x] as usize
        // return self.root(self.rank[x] as usize);
    }

    fn unite(&mut self, x: usize, y: usize) -> bool {
        // 各木の根を求める
        let x_root = self.root(x);
        let y_root = self.root(y);
        // 根が一致するならもうすでに数えられているため計算しないfalse
        if x_root == y_root {
            return false;
        }
        // 二つの根を合成する
        // すでに多くの子を持っているものをxとしておく
        // のちにxを根として合成していく
        if self.rank[x_root] > self.rank[y_root] {
            self.rank.swap(x_root, y_root);
        }
        // 各根の保持するノード数を合計してして数を保存
        self.rank[x_root] += self.rank[y_root];
        // yのルートを更新
        self.rank[y_root] = x_root as i32;
        true
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn size(&mut self, x: usize) -> i32 {
        let root = self.root(x);
        -1 * self.rank[root]
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut uf = UnionFind::new(n);
    for pair in ab {
        uf.unite(pair.0 - 1, pair.1 - 1);
    }

    let size = (0..n).map(|i| uf.size(i)).max().unwrap();

    println!("{:?}", size);
}


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

class Program
{
    static void Main(string[] args)
    {
        var n = Console.ReadLine();
        var input = Console.ReadLine().Split(' ')
                .Select(__ => Int32.Parse(__));

        var count = 0;
        for (var i = 1; i <= input.Count(); i++)
        {
            count += input.ElementAt(i-1) == i ? 0 : 1;
        }
        var a = Math.Min(input.ElementAt(0) , input.ElementAt(1));
        var b = Math.Max(input.ElementAt(0) , input.ElementAt(1));

        Console.WriteLine( count == 2 || count == 0 ? "YES":"NO");
    }
}



Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x, y;
	while(1){
		long count=0, tmp;
		cin>>x>>y;
		if(x < y){
			tmp = x, x = y,  y = tmp;
		}
		if(x == 0 && y == 0) break;
		while(1){
			if(y == 0) break;
				
				tmp = x % y;
				x = y;
				y = tmp;
				count++;
		}
		cout<<x<<" "<<count<<endl;
	}
	return 0;
}



Measured memory_bytes: 3044
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
p = list(map(int, input().split()))
q = [0]
for i in range(N):
    q.append(q[-1] + p[i]*(p[i]+1)/(2*p[i]))
print(max([q[i+K]-q[i] for i in range(N-K+1)]))

Measured memory_bytes: 24812
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
import math
import itertools
input = sys.stdin.readline

N, D = map(int, input().split())
P = []
for i in range(N):
    P.append(list(map(int, input().split())))
ans = 0
for c in itertools.combinations(range(N), 2):
    i = c[0]
    j = c[1]
    dis = 0
    for k in range(D):
        dis += (P[j][k] - P[i][k])**2
    if math.sqrt(dis) == int(math.sqrt(dis)):
        ans += 1
print(ans)


Measured memory_bytes: 9140
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

long long gcd(long long a, long long b) {
  while (b) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}

bool solve(long long a, long long b, long long c, long long d) {
  c++; // less than C -> +d
  if (a < b) return false;
  // a >= b
  if (b > d) return false;
  if (c >= b) return true;
  // a >= b && b <= d && c < b
  long long start = ((a - c)) % d;
  start %= gcd(b, d);
  if (start - b < -c) return false;
  return true;
}

int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    bool answer = solve(a, b, c, d);
    if (answer) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}


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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C, X, Y = read_h()

    base_cnt = min(X, Y)
    ans = min(A + B, C * 2) * base_cnt + (X - base_cnt) * min(A, C * 2) + \
        (Y - base_cnt) * min(B, C * 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
  int N, M, K;
  while (cin >> N >> M >> K && N != 0) {
    vector<vector<int> > dp(N, vector<int>(N*M+1, 0));
    for (int j = 1; j <= M; j++) {
      dp[0][j] = 1;
    }
    for (int i = 1; i < N; i++) {
      for (int j = 1; j <= N*M; j++) {
        for (int k = 1; k <= M && j-k >= 0; k++) {
          dp[i][j] += dp[i-1][j-k];
        }
      }
    }

    int n = 0;
    for (int j = 1; j <= N*M; j++) {
      n += dp[N-1][j] * max(1, j-K);
    }
    printf("%.8f\n", double(n)/pow(double(M), double(N)));
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,x;
    int i,j,k,count;
    while(1){
        count=0;
        scanf("%d %d",&n,&x);
        if(n==0&&x==0){
            break;
        }
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                for(k=1;k<=n;k++){
                    if(i!=k&&i!=j&&k!=j){
                        if(i+k+j==x){
                            count++;
                        }
                    }
                }
            }
        }printf("%d\n",count/6);
    }
    
    return 0;
}

Measured memory_bytes: 600
//author : raghav_0901

#include <bits/stdc++.h>
using namespace std; 
#define int long long int

int n;
int arr[3];
signed main()
{
    cin>>n>>arr[0]>>arr[1]>>arr[2];
    vector<string> s(n);
    for(auto &x:s) cin>>x;
    vector<char> ans;
    for(int i=0;i<n;i++)
    {
        int p1=s[i][0]-'A';
        int p2=s[i][1]-'A';
        if(arr[p1]+arr[p2]==0)
        {
            cout<<"No"<<endl;
            return 0;
        }
        else if(arr[p1]==arr[p2] && i+1<n)
        {
            int np1=s[i+1][0]-'A';
            int np2=s[i+1][1]-'A';
            if(np1==p1 || np2==p1)
            {
                ans.push_back(s[i][0]);
                arr[p1]++;arr[p2]--;
            }
            else
            {
                ans.push_back(s[i][1]);
                arr[p1]--;arr[p2]++;
            }
        }
        else if(arr[p1]<arr[p2])
        {
            ans.push_back(s[i][0]);
            arr[p1]++;arr[p2]--;
        }
        else
        {
            ans.push_back(s[i][1]);
            arr[p1]--;arr[p2]++;
        }
    }
    cout<<"Yes"<<endl;
    for(auto x:ans) cout<<x<<'\n';
}


Measured memory_bytes: 6716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    vector<string> v;
    int k;
    cin >> s;
    cin >> k;
    for(int i = 0;i < s.length();i++){
        for(int j = 1;j <= k;j++){
            v.push_back(s.substr(i,j));
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    cout << v[k-1] << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	int idx = -1;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 1) {
			idx = i;
		}
	}

	int ops = 1;
	int curr = k - 1;
	while (curr < idx) {
		++ops;
		curr += k - 1;
	}

	while (curr < n - 1) {
		++ops;
		curr += k - 1;
	}

	cout << ops << "\n";

	return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<char, int> P;
int N;
string s1,s2;
int Decode(string s){
    int tmp=0;
    int ans=0;
    map<char,int> rate;
    rate['m']=1000;
    rate['c']=100;
    rate['x']=10;
    rate['i']=1;
    int scene=0;
    for(int i=0;i<s.length();i++){
        if(isalpha(s[i])){
            if(tmp==i){
                ans+=rate[s[i]];
            }else{
                ans+=rate[s[i]]*stoi(s.substr(tmp,i-tmp));
            }
            tmp=i+1;
        }
    }
    return ans;
}
string Encode(int n){
    string ans;
    int t[4]={1000,100,10,1};
    char c[4]={'m','c','x','i'};
    for(int i=0;i<4;i++){
        int a=n/t[i];
        n%=t[i];
        if(a>=1){
            if(a>=2)ans+=to_string(a);
            ans+=c[i];
        }
    }
    return ans;
}
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>s1>>s2;
        cout<<Encode(Decode(s1)+Decode(s2))<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3232
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long inf = 1e17;
const int mod = 1000000007;
int a[405], b[405];
int rwa[405][405];
int dp[405][405];
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res * a%mod;
		a = a * a%mod;
		x >>= 1;
	}
	return res;
}
signed main() {
	int n, c; cin >> n >> c;
	rep(i, n)cin >> a[i]; rep(i, n)cin >> b[i];
	rep(i, 402) {
		rep(j, 402) {
			rwa[i][j] += modpow(i, j);
			rwa[i][j] %= mod;
			rwa[i + 1][j] += rwa[i][j];
			rwa[i + 1][j] %= mod;
		}
	}
	dp[0][0] = 1;

	rep(i, n) {
		for (int j = 0; j <= c; j++) {
			if (!dp[i][j])continue;
			for (int k = j; k <= c; k++) {
				int d = rwa[b[i]][k - j] - rwa[a[i] - 1][k - j];
				d = (d + mod) % mod;
				dp[i + 1][k] += dp[i][j] * d;
				dp[i + 1][k] %= mod;
			}
		}
	}
	cout << dp[n][c] << endl;
}

Measured memory_bytes: 2816
#include<iostream>
using namespace std;
long long m,n,ans;
int main()
{
    while(cin>>n>>m&&n)
    {
        if(m>=2*n)
        {
            ans=(m-2*n)/4+n;
        }
        else
        {
            ans=m/2;
        }
        cout<<ans<<endl;

    }

}


Measured memory_bytes: 256
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)

Measured memory_bytes: 85220