akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int dp[1<<21];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    bool a[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin >> a[i][j];
    dp[0]=1;
    for(int i=1;i<(1<<n);i++)
    {
        int d=0;
        for(int j=0;j<n;j++)
            if(i&(1<<j))
                d++;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j)&&a[j][d-1])
                dp[i]=(dp[i]+dp[i^(1<<j)])%mod;
        }
    }
    cout << dp[(1<<n)-1];
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

int main() {
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if (c>=(a-d) && c<=(a+d)) cout<<"Yes";
	else {
		if (b<(a-d) || b>(a+d)) cout<<"No";
		else {
			if (c>=(b-d) && c<=(b+d)) cout<<"Yes";
			else cout<<"No";
		}
	}
	cout<<endl;
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b < c+d)
    cout << "Right" << endl;
  else if(a+b > c+d)
    cout << "Left" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N ;
  ll A; cin >> A;

  N%=500;

  if(N <= A) cout <<"Yes" << endl;
  else cout <<"No" << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let [n,m]=tnn(2),r1=[],r2=[]
  for(let i=0;i<n;i++){
    r1.push([tn(),tn()])
  }
  for(let i=0;i<m;i++){
    r2.push([tn(),tn()])
  }
  for(let i=0;i<n;i++){
    let d=Infinity,a;
    for(let j=m-1;0<=j;j--){
      const m=abs(r1[i][0]-r2[j][0])+abs(r1[i][1]-r2[j][1])
      if(d>=m){
        d=m
        a=j+1
      }
    }
    to(a)
  }

}
main()

