akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
string s;
string sw = "SW";
int d[100100];
int cir(int pos){
	return (pos+N)%N;
}
bool check(int pos){
	if(d[pos]==0){
		if(s[pos]=='o'&&d[cir(pos-1)]!=d[cir(pos+1)])return false;
		if(s[pos]=='x'&&d[cir(pos-1)]==d[cir(pos+1)])return false;
	}else{
		if(s[pos]=='o'&&d[cir(pos-1)]==d[cir(pos+1)])return false;
		if(s[pos]=='x'&&d[cir(pos-1)]!=d[cir(pos+1)])return false;
	}
	return true;
}
string solve(int a,int b){
	d[0]=a;
	d[1]=b;
	for(int i=1;i<N-1;i++){
		if(d[i]==0){
			if(s[i]=='o')d[i+1]=d[i-1];
			else d[i+1]=!d[i-1];
		}else{
			if(s[i]=='o')d[i+1]=!d[i-1];
			else d[i+1]=d[i-1];
		}
	}
	if(check(0)&&check(N-1)){
		string res = "";
		for(int i=0;i<N;i++)res+=sw[d[i]];
		return res;
	}else{
		return "-1";
	}
}
int main(){
	cin >> N;
	cin >> s;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			string res = solve(i,j);
			if(res!="-1"){
				cout << res << endl;
				return 0;
			}
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> interval(100005);
    rep(i,n){
        if(a[i] != 0) interval[a[i]-1]++;
        interval[a[i]]++;
        interval[a[i]+1]++;
    }
    ll maxcnt = 0;
    rep(i,100002){
        maxcnt = max(maxcnt, interval[i]);
    }
    cout << maxcnt << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int INF = 1001001001;
int n;

vector<int> to[1005];

vector<int> bfs(int sv) {
    vector<int> dist(n, INF), pre(n, -1);
    queue<int> q;
    dist[sv] = 0;
    q.push(sv);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            pre[u] = v;
            dist[u] = dist[v] + 1;
            q.push(u);
        }
    }

    pair<int, int> best(INF, -1);
    rep(v, n) {
        if (v == sv) continue;
        for (int u : to[v]) {
            if (u == sv) {
                best = min(best, make_pair(dist[v], v));
            }
        }
    }
    if (best.first == INF) return vector<int>(n + 1);
    int v = best.second;
    vector<int> res;
    while (v != -1) {
        res.push_back(v);
        v = pre[v];
    }
    return res;
}

int main() {
    int m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
    }

    vector<int> ans(n + 1);
    rep(s, n) {
        vector<int> now = bfs(s);
        if (now.size() < ans.size()) ans = now;
    }

    if (ans.size() == n + 1) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans.size() << endl;
    for (int v : ans) {
        cout << v + 1 << endl;
    }
}

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

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

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

  sort(h.begin(), h.end());

  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(h[i] < k) continue;
    else cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 3");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("0 1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("32 21");
            //58
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int P = wkArr[1];

        Console.WriteLine((A * 3 + P) / 2);
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<string> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	int ans = 0;
	int mighty = 0;
	int A = 0;
	int B = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 1; j < a[i].size(); j++) {
			if (a[i][j - 1] == 'A' && a[i][j] == 'B'){
				ans ++;
			}
		}
		if (a[i][0] == 'B' && a[i][a[i].size() - 1] == 'A'){
			mighty++;
		}
		else if (a[i][a[i].size() - 1] == 'A')A++;
		else if (a[i][0] == 'B')B++;
	}
	// cout << A << " " << B << " " << mighty << endl;
	int tmp = 0;
	if (mighty != 0){
		ans +=  mighty - 1;
		if (A != 0){
			B++;
		}
		if (B != 0)A++;
	}
	ans += min(A,B);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  for ( int i = 0; i < n; i++ ) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while ( 1 ) {
    minv = INFTY;
    int u = -1;
    for ( int i = 0; i < n; i++ )
      if ( minv > d[i] && color[i] != BLACK ) {
        u = i;
        minv = d[i];
      }
    if ( u == -1 ) break;
    color[u] = BLACK;
    for ( int v = 0; v < n; v++ )
      if ( color[v] != BLACK && M[u][v] != INFTY )
        if ( d[v] > d[u] + M[u][v] ) {
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
  }

  for ( int i = 0; i < n; i++ )
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
}

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ )
      M[i][j] = INFTY;

  int k, c, u, v;
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 3096
#include <complex>
#include <cmath>
#include <stdio.h>
using namespace std;
typedef complex<double> xy_t;
xy_t p[110];
double cross_product(xy_t a,xy_t b)
{
    return (conj(a)*b).imag();
}
int main()
{
    int N=0;
    double x,y;
    while(scanf("%lf,%lf",&x,&y)!=EOF)
    {
        p[N++]=xy_t(x,y);
    }
    
    double sum=0.0;
    for(int i=0;i+2<N;i++)
    {
        xy_t a=p[0],b=p[i+1],c=p[i+2];
        sum+=cross_product(b-a,c-a)/2.0;
    }
    
    printf("%.6f\n",abs(sum));
}

