akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = read!(usize);
    let mut A = read![[i64]];

    for i in 1..N {
        println!("{}", A.iter().map(|&x| x.to_string()).vec().join(" "));
        let key = A[i];

        // Insert A[i] into the sorted seq.
        // Let k = j + 1 for j defined in the given pseudocode.
        let mut k = i;
        while k >= 1 && A[k - 1] > key {
            A[k] = A[k - 1];
            k -= 1;
        }
        assert!(k == 0 || A[k - 1] <= key);
        A[k] = key;
    }

    println!("{}", A.iter().map(|&x| x.to_string()).vec().join(" "));
    return;
}



Measured memory_bytes: 5048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int i=0;
		for(i=0;N!=1;i++){
			if((N&1)==0) N /= 2;
			else N = N*3+1;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct timer {
    std::chrono::system_clock::time_point start, end;

    timer() {
        start = std::chrono::system_clock::now();
    }

    double get() {
        end = std::chrono::system_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    }
};

int D;
int c[26], s[365][26], t[365], last[26], ans[366];

void calc() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 < last[j] ? i + 1 : i + 1 - last[j]);
    }
}

void change(int d, int q) {
    int old = t[d];
    if (old == q)
        return;

    t[d] = q, last[old] = 0, last[q] = 0;
    int dif = 0, pos1 = 0, pos2 = 0;
    for (int i = 0; i < D; ++i) {
        last[t[i]] = i + 1;
        if (i < d)
            pos1 = last[q], pos2 = last[old];
        else {
            ans[i + 1] += s[d][q] - s[d][old];
            if (last[q] == d + 1)
                dif += c[q] * (d + 1 - pos1);
            if (last[old] <= d + 1)
                dif -= c[old] * (d + 1 - pos2);
        }
        ans[i + 1] += dif;
    }
}

void greedy() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = INT_MIN;
        int maidx = 0;
        for (int k = 0; k < 26; ++k) {
            int res = ans[i] + s[i][k], old = last[k];
            last[k] = i + 1;
            for (int j = 0; j < 26; ++j)
                res -= c[j] * (i + 1 - last[j]);

            if (ans[i + 1] < res) {
                ans[i + 1] = res;
                maidx = k;
            }
            last[k] = old;
        }
        t[i] = maidx;
        last[t[i]] = i + 1;
    }
}

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

    cin >> D;
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];

    greedy();
    std::mt19937_64 gen(0);
    std::uniform_int_distribution<> dist1(1, D);
    std::uniform_int_distribution<> dist2(1, 26);

    timer tm;
    while (tm.get() < 1900) {
        stack<pii> stk;
        int pres = ans[D];
        for (int j = 0; j < 100; ++j) {
            int d = dist1(gen), q = dist2(gen);
            d--, q--;
            stk.emplace(pii{d, t[d]});
            change(d, q);
            if (ans[D] >= pres)
                break;
        }
        if (ans[D] < pres) {
            while (!stk.empty()) {
                auto [d, q] = stk.top();
                change(d, q);
                stk.pop();
            }
        }
    }
    for (int i = 0; i < D; ++i)
        cout << t[i] + 1 << '\n';

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    vi dp(k+1, 0), temp(k+1, 0);
    dp[0] = 1;
    rep(i, 1, n+1){
        cin>>A[i];
        temp[0] = dp[0];
        rep(j, 1, k+1){
            temp[j] = temp[j-1]+dp[j];
            if(j>A[i]) temp[j] -= dp[j-A[i]-1];
            temp[j] = temp[j]%inf+inf;
            temp[j]%=inf;
        }
        dp = temp;
    }
    cout<<dp[k];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double a, b, v, w, t, dist;
  cin >> a >> v >> b >> w >> t;
  
  if(a-b >= 0) dist = a-b;
  else dist = b-a;
  
  if(dist <= (v-w)*t) cout << "YES" << endl;
  else cout << "NO" << endl;
  
return 0;
}

Measured memory_bytes: 3724
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools
import fractions

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

def main():
    C = sRaw()
    
    return chr(ord(C)+1)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 66156
