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

const int N = 4040, inF = N;

int n, r[N], l[N], pmax[N];
int ans = inF;
string a, b;

string shift_R(string s, int l) {
	return s.substr(n - l) + s.substr(0, n - l);
}

string shift_L(string s, int l) {
	return s.substr(l) + s.substr(0, l);
}

int dis(int a, int b) {
	return min(fabs(a - b), n - fabs(a - b));
}

void check(int dex) {
	vector<int> vec;
	for (int i = 0; i < n; i++)
		if(a[i] != b[(i + dex) % n])
			vec.push_back(i);
	vec.push_back(n);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return l[a] < l[b];
	});
	
	int m = vec.size();
	memset(pmax, 0, sizeof pmax);
	for (int i = m - 1; ~i; i--)
		pmax[i] = max(pmax[i + 1], r[vec[i]]);
	for (int i = 0; i < m; i++) {
		int help = l[vec[i]] << 1;
		help += pmax[i + 1] + dis(pmax[i + 1], dex);
		ans = min(ans, help + m - 1);
	}
	ans = min(ans, l[vec.back()] + dis((n - l[vec.back()]) % n, dex) + m - 1);
	
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return r[a] < r[b];
	});
	memset(pmax, 0, sizeof pmax);
	for (int i = m - 1; ~i; i--)
		pmax[i] = max(pmax[i + 1], l[vec[i]]);
	for (int i = 0; i < m; i++) {
		int help = r[vec[i]] << 1;
		help += pmax[i + 1] + dis((n - pmax[i + 1]) % n, dex);
		ans = min(ans, help + m - 1);
	}
	ans = min(ans, r[vec.back()] + dis(r[vec.back()], dex) + m - 1);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a >> b;
	n = a.length();
	r[0] = -1;
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; ~j; j--) {
			if(b[(i + j) % n] == '1')
				r[i] = j;
			if(b[(i - j + n) % n] == '1')
				l[i] = j;
		}
		
		if(shift_L(a, i) == b)
			ans = min(ans, i);
		if(shift_R(a, i) == b)
			ans = min(ans, i);
	}
	if(r[0] == -1) {
		cout << (ans == inF? -1: ans);
		return 0;
	}
	for (int i = 0; i < n; i++)
		check(i);
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 5;
ll pre[N];