Measured memory_bytes: 2596
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

import heapq
pop = heapq.heappop
push = heapq.heappush
q  = []

for i in A:
  push(q, -1 * i)

for i in range(M):
  t = pop(q)
  push(q, ((t * -1) // 2) * -1)

ans = 0
for i in range(N):
  ans += -1 * pop(q)

print(ans)

Measured memory_bytes: 66840
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[1000], n, m, h, k, r[1000], H1[100000], H2[100000], b[1000]; vector<pair<int, int>>x;
int main() {
	while (true) {
		cin >> n >> m >> h >> k; x.clear(); if (n == 0)break; for (int i = 0; i < n; i++) { cin >> a[i]; r[i] = i; }
		for (int i = 0; i < m; i++) { int p1, p2; cin >> p2 >> p1; p2--; x.push_back(make_pair(p1, p2)); }
		sort(x.begin(), x.end());
		for (int i = 0; i < x.size(); i++) { H1[i] = r[x[i].second]; H2[i] = r[x[i].second + 1]; swap(r[x[i].second], r[x[i].second + 1]); }
		int sum = 0, minx = 0; for (int i = 0; i < n; i++) { if (r[i] < k)sum += a[i]; b[r[i]] = a[i]; }
		for (int i = 0; i < x.size(); i++) { if (H1[i] < k && H2[i] >= k)minx = min(minx, b[H2[i]] - b[H1[i]]); if (H1[i] >= k && H2[i] < k)minx = min(minx, b[H1[i]] - b[H2[i]]); }
		cout << sum + minx << endl;
	}
	return 0;
}

Measured memory_bytes: 4432
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

int main() {
	ll n;
	cin >> n;
	if (n % 2 == 0)
		cout << n / 2 - 1 << endl;
	else
		cout << n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[100010];
priority_queue<int> Q;

signed main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i];
		Q.push(A[i]);
	}
	REP(i,M){
		int p=Q.top();
		Q.pop();
		Q.push(p/2);
	}
	int ans=0;
	while(Q.size()){
		int p=Q.top();
		Q.pop();
		ans+=p;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1912
#include<bits/stdc++.h> 
using namespace std;
//#define int long long
#include<algorithm>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
#define F first
#define S second
#define pb push_back
#define mk make_pair
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define rep(i,a,b) for(int i = a; i<= b; i++)
#define all(c) c.begin(), c.end()
#define ws " "
#define ln "\n"
#define get(x) int x; cin >> x;
#define prt printf("hello world\n")
#define MOD 1e16 + 7;
#define pi atan(1)*4;
int main()
{   
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        int n, m;
        cin >> n >> m;
        int sum = 0, arr[m];
        rep(i,0,m-1){
            cin >> arr[i];
            sum = sum + arr[i];
        }

        if(sum > n){
            cout << -1 << ln;
        }
        else {
            cout << n-sum << ln;
        }
        
       return 0;
}


Measured memory_bytes: 3692
def main():
    """
    1 <= N  <= 10^5
    2 <= M  <= 10^9
    1 <= Ai <= 10^9
    1 <= i  <= N

    1 <= l <= r  <= N
    A_l + A_l+1 + ... + Ar = x * M
    """
    N, M = map(int, input().split())
    *A, = map(int, input().split())

    # ans = f(N, M, A)
    ans = editorial(N, M, A)
    print(ans)


def f(N, M, A):
    """
    直感: 累積和, 10^5^2: TLE
        二分探索?
    """
    b = [0] * N
    b[0] = A[0]
    for i in range(1, N):
        b[i] = b[i-1] + A[i]

    ans = TLE(N, M, A, b)
    return ans


def editorial(N, M, A):
    """
    """
    b = [0] * (N + 1)
    for i in range(N):
        b[i+1] = b[i] + A[i]
    c = [x % M for x in b]

    return binomial_coefficients(c)
    # return loop(c)


def binomial_coefficients(c):
    from collections import Counter

    ans = 0
    for i, n in Counter(c).items():
        ans += n * (n - 1) // 2

    return ans


def loop(c):
    ans = 0
    m = {}
    for x in c:
        if not x in m:
            m[x] = 0
        else:
            ans += m[x]
        m[x] += 1

    return ans


def TLE(N, M, A, b):
    ans = 0
    for l in range(N):
        for r in range(l, N):
            if l - 1 < 0:
                s = b[r]
            else:
                s = b[r] - b[l-1]
            if s % M == 0:
                ans += 1

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 19528
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    int x[10][10];
    rep(i, n) {
        rep(j, d) cin >> x[i][j];
    }
    int ans = 0;
    rep(i, n) {
        REP(j, i + 1, n - 1) {
            int sum = 0;
            rep(k, d) {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            REP(k, 1, 1000) {
                if(k * k == sum) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
"use strict"
function main(arg) {
    var p = arg.trim().split("\n")[0].split(" ").map(Number)
    let A = p[0]
    let B = p[1]
    let C = p[2]
    let D = p[3]
    let ans = 'Yes'
    for (let i = 0; i < 200; i++) {
        if (i % 2 === 0) {
            // t
            C -= B
            if (C <= 0) {
                ans = 'Yes'
                break
            }
        } else {
            // a
            A -= D
            if (A <= 0) {
                ans = 'No'
                break
            }
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29624
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)

typedef long long ll;
using namespace std;

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

int main(){
    ll a,b,c,memo = 0;
    cin >> a >> b >> c;
    memo = gcd(a,b);
    
    cout << (a/memo)*(b/memo)*c << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  ll ans = 0;
  rep(i, N) {
    repp(j, i + 1, N - 1) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 10e18;

signed main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  vector<int> Y(N);
  for( int i = 0; i < N; i++ ) cin >> X.at(i) >> Y.at(i);
  
  if( N == 1 ){
    cout << 1 << endl;
    return 0;
  }
  
  int ans = INF;
  for( int i = 0; i < N; i++ ){ //1つ目
    for( int j = i+1; j < N; j++ ){ //2つ目
      //P,Qを決める
      int P = X.at(j)-X.at(i);
      int Q = Y.at(j)-Y.at(i);
      int now = 0;
      for( int k = 0; k < N; k++ ){
        for( int l = 0; l < N; l++ ){
          if( k == l ) continue;
          int dx = X.at(l)-X.at(k);
          int dy = Y.at(l)-Y.at(k);
          if( P == dx && Q == dy ) now++;
        }
      }
      ans = min(ans, N-now);
    }
  }
  cout << ans << endl;
}


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


int main(){
    int i, N, lcm_num;
    int ans = 0;
    int temp_ans = 0;
    int a[3200];
    cin >> N;
   
    for (i=0; i<N; i++){
        cin >> a[i];
        ans=ans+a[i]-1;
        }

        cout << ans << endl;

    }



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

  int N,a[1000];
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> a[i];
  }

  int min = 2000,max = -1;
  for(int i = 0;i < N;i++){
    if(min >= a[i]) min = a[i];
    if(max <= a[i]) max = a[i];
  }

  cout << max - min << endl;

}


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

using namespace std;

#define N (int)1e5

int n, s, ans, x[N+5], t;

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}

signed main() {
	cin >> n >> s;
	for(int i = 1; i <= n; ++i) cin >> x[i];
	if(n == 1) {
		cout << abs(x[1]-s);
		return 0;
	}
	sort(x, x+n+1);
	t = x[2]-x[1];
	for(int i = 2; i < n; ++i)
		t = gcd(t, x[i+1]-x[i]);
	for(int i = 1; i <= n; ++i)
		ans = max(ans, gcd(abs(s-x[i]), t));
	cout << ans;
	return 0;
}

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

struct node{
	int x,y,t;
}p[500];
int n,m;
int vis[505];
bool cmp(node x,node y){
	x.x<y.x||(x.x==y.x&&x.y<y.y);
}
struct edge{
	int to,next,val;
}e[10000];
const int N = 300;
int h[N],cur[N],dis[N];
int cnt=1,s,t;
queue<int>q;

inline void add(int from,int to,int val){
//	printf("%d-%d\n ",from,to);
	e[++cnt]=(edge){to,h[from],val},h[from]=cnt;
	e[++cnt]=(edge){from,h[to],0},h[to]=cnt;
}

bool bfs(){
	memset(dis,-1,sizeof(dis));
	dis[s]=1;q.push(s);
	while(!q.empty()){
		int j=q.front();
		q.pop();
		for(int i=h[j];i;i=e[i].next){
			int v=e[i].to;
			if(dis[v]<0&&e[i].val){
				dis[v]=dis[j]+1;
				q.push(v);
			}
		}
	}
	return dis[t]>0;
}


int find(int x,int flow){
	if(x==t||flow==0) return flow;
	int a=0,tmp;
	for(int i=h[x];i;i=e[i].next){
		int v=e[i].to;
		if(dis[v]==dis[x]+1&&e[i].val){
			tmp=find(v,min(e[i].val,flow-a));
			e[i].val-=tmp;
			e[i^1].val+=tmp;
			a+=tmp;
			if(a==flow) break;
		}
	}
	if(!a) dis[x]=-1;
	return a;
}

int dinic(){
	int res=0;
	while(bfs()){
		res+=find(s,0x7fffffff);
	}
	return res;
}





int main(){
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y),p[i].t=2;
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i+n].x,&p[i+n].y),p[i+n].t=1;
	//sort(p+1,p+n+1,cmp);
	s=0,t=n*2+1;
	for(int i=1;i<=n*2;i++){
		if(p[i].t==1){
			add(s,i,1);
			for(int j=1;j<=n*2;j++){
				if(p[j].x<p[i].x&&p[j].y<p[i].y&&p[j].t==2) add(i,j,1);
			}
		}
		else add(i,t,1);
	}
	cout<<dinic()<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cassert>
using namespace std;
typedef long long ll;
int N,cnt[110] = {};
ll p[110],q[110],r[110],b[110],dp[110] = {};

ll gcd(ll n,ll m){
    assert(m!=0);
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

void dfs(int n){
    if(n==0){
        dp[0] = 1;
    }else{
        dfs(r[n]); dfs(b[n]);
        assert(dp[r[n]]*p[n]!=0 && dp[b[n]]*q[n]!=0);
        ll g = gcd(dp[r[n]]*p[n],dp[b[n]]*q[n]);
        dp[n] = (dp[r[n]]*p[n])/g*dp[b[n]]+(dp[b[n]]*q[n])/g*dp[r[n]];
    }
}

int main(){
    while(cin >> N && N>0){
        int par;
        for(int i=0;i<=N;i++) cnt[i] = 0;
        for(int i=1;i<=N;i++){
            cin >> p[i] >> q[i] >> r[i] >> b[i];
            cnt[r[i]]++; cnt[b[i]]++;
        }
        for(int i=1;i<=N;i++) if(cnt[i]==0) par = i;
        dfs(par);
        cout << dp[par] << endl;
    }
}


Measured memory_bytes: 2988
S = input()
K = int(input())

for i in range(0, len(S)):
    if S[i] == '1':
        if K == i+1:
            print(S[i])
            break
        elif S[i+1] != '1':
            print(S[i+1])
            break
    else:
        print(S[0])
        break



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3588
#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars, marker::Usize1};

use std::convert::From;
use std::iter;
use std::ops;

const P: u32 = 1000000007;

#[derive(Copy, Clone)]
pub struct Fp(pub u32);

impl Fp {
    pub fn pow(mut self, mut exp: u32) -> Fp {
        let mut res = Fp(1);
        while exp != 0 {
            if exp % 2 != 0 {
                res *= self;
            }
            self *= self;
            exp /= 2;
        }
        res
    }
}

impl From<i64> for Fp {
    fn from(mut x: i64) -> Fp {
        x %= P as i64;
        if x < 0 {
            x += P as i64;
        }
        Fp(x as u32)
    }
}

impl iter::Product for Fp {
    fn product<I>(iter: I) -> Fp
    where
        I: Iterator<Item = Fp>,
    {
        iter.fold(Fp(1), |b, i| b * i)
    }
}

impl iter::Sum for Fp {
    fn sum<I>(iter: I) -> Fp
    where
        I: Iterator<Item = Fp>,
    {
        iter.fold(Fp(0), |b, i| b + i)
    }
}

impl ops::Add<Fp> for Fp {
    type Output = Fp;
    fn add(mut self, rhs: Fp) -> Fp {
        self += rhs;
        self
    }
}

impl ops::AddAssign<Fp> for Fp {
    fn add_assign(&mut self, rhs: Fp) {
        self.0 += rhs.0;
        if self.0 >= P {
            self.0 -= P;
        }
    }
}

impl ops::Mul<Fp> for Fp {
    type Output = Fp;
    fn mul(mut self, rhs: Fp) -> Fp {
        self *= rhs;
        self
    }
}

impl ops::MulAssign<Fp> for Fp {
    fn mul_assign(&mut self, rhs: Fp) {
        self.0 = (self.0 as u64 * rhs.0 as u64 % P as u64) as u32;
    }
}

impl ops::Neg for Fp {
    type Output = Fp;
    fn neg(self) -> Fp {
        Fp(match self.0 {
            0 => 0,
            s => P - s,
        })
    }
}

impl ops::Sub<Fp> for Fp {
    type Output = Fp;
    fn sub(mut self, rhs: Fp) -> Fp {
        self -= rhs;
        self
    }
}

impl ops::SubAssign<Fp> for Fp {
    fn sub_assign(&mut self, rhs: Fp) {
        if self.0 < rhs.0 {
            self.0 += P;
        }
        self.0 -= rhs.0;
    }
}

impl ops::Div<Fp> for Fp {
    type Output = Fp;
    fn div(self, rhs: Fp) -> Fp {
        self * Fp::pow(rhs, P - 2)
    }
}

use std::str::FromStr;

impl FromStr for Fp {
    type Err = <u32 as FromStr>::Err;
    fn from_str(s: &str) -> Result<Fp, <Fp as FromStr>::Err> {
        u32::from_str(s).map(|x| Fp(x))
    }
}

use std::fmt::{Display, Error, Formatter};

impl Display for Fp {
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
        self.0.fmt(f)
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [Fp; n],
    }
    println!(
        "{}",
        (Fp::pow(a.iter().copied().sum(), 2) - a.iter().map(|&a| Fp::pow(a, 2)).sum()) / Fp(2)
    );
}


Measured memory_bytes: 4760
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    answer = 0
    for i in range(1, N):
        if (X[i] - X[i - 1]) * A < B:
            answer += (X[i] - X[i - 1]) * A
        else:
            answer += B
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
/* author   : mpily :-()
title : Competing.cpp
time :Tue Aug 27 14:23:32 2019

*/
#include<bits/stdc++.h>
using namespace std;
bool lt(pair<int,int>a, pair<int,int>b){
	if (a.second != b.second)return a.second < b.second;
}
int main(){
	int N,M;
	cin>>N>>M;
	vector<pair<int,int>>arr(N);
	for(int i = 0; i < N; i++){
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr.begin(),arr.end());
	priority_queue<int> myq;

	long long sum = 0;
	int count = 0;
	int j = 0;
	for(int i = 1 ; i <= M; i++){
		while(j < N && arr[j].first <= i){
			myq.push(arr[j].second);j++;
			//cout<<arr[j-1].second<<" was added to the group \n";
			
		}
		if(myq.size()>0){
		sum+=myq.top();
		myq.pop();}
	}
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 1788
N=int(input())
stock=[N-i for i in range(N)]

"""
if N==2:
    print("Yes")
    print(2)
    print(2,1,2)
    print(2,1,2)
    exit()
"""

N*=2
n=-int(-N**0.5//1)
if N/n==N//n and (n-N//n)==1:
    yoko=N//n
else:
    print("No")
    exit()

ans=[[0 for j in range(yoko)]for i in range(n)]

for i in range(N-1):
    for j in range(i,yoko):
        temp=stock.pop(-1)
        ans[i][j]=temp
        ans[j+1][i]=temp

print("Yes")
print(len(ans))
for item in ans:
    print(len(item), *item)


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

#define ll long long 
using namespace std;
int main(){
    ll a,i,x;
    string s;
    cin>>a;
    cin>>s;
    for(int i =0;i<s.length();i++){
        if(s[i]=='.'){
            s.erase(i,1);
        }
    }
    x=atoi(s.c_str());
    x=x*a/100;
    cout<<x;
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		long ans = Long.MAX_VALUE;
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				ans = Math.min(ans, i + n / i - 2);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
N = int(input())
h_list = list(map(int, input().split()))

dp = [0] * N # DPテーブルの作成
dp[1] = abs(h_list[1] - h_list[0])

if N>= 3:
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]))

print(dp[N-1])

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;
int a[N], b[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    b[i] = a[i];
  }
  sort(b, b+n);
  for (int i = n-1; i > 0; --i) {
    b[i] -= b[i-1];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (!b[i]) continue;
    bool f = true;
    for (int j = 0; j < n; ++j) {
      if (a[j]) {
	a[j] -= b[i];
	f = false;
      } else {
	if (!f)	ans += b[i];
	f = true;
      }
    }
    if (!f) ans += b[i];
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
    int get_Size(int a){
        return s[a];
    }
};
signed main(){
    int n,ans=0;
    cin>>n;
    int a[20],b[20];
    rep(i,n)cin>>a[i];
    rep(i,n){
        cin>>b[i];
        if(a[i]>b[i])ans+=a[i]-b[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int cost,time;
        int minCost = Integer.MAX_VALUE;
        for(int i = 1;i <= n;i++){
            cost = sc.nextInt();
            time = sc.nextInt();
            if(t < time)continue;
            else if(minCost > cost){
                minCost = cost;
            }
        }
        System.out.println(minCost != Integer.MAX_VALUE? minCost:"TLE");
    }
}

Measured memory_bytes: 23892
-- Is it a Right Triangle?
import Data.List -- sortBy
import Data.Ord  -- comparing Down
import Control.Applicative -- <$>, <*>

main = (solve <$> getLine) <*> getContents >>= putStr

solve :: String -> String -> String
solve _ = unlines . map (isRight . sortBy (comparing Down) . map read) . map words . lines

isRight :: [Int] -> String
isRight [a,b,c] | a^2 == b^2 + c^2 = "YES"
                | otherwise        = "NO"

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int H[N],W[N],HHH[N],WWW[N];
bool HH[N],WW[N];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int myh,myw,n;
	cin>>myh>>myw>>n;
	for(int i=1;i<=n;++i){
		int h,w;
		cin>>h>>w;
		HHH[i]=h,WWW[i]=w;
		++H[h],++W[w];
	}
	int tmph=0,tmpw=0;
	for(int i=1;i<=myh;++i){
		if(tmph<H[i]) tmph=H[i];
	}
	for(int i=1;i<=myw;++i){
		if(tmpw<W[i]) tmpw=W[i];
	}
	int cnth=0,cntw=0;
	for(int i=1;i<=myh;++i){
		if(tmph==H[i]){
			HH[i]=1;
			++cnth;
		}
	} 
	for(int i=1;i<=myw;++i){
		if(tmpw==W[i]){
			WW[i]=1;
			++cntw;
		} 
	}
	int cnt=0;
	for(int i=1;i<=n;++i){
		int &r=HHH[i],&l=WWW[i];
		if(HH[r] && WW[l]) ++cnt;
	} 
	if(cntw*cnth==cnt) cout<<tmph+tmpw-1;
	else cout<<tmph+tmpw;
	return 0;
}

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

using namespace std;

void solve() {
  int N;
  cin >> N;
  constexpr auto n2 = 100004;
  vector<bool> not_prime(n2);
  auto limit = sqrt(n2) + 1;
  for (int i = 2; i <= limit; ++i) {
    for (int n = i * 2; n < n2; n += i) {
      not_prime[n] = true;
    }
  }
  for (int i = N; i < n2; ++i) {
    if (!not_prime[i]) {
      cout << i << endl;
      return;
    }
  }
  assert(false);
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
int a[200000];

int main(){
    int n, k, t;
    scanf("%d%d", &n, &t);
    int i;
    int l = 0, r = 0, m;
    for(i = 0; i < n; ++i){
        scanf("%d", &a[i]);
        if(a[i] > r)
            r = a[i];
    }
    sort(a, a + n);
    while(true){
        m = (l + r) >> 1;
        if(m == 0){
            printf("1\n");
            return 0;
        }
        k = t;
        for(i = n - 1; i >= 0; --i)
            if(a[i] <= m)
                break;
            else{
                k -= (a[i] - 1) / m;
                if(k < 0)
                    break;
            }
        if(k >= 0)
            r = m;
        else
            l = m;
        if(r == l + 1){
            printf("%d\n", r);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2484
N = int(input())
A = list(map(int, input().split()))
k = 1
x = y = 0
c = A[0]
for i in A[1:]:
    if c < i:
        x = 1
    elif c > i:
        y = 1
    if x == 1 and y == 1:
        k += 1
        x = y = 0
    c = i
print(k)

Measured memory_bytes: 19988
# -*- coding: utf-8 -*-
n = int(raw_input())
w_arr = map(int, raw_input().split())
w_len = len(w_arr)

w_arr_rev = w_arr[::-1]

w_sum_arr_a = []
for idx_a in range(0, w_len):
  w_temp = w_arr_rev[idx_a]
  w_sum_arr_a.append(w_temp)
  for idx_b in range(0, len(w_sum_arr_a)-1):
    w_sum_arr_a[idx_b] += w_temp
  pass
w_sum_arr_a = w_sum_arr_a[::-1]

sum_all = w_sum_arr_a[-1]
abs_min = -1

for t in range(0, w_len):
  S1 = w_sum_arr_a[t]
  S2 = sum_all - S1
  abs_temp = abs(S2-S1)
  if abs_min < 0:
    abs_min = abs_temp
  else:
    abs_min = min(abs_min, abs_temp)
  pass

print(abs_min)

Measured memory_bytes: 2692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());

		int less = 0;

		for(int i=0; i<m; i++){
			int s = Integer.parseInt(sc.next());
			if (s < x){
				less += 1;
			}else{
				break;
			}
		}
		System.out.println(Math.min(less, m-less));
	}
}

Measured memory_bytes: 22740
from collections import defaultdict
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def S(): return input()
# ----------------------------------------------------------- #

n = I()
s = S()
sa = s[:n]
sb = s[n:][::-1]

A = defaultdict(int)
B = defaultdict(int)

for bit in range(1<<n):
    red_A = []
    red_B = []
    blue_A = []
    blue_B = []
    for i in range(n):
        if bit & 1<<i:
            red_A.append(sa[i])
            blue_B.append(sb[i])
        else:
            blue_A.append(sa[i])
            red_B.append(sb[i])
    a_key = ''.join(red_A) + ',' + ''.join(blue_A)
    b_key = ''.join(blue_B) + ',' + ''.join(red_B)
    A[a_key] += 1
    B[b_key] += 1

ans = 0
for key in A.keys():
    if key in B:
        ans += A[key]*B[key]

print(ans)


Measured memory_bytes: 126556
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, i;
	short a[1000];

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

	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');

	return 0;
}


Measured memory_bytes: 2036
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	used := make(map[string]bool, n)
	ok := true
	var word string
	var last byte

	for i := 0; i < n; i++ {
		sc.Scan()
		word = sc.Text()
		if i == 0 || !used[word] && last == word[0] {
			last = word[len(word)-1]
			used[word] = true
		} else {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
bool check(int n,int m,int x,int y) {return x>=0&&x<n&&y>=0&&y<m;}
 
int a[111][111],d[55][111][111];
map<P,int> ma;
int main() {
  int n,m;
  cin >> m >> n;
  string s[n];
  for(int i=0; i<n; i++) cin >> s[i];
  priority_queue<PP,vector<PP>,greater<PP> > que;
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      a[i][j]=1;
      for(int k=0; k<(1<<5); k++) d[k][i][j]=1<<29;
      if(s[i][j]=='S') {
        d[0][i][j]=0;
        que.push(PP(P(0,0),P(i,j)));
      }
      if(s[i][j]=='M') {
        int k=ma.size();
        ma[P(i,j)]=k;
      }
      for(int k=-2; k<=2; k++) {
        for(int l=-2; l<=2; l++) {
          int x=i+k,y=j+l;
          if(!check(n,m,x,y)||s[x][y]!='#') continue;
          int d=max(abs(i-x),abs(j-y));
          if(d==1) a[i][j]=max(a[i][j],3);
          if(d==2) a[i][j]=max(a[i][j],2);
        }
      }
    }
  }
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int xx=p.second.first,yy=p.second.second,cc=p.first.first,tt=p.first.second;
    if(s[xx][yy]=='G'&&tt==(1<<ma.size())-1) {
      cout << d[tt][xx][yy] << endl;
      return 0;
    }
    if(d[tt][xx][yy]<cc) continue;
    for(int i=0; i<4; i++) {
      int x=xx+dx[i],y=yy+dy[i];
      int t=tt;
      if(!check(n,m,x,y)||s[x][y]=='#') continue;
      if(s[x][y]=='M') t|=1<<ma[P(x,y)];
      if(d[t][x][y]<=d[tt][xx][yy]+a[xx][yy]) continue;
      d[t][x][y]=d[tt][xx][yy]+a[xx][yy];
      que.push(PP(P(d[t][x][y],t),P(x,y)));
    }
  }
  return 0;
}


Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int left = 0;
        int under = 0;
        int width = scan.nextInt();
        int height = scan.nextInt();
        int n = scan.nextInt();
        int x;
        int y;
        int a;
        for (int i = 0; i < n; i++) {
            x = scan.nextInt();
            y = scan.nextInt();
            a = scan.nextInt();
            switch (a) {
                case 1:
                    if (left < x) {
                        left = x;
                    }
                    break;
                case 2:
                    if (width > x) {
                        width = x;
                    }
                    break;
                case 3:
                    if (under < y) {
                        under = y;
                    }
                    break;
                case 4:
                    if (height > y) {
                        height = y;
                    }
                    break;
            }
        }
        if (width < left || height < under) {
            System.out.println(0);
        } else {
            System.out.println((width-left) * (height-under));
        }
    }
}


Measured memory_bytes: 10320
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}



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