#include <stdio.h>
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int n, m, a, x, cost1 = 0, cost2 = 0;
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a);
		if (a < x)
			cost1++;
		else
			cost2++;
	}
	printf("%d\n", min(cost1, cost2));
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void printArray(long[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	static final long MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		byte[] bytes = s.getBytes();
		int LEN = bytes.length;
		long[][] X = new long[LEN][13];

		if (bytes[LEN-1] == '?') {
			for (int i = 0; i <= 9; i++) {
				X[0][i] = 1;
			}
		} else {
			int c = bytes[LEN-1] - '0';
			X[0][c] = 1;
		}
		// System.out.println(LEN);
		// printArray(X[0]);

		int baseMod = 1;
		for (int i = 1; i < LEN; i++) {
			baseMod *= 10;
			baseMod %= 13;
			byte c = bytes[LEN - i - 1];
			if (c == '?') {
				for (int n = 0; n <= 9; n++) {
					int mod = n * baseMod % 13;
					for (int j = 0; j < 13; j++) {
						long v = X[i-1][j];
						X[i][(j + mod) % 13] += v;
						X[i][(j + mod) % 13] %= MOD;
					}
				}
			} else {
				int n = c - '0';
				int mod = n * baseMod % 13;
				for (int j = 0; j < 13; j++) {
					X[i][(j + mod) % 13] = X[i-1][j];
				}
			}
			// printArray(X[i]);
		}

		System.out.println(X[LEN-1][5]);
	}
}