int main()
{
	ll n,d,a;
	cin >> n >> d >> a;
	vector< pair<ll, ll> > v;
	for(int i = 1; i <= n; ++i){
		ll x,y;
		cin >> x >> y;
		ll z = (y-1) / a + 1;
		v.push_back({x,z});
	}
	sort(v.begin(),v.end());
	ll ans = 0,sum = 0;
	int r = 1;	//打不到的范围 
	for(int i = 0; i < n; ++i){
		while(r < n && v[r].first <= v[i].first + 2 * d)
			++r;
		sum -= pre[i];	//sum为当前位置已经预先受到的伤害总量 
		v[i].second -= sum;
		if(v[i].second <= 0)
			continue;
		sum += v[i].second;	//累计伤害 
		pre[r] += v[i].second;	//r位置以前受到的伤害总量 
		ans += v[i].second; 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include <intrin.h>

using namespace std;

typedef uint64_t ll;

map<ll, ll> mem;

ll go(ll n, ll a, ll b, ll c, ll d) {
	if (n == 0)
		return 0;
	if (n == 1)
		return d;
	if (mem[n] != 0)
		return mem[n];

	vector<ll> res;

	if (n / 5 > 0)
		res.push_back((n % 5) * d + c + go((n - n % 5) / 5, a, b, c, d));
	if (n % 5 != 0)
		res.push_back((5 - n % 5) * d + c + go((n + (5 - n % 5)) / 5, a, b, c, d));

	if (n / 3 > 0)
		res.push_back((n % 3) * d + b + go((n - n % 3) / 3, a, b, c, d));
	if (n % 3 != 0)
		res.push_back((3 - n % 3) * d + b + go((n + (3 - n % 3)) / 3, a, b, c, d));

	if (n / 2 > 0)
		res.push_back((n % 2) * d + a + go((n - n % 2) / 2, a, b, c, d));
	if (n % 2 != 0)
		res.push_back((2 - n % 2) * d + a + go((n + (2 - n % 2)) / 2, a, b, c, d));

	res.push_back(n * d);

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

	mem[n] = res[0];

	return res[0];
}

inline void solve() {
	mem.clear();
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	cout << go(n, a, b, c, d);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 4484
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		StringTokenizer stk=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(stk.nextToken());
		int b=Integer.parseInt((String)stk.nextElement());
		System.out.println(yakusuu(a,b));
	}
	static int yakusuu(int a,int b){
		if(a<b){int tmp=a;
			a=b;
			b=tmp;}
		while(a%b!=0){			
			int l=a%b;
			a=b;b=l;}
		return b;
	}

}

Measured memory_bytes: 16888
H,W=list(map(int,input().split()))
num=[]
hyouji=[]

while H!=0 or W!=0:
    board=[]
    num.append([H,W])
    for i in range(H):
        gyou=[]
        for j in range(W):
            if i%2==0:
                if j%2==0:
                    gyou.append("#")
                else:
                    gyou.append(".")
            else:
                if j%2==0:
                    gyou.append(".")
                else:
                    gyou.append("#")
        board.append(gyou)
    hyouji.append(board)
    H,W=list(map(int,input().split()))

for i in range(len(num)):
    for j in range(num[i][0]):
        for k in range(num[i][1]):
            print(hyouji[i][j][k],end="")
        print()
    print()



Measured memory_bytes: 7456
import sys
a=sys.stdin.readline()
res=[i for i in a.split()]
A,B,C=[float(res[i]) for i in (0,1,2)]
E,F,G=A.is_integer(),B.is_integer(),C.is_integer()
if E==F==G==True:
    if 1<=B<=A<=20 and 1<=C<=20:
        w=C-A+B
        if w<0:
            print(0)
        else:
            print(int(w))

Measured memory_bytes: 9068
n = int(input())
list = [int(input()) for _ in range(n)]

def main(n, list):
    result = 0
    num = 0
    if list[0] != 0:
        return -1
    
    for i in range(n - 1, - 1, - 1):
        if list[i] >= num:
            result += list[i]
            num = list[i]
        elif list[i] == num - 1:
            num -= 1
        else:
            return -1
    return result

print(main(n, list))

Measured memory_bytes: 11052
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
using namespace std;


int main()
{
    slowanddetermined

    string s;
    cin>>s;

    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll x[100005];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    sort(x,x+n);
    ll ans=0;
    for(int i=1;i<n;i++){
        int mx=min(b,a*(x[i]-x[i-1]));
        ans+=mx;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readInt();
    auto a = readInts().map!("a-1").array;
    int ans;
    foreach(i; iota(n)) {
        if(a[a[i]] == i) { 
            ++ans;
        }
    }
    writeln(ans/2);
}



Measured memory_bytes: 3388
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

int N, M;

int parent[100005];
void init()
{
	for(int i = 1; i <= N; i++){
		parent[i] = i;
	}
}

int root(int i)
{
	if(parent[i] == i) return i;
	return parent[i] = root(parent[i]);
}

bool same(int i, int j)
{
	return root(i) == root(j);
}

void unite(int i, int j)
{
	int root_i = root(i), root_j = root(j);
	if(root_i == root_j) return;
	parent[root_i] = root_j;
}

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2) return ((a % mod) * (pow(a, n-1) % mod)) % mod;
	llint t = pow(a, n/2);
	return ( (t%mod) * (t%mod) ) % mod;
}

int main(void)
{
	while(1){
		cin >> N >> M;
		if(N == 0 && M == 0) break;
		
		init();
		
		int a, b;
		for(int i = 0; i < M; i++){
			cin >> a >> b;
			unite(a, b);
		}
		
		llint X = 0;
		for(int i = 1; i <= N; i++) if(parent[i] == i) X++;
		
		llint ans = pow(2, X);
		if(M) ans++;
		cout << ans % mod << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3472
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {


    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(x); readint(tt);
        int times_ = n/x;
        if (n%x!=0) {times_++;}
        cout << tt * times_ << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();

        if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }


        scn.close();
    }
}



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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int store[n];
	forn(i, n) scanf("%d", &store[i]);
	int total = 0;
	for1(i, n - 2) {
		if(store[i] > store[i + 1] && store[i] < store[i - 1]){
			total++;
		}
		else if(store[i] < store[i + 1] && store[i] > store[i - 1]){
			total++;
		}
	}
	printf("%d", total);






	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0]-0;
    let tmp = 0;
    for(let i=1;i<=1000000;i++){
        tmp *= 10;
        tmp += 7;
        tmp %= N;
        if(tmp === 0){
            console.log(i);
            return;
        }
    }
    console.log(-1);
});