using namespace std;

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

    if (a * b % 2 ==0){
      s="Even";
    }
    else{
      s="Odd";
    }

    cout << s << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define range(n) for(int i = 0; i < n; i++)
#define forn(x, n) for(int x = 0; x < n; x++)
#define maxn "100000"
#define mod "1000000007"
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int n, m, a, b, c, k;
ii li[50];
set<ii> s;
int main(){
	sc("%d", &n);
    for(int i = 0; i < n; i++) {
        sc("%d %d", &a, &b);
        li[i] = {a, b};
        s.insert({a, b});
    }
    int cost = n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if (i != j) {
                int dimcost = 0;
                ii prop = {li[i].fi-li[j].fi, li[i].se-li[j].se};
                if (prop.fi == 0 && prop.se == 0) {
                    continue;
                }
                for(int k = 0; k < n; k++) {
                    if (s.count({li[k].fi+prop.fi, li[k].se + prop.se})) {
                        continue;
                    }
                    ii pt = li[k];
                    pt.fi -= prop.fi;
                    pt.se -= prop.se;
                    while(s.count(pt)) {
                        dimcost++;
                        pt.fi -= prop.fi;
                        pt.se -= prop.se;
                    }
                }
                cost = min(cost, n-dimcost);
            }
            
        }
    }
    pr("%d\n", cost);
 	return 0;
}