Measured memory_bytes: 38572
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		for(int i = 0; i < 5; i++){
			a[i] = sc.nextInt();
		}
		int min = 999;
		int soe = -1;
		for(int i = 0; i < 5; i++){
			if(a[i]%10 != 0){
				if(min > a[i]%10){
					soe = i;
					min = a[i]%10;
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < 5; i++){
			if(soe == i){
				ans+=a[i];
			}else{
				ans+=(a[i]/10+(a[i]%10==0?0:1))*10;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    ll ans = 0;
    map<int, int> m;
    for (int i = 0; i < n; ++i) {
        ans += m[i-v[i]];
        m[v[i]+i]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 21088
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

#define X first
#define Y second 

int main(){
	for(int N; cin >> N, N;){
		vector<pair<int, int> > tre;
		pair<int, int> cur;
		bool map[21][21];
		for(int i = 0; i < 21; i++)
			for(int j = 0; j < 21; j++)
				map[i][j] = 0;
		for(int i = 0; i < N; i++){
			int x, y; cin >> x >> y;
			tre.push_back(make_pair(x, y));
		}

		int M; cin >> M;
		cur.X = cur.Y = 10;
		map[10][10] = 1;
		for(int i = 0; i < M; i++){
			char op; int I; cin >> op >> I;
			switch(op){
			case 'N' :
				for(int j = 0; j < I; j++){cur.Y++; map[cur.X][cur.Y] = 1;}
			break;

			case 'E' :
				for(int j = 0; j < I; j++){cur.X++; map[cur.X][cur.Y] = 1;}
			break;

			case 'S' :
				for(int j = 0; j < I; j++){cur.Y--; map[cur.X][cur.Y] = 1;}
			break;

			case 'W' :
				for(int j = 0; j < I; j++){cur.X--; map[cur.X][cur.Y] = 1;}
			break;
			}	
		}
		bool res = 1;
		for(int i = 0; i < tre.size(); i++){res *= map[tre[i].X][tre[i].Y];}
		
		res ? cout << "Yes" << endl : cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
N=int(input())
A=[0]*N
B=[0]*N
for i in range(0,N):
    A[i],B[i]=map(int,input().split())
A=[A[i]%B[i] for i in range(0,N)]
count=0
for i in range(0,N):
    count+=(B[N-1-i]-A[N-1-i])%B[N-1-i]
    if N-2-i>=0:
        A[N-2-i]=(A[N-2-i]+count)%B[N-2-i]
print(count)


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

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const int INF = 1000000007;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAX = 100047;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, k, pos;
	cin >> n >> k;
	FOR(i, 1, n + 1)
	{
		int a;
		cin >> a;
		if (a == 1)
			pos = i;
	}
	int ans = 0, len = 1;
	if (pos > 1)
	{
		len = k;
		ans++;
		while (len < pos)
		{
			len += k - 1;
			ans++;
		}
	}
	pos = n + 1 - len;
	if (pos > 1)
	{
		len = k;
		ans++;
		while (len < pos)
		{
			len += k - 1;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(a) begin(a),end(a)
#define INF 999999999
#define debug(x) cerr << #x << ":" << x << '\n'
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int  ui;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int Xi[N+1], Yi[M+1];
	REP(i, N)
		cin >> Xi[i];
	Xi[N] = X;
	REP(i, M)
		cin >> Yi[i];
	Yi[M] = Y;
	sort(Xi, Xi + N + 1);
	sort(Yi, Yi + M + 1);
	if(Xi[N] >= Yi[0]) cout << "War" << '\n';
	else cout << "No War" << '\n';
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    n = n%10;
    if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) {
        cout << "hon" << endl;
    } else if ( n == 0 || n == 1 || n == 6 || n == 8 ) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<P> G[100000];
bool used[100000];
pair<long long, int> data[100000];

long long A[100000];
void dfs2(int x, long long val) {
  if (used[x]) {
    if (val != A[x]) {
      cout << 0 << "\n";
      exit(0);
    }
    return;
  }
  used[x] = true;
  A[x] = val;
  for (P p : G[x]) dfs2(p._1, p._2-val);
}

void solve(long long x) {
  //cout<<"solve("<<x<<")\n";
  rep(i, N) used[i] = false;
  dfs2(0, x);
  bool ok = true;
  rep(i, N) if (A[i] <= 0) ok = false;
  cout << (ok?1:0) << "\n";
  exit(0);
}

// C+x or C-x
void dfs(int x, long long C, int sign) {
  if (used[x]) {
    if (data[x]._2 == sign) {
      if (data[x]._1 != C) {
        cout << 0 << "\n";
        exit(0);
      }
    }
    else {
      // c1+s1*x = c2+s2*x
      // <=> x = (c1-c2)/(s2-s1)
      long long p = C-data[x]._1, q = data[x]._2-sign;
      if ((p%2) != 0) {
        cout << 0 << "\n";
        exit(0);
      }
      solve(p/q);
    }
    return;
  }
  data[x] = make_pair(C, sign);
  used[x] = true;
  for (P p : G[x]) {
    int t = p._1, s = p._2;
    dfs(t, s-C, -sign);
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].pb(P(v, w));
    G[v].pb(P(u, w));
  }
  dfs(0, 0, +1);
  long long lo = 1, hi = 1LL<<60;
  rep(i, N) {
    long long c = data[i]._1, sign = data[i]._2;
    //cout<<"c="<<c<<"+x*"<<sign<<"\n";
    if (sign == -1) hi = min(hi, c-1);
    else lo = max(lo, -c+1);
  }
  cout << max(hi-lo+1, 0LL) << "\n";
  return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

const int MAX_N = 100000;
const int MAX_B = 10000;
int n, m;
multiset<pii> s;
priority_queue<int> Q;

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,n) {
		int a, b;
		cin >> a >> b;
		s.insert(mp(a,b));
	}
	int total = 0;
	auto start = s.begin();
	per(i,0,m) {
		int limit = m - i;
		auto end = s.upper_bound(mp(limit,MAX_B));
		for(auto it = start; it != end; ++it) {
			int b = it->S;
			Q.push(b);
		}
		if(!Q.empty()) {
			total += Q.top();
			Q.pop();
		}
		start = end;
	}
	cout << total << endl;
	return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k = 2019;

    string s;

    cin >> s;

    int n = s.length();
    int r = 0;
    
    vector <int> remainders(k, 0);

    reverse(s.begin(), s.end());

    int t = 1;

    for (int i = 0; i < n; i++)
    {
        int d = s[i] - '0';

        t = t % k;
        r = (r + t*d) % k;
        remainders[r]++;

        // cout << t << " " << d << " " << r << "\n";

        t = (t * 10) % k;
    }
    
    long long int ans = remainders[0];

    for (int r: remainders)
    {
        // cout << i << " " << remainders[i] << "\n";
        ans = ans + ((r * (r-1)) / 2);
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstring>
const int SIZE = 10010;
const int MAX = 0x3f3f3f3f;

typedef struct Road
{
	int from;
	int to;
	int length;
	int cost;
	int next;
} Road;

int head[SIZE];
int dis[SIZE];
Road roads[SIZE * 5];
int front[SIZE];
bool visit[SIZE];

int city, road, capital;

void init()
{
	memset(head, -1, sizeof(head));
	memset(front, -1, sizeof(front));
	memset(visit, false, sizeof(visit));
	for (int i = 0; i <= city; ++i)
	{
		dis[i] = MAX;
	}
	dis[1] = 0;
}

void dijkstra()
{
	while (true)
	{
		int pos = -1;
		for (int i = 1; i <= city; ++i)
		{
			if (!visit[i] && (pos == -1 || dis[pos] > dis[i]))
			{
				pos = i;
			}
		}
		if (pos == -1)
		{
			break;
		}
		visit[pos] = true;
		for (int i = head[pos]; i != -1; i = roads[i].next)
		{
			int to = roads[i].to;
			if (dis[to] > dis[pos] + roads[i].length)
			{
				dis[to] = dis[pos] + roads[i].length;
				front[to] = i;
			}
			else if ((dis[to] == dis[pos] + roads[i].length) && front[to] != -1 && roads[i].cost < roads[front[to]].cost)
			{
				front[to] = i;
			}
		}
	}
}

int main()
{
	while (true)
	{
		std::cin >> city >> road;
		if (city == 0 && road == 0)
		{
			break;
		}
		init();
		int en = 0;
		for (int i = 0; i < road; ++i)
		{
			std::cin >> roads[en].from >> roads[en].to >> roads[en].length >> roads[en].cost;
			roads[en].next = head[roads[en].from];
			head[roads[en].from] = en;
			en++;
			roads[en].from = roads[en - 1].to;
			roads[en].to = roads[en - 1].from;
			roads[en].length = roads[en - 1].length;
			roads[en].cost = roads[en - 1].cost;
			roads[en].next = head[roads[en].from];
			head[roads[en].from] = en;
			en++;
		}
		dijkstra();
		int result = 0;
		for (int i = 1; i <= city; ++i)
		{
			if (front[i] != -1)
			{
				result += roads[front[i]].cost;
			}
		}
		std::cout << result << std::endl;
	}
	return 0;
}

Measured memory_bytes: 2080
#include <algorithm>

class UnionFindTree {
public:
    UnionFindTree(int sz){
        mem = new int[sz*2];
        if(mem == NULL) return;
        par = mem;
        rank = mem + sz;
        for(int i = 0; i < sz; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    ~UnionFindTree(){
        if(mem != NULL) delete [] mem;
    }
    int find(int x){
        if(par[x] != x) par[x] = find(par[x]);
        return par[x];
    }
    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) std::swap(x,y);
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
        return false;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
private:
    int * par, * rank, * mem;
};

#include <cstdio>

int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    UnionFindTree uf(n);
    while(q--){
        int c,x,y;
        scanf("%d%d%d",&c,&x,&y);
        if(c){
            printf("%d\n",uf.same(x,y));
        } else {
            uf.unite(x,y);
        }
    }
}

Measured memory_bytes: 1112
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int w[n];
    for (i = 0; i < n; i++)
    {
        scanf("%d", &w[i]);
        if (i)
        {
            w[i] += w[i - 1];
        }
    }
    int min = 100;
    for (i = 0; i < n; i++)
    {
        if (min >= abs(w[n - 1] - 2 * w[i]))
        {
            min = abs(w[n - 1] - 2 * w[i]);
        }
    }
    printf("%d\n", min);
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        public static int GetInt()
        {
            int a = int.Parse(Console.ReadLine());
            return a;
        }

        public static int[] GetIntArray()
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            return a;
        }

        public static string[] GetStringArray()
        {
            var a = Console.ReadLine().Select(x => x.ToString()).ToArray();
            return a;
        }

        static void Main(string[] args)
        {
            var S = GetStringArray();
            string ans = "Yes";
            for(int i = 0; i < S.Length; i++)
            {
                if(i % 2 == 0 && (S[i] != "R" && S[i] != "U" && S[i] != "D"))
                {
                    ans = "No";
                }
                if(i % 2 != 0 && (S[i] != "L" && S[i] != "U" && S[i] != "D"))
                {
                    ans = "No";
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b +50*c ==X:
        counter +=1
print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int a[4][4];
	 for(int i=1;i<=3;i++)
	 	for(int j=1;j<=3;j++)
	 		cin>>a[i][j];
	 int n;
	 cin>>n;
	 set<int>s;
	 for(int i=0;i<n;i++)
	 {
	 	   int x;
	 	   cin>>x;
	 	   s.insert(x);
	 }
	 for(int i=1;i<=3;i++)
	 {
	 	    bool ok=true;
	 	    for(int j=1;j<=3;j++)
	 	    	ok&=s.find(a[i][j])!=s.end();
	 	    if(ok)
	 	    {
	 	    	 cout<<"Yes"<<endl;
	 	    	 return 0;
	 	    }
	 	    ok=true;
	 	    for(int j=1;j<=3;j++)
	 	    	ok&=s.find(a[j][i])!=s.end();
	 	    if(ok)
	 	    {
	 	    	 cout<<"Yes"<<endl;
	 	    	 return 0;	 	    }

	 }
	 bool ok=true;
	 for(int i=1;i<=3;i++)
	 {
          ok&=s.find(a[i][i])!=s.end();
	 }
	 if(ok)
	 {
	 	  cout<<"Yes\n";
	 	  return 0;
	 }
	 ok=true;
	 for(int i=1;i<=3;i++)
	 	ok&=s.find(a[i][4-i])!=s.end();
	 if(ok)
	 {
	 	  cout<<"Yes\n";
	 	  return 0;
	 }
	 cout<<"No\n";
	 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll a,b,c;
    cin >> a >> b >> c;
    int n = 0;
    while(n <= 1000000){
        if((a&1) || (b&1) || (c&1)){
            pr(n);
            return 0;
        }
        ll ta = a;
        ll tb = b;
        ll tc = c;
        a = tb/2 + tc/2;
        b = ta/2 + tc/2;
        c = tb/2 + ta/2;

        n++;
    }
    pr(-1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  string t;
  cin>>s;
  cin>>t;
  int count=0;
  for(int i=0;i<s.length();i++)
  {
  	if(s[i]==t[i])
  	continue;
  	else
  	count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3920
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);

      String st1 = scan.next();
      String st2 = scan.next();
      String st3 = scan.next();



      System.out.print(st1.charAt(0));
      System.out.print(st2.charAt(1));
      System.out.print(st3.charAt(2));
   }
}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		String[] S = new String[N];


		//WK変数
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;

		//演算
		for (int i = 0; i < N; i++) {
			S[i] = scan.next();
			if (S[i].equals("AC")) {
				AC++;
			} else if (S[i].equals("WA")) {
				WA++;
			} else if (S[i].equals("TLE")) {
				TLE++;
			} else if (S[i].equals("RE")) {
				RE++;
			}
		}

		//結果出力
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}
}

Measured memory_bytes: 64200
#include <stdio.h>
#include <stdlib.h>

#define M 500000
#define END NULL

struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

typedef struct node *nodepointer;

nodepointer root;

void insert(int sample){
  nodepointer y,x,z;
  
  y = END;
  x = root;

  z = malloc(sizeof(struct node));
  z -> key = sample;
  z -> left = z -> right = END;

  while(x != END){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == END) root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;
}



/* int find(nodepointer n,int sample2){  2. WA  error

  if(n == END)return 0;
  
  while(n->key != sample2){
    if(n->key == sample2)return 1;
    return find(n->left,sample2) || find(n->right,sample2);
  }

 
  }*/


/* int find(nodepointer n,int sample2){  5. TLE error

  if(n == END)return 0;
  if(n->key == sample2)return 1;
  
  while(n->key != sample2){
    return find(n->left,sample2) || find(n->right,sample2);
  }

 
  }*/


int  find(nodepointer n,int sample2){ //correction
 
   while (n != END && n->key != sample2 ){
      if (sample2 < n->key) n = n->left;
      else n = n->right;   
    }
  
  if(n != END) return 1;
  return 0;
   
}


void in(nodepointer n){
  if(n != END){
    in(n->left);
    printf(" %d",n->key);
    in(n->right);
  }
}

void pre(nodepointer n){
  if(n != END){
    printf(" %d",n->key);
    pre(n->left);
    pre(n->right);
  }
}
   
int main(){
  int command,thing,i;
  char direct[7];

  scanf("%d",&command);
  
  for(i=0;i<command;i++){
    scanf("%s",direct);
    
    if(direct[0] == 'i'){
      
      scanf("%d",&thing);
      insert(thing);
      
    }else if(direct[0] == 'f') {

      scanf("%d",&thing);
      if (find(root,thing)) printf("yes\n");
      else printf("no\n");
      
    }else if(direct[0] == 'p'){
        in(root);
	printf("\n");
	pre(root);
	printf("\n");
    }
  }
  return 0;
}
      
      
  



Measured memory_bytes: 20556
from collections import deque

N, M = map(int, input().split())

G = [[] for _ in range(N)]
for i in range(M):
  L, R, D = map(int, input().split())
  G[L-1].append((R-1, D))
  G[R-1].append((L-1, -D))
  
visited = [False] * N
xs = [0] * N
xs[0] = 0
x = 0
for i in range(N):
  if visited[i]:
    continue
  stack = deque([(i, x)])
  visited[i] = True
  while stack:
    now, xi = stack.popleft()
    for nx, di in G[now]:
      if visited[nx]:
        if xs[nx] != xi + di:
          print('No')
          exit()
      else:
        xs[nx] = xi + di
        visited[nx] = True
        stack.append((nx, xi+di))
        
if max(xs)-min(xs) > 1000000000:
  print('No')
else:
  print('Yes')



Measured memory_bytes: 73816
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;

  int S = A;
  for (int i = 0; i < B; i++)
  {
    if(S%B == C)
    {
      cout<<"YES"<<endl;
      return;
    }
    S += A;
  }
  cout<<"NO"<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

dicesum = 0
maxsum = 0
for i in range(n):
	dicesum += p[i]
	if i >= k:
		if n != k: dicesum -= p[i-k]
	maxsum = max(maxsum, dicesum)

ans = (maxsum + k) / 2
print(ans)


Measured memory_bytes: 25060
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var a = readLine()!!.split(' ').map { it.toInt() }.toIntArray()

    for (j in 0 until Math.min(k, 42)) {
        val b = IntArray(n)
        var lb = 0
        var rb = 0
        val led = IntArray(n)
        val red = IntArray(n)
        for (i in 0 until n) {
            val llight = a[i]
            lb++
            val max = Math.min(n - 1, i + llight)
            b[i] += lb
            led[max]++
            lb -= led[i]

            val rix = n - i - 1
            val rlight = a[rix]
            rb++
            val min = Math.max(0, rix - rlight)
            b[rix] += rb-1
            red[min]++
            rb -= red[rix]

        }
        a = b
    }
    println(a.joinToString(" "))
}


Measured memory_bytes: 71868
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using lint = long long int;
using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;
vector <point> pl;
  
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}
  
point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
 
namespace std{
  bool operator < (const point &a,const point &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};
 
vector<point> andrewScan(vector<point> &t){
  int N=t.size(),C=0;
  vector<point> R(N);
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)C--;
    R[C++]=t[i];
  }
  vector<point> res(C);
  for(int i=0;i<C;i++)res[i]=R[i];
  return res;
}
  
vector<point> ConvexHull2(vector<point> &t){
  sort(t.begin(),t.end());
  vector<point> u=andrewScan(t);
  reverse(t.begin(),t.end());
  vector<point> l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}
 
vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return ConvexHull2(res);
}
  
double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}
  
  
int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));
  
  int m;
  cin>>m;
  for(int i=0,c,d;i<m;i++){
    cin>>c>>d;
    point a,b;
    a=point(c,d);
    cin>>c>>d;
    b=point(c,d);
    vector<point> res=ConvexCut(pl,a,b);
    printf("%.8f\n",get_area(res));
  }
  
  
  return 0;
}