function check(ans){
    
    return true;
}


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

int main() {

	int n, m; cin >> n >> m;
	ll ansAC = 0;
	ll ansWA = 0;
	vector<bool> usedAC(n, false);
	vector<int> cntWA(n, 0);
	for (int i = 0; i < m; i++) {
		int p; string s; cin >> p >> s;
		--p;
		if (s == "AC") {
			if (usedAC[p]) {}
			else {
				usedAC[p] = true;
				ansAC++;
			}
		}
		else { // s == "WA" 
			if (usedAC[p]) {}
			else {
				cntWA[p]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (usedAC[i]) ansWA += cntWA[i];
	}
	cout << ansAC << " " << ansWA << endl;
	return 0;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3584
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class SegmentTree:
        def __init__(self, A, initialize=True, segfunc=min, ident=2000000000):
            self.N = len(A)
            self.LV = (self.N - 1).bit_length()
            self.N0 = 1 << self.LV
            self.segfunc = segfunc
            self.ident = ident
            if initialize:
                self.data = [self.ident] * self.N0 + A + [self.ident] * (self.N0 - self.N)
                for i in range(self.N0 - 1, 0, -1):
                    self.data[i] = segfunc(self.data[i * 2], self.data[i * 2 + 1])
            else:
                self.data = [self.ident] * (self.N0 * 2)

        def update(self, i, x):
            i += self.N0 - 1
            self.data[i] = x
            for _ in range(self.LV):
                i >>= 1
                self.data[i] = self.segfunc(self.data[i * 2], self.data[i * 2 + 1])

        # open interval [l, r)
        def query(self, l, r):
            l += self.N0 - 1
            r += self.N0 - 1
            ret_l = self.ident
            ret_r = self.ident
            while l < r:
                if l & 1:
                    ret_l = self.segfunc(ret_l, self.data[l])
                    l += 1
                if r & 1:
                    ret_r = self.segfunc(self.data[r - 1], ret_r)
                    r -= 1
                l >>= 1
                r >>= 1
            return self.segfunc(ret_l, ret_r)

        # return smallest i(l <= i < r) s.t. check(A[i]) == True
        def binsearch(self, l, r, check):
            if not check(self.query(l, r)):
                return r
            l += self.N0 - 1
            val = self.ident
            while True:
                if check(self.segfunc(val, self.data[l])):
                    break
                if l & 1:
                    val = self.segfunc(val, self.data[l])
                    l += 1
                l >>= 1
            while l < self.N0:
                newval = self.segfunc(val, self.data[l * 2])
                if not check(newval):
                    val = newval
                    l = (l << 1) + 1
                else:
                    l <<= 1
            return l - self.N0 + 1

    def check(val):
        return val >= v

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

    ST = SegmentTree(A, segfunc=max, ident=-2000000000)
    for _ in range(Q):
        t, x, v = map(int, input().split())
        if t == 1:
            ST.update(x, v)
        elif t == 2:
            l = x
            r = v+1
            print(ST.query(l, r))
        else:
            print(ST.binsearch(x, N+1, check))


if __name__ == '__main__':
    main()


Measured memory_bytes: 105768
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

typedef long long ll;
const ll inf = 10000000000000000;
const int mx = 3010;
ll a[mx];
ll dp1[mx][mx];
ll dp2[mx][mx];

ll dfs1(int l, int r);
ll dfs2(int l, int r);

ll dfs1(int l, int r){
    if(l == r)return a[l];
    if(dp1[l][r] > -inf)return dp1[l][r];
    ll res = -inf;
    chmax<ll>(res, dfs2(l, r - 1) + a[r]);
    chmax<ll>(res, dfs2(l + 1, r) + a[l]);
    return dp1[l][r] = res;
}

ll dfs2(int l, int r){
    if(l == r)return -a[l];
    if(dp2[l][r] < inf)return dp2[l][r];
    ll res = inf;
    chmin<ll>(res, dfs1(l, r - 1) - a[r]);
    chmin<ll>(res, dfs1(l + 1, r) - a[l]);
    return dp2[l][r] = res;
}

int main(){
    
    int n; cin >> n;
    rep(i, n)cin >> a[i];

    rep(i, mx)rep(j, mx){
        dp1[i][j] = -inf;
        dp2[i][j] = inf;
    }

    cout << dfs1(0, n - 1) << endl;
    return 0;

}

Measured memory_bytes: 141952
N = int(input())
d = {i+1: 0 for i in range(N)}
for i in range(1, int(N**0.5)):
    for j in range(1, i+1):
        for k in range(1, j+1):
            n = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if n > N:
                continue
            if len(set([i, j, k])) == 1:
                d[n] +=  1
            elif len(set([i, j, k])) == 2:
                d[n] +=  3
            else:
                d[n] +=  6
for i in range(N):
    print(d[i+1])

Measured memory_bytes: 69448
import java.util.*;
public class Main{
public static void main(String gg[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int counter = 0;
        int i = 0;
        while (i < n-2) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C') {
                counter++;
                i++;
            } else {
                i++;
            }
        }
        System.out.println(counter);
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

long long getxor(long long a) {
    int keta = 0;
    long long tmp = a;
    while (tmp > 0) {
        keta++;
        tmp >>= 1;
    }

    long long period = 2;
    long long ans = 0;

    for (int i = 0; i < keta; i++) {
        long long ret = 0;
        if (i == 0) {
            if (a % 4 == 2 || a % 4 == 3)
                ret = 1;
        } else {
            long long t = a % period;
            if (t < period / 2) {
                ret = 0;
            } else if ((t - period / 2) % 2 == 0)
                ret = 0;
            else
                ret = 1;
        }
        ans += ret * period / 2;
        period *= 2;
    }

    return ans;
}
int main() {
    long long a, b;
    cin >> a >> b;

    cout << (getxor(a) ^ getxor(b + 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	int a,b;cin>>a>>b;
	int g=__gcd(a,b);
	int ans=0;
	if(g%2==0){ans++;}while(g%2==0){g/=2;}
	for(int i=3;i<=sqrt(g);i+=2)
	{
		if(g%i==0){ans++;}
		while(g%i==0){g/=i;}
	}
	
	if(g>1)ans++;
	cout<<ans+1;
}

Measured memory_bytes: 3680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

type SliceSort [][]int

func (x SliceSort) Len() int           { return len(x) }
func (x SliceSort) Less(i, j int) bool { return x[i][1] < x[j][1] }
func (x SliceSort) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	_, _ = strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	ab := make([][]int, m)
	for i := 0; i < m; i++ {
		a, _ := strconv.Atoi(Scanner())
		b, _ := strconv.Atoi(Scanner())
		ab[i] = []int{a, b}
	}
	sort.Sort(SliceSort(ab))
	r := 0
	ans := 0
	for i := 0; i < m; i++ {
		if ab[i][0] >= r {
			ans++
			r = ab[i][1]
		}
	}
	fmt.Println(ans)
}


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

int main()
{
    long long N,blue,red;
    cin>>N>>blue>>red;
    long long ans=N/(blue+red)*blue;
    long long temp=N%(blue+red);
    if (temp<blue) ans+=temp;
    else ans+=blue;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize, k: i64,
        a: [i64; n],
        b: [i64; m],
    }

    let mut acum = vec![0; n+1];
    for i in 0..n {
        acum[i+1] = acum[i] + a[i];
    }

    let mut bcum = vec![0; m+1];
    for i in 0..m {
        bcum[i+1] = bcum[i] + b[i];
    }

    let mut ans = 0;
    for i in 0..=n {
        if acum[i] > k {
            break;
        }
        let r = k - acum[i];
        let u = bcum.upper_bound(&r) - 1;
        ans = max(ans, i + u);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1){
			res=res*x%MOD;
		}
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll fact[2000005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

int main(void){
	int k;
	string s;
	fact[0]=1;
	for(int i=1;i<=2000000;i++){
		fact[i]=(ll)fact[i-1]*(i)%MOD;
	}
	scanf("%d",&k);
	cin >> s;
	ll ans=0;
	int n=s.size();
	for(int i=0;i<=k;i++){
		ll val=mod_pow(25,i);
		ll val2=mod_comb(n+i-1,i,MOD);
		ll val3=mod_pow(26,k-i);
		//printf("%d %d\n",n+i,i);
		//printf("%lld %lld %lld\n",val,val2,val3);
		val=val*val2%MOD;
		val=val*val3%MOD;
		ans+=val;
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 20996
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.MinPuro2019 {
    class A {
        static void Main() => CustomMain();

        static void Solve() {
            int n, k;
            ReadMulti(out n, out k);
            if (n % 2 == 1) {
                WriteAnswer(k <= n / 2 + 1 ? "YES" : "NO");
            } else {
                WriteAnswer(k <= n / 2 ? "YES" : "NO");
            }
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());
        static float ReadFloat() => float.Parse(Console.ReadLine());
        static double ReadDouble => double.Parse(Console.ReadLine());
        static string ReadString() => Console.ReadLine();

        static int[] ReadIntArray() => Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(Console.ReadLine().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
        static string[] ReadStringArray() => Console.ReadLine().Split(' ');

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
from sys import stdin
input = stdin.buffer.readline

def main():
    n, m = map(int, input().split())
    ab = [(0, 0)] * n
    for i in range(n):
        ab[i] = tuple(map(int, input().split()))

    ab.sort(key=lambda x: x[0])

    ans = 0
    for a, b in ab:
        if b < m:
            ans += a * b
            m -= b
        else:
            ans += a * m
            print(ans)
            break

main()

Measured memory_bytes: 80260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll A,B;cin>>A>>B;
    cout<<100<<' '<<100<<endl;
    ll ans[100][100];rep(i,0,99)rep(j,0,99)ans[i][j]=0;
    ll a=1;
    ll b=0;
    for(ll i=0;i<=99;i+=2){
        if(a==A)break;
        for(ll j=0;j<=99;j+=2){
            if(a==A)break;
            b=1;
            a++;
            ans[i][j]=0;
            ans[i+1][j]=1;
            ans[i][j+1]=1;
            ans[i+1][j+1]=1;
            if(a==A)break;
        }
        if(a==A)break;
    }
    for(ll i=99;i>=0;i-=2){
        if(b==B)break;
        for(ll j=99;j>=0;j-=2){
            if(b==B)break;
            ans[i][j]=1;
            b++;
            if(b==B)break;
        }
        if(b==B)break;
    }
    rep(i,0,99){
        rep(j,0,99){
            if(ans[i][j]==1){
                cout<<'#';
            }else{
                cout<<'.';
            }
        }
        cout<<endl;
    }
        
    return 0;
}





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

const int MAX = 1400;
int dp[1400][1400], G[1400][1400];

int getLargest(int H, int W)
{
	int maxwidth = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j){
			dp[i][j] = (G[i][j] + 1) % 2;
			maxwidth |= dp[i][j];
		}
	}
	
	for (int i = 1; i < H; ++i)
	{
        for (int j = 1; j < W; ++j)
        {
        	if (G[i][j])dp[i][j] = 0;
        	else {
        		dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        		maxwidth = max(maxwidth, dp[i][j]);
			}
		}
	}
	return maxwidth * maxwidth;
}

int main()
{
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)cin >> G[i][j];
	}
	cout << getLargest(H, W) << endl;
	return 0;
}


Measured memory_bytes: 18400
#include <iostream>

int main() {
  size_t N;

  size_t ans = 0;
  unsigned int prev;
  bool prev_changed = false;

  std::cin >> N;

  for (size_t i=0; i<N; i++) {
    unsigned int a;
    std::cin >> a;

    if (i>0) {
      if (prev_changed) {
        prev_changed = false;
      } else if (prev == a) {
        prev_changed = true;
        ans++;
      }
    }

    prev = a;
  }

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT XS(N);
  VECINT xs_dup(N);
  REP(i,N) {
    cin>>XS[i];
    xs_dup[i] = XS[i];
  }
  sort(ALL(xs_dup));
  int former = xs_dup[N/2-1];
  int latter = xs_dup[N/2];
  REP(i,N) {
    if (XS[i]<=former) {
      OUT(latter);
    } else {
      OUT(former);
    }
  }

  return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

int main(){
  int N;

  scanf("%d",&N);

  if(N <= 111){
    printf("111\n");
    return 0;
  }
  if(N <= 222){
    printf("222\n");
    return 0;
  }
  if(N <= 333){
    printf("333\n");
    return 0;
  }
  if(N <= 444){
    printf("444\n");
    return 0;
  }
  if(N <= 555){
    printf("555\n");
    return 0;
  }
  
  if(N <= 666){
    printf("666\n");
    return 0;
  }
  if(N <= 777){
    printf("777\n");
    return 0;
  }
  if(N <= 888){
    printf("888\n");
    return 0;
  }
  if(N <= 999){
    printf("999\n");
    return 0;
  }
  
  
  
  
}

Measured memory_bytes: 128
import collections

n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]

t.sort()

passenger = 0
departure_limit = t[0] + k
bus_cnt = 0

for T in t:
    if passenger+1 > c or T > departure_limit:
        departure_limit = T+k
        passenger = 1
        bus_cnt += 1
    else:
        passenger+=1

print(bus_cnt+1)

Measured memory_bytes: 7744
// ##MohK
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int a,b,c,d;
	while (1) {
		cin >> a >> b>>c>>d;
		if (a == 0 && b == 0&&c==0&&d==0) break;
		if (a / b >= c) {
			cout << 0 << endl;
			continue;
		}
		else {
			int r = 1;
			while (c > (a + d*r) / b) {
				r++;
			}
			cout <<r << endl;
		}
	}
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define repr(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
template<typename T> constexpr auto square(T x) { return (x)*(x); }

int main()
{
	unsigned long long L, R;
	cin >> L >> R;
	unsigned long long ans = (L*R) % 2019;

	if (R - L >= 673) ans = 0;
	else {
		for (unsigned long long i = L; i < R; i++) {
			for (unsigned long long j = i+1; j < R+1; j++) {
				ans = min(ans, ((i*j) % 2019));
				if (ans == 0) break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
a, b, c, x, y = gets.split.map(&:to_i)

diff = x - y
if diff > 0
  total1 = 2 * c * x
  total2 = 2 * c * y + a * diff
else
  total1 = 2 * c * y
  total2 = 2 * c * x + b * diff.abs
end

total3 = a * x + b * y

puts [total1, total2, total3].min


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}


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

int main()
{

    int n;
    cin >> n;

    int arr[101] = {0};

    for (int i = 0; i < n; i++)
    {

        cin >> arr[i];
    }

    int count = 0;

    for (int i = 0; i < n; i++)
    {

        if ((i + 1) % 2 == 1 && arr[i] % 2 == 1)
        {

            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222




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

  cin >> n;
  ll h, w;
  cin >> h >> w;
  cout << (n + 1 - h)*(n + 1 - w) << endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {
 
	int n;
	cin >> n;
 
	vector<int> a(2*n);
 
	rep(i, n*2) cin >> a[i];

/*
	rep(i, n*2) {
		for(int j = i; j < n*2- 1; j++) {
			if (a[j] > a[j + 1]) {
				int tmp = a[j];
				a[j] = a[j+1];
				a[j+1] = tmp;
			}
		}
	}
*/
	sort(a.begin(), a.end());

	int ans = 0;
/*
	rep(i, n*2)
	cout << endl;
 */
	for(int i = 0; i < n*2; i += 2) {
		ans += a[i];
	}
	 
	cout << ans << endl;
}

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

int main() {
	int H, W, N, T[110][110], a; cin >> H >> W >> N;
	int hn=0, wn=0;
	for(int i=1; i<=N; ++i){
	    cin >> a;
	    for(int j=0; j<a; ++j){
	        if(hn%2<1) T[hn][wn]=i;
	        else T[hn][W-wn-1]=i;
	        if(wn+1<W) ++wn;
	        else{
	            ++hn;
	            wn=0;
	        }
	    }
	}
	for(int i=0; i<H; ++i){
	    for(int j=0; j<W; ++j){
	        cout << T[i][j];
	        if(j+1<W) cout << ' ';
	        else cout << endl;
	    }
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
  int u=31,c,n,a,i;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    c=0;
    while(a%2==0){
      c++;
      a/=2;}
    if(c<u)u=c;}
  cout<<u;
}

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

struct data {
  int x1, x2, y1, y2;
};

bool operator<(const data &l, const data &r) {
  if(l.x1 != r.x1) return l.x1 < r.x1;
  if(l.x2 != r.x2) return l.x2 < r.x2;
  if(l.y1 != r.y1) return l.y1 < r.y1;
  return l.y2 < r.y2;
}

long long m, n;
vector<string> c;
map<char, data> mp;
set<char> st;

long long solve();
bool ch(data now);
bool checkx(int x, int d, int u);
bool checky(int y, int l, int r);

int main() {
  cin >> m >> n;
  c.resize(m);
  for(int i = 0; i < m; ++i) cin >> c[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  int ans = 0;
  for(int i = 0; i < m; ++i)
    for(int j = 0; j < n; ++j)
      if(c[i][j] != '.') {
        if(mp.find(c[i][j]) != mp.end()) {
          mp[c[i][j]].x2 = i;
          mp[c[i][j]].y2 = j;
        }
        else {
          mp[c[i][j]].x1 = i;
          mp[c[i][j]].y1 = j;
        }
      }
  for(int T = 0; T < 30; ++T) {
    for(auto nowmp : mp)
      if(st.find(nowmp.first) == st.end()) {
        data now = nowmp.second;
        if(ch(now)) {
          c[now.x1][now.y1] = c[now.x2][now.y2] = '.';
          ans += 2;
          st.insert(nowmp.first);
        }
      }
  }
  return ans;
}

bool ch(data now) {
  if(now.x1 == now.x2)
    return checkx(now.x1, min(now.y1, now.y2),
                  max(now.y1, now.y2));
  else if(now.y1 == now.y2) {
    return checky(now.y1, min(now.x1, now.x2),
                  max(now.x1, now.x2));
  }
  else {
    if((min(now.y1, now.y2) + 1 == max(now.y1, now.y2) ||
        checkx(now.x1, min(now.y1, now.y2),
               max(now.y1, now.y2))) &&
       (min(now.x1, now.x2) + 1 == max(now.x1, now.x2) ||
        checky(now.y2, min(now.x1, now.x2),
               max(now.x1, now.x2))) &&
       c[now.x1][now.y2] == '.')
      return 1;
    return (min(now.y1, now.y2) + 1 ==
                max(now.y1, now.y2) ||
            checkx(now.x2, min(now.y1, now.y2),
                   max(now.y1, now.y2))) &&
           (min(now.x1, now.x2) + 1 ==
                max(now.x1, now.x2) ||
            checky(now.y1, min(now.x1, now.x2),
                   max(now.x1, now.x2))) &&
           c[now.x2][now.y1] == '.';
  }
}

bool checkx(int x, int d, int u) {
  bool res = 0;
  for(int i = d + 1; i < u; ++i) {
    if(i == d + 1) res = 1;
    if(c[x][i] != '.') res = 0;
  }
  return res;
}
bool checky(int y, int l, int r) {
  bool res = 0;
  for(int i = l + 1; i < r; ++i) {
    if(i == l + 1) res = 1;
    if(c[i][y] != '.') res = 0;
  }
  return res;
}



Measured memory_bytes: 3344
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    if(n == 1)
      System.out.println("Hello World");
    else 
      System.out.println(s.nextInt() + s.nextInt());
  }

}

Measured memory_bytes: 24148
import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall,csgraph_from_dense
from scipy.sparse import csr_matrix
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M,L = inputs()
ABC =[inputs() for _ in range(M)]
graph = [[10**13]*(N+1) for _ in range(N+1)]
for a,b,c in ABC:
    graph[a][b] = c
G = csgraph_from_dense(graph, null_value=10**13)
dist_mat = floyd_warshall(graph,directed=False)
graph2 = np.array([[10**13]*(N+1) for _ in range(N+1)])
np.fill_diagonal(graph2,0)
graph2[dist_mat<=L]=1
dist_mat2 = floyd_warshall(graph2,directed=False)
dist_mat2[dist_mat2==10**13]=0
Q = int(input())
for i in range(Q):
    s,t = inputs()
    print(int(dist_mat2[s,t])-1)



Measured memory_bytes: 25640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}


int main(){
    ll N, W;
    cin >> N >> W;
    ll weight[110] = {0}, value[110] = {0};
    for(int i=0; i<N; ++i)cin >> weight[i] >> value[i];
    vector<vector<ll>> dp(N+1, vector<ll>(100100));
    for(int i=0; i<N+1; ++i)for (int j = 0; j < 100100; ++j) dp[i][j] = INF;

    dp[0][0] = 0;

    for (int i = 0; i < N; i++){
      for (int j = 0; j < 100100; j++){
        if (j >= value[i]) chmin(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
        chmin(dp[i + 1][j], dp[i][j]);
      }
    }
    ll out = 0;
    for (int i = 0; i < 100100; i++){
      if (dp[N][i] <= W) out = i;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 83180
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#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)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};


#define MAX_N 100000

// 隣接リスト
bool used[MAX_N];
vector<int>G[MAX_N];
int h[MAX_N]; // 入次数を管理
int ans[MAX_N];

int main() {
    int N, M; cin >> N >> M;
    vector<int>A,B;
    rep(i,N+M-1){
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        h[b]++;
    }

    stack<int> st;
    // 根を求める
    int root=0;
    for(int i=1; i<=N; i++){
        if(h[i]==0){
            root=i;
        }
    }

    st.push(root);
    while(!st.empty()){
        int i=st.top(); st.pop();
        for(auto& j: G[i]){
            h[j]--;
            if(h[j]==0){
                st.push(j);
                ans[j]=i;
            }
        }
    }

    for(int i=1; i<=N; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n;
  cin >> n;
  int ans=1;
  if(n==1){cout << 1 << endl;
  return 0;}
  for(int i=1;i<10;i++){
    ans*=2;
    if(ans>n){cout << ans/2 << endl;
    return 0;}
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a, b; cin >> a >> b;
	if (a % b == 0)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}
area = []
price = {}
trans = {}
modified_price = []
for i in range(n):
    [a,b] = [i for i in input().split()]
    if a not in area:
        area.append(a)
        dic[a] = [int(b)]
    else:
        dic[a].append(int(b))
    price[int(b)] = i+1
area.sort()
#print(area)
for i in range(len(area)):
    for j in range(len(dic[area[i]])):
        trans[dic[area[i]][j]+(len(area)-i)*1000] = dic[area[i]][j]
        modified_price.append(dic[area[i]][j] + (len(area)-i) * 1000)
modified_price.sort(reverse = True)
for i in range(len(modified_price)):
    print(price[trans[modified_price[i]]])


Measured memory_bytes: 38512
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
	stack<int> st;
	string exps;
    int a, b;

	while( cin>>exps ) {
    	if( "+" == exps ) {
    		b = st.top();
    		st.pop();
    		a = st.top();
    		st.pop();
    		st.push( a + b );
    	} else if( "-" == exps ) {
    		b = st.top();
    		st.pop();
    		a = st.top();
    		st.pop();
    		st.push( a - b );
    	} else if( "*" == exps ) {
    		b = st.top();
    		st.pop();
    		a = st.top();
    		st.pop();
    		st.push( a * b );    		
    	} else {
	   		st.push( atoi( exps.c_str( ) ) );
	   	}
    }
   
    cout<<st.top()<<endl;

    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const double a = 6.28318530717958623200;
int main()
{
   int n,m;
   cin>>n>>m;
   ll sum=0;
   for (int i=0;i<m;i++){
      int b;
      cin>>b;
      sum+=b;
   }
   n-=sum;
   if(n>=0) cout<<n;
   else cout<<-1;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=1010;



signed main(){
    ll cnt=0;
    string s;cin>>s;
    rep(i,s.size())cnt+=s[i]-'0';
    if(cnt%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3748