Measured memory_bytes: 256
#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 gcd(int a,int b){
  int r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
  
int main(){
  int K;
  cin>>K;
  long long int ans=0;
  
  int abgcd;
  
  for(int a=1;a<K+1;a++){
    for(int b=1;b<K+1;b++){
    
      if(a<b){
        abgcd=gcd(b,a);
      }else{
        abgcd=gcd(a,b);
      }
      
      for(int c=1;c<K+1;c++){
        if(abgcd<c){
          ans+=gcd(c,abgcd);
          //printf("%d %d %d %d\n",a,b,c,ans);
        }else{
          ans+=gcd(abgcd,c);
          //printf("%d %d %d %d\n",a,b,c,ans);
        }
      }
    }
  }
 cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {

    fast
	string s,t;
	cin>>s;
	cin>>t;

	int n=s.size();
	int res=0;
	for(int i=0; i<n; i++) {
		if(s[i] != t[i])
			res++;
	}
	cout<<res<<endl;
}


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

int main() {
	int a, b, c, d, n, e ;
	while (cin>>n) {
		e = 0;
		for (a = 0; a<10; a++) {
			for (b = 0; b<10; b++) {
				for (c = 0; c <10; c++) {
					for (d = 0; d <10; d++) {
						if (a + b + c + d == n)e++;
					}
				}
			}
		}
		cout << e << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   ll n,m,d;
   cin>>n>>m>>d;
   ll cnt=2*(n-d);
   if(d==0)cnt=n;
   cout<<fixed<<setprecision(15)<<(long double)cnt*(m-1)*pow(n,-2)<<endl;
   
   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>

using namespace std;

bool isPrime(int x) {
    if (x == 2)
        return (true);
    
    if ( (x < 2) || (x % 2 == 0) )
        return (false);

    int i = 3;
    while (i <= (int)sqrt(double(x))) {
        if (x % i == 0)
            return (false);
        i = i + 2;
    }
    return (true);
}

int main() {
    int n;
    int count = 0;
    
    // 入力数
    cin >> n;
    
    int* a = new int[n];
    
    // 数値入力
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (isPrime(a[i]))
            count++;
    }
    cout << count << '\n';

    delete a;

    return (0);
}


Measured memory_bytes: 3084
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    ll n, k;
    cin >> n >> k;
    if(k == 0){
        ll ans = n * n;
        print(ans);
        return 0;
    }

    ll ans = 0;
    rep(b, k + 1, n + 1){
        ll N = (n + 1) / b;
        ll d = 0;
        d += (b - k) * N;
        ll R = n;
        ll L = k + N * b;
        if(L <= R){
            d += R - L + 1;
        }
        ans += d;
    }
    print(ans);
}

Measured memory_bytes: 256
n = int(input())
d_line = []
for i in range(n):
    a, b = map(int, input().split())
    d_line.append([a, b])
d_line.sort(key = lambda x:-x[1])
time = d_line[0][1] - d_line[0][0]
for i, j in d_line[1:]:
    time = min(time,j)
    if time - i < 0:
        print('No')
        exit()
    time -= i
print('Yes' if time >= 0 else 'No')

Measured memory_bytes: 44312
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll H, W, M;
    cin >> H >> W >> M;

    ll h, w;
    pair<ll, ll> r[H + 1], c[W + 1];
    set<ll> b[H + 1];
    rep(i, H + 1){
        r[i] = make_pair(0, i);
    }
    rep(i, W + 1){
        c[i] = make_pair(0, i);
    }
    rep(i, M){
        cin >> h >> w;
        r[h] = make_pair(r[h].first + 1, h);
        c[w] = make_pair(c[w].first + 1, w);
        b[h].insert(w);
    }
    sort(r, r + H + 1, greater<pair<ll, ll> >());
    sort(c, c + W + 1, greater<pair<ll, ll> >());

    ll maxRowTarget = r[0].first;
    ll maxColTarget = c[0].first;
    ll rp = 0, cp = 0;
    bool foundAns = false;
    ll ans;
    while(r[rp].first == maxRowTarget){
        cp = 0;
        while(c[cp].first == maxColTarget){
            if(b[r[rp].second].find(c[cp].second) == b[r[rp].second].end()){
                ans = maxRowTarget + maxColTarget;
                foundAns = true;
                break;
            }
            cp++;
        }
        if(foundAns){
            break;
        }
        rp++;
    }
    if(!foundAns){
        ans = maxRowTarget + maxColTarget - 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 41124
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A,B,C;

int main(){
    cin>>A>>B>>C;
    out(min(B/A,C));
}


Measured memory_bytes: 256