Measured memory_bytes: 3292
#include<stdio.h>
#include<stdlib.h>
#define Max 2000000

int heap,A[Max+1];
void MaxHeapify(int);
void swap(int *,int *);
int main(){
  int i;
  scanf("%d",&heap);
  for( i=1;i<=heap;i++)
    scanf("%d",&A[i]);
  for( i=heap/2;i>=1;i--)MaxHeapify(i);
  for( i=1;i<=heap;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}
void MaxHeapify(int x){
  int left,right,maximum;
  left=2*x;
  right=2*x+1;
  if(left<=heap&&A[left]>A[x])maximum=left;
  else maximum=x;
  if(right<=heap&&A[right]>A[maximum])maximum=right;

  if(maximum !=x){
    swap(&A[x],&A[maximum]);
    MaxHeapify(maximum);
  }
}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int maxn = 100000 + 10;
 
template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
long long N, A, B, C, D;

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    cin >> N >> A >> B >> C >> D; 

    long long L = A + (N-1) * C, R = A + (N-1) * D;

    for(int i = 0; i < ((N-1) << 1); i++) {

        if(L <= B && B <= R) {
            return puts("YES"), 0;
        }
        L -= D + C;
        R -= D + C;
    }
    puts("NO");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int x,y;

        scanf("%d%d",&x,&y);

        if(x==2 || y==2)
                printf("No\n");
        else if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12){
                if(y==4 || y==6 || y==9 || y==11)
                        printf("No\n");
                else
                       printf("Yes\n");
        }
        else{
                if(y==4 || y==6 || y==9 || y==11)
                        printf("Yes\n");
                else
                        printf("No\n");
        }

        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//129A