Measured memory_bytes: 7500
import java.util.Scanner;
class Main{
	
	
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			//Input
			int W=Integer.parseInt(sc.next());
			int A=Integer.parseInt(sc.next());
			int B=Integer.parseInt(sc.next());
			//calculate
			int X=B-(A+W);
			int Y=A-(B+W);
			int ans;
			if(X>0){
				ans=X;
			}else if(Y>0){
				ans=Y;
			}else{
				ans=0;
			}
			System.out.println(ans);
		
			
			
		}
	}
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  int H[20];
  cin >> N;
  REP(i, N) { cin >> H[i]; }

  int result = 0;
  bool ok = true;
  REP(i, N) {
    ok = true;
    REP(j, i) {
      if (H[j] > H[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ++result;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(dot(a,a));
}

typedef point Vector;
typedef pair<point,point> Line;

point projection(point p,point b){
  return b*dot(p,b)/dot(b,b);
}

point projection(Line l,Vector p){
  point a=l.second-l.first;
  point b=p-l.first;
  return l.first+projection(b,a);
}

int main(void){

  Line l;
  point c;
  int q;
  cin >> l.first.x >> l.first.y >> l.second.x >> l.second.y;
  cin >> q;
  while(q--){
    cin >> c.x >> c.y;
    point res=projection(l,c);
    printf("%.10f %.10f\n",res.x,res.y);
  }

  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


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

	int N;
	cin >> N;
	int cnt = 0;
	int n = N;

	while (n>10) {
		cnt += n % 10;
		n /= 10;
	}
	cnt += n;
	//cout << cnt << " " << N<<endl;
	if (N%cnt==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	char c[h][w];
	for(i=0;i<w+2;i++)	printf("#");
	printf("\n");
	for(i=0;i<h;i++){
		printf("#");
		for(j=0;j<w;j++){
			char c;
			cin>>c;
			printf("%c",c);
		}
		printf("#\n");
	}
	for(i=0;i<w+2;i++)	printf("#");
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

if a == 1:
    if b == 1:
        print(1000000)
    elif b == 2:
        print(500000)
    elif b == 3:
        print(400000)
    else:
        print(300000)
elif a == 2:
    if b == 1:
        print(500000)
    elif b == 2:
        print(400000)
    elif b == 3:
        print(300000)
    else:
        print(200000)
elif a == 3:
    if b == 1:
        print(400000)
    elif b == 2:
        print(300000)
    elif b == 3:
        print(200000)
    else:
        print(100000)
elif a >= 3:
    if b == 1:
        print(300000)
    elif b == 2:
        print(200000)
    elif b == 3:
        print(100000)
    else:
        print(0)

Measured memory_bytes: 8972
#include <stdio.h>

#define RANGE 101

void sort(int a[],int n){
    int i,bucket[RANGE]={0};
    for(i=0;i<n;i++){
        bucket[a[i]]++;
    }
    int target=100;
    for(i=0;i<n;i++){
        while(bucket[target]==0){
            target--;
        }
        a[i]=target;
        bucket[target]--;
    }
}

int main(void){
    int n,i,alice=0;
    scanf("%d",&n);

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

    sort(a,n);
    for(i=0;i<n;i++){
        if(i%2==0){
            alice+=a[i];
        }else{
            alice-=a[i];
        }
    }
    printf("%d\n", alice);
    return 0;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int b[k];
  for(int i = 0; i < k; i++){
    cin >> b[i];
  }
  bitset<18> a[n];
  for(int i = 0; i < n; i++){
    a[i][i] = 1;
  }
  vector<set<int>> v((1 << n));
  for(int x = 1; x < (1 << n); x++){
    bitset<18> b(x);
    bitset<18> e(0);
    for(int i = 0; i < 18; i++){
      if(b[i] == 0) continue;
      if(e == 0){
        e = a[i];
      }else{
        e |= a[i];
      }
    }
    int idx = e.to_ulong();
    for(int i = 0; i < 18; i++){
      if(b[i] == 1){
        v[idx].insert(i);
      }
    }
  }
  map<int, set<int>> m;
  for(int i = 1; i < v.size(); i++){
    bool flag = true;
    for(int j = 0; j < k; j++){
      if(!v[i].count(b[j])){
        flag = false;
        break;
      }
    }
    if(flag){
      m.insert(make_pair(i, v[i]));
    }
  }
  if(k == 0){
    cout << "0:\n";
  }
  auto it = m.begin();
  while(it != m.end()){
    cout << it->first << ":";
    set<int> s = it->second;
    auto i = s.begin();
    while(i != s.end()){
      cout << " " << *i++;
    }
    cout << "\n";
    it++;
  }
  return 0;
}



Measured memory_bytes: 260972
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

X = sorted([a for a in A if a >= 0])
Y = sorted([a for a in A if a < 0], key=lambda x: abs(x))
ans = 1

if 2 * (min(K, len(Y)) // 2) + len(X) >= K:
    if K % 2 == 1:
        ans *= X.pop()
        K -= 1

    XX = [(x1 * x2) for x1, x2 in zip(*[iter(X[::-1])] * 2)]
    YY = [(y1 * y2) for y1, y2 in zip(*[iter(Y[::-1])] * 2)]
    ZZ = sorted(XX + YY)

    for i in range(K // 2):
        ans *= ZZ.pop()
        ans %= MOD

else:
    Z = sorted(X + Y, key=lambda x: abs(x), reverse=True)
    for i in range(K):
        ans *= Z.pop()
        ans %= MOD

print(ans)


Measured memory_bytes: 31824
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
    int i,k; cin >> k >> s;
    if(s.size()<=k){
        cout << s << endl;
    }else{
        for(i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

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

int main() {
  int X,Y;
  cin>>X>>Y;
  int Z;
  Z=(Y-2*X)/2;
 if((Y-2*X)%2==0 && Z>=0 && Z<=X){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3632
# coding: utf-8

import sys

def gcd(a, b):
    while a % b:
        a, b = b, a%b
    return b

def lcm(a, b):
    return a * b / gcd(a, b)

for n in sys.stdin:
    a, b = map(int, n.split())
    a, b = max(a, b), min(a,b)
    print gcd(a, b), lcm(a, b)

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s;
	cin >> s;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			vector<int> res;
			res.push_back(i);
			res.push_back(j);
			for(int k=1;k<N;k++){
				if(s[k]=='o')res.push_back(res[k-1]^res[k]);
				else res.push_back((res[k-1]+1^res[k])%2);
			}
			bool ok = 0;
			if(res[N]==res[0]){
				if(s[0]=='o'){
					if(res[0]==0){
						if(res[1]==res[N-1])ok=1;
					}else{
						if(res[1]!=res[N-1])ok=1;
					}
				}else{
					if(res[0]==0){
						if(res[1]!=res[N-1])ok=1;
					}else{
						if(res[1]==res[N-1])ok=1;
					}
				}
			}
			if(ok){
				for(int a=0;a<N;a++){
					if(res[a]==0)cout << "S";
					else cout << "W";
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1388
#include <stdio.h>

int main(void)
{
	int x;
	int i;

	for (i = 1;1 ; i++)
	{
		scanf("%d", &x);

		if (x == 0)
			break;

		printf("Case %d: %d\n", i, x);

	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[1005],n,a[1005],l[1005],r[1005],id,ans[1005],tail;
int main(){
	scanf("%lld",&n);
	dp[0]=-0x3f3f3f3f;
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]),dp[i]=a[i];
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;++j)
			if((i-j)%2==0&&dp[j]+a[i]>dp[i])
				dp[i]=dp[j]+a[i],l[i]=j;
	for(int i=1;i<=n;++i) if(dp[i]>dp[id]) id=i;
	printf("%lld\n",dp[id]);
	for(int i=n;i>id;--i) ans[++tail]=i;
	while(l[id]!=0){
		int mid=(id+l[id])>>1;
		for(int i=mid;i>l[id];--i) ans[++tail]=i;
		id=l[id];
	}
	for(int i=1;i<id;++i) ans[++tail]=1;
	printf("%lld\n",tail);
	for(int i=1;i<=tail;++i) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = LongArray(n){long()}
    val b = LongArray(n){long()}
    var cnt = 0L
    for (i in n) if (a[i] < b[i]) cnt += (b[i] - a[i]) / 2
    for (i in n) if (a[i] > b[i]) cnt -= a[i] - b[i]
    println((if (cnt < 0) "No" else "Yes"))
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31392
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
using namespace std;
long long S_as_int[200000];
int main(void){
    int N;
    int P;
    cin >> N >> P;
    string S;
    cin >> S;

    
    long long ans = 0;
    if(P == 2){
        for(int i = 0; i < N; i++){
            if((S[i] - '0') % 2 == 0){
                ans += (i + 1);
            }
        }
    } else if(P == 5){
        for(int i = 0; i < N; i++){
            if((S[i] - '0') % 5 == 0){
                ans += (i + 1);
            }
        }
    } else {
        S_as_int[N - 1] = (S[N - 1] - '0') % P;
        long long ten_power = 1;
        for(int i = N - 2; i >= 0; i--){
            ten_power = (ten_power * 10) % P;
            S_as_int[i] = (S_as_int[i + 1] + (ten_power * (long long) (S[i] - '0')) % P) % P;
        }
        map <long long, int> occurences;
        for(int i = 0; i < N; i++){
            if(occurences.find(S_as_int[i]) != occurences.end()){
                occurences[S_as_int[i]] ++;
            } else {
                occurences[S_as_int[i]] = 1;
            }
            long long target;
            if(i != N - 1){
                target = S_as_int[i + 1];
            } else {
                target = 0;
            }
            if(occurences.find(target) != occurences.end()){
                ans += (long long) occurences[target];
            }
        } 
    }
    cout << ans << endl;
    return 0;
}

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

bool solve(vector<vector<char>>hyo){
  bool ans=true;
  for(int i=0;i<hyo.size();i++){
    for(int j=0;j<hyo.at(0).size();j++){
      if(hyo.at(i).at(j)=='#'){
      bool ok=false;
      if(j!=0&&hyo.at(i).at(j-1)=='#')
        ok=true;
      if(j!=hyo.at(0).size()-1&&hyo.at(i).at(j+1)=='#')
        ok=true;
      if(i!=0&&hyo.at(i-1).at(j)=='#')
        ok=true;
      if(i!=hyo.size()-1&&hyo.at(i+1).at(j)=='#')
        ok=true;
      if(!ok)
        ans=false;
      }
    }
  }
  return ans;
}
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>>hyo(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cin >> hyo.at(i).at(j);
  }
  cout << (solve(hyo)?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int  main(){
    long long int  n,y;
    cin>>n>>y;
    bool found=false;
    for(long long int  i=0;i<=n;i++)
    {
        for(long long int  j=0;j<=n-i;j++)
        {
            long long int  rem=y-(10000*i)-(5000*j);
            long long int  r=n-i-j;
            if((rem%1000==0)&&(rem/1000==r)){
                cout<<i<<" "<<j<<" "<<r;
                found=true;
                break;
            }
        }
        if(found)
        break;
    }
    if(!found)
    {
        cout<<"-1 -1 -1\n";
    }
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        long a = scn.nextLong();
        double b = scn.nextDouble();
        double b2 = Math.round(b*100);

        long B = (long)b2;

        long ans = a*B;

        long ans2 = ans/100;

        System.out.println(ans2);

        scn.close();


    }


}

Measured memory_bytes: 28952
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int ans = 0;
    rep(i,5){
        int x;
        cin >> x;
        if(x==0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
n, l = map(int, input().split())
t = list(map(lambda x: l + x, range(n)))
r = sum(t)
dif = 10 ** 100
for i in range(n):
    tmp = sum(t[:i] + t[i + 1:])
    dif_t = abs(r - tmp)
    if dif_t < dif:
        ans = tmp
        dif = dif_t
print(ans)


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

int main(){
	int x, y;
  	cin >> x >> y;
  	string ans = "No";
  
  	rep(i, x+1){
    	int four = (x - i) * 4;
      	int two = i * 2;
      
      	if(four + two == y) ans = "Yes";
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(){
  int a[3],i,h,w,s;

  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(h=0;h<2;h++){

    for(i=2;i>h;i--){

      if(a[i]<a[i-1]){
	w=a[i];
	a[i]=a[i-1];
	a[i-1]=w;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    a=LI()
    L=[]
    S=[0]*(N+1)
    
    for i in range(N):
        S[i+1]=S[i]+a[i]
        
    for i in range(N+1):
        for j in range(i+1,N+1):
            s=S[j]-S[i]
            L.append(s)
            
    x=0
    #答えがxになりうるか
    N2=43
    p=[1]*N2
    for i in range(N2-1):
        p[i+1]=p[i]*2
        
    for i in range(N2):
        temp=x+p[N2-1-i]
        cnt=0
        for a in L:
            if (a&temp)==temp:
                cnt+=1
        if cnt>=K:
            x=temp
            
    print(x)
            

main()


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

int main(){
  int N;
  int F[100][10];
  int P[100][11];
  cin >> N;
  for(int i=0; i<N; i++){
    for(int j=0; j<10; j++){
      cin >> F[i][j];
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<11; j++){
      cin >> P[i][j];
    }
  }
  int result=-1000000000;
  for(int i=1; i<(1<<10); i++){
    int temp=0;
    for(int j=0; j<N; j++){
      int c=0;
      for(int k=0; k<10; k++){
        if(((i&(1<<k))>0)&&(F[j][k]==1)) c++;
      }
      temp+=P[j][c];
    }
    result=max(result,temp);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::fs::File;
use std::io;
use std::io::prelude::*;

const INF: i64 = 1223372036854775807;

macro_rules! input {
    (source = s:expr, $(r:tt)*) => {
        let mut iter = s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $(r)*}
    };
    ($(r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $(r)*}
    };
}

macro_rules! input_inner {
    (next:expr) => {};
    (next:expr, ) => {};

    (next:expr, var:ident : t:tt $(r:tt)*) => {
        let var = read_value!(next, t);
        input_inner!{next $(r)*}
    };
}

macro_rules! read_value {
    (next:expr, ( $(t:tt),* )) => {
        ( $(read_value!(next, t)),* )
    };

    (next:expr, [ t:tt ; len:expr ]) => {
        (0..len).map(|_| read_value!(next, t)).collect::<Vec<_>>()
    };

    (next:expr, chars) => {
        read_value!(next, String).chars().collect::<Vec<char>>()
    };

    (next:expr, usize1) => {
        read_value!(next, usize) - 1
    };

    (next:expr, t:ty) => {
        next().parse::<t>().expect("Parse error")
    };
}

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

/// Equivalent to std::lowerbound and std::upperbound in c++

fn solve() {
    let (n, k) = {
        let s = {
            let mut s = String::new(); // バッファを確保
            std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
            s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
        };

        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let mut n: i64 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に
        let mut k: i64 = ws.next().unwrap().parse().unwrap();
        (n, k)
    };
    let mut res: i64 = 0;
    if(k == 0)
    {
        println!("{:?}", n*n);
        return;
    }
    for i in 1..(n + 1) as i64 {
        //iで割ったときのあまりを考える
        let mut x = max(i - k , 0);
        res += x*(n/i);
        res += max(0,n%i - k + 1);
        // println!("{:?}", res);
    }
    println!("{:?}", res);
}
fn main() {
    solve()
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    REP(i, N) { cout << S[i] << T[i]; }
    cout << endl;
    return 0;
}

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

#define dbg(x) cerr << #x"=" << x << endl;
const int MAX_N = 1e5+100;
vector<int> G[MAX_N];
int N,M;
vector<int> topo;
int in[MAX_N];
int ans[MAX_N];

int main(){
    //freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    int u,v;
    memset(in, 0, sizeof in);
    for(int i = 0; i < N+M-1; ++i){
        cin >> u >> v;
        G[u].push_back(v);
        ++in[v];
    }
    queue<int> que;
    for(int i = 1; i <= N; ++i) {
        if(in[i] == 0){
            ans[i] = 0;
            que.push(i);
        }
    }
    while(!que.empty()){
        u = que.front(); que.pop();
        for(int v : G[u]){
            if(in[v] > 0){
                --in[v];
                if(in[v] == 0) {
                    ans[v] = u;
                    que.push(v);
                }
            }
        }
    }
    for(int i = 1; i <= N; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 7040
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
//const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<0||b<0) return 0;
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

void solve(){
	int n ;
	cin >> n ;
	vector<int> a(n) ;
	forn(i,n) cin >> a[i] ;
	int sm = 0 ;
	forn(i,n) radd(sm,a[i]) ;
	sm = mult(sm,sm) ;
	int t = 0 ;
	forn(i,n) radd(t, mult(a[i],a[i])) ;
	sm = ((sm+MOD-t)%MOD+MOD)%MOD ;
	int ans = (sm * inverse(2LL)) % MOD ;
	cout << ans << endl ;
}


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


Measured memory_bytes: 4776
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

bool prime(int n)
{
  for (int i = 2; i < min(500000,n); ++i)
  {
    if(n%2 == 0)
    {
      return 0;
  }
}
return 1;
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
}
return res;
}
void debug_out(
    vector<string> __attribute__ ((unused)) args,
    __attribute__ ((unused)) int idx,
    __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

// 2+3+5+7+11+13
//   consecutivePrimes = (41) is also a prime

const int  N = 1000 * 10000 + 4;
vector <bool> isPrime(N,true);
vector <int> odd;
void  oddnum()
{
    for (int i = 1; i < N; i+=2 )
    {
        odd.pb(i);
    }
}
bool pall (int n)
{
    string s = to_string(n),r = "";
    r = string(s.rbegin(),s.rend());
    if (s == r)
        return true;
    else
        return false;

}
int main()
{

	// int x = -1, y = 10000;
	// double z = 0.2;
	// string s2 = "beginner1010";
	// long long b = 1LL << 60;B
	// // debug(x, y, z, s, b);
	// double aux = 1010.0;
	// string code = "code";

	// debug(code + "forces",-aux / 10 * 2.3);
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, l;
    cin >> a >> l;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= a; j++) {
            if (4 * i + 2 * j == l && i + j == a) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 4384
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def solve():
    N, A, B, C, D = map(int, raw_input().split()) 
    A, B = 0, B - A
    if B < 0: B *= -1
    M = N - 1

    for i in xrange(0, N, 2):
        if C*(M - i) <= B <= (D - C)*((i + 1)/2) + D*(M - i):
            return True

    for i in xrange(N):
        if C*(M - i) - D*i <= B <= D*(M - i) - C*i:
            return True

    return False

print "YES" if solve() else "NO"



Measured memory_bytes: 4392
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2 else r-c
  a=max(a,b)
 print(a)


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

const int INF = 1 << 30;

using Edge = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;
Graph G;

std::vector<bool> visited;
std::vector<int> X;

void dfs(const int v, bool &res) {
  visited[v] = true;

  for (auto e : G[v]) {
    int nv = e.first;
    int d = e.second;
    if (visited[nv]) {
      if (X[nv] != X[v] + d)
        res = false;
      continue;
    }

    X[nv] = X[v] + d;
    dfs(nv, res);
  }
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M), R(M), D(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    --L[i], --R[i];
  }

  G.resize(N);
  for (int i = 0; i < M; ++i) {
    G[L[i]].push_back(std::make_pair(R[i], D[i]));
    G[R[i]].push_back(std::make_pair(L[i], -D[i]));
  }

  visited.assign(N, false);
  X.assign(N, 0);

  bool res = true;
  for (int v = 0; v < N; ++v) {
    if (visited[v])
      continue;
    dfs(v, res);
  }

  if (res)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

double EPS = 1e-9;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(-p.y, p.x); } // 反時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
istream& operator>>(istream& is, Point& p) { char c; return is >> p.x >> c >> p.y; }

int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;
    if (cross(b, c) > EPS) return +1;      // a,b,cの順に反時計周り
    if (cross(b, c) < -EPS) return -1;     // a,b,cの順に時計周り
    if (dot(b, c) < 0) return +2;          // c--a--b 直線
    if (norm(b) < norm(c)) return -2;      // a--b--c 直線
    return 0;                              // a--c--b 直線
}

/* 与えら れた点集合の凸包をかえす.
 * psは3つ以上の要素を持たねばならない. */
bool operator<(const Point& a, const Point& b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
void convexHull(vector<Point> ps, vector<Point>& ans) {
    sort(ps.begin(), ps.end());
    int N = ps.size();
    int k = 0;
    ans.resize(N * 2);
    for (int i = 0; i < N; ans[k++] = ps[i++])
        while (k >= 2 && ccw(ans[k - 2], ans[k - 1], ps[i]) <= 0) k--;
    for (int i = N - 2, t = k + 1; i >= 0; ans[k++] = ps[i--])
        while (k >= t && ccw(ans[k - 2], ans[k - 1], ps[i]) <= 0) k--;
    /* 返上の点も頂点としたい場合は上4行を
     *     for (int i = 0; i < N; ans[k++] = ps[i++])
     *         while (k >= 2 && ccw(ans[k - 2], ans[k - 1], ps[i]) == -1) k--;
     *     for (int i = N - 2, t = k + 1; i >= 0; ans[k++] = ps[i--])
     *         while (k >= t && ccw(ans[k - 2], ans[k - 1], ps[i]) == -1) k--;
     * にする. */
    ans.resize(k - 1);
}

int main() {
    while (true) {
        int N; cin >> N;
        if (N == 0) break;
        vector<Point> ps(N);
        for (int i = 0; i < N; i++) {
            cin >> ps[i];
        }
        vector<Point> hull;
        convexHull(ps, hull);
        cout << N - hull.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
# -*- coding: utf-8 -*-
# ABC 087 B - Coins
# 整数の入力
a = int(input())
b = int(input())
c = int(input())
x = int(input())
t = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            s = i * 500 + j * 100 + k * 50
            if x == s:
                t = t +1
print(t)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<int> a(n*2),sum(n*2);
    REP(i,n) {
        cin>>a[i];
        a[i+n]=sum[i]=sum[i+n]=a[i];
    }
    REP(i,n*2-1) sum[i+1]+=sum[i];

    int L=sum[n-1];

    int ans=0;
    REP(i,n) {
        int l=0,r=L;
        while(r-l>1) {
            int k=(l+r)/2;
            auto itr1=lower_bound(begin(sum)+i,begin(sum)+i+n,k+(i==0?0:sum[i-1]));
            int p1=*itr1;
            auto itr2=lower_bound(itr1,begin(sum)+i+n,k+p1);
            int p2=*itr2;
            int p3=sum[i+n-1]-p2;
            if(p3>=k) {
                l=k;
                chmax(ans,k);
            } else {
                r=k;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5988
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toLong() }
    if(w == 1L || h == 1L) println(1)
    else if(w%2 == 0L) println(h*w/2) 
    else{
        if(h%2 == 0L) println(w*h/2)
        else println((w*(h-1)/2 + w/2 + 1L))
    }
} 

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

int main()
{
    int N, W, ans;
    long w[105], v[105];
    long dp1[100005], dp2[100005];
    cin >> N >> W;
    REP(i, N)
        cin >> w[i] >> v[i];
    REP(i, 100005)
        if(i == v[0])
            dp1[i] = w[0];
        else
            dp1[i] = 100000000005;
        
    REP(i, N-1){
        REP(j, 100005){
            if(j < v[i+1]){
                dp2[j] = dp1[j];
            }else if(j > v[i+1]){
                dp2[j] = min(dp1[j], dp1[j-v[i+1]] + w[i+1]);
            }else{
                dp2[j] = min(dp1[j], w[i+1]);
            }
        }
        REP(j, 100005)
            dp1[j] = dp2[j];
    }
    REP(i, 100005)
        if(W >= dp1[100004-i]){
            cout << 100004-i << endl;
            break;
        }
    return 0;
}



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

int main() {
    int n;
    cin>>n;
  long long sum=0;
   for(int i=1;i<=n;i++)
   {
     int j=i;
     if(j%3==0 ||j%5==0)
     {
		j=0;
     }
     sum=sum+j;
     //cout<<j<<" ";
   }
  cout<<sum;
	return 0;
}


Measured memory_bytes: 3624
def main():
    K = input()
    AB = input().split()
    A = int(AB[0])
    B = int(AB[1])
    K = int(K)
    count = 0
    for i in range((B // K)+1):
        if K * i >= A:
            print("OK")
            count = 1
            break
    if count == 0:
        print("NG")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
A,V = [int(i) for i in input().split()]
B,W = [int(i) for i in input().split()]
T = int(input())

if A < B:
    if A+V*T >= B+W*T:
        print('YES')
    else:
        print('NO')
else:
    if A-V*T <= B-W*T:
        print('YES')
    else:
        print('NO')


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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;

bool check(string s)
{
   int k = s.size()/2;
   for(int i = 0; i <k; i++)
   {
      if(s[i] != s[i+k])
         return false;
   }
   return true;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   cout << "ABC" << n;
   return 0;
}


Measured memory_bytes: 3644
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
lines = readlines()
edge = np.array([line.split() for line in lines], dtype = np.int64)
edge = sorted(edge,key=lambda x:(x[0],x[1],x[2]))

for i in range(1,M):
  if edge[i][0] == edge[i-1][0] and edge[i][1] == edge[i-1][1]:
    edge[i][2] = 0
#print(edge)
x = np.arange(N,1,-1)
y = np.arange(N-1,0,-1)
z = np.zeros(N-1,int)
X = np.vstack([x,y,z]).T
edge = np.concatenate([X,edge]).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
distance_mat = dijkstra(graph, directed = True, indices = 0)
#print(distance_mat)
print(-1 if distance_mat[-1] == float("inf") else int(distance_mat[-1]))



Measured memory_bytes: 68084
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c, k] <- getIntList
  if a > k then
  	putStrLn $ show k
  else
    if b > (k - a) then
      putStrLn $ show a
    else
      putStrLn $ show (2 * a - k + b)

Measured memory_bytes: 3804
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
template<class T>
int print(T& x){ cout << x << '\n'; return 0;}
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll K, N;
    cin >> N >> K;
    vector<ll> t(N), d(N);
    priority_queue<P> que;
    for (int i = 0; i < N; i++)
    {
        cin >> t[i] >> d[i];
        t[i]--;
        que.push(P(d[i], t[i]));
    }
    ll res = 0, var = 0, sum = 0;
    vector<int> used(N, 0);
    priority_queue<ll, vector<ll>, greater<ll>> amari;
    for (int i = 0; i < K; i++)
    {
        P p = que.top();
        que.pop();
        sum += p.first;
        if (used[p.second])
        {
            amari.push(p.first);
        }
        else
        {
            var++;
            used[p.second] = 1;
        }
    }
    res = sum + var * var;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        if (used[p.second])
            continue;
        if (amari.empty())
            continue;
        sum -= amari.top();
        sum += p.first;
        amari.pop();
        var++;
        used[p.second] = 1;
        res = max(res, sum + var * var);
    }
    cout << res << endl;
}


Measured memory_bytes: 3828
a11,a12,a13=(int(x) for x in input().split())
a21,a22,a23=(int(x) for x in input().split())
a31,a32,a33=(int(x) for x in input().split())
n=int(input())
list=[]
for i in range(n):
	list.append(int(input()))
s=set(list)

def ch(a,b,c,s):
	k=0
	if a in s:
		if b in s:
			if c in s:
				k=1
	return k
co=0
co+=ch(a11,a12,a13,s)
co+=ch(a21,a22,a23,s)
co+=ch(a31,a32,a33,s)
co+=ch(a11,a21,a31,s)
co+=ch(a12,a22,a32,s)
co+=ch(a13,a23,a33,s)
co+=ch(a11,a22,a33,s)
co+=ch(a13,a22,a31,s)
if co>0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
#include <math.h>
# define M_PIl 3.141592653589793238462643383279502884L
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int R = 0;
    cin>>R;
    cout<<M_PIl*2LL*R<<endl;
    return 0;
}



Measured memory_bytes: 3768