int main(void) {
	vector<int> pqr(3);
	cin >> pqr[0] >> pqr[1] >> pqr[2];
	sort(pqr.begin(), pqr.end());
	cout << pqr[0] + pqr[1] << endl;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split(/\n/)

  if (input[0] == 1) {
    console.log('Hello World')
  } else {
    console.log(~~input[1] + ~~input[2])
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
147 105

output:
21
"""

import sys


def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2))

Measured memory_bytes: 7716
//Author:Chacha
//Date:24/01/19

#include<bits/stdc++.h>

using namespace std;

vector<char>vec;

char s1[10001],s2[10001];
int l1,l2,saved[10001][10001],diretion[10001][10001];

int lcs_counter(int i,int j){
    if(i==l1||j==l2)
        return 0;
    if(saved[i][j]!=-1)
        return saved[i][j];

    int ans=0;
    if(s1[i]==s2[j]){
        int ans2=1+lcs_counter(i+1,j+1);
        if(ans2>ans){
            ans=ans2;
            diretion[i][j]=0;
        }
    }
    int ans2=lcs_counter(i,j+1);
        if(ans2>ans){
            ans=ans2;
            diretion[i][j]=1;
        }
    ans2=lcs_counter(i+1,j);
        if(ans2>ans){
            ans=ans2;
            diretion[i][j]=2;
        }

    saved[i][j]=ans;
    return ans;
}

int back_track(int i, int j){
    if(i==l1||j==l2)
        return 0;

    if(diretion[i][j]==0){
        if(s1[i]==s2[j])
            vec.push_back(s1[i]);
        back_track(i+1,j+1);
    }
    else if(diretion[i][j]==1){
        if(s1[i]==s2[j])
            vec.push_back(s1[i]);
        back_track(i,j+1);
    }
    else if(diretion[i][j]==2){
        if(s1[i]==s2[j])
            vec.push_back(s1[i]);
        back_track(i+1,j);
    }
}


int main(){
    int len,i,len_of_lcs;

    for(i=0;i<10001;i++)
        memset(saved[i],-1,sizeof(saved[i]));

    scanf(" %s %s",s1,s2);
    l1=strlen(s1);
    l2=strlen(s2);

    len=lcs_counter(0,0);
    //cout<<len<<endl;

    len_of_lcs=back_track(0,0);

    len_of_lcs=vec.size();

    for(i=0;i<len_of_lcs;i++){
        printf("%c",vec[i]);
    }

    cout<<endl;

    return 0;
}



Measured memory_bytes: 510592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    int dist = t * s;
    if(d <= dist) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std; 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    bool p1 = true, p2 = true;
    for(int i = a; i < c; i++) {
        if(s[i] == '#' and s[i + 1] == '#') {
            p1 = false;
            break;
        }
    }
    for(int i = b; i < d; i++) {
        if(s[i] == '#' and s[i + 1] == '#') {
            p2 = false;
            break;
        }
    }

    if(p1 and p2) {
        if(c < d) cout << "Yes";
        else {
            bool flag = false;
            for(int i = b; i <= d; i++) {
                if(s[i - 1] == '.' and s[i + 1] == '.' and s[i] != '#') {
                    flag = true;
                    break;
                }
            }
            if(flag) cout << "Yes";
            else cout << "No";
        }
    }
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 592
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
n = iin()
k = iin()
x = [int(x) for x in input().split()]

for i in range(n):
    if(abs(x[i]-k) < x[i]):
        neko = neko + 2*abs(x[i]-k)
    else:
        neko = neko + 2*x[i]
print(neko)

Measured memory_bytes: 3064
N, M = map(int, input().split())
L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
if min(R)-max(L)+1>0:
    print(min(R)-max(L)+1)
else:
    print(0)

Measured memory_bytes: 16724
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int dx[7][4]={{0,0,1,1},{0,0,0,0},{0,1,2,3},{0,0,-1,-1},{0,1,1,2},{0,0,1,1},{0,-1,0,1}};
int dy[7][4]={{0,1,1,0},{0,1,2,3},{0,0,0,0},{0,1,1,2},{0,0,1,1},{0,1,1,2},{0,1,1,0}};
string MAP[8];
string ans="ABCDEFG";

int main(){
	while(1){
	for(int i=0; i<8; ++i){
		if(!(cin >> MAP[i])){
			return 0;
		}
	}
	for(int i=0; i<8; ++i){
		for(int j=0; j<8; ++j){
			if(MAP[i][j]=='1'){
				for(int k=0; k<7; ++k){
					bool ok=true;
					for(int l=0; l<4; ++l){
						int nx=j+dx[k][l];
						int ny=i+dy[k][l];
						if((0<=nx&&nx<8&&0<=ny&&ny<8&&MAP[ny][nx]!='1')||(nx<0||8<=nx||ny<0||8<=ny)){
							ok=false;
							break;
						}
					}
					if(ok){
						cout << ans[k] << "\n";
						break;
					}
				}
			}
		}
	}
	}
	return 0;
}

Measured memory_bytes: 1168
s = int(input())
M = 1000000
m = 1
a = s

while m <= M:
    if a == 4:
        m += 3
        break
    if a % 2 == 0:
        a //= 2
    else:
        a = 3 * a + 1
    m += 1

if s in (1, 2):
    m = 4

print(m)


Measured memory_bytes: 2940
w, a, b = gets.split.map(&:to_i)

def calc(p1, p2)
  if p1 >= p2
    p1 - p2
  else
    p2 - p1
  end
end

a1 = a
a2 = a + w
b1 = b
b2 = b + w

if b1 >= a1 && b1 <= a2 || b2 >= a1 && b2 <= a2
  p 0
else
  arr = []
  arr.push(calc(b1, a1))
  arr.push(calc(b1, a2))
  arr.push(calc(b2, a1))
  arr.push(calc(b2, a2))
  p arr.min
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,a[1000000],i,k,s=0;
    cin>>n;
    while(n){
        n/=2;
        s++;
    }
    ll c=1;
    for(i=1;i<=s;i++){
        c=c*2;
    }
    cout<<c-1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=1000006;
const ll INF=-1e12;
const long double PI=acos(-1);



void solve(int T){
    string s,t;
    cin>>s>>t;
    if(t.size()!=s.size()+1){
        cout<<"N0";
        return;
    }
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return;;
        }
    }
    cout<<"Yes";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


Measured memory_bytes: 3608