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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<ll, ll> P;

void print_line(vector<vector<int>> &ans) {
    for (int i = 0; i < ans.size(); i++) {
        for (int y = 0; y < ans[i].size(); y++) {
            cout << ans[i][y];
        }
        cout << endl;
    }
}

struct RangeCount {
    int upper, r_equal, between, l_equal, lower;

    friend std::ostream &operator<<(std::ostream &out, const RangeCount &o) {
        cout << endl;
        cout << "upper" << ' ' << o.upper << endl;
        cout << "r_equal" << ' ' << o.r_equal << endl;
        cout << "between" << ' ' << o.between << endl;
        cout << "l_equal" << ' ' << o.l_equal << endl;
        cout << "lower" << ' ' << o.lower << endl;
        return out;
    }
};


// startは含む
// endは含まない
RangeCount range_count(vector<int>::iterator begin, vector<int>::iterator end, int l, int r) {
    if (l > r) return RangeCount{0, 0, 0, 0, 0};
    if (begin >= end) return RangeCount{0, 0, 0, 0, 0};

    if (l == r) {
        RangeCount rc;
        auto it = std::equal_range(begin, end, r);
//        auto it_u = upper_bound(begin, end, r);
//        auto it_l = lower_bound(begin, end, r);

        rc.upper = distance(it.second, end);
        rc.r_equal = distance(it.first, it.second);
        rc.between = 0;
        rc.l_equal = rc.r_equal;
        rc.lower = distance(begin, it.first);

        return rc;
    }

    RangeCount rc;
    auto it_r = std::equal_range(begin, end, r);
    auto it_l = std::equal_range(begin, end, l);

    auto it_ru = it_r.second;
    auto it_rl = it_r.first;
    rc.upper = distance(it_ru, end);
    rc.r_equal = distance(it_rl, it_ru);
    auto it_lu = it_l.second;// upper_bound(begin, end, l);
    auto it_ll = it_l.first;// lower_bound(begin, end, l);
    rc.between = distance(it_lu, it_rl);
    rc.l_equal = distance(it_ll, it_lu);
    rc.lower = distance(begin, it_ll);

    return rc;

}


int main() {

    int n;
    cin >> n;
    vector<int> edges(n);
    rep(i, n) cin >> edges[i];
    sort(edges.begin(), edges.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int a = edges[i], b = edges[j];

            RangeCount rc = range_count(edges.begin() + j + 1, edges.end(), b - a, b + a);

            ans += rc.between;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
import collections
import copy
input = sys.stdin.readline
N = int(input())
A = list(int(i) for i in input().split())
B = list(int(i) for i in input().split())
ans = 0
for i in range(N):
	if B[i]-A[i] > 0:
		if B[i] < (A[i]+A[i+1]):
			ans += B[i]
			A[i+1] -= B[i] - A[i]
		else:
			ans += A[i] + A[i+1]
			A[i+1] = 0
	else:
		ans += B[i]
print(ans)

Measured memory_bytes: 79324
/* **********************************************

  File Name: j.cpp

  Auther: zhengdongjian@tju.edu.cn

  Created Time: 2015??´10???03??\ ????????? 09??¶57???17?§?

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAX = 1000007;
struct Node {
	int len;
	int to;
} a[MAX];
ll bb[MAX << 1];
int stk[MAX];
vector<int> G[MAX];
vector<int> bakup[MAX];

ll dfs(int u) {
	int top = 0;
	stk[++top] = u;
	ll res = 0LL;
	while (top > 0) {
		u = stk[top];
		//printf("top = %d, u = %d\n", top, u);
		if (G[u].empty()) {
			int tail = 0;
			for (int i = 0; i < (int)bakup[u].size(); ++i) {
				bb[tail++] = a[bakup[u][i]].len;
				a[u].len += a[bakup[u][i]].len;
			}
			ll tp = 0LL;
			sort(bb, bb + tail);
			for (int i = 0; i < tail; ++i) {
				res += tp;
				tp += bb[i];
			}
			--top;
		} else {
			int v = *G[u].rbegin();
			G[u].pop_back();
			stk[++top] = v;
		}
	}
	return res;
}
/*
ll dfs(int u) {
	multiset<ll> st;
	ll res = 0LL;
	ll son = 0LL;
	for (int i = 0; i < (int)G[u].size(); ++i) {
		int& v = G[u][i];
		res += dfs(v);
		st.insert(a[v].len);
		son += a[v].len;
	}
	int sz = st.size() - 1;
	for (multiset<ll>::iterator it = st.begin(); it != st.end(); ++it) {
		res += (*it) * (sz--);
	}
	a[u].len += son;
	//fprintf(stderr, "dfs %d: len = %d, res = %lld\n", u, a[u].len, res);
	return res;
}
*/

int main() {
	int n;
	while (~scanf(" %d", &n)) {
		for (int i = 0; i < n; ++i) {
			G[i].clear();
			bakup[i].clear();
		}
		for (int i = 0; i < n; ++i) {
			scanf(" %d %d", &a[i].len, &a[i].to);
			if (a[i].to != -1) {
				G[a[i].to].push_back(i);
				bakup[a[i].to].push_back(i);
			}
		}
		ll sum = 0LL;
		for (int i = 0; i < n; ++i) {
			if (a[i].to == -1) {
				sum += dfs(i);
			}
		}
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 123576
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a(0),b,c,ans(0),tmp(0);
  	string s;
  	//vector<>x();
  	cin >> a >> b >> c;
  	for(int i = a;i <= b;i++){
      if(i % c == 0)ans++;
    }
  cout << ans;
  
}
   


Measured memory_bytes: 3628
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("A{}C",if a>=1200{"R"}else{"B"})
}

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)

	var res int

	if a == 0 && b == 0 {
		res = 0
	} else {
		ab := a + b

		sho := n / ab
		amari := n % ab

		if a - amari < 0 {
			res = sho * a + a
		} else {
			res = sho * a + amari
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ul T[N];
    ul lcd = 1;
    for(int i = 0; i < N; i++){
        cin >> T[i];
        lcd = lcd / gcd(lcd, T[i]) * T[i];
    }
    cout << lcd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  int n,l;
  cin >> n >> l;
  int nsum = n*(l-1) + n*(n+1)/2;
  int dmin = 100000;
  
  if(nsum<0){
    for(int i=1;i<=n;i++){
      int dif = i+l-1;
      if(dif<0)
        dif = dif*(-1);
      dmin = min(dmin,dif);
    }
    cout << nsum + dmin << endl;
  }
  else{
    for(int i=1;i<=n;i++){
      int dif = i+l-1;
      if(dif<0)
        dif = dif*(-1);
      dmin = min(dmin,dif);
    }
    cout << nsum - dmin << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,n,i,flag=0,j;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
               flag=1;
        }
    }
    if(flag==1)
        cout<<"Yes";
    else
        cout<<"No";

}

Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for(int  i = 0; i < N; i++)
        cin >> a[i];
    sort(a, a+ N);

    cout << a[N-1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
ans=0
for v in range(1,n+1):
 for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
   if arr[u]>=arr[v]:
     break
 else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
   ans+=1
print(ans)

Measured memory_bytes: 29468
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    int ans[40][99];

    for(int i=0; i<38; i++)
        for(int j=0; j<99; j++)
            ans[i][j] = -1;

    for(int i=0; i<19; i++)
        for(int j=0; j<99; j++)
            ans[i][j] = 1;

    for(int i=21; i<40; i++)
        for(int j=0; j<99; j++)
            ans[i][j] = 0;

    for(int i=0; i<19; i+=2)
        for(int j=0; j<99; j+=2)
            ans[i][j] = 0;
    for(int i=21; i<40; i+=2)
        for(int j=0; j<99; j+=2)
            ans[i][j] = 1;

    for(int i=0; i<98; i++)
        ans[19][i] = 1;

    for(int i=1; i<99; i++)
        ans[20][i] = 0;
    ans[19][98] = 0;
    ans[20][0] = 1;


    int x = 0, y = 1;
    while(A != 500){
        ans[y][x] = 0;
        A++;
        if(A == 500) break;

        if(y == 0) x += 2;
        else if(y == 17 && x == 98){
            x = 1;
            y = 0;
        }else if(y == 17){
            x += 2;
            y = 1;
        }else{
            y += 2;
        }
    }

    x = 0, y = 38;
    while(B != 500){
        ans[y][x] = 1;
        B++;
        if(B == 500) break;

        if(y == 39) x += 2;
        else if(y == 22 &&  x == 98){
            x = 1;
            y = 39;
        }else if(y == 22){
            x += 2;
            y = 38;
        }else{
            y -= 2;
        }
    }

    cout << 40 << " " << 99 << endl;
    for(int i=0; i<40; i++){
        for(int j=0; j<99; j++){
            if(ans[i][j] == 0)
                cout << ".";
            else if(ans[i][j] == 1)
                cout << "#";
            else
                cout << " ";
        }
        cout << endl;
    }



    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc156/tasks/abc156_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

ll div_ceil(ll a, ll b) { return (a + b - 1) / b; }

void solve() {
  ll K, Q;
  cin >> K >> Q;

  VL ds(K);
  rep(i, K) cin >> ds[i];

  auto query = [&](ll n, ll x, ll m) -> ll {
    ll last = x;
    ll zero_ct = 0;

    rep(i, K) {
      // 要素が N -> ds で足されるのは先頭 N-1 個
      ll added_count = div_ceil(n - 1 - i, K);
      last += (ds[i] % m) * added_count;

      if (ds[i] % m == 0) zero_ct += added_count;
    }

    // 商が増えた数 = あまりが減った数
    ll less_ct = last / m - x / m;

    return n - 1 - less_ct - zero_ct;
  };

  rep(i, Q) {
    ll n, x, m;
    cin >> n >> x >> m;
    cout << query(n, x, m) << endl;
  }
}

void solve2() {
  ll K, Q;
  cin >> K >> Q;

  VL ds(K);
  rep(i, K) cin >> ds[i];

  auto query = [&](ll n, ll x, ll m) -> ll {
    ll last = 0;
    ll zero_ct = 0;

    rep(i, K) {
      last += ds[i] % m;
      if (ds[i] % m == 0) zero_ct++;
    }

    // 要素が N -> ds で足されるのは先頭 N-1 個

    last *= (n - 1) / K;
    zero_ct *= (n - 1) / K;

    rep(i, (n - 1) % K) {
      last += ds[i] % m;
      if (ds[i] % m == 0) zero_ct++;
    }

    last += x;

    // 商が増えた数 = あまりが減った数
    ll less_ct = last / m - x / m;

    return n - 1 - less_ct - zero_ct;
  };

  rep(i, Q) {
    ll n, x, m;
    cin >> n >> x >> m;
    cout << query(n, x, m) << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int a[1000005];
bool ans[1000005];

int balls = 0;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  
  for(int i = n; i >= 1; i--) {
    int cnt = 0;
    for(int j = i; j <= n; j += i)
      cnt += ans[j];
    
    if(cnt % 2 != a[i] % 2) {
      ans[i] = true;
      balls++;
    }
  }
  cout << balls << endl;
  for(int i = 1; i <= n; i++)
    if(ans[i]) cout << i << " ";
}


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

using namespace std;

const int N = 2e5 + 10;
const long long MOD = 1e9 + 7;

long long dp[N], size[N], _count[N];
long long factorial[N];

int n;
vector <int> adjList[N];

void setup(){
    factorial[0] = 1;
    for (long long i=1;i<N;i++){
        factorial[i] = factorial[i - 1] * i % MOD;
    }
}

long long fpow(long long a, long long b){
    if (b == 0) return 1;
    long long temp = fpow(a, b / 2);
    temp = temp * temp % MOD;
    if (b & 1) temp = temp * a % MOD;
    return temp;
}

long long inv(long long a){ // inverse modulo
    return fpow(a, MOD - 2);
}

void solveSize(int i, int parent){
    size[i] = 1;
    for (auto j : adjList[i]){
        if (j == parent) continue;
        solveSize(j, i);
        size[i] += size[j];
    }
}

void solveDp(int i, int parent){
    if (size[i] == 1){ // Basis
        dp[i] = 1;
        return;
    }
    dp[i] = factorial[size[i] - 1];
    for (auto j : adjList[i]){ // iterasi semua tetangga simpul i
        if (j == parent) continue;
        solveDp(j, i);
        dp[i] = (dp[i] * dp[j] % MOD) * inv(factorial[size[j]]) % MOD;
    }
}

void solve_count(int i, int parent){
    if (i == parent){ // Akar
        _count[i] = dp[i];
    } else{
        _count[i] = (_count[parent] * factorial[size[i]] % MOD) * inv((n - size[i]) * dp[i] % MOD) % MOD;
        for (auto j : adjList[i]){ // iterasi semua tetangga simpul i
            if (j == parent) continue;
            _count[i] = (_count[i] * dp[j] % MOD) * inv(factorial[size[j]]) % MOD;
        }
    }
    for (auto j : adjList[i]){
        if (j == parent) continue;
        solve_count(j, i);
    }
}

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

    setup();

    cin >> n;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }

    // akar = 1
    solveSize(1, 1);
    solveDp(1, 1);
    solve_count(1, 1);

    long long result = 0;
    for (int i=1;i<=n;i++){
        result += _count[i];
        cout << _count[i] << endl;
    }
    // cout << result << endl;

    return 0;
}

Measured memory_bytes: 20212
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    for(int i = 1; i < s.size(); i++){
        if(s[i - 1] != s[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v1)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
            if i == lev - 1:
                events.append((prev[0] - eps, 1))
                events.append((prev[1], 0))
                break
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev[0] = val[0]
            prev[1] = val[1]
            if i==lev-1:
                events.append((val[0]-eps, 1))
                events.append((val[1], 0))
                break
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Measured memory_bytes: 34636
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> ;
#define pal pair < ll, ll> ;
#define vi vector <int> ;
#define vl vector < ll > ;
#define vpai vector < pii > ;

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 100045;

int dp[sze];

int solve(int k,int n,int arr[]) {
    if(dp[k]) return dp[k];

    rep(i,n){
        if(k>=arr[i]){
            if(solve(k-arr[i],n,arr)==2){
                dp[k]=1;
                return dp[k];
            }
        }
    }
    dp[k]=2;
    return dp[k];
}   

int main() {
    IOS;

    int t = 1;
    // cin >> t;
    while (t--) {
        int n,k;
        cin>>n>>k;
        int arr[n];
        dp[0]=2;
        rep(i,n) cin>>arr[i];
        if (solve(k,n,arr)==1)
        {
            cout<<"First";   
        }else cout<<"Second";
    }

  return 0;
}

Measured memory_bytes: 8716
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[230000];
signed main() {
	int n; cin >> n;
	int ans = inf;
	rep(i, n)cin >> a[i];
	int sum = 0, nsum = 0;
	rep(i, n)nsum += a[i];
	rep(i, n) {
		nsum -= a[i];
		sum += a[i];
		ans =min(ans, abs(sum - nsum));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll D,N;
    cin >> D >> N;
    ll n = (ll)pow(100, D);
    ll cnt = 0;
    for(ll i = 1; i <= 1010000; i++) {
        ll tmp = i;
        ll d = 0;
        while(tmp % 100 == 0) {
            tmp /= 100;
            ++d;
        }
        if (d == D) ++cnt;
        if (cnt == N) {
            print(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
l = list(map(int, input().split()))
x, k, d = map(abs, l)
if x - k*d > 0:
    print(x - k*d)
else:
    cnt = x//d
    val1 = x%d
    val2 = d-val1
    if (k-cnt)%2 == 0:
        print(val1)
    else:
        print(val2)


Measured memory_bytes: 61900
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    var ans = 0
    val H: MutableList<Int> = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var X: MutableList<Int> = mutableListOf()
    for (i in 1..N) {
        X.add(0)
    }
    for (i in 1..M) {
        val (A, B) = readLine()!!.split(" ").map(String::toInt)
        if (H[A - 1] == H[B - 1]) {
            X[A - 1] = -1
            X[B - 1] = -1
        } else if (H[A - 1] < H[B - 1]) {
            X[A - 1] = -1
        } else {
            X[B - 1] = -1
        }
    }
    for (i in X) {
        if (i == 0) {
            ans += 1
        }
    }
    println(ans)
}

Measured memory_bytes: 63308
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
 
int dp[70000];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	rep(i, (1 << n)) {
		rep(j, n) {
			rep(k, n) {
				if ((i >> j)&(i >> k) & 1) {
					dp[i] += a[j][k];
				}
			}
		}
		dp[i] /= 2;
	}
	rep(i, (1 << n)) {
		vector<int> vec;
		rep(j, n) {
			if ((i >> j) & 1) {
				vec.pb(j);
			}
		}
		int v = vec.size();
		rep(j, (1 << v)) {
			int c = 0;
			rep(k, v) {
				if ((j >> k) & 1) {
					c += (1 << vec[k]);
				}
			}
			chmax(dp[i], dp[c] + dp[i - c]);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 768
#include <iostream>                                           
using namespace std;
 
int main(){
  int n;
  int array[1001] = {0};
  bool is_prime[1001];
  cin >> n;
  for(int i = 0; i <= 1000; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= n; i++){
    int num = i;
    int count = 1;
    for(int j = 2; j <= i; j++){
      while(num%j==0 && is_prime[j]){
        count++;
        num/=j;
        array[j]++;
      }   
    }   
    if(count != 2) is_prime[i] = false;
  }
  long long ans = 1;
  for(int i = 0; i <= 1000; i++){
    ans *= (array[i]+1);
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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() {
  int K;
  cin >> K;
  int x = 7 % K;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x * 10 + 7) % K;
    ++i;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 50472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	ll i;
	ll maxx=INT_MIN;
	ll minn=INT_MAX;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		if(a[i]>maxx)
			maxx=a[i];
	for(i=0;i<n;i++)
		if(a[i]<minn)
			minn=a[i];
	cout<<abs(maxx-minn)<<endl;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c)cout<<a<<" "<<b<<" "<<c<<endl;
	else if(a<=c&&c<=b)cout<<a<<" "<<c<<" "<<b<<endl;
	else if(b<=a&&a<=c)cout<<b<<" "<<a<<" "<<c<<endl;
	else if(b<=c&&c<=a)cout<<b<<" "<<c<<" "<<a<<endl;
	else if(c<=a&&a<=b)cout<<c<<" "<<a<<" "<<b<<endl;
	else cout<<c<<" "<<b<<" "<<a<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<set>

using namespace std;

int main()
{
	string str;
	set<string> s;
	int n;
	cin >> str >> n;
	for (int i = 0; i < str.size(); i++) {
		for (int j = 1; j<=6; j++) {
			if (i + j > str.size())
				break;
			string t = str.substr(i, j);
			s.insert(t);
		}
	}
	set<string>::iterator it;
	it = s.begin();

	for (int i = 0; i < n-1; i++)
		it++;
	cout << *it << endl;
}

Measured memory_bytes: 2176
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

func printInts(a []int) {
	for i, e := range a {
		if e == 0 {
			continue
		}
		fmt.Print(i+1)
		if i != len(a)-1 {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}

	m := 0
	b := make([]int, n)

	for i := n; i >= 1; i-- {
		c := 0
		for j := 2; j*i < n+1; j++ {
			c += b[j*i-1]
		}

		if c%2 == a[i-1] {
			b[i-1] = 0
		} else {
			b[i-1] = 1
			m++
		}
	}

	fmt.Println(m)
	if m!=0 {
		printInts(b)
	}

}


Measured memory_bytes: 6144
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;
using ll=long long int ;

int main() {

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

	int ans = k;
	for (int i = 0; i < n-1; i++) {
		ans *= (k - 1);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
K = int(input())

for i in range(K):
	if S[i] == '1':
		continue
	else:
		print(S[i])
		sys.exit()

print(S[K-1])


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

int main() {
    string s; cin >> s;

    vector<int> ans(s.size(), 0);
    s.push_back('R');
    int r = 0, l = 0;
    char prv = s[0];
    for (int i = 0; i < s.size(); ++i) {
        if (prv == 'L' && s[i] == 'R') {

            // Rの右端の座標を探索する
            int j = i - 1;
            while (s[j] == 'L') j--;

            // abs(r - l)が偶数のケース
            if (abs(r - l) % 2 == 0) {
                ans[j] = (r + l) / 2, ans[j + 1] = (r + l) / 2;
            } else {
                int com = min(r, l);
                int t = (r + l) / 2;

                // 共通：偶数、r：奇数
                if (com % 2 == 0 && r > l) {
                    ans[j] = t + 1, ans[j + 1] = t;
                }

                // 共通：偶数、l：奇数
                if (com % 2 == 0 && r < l) {
                    ans[j] = t, ans[j + 1] = t + 1;
                }

                // 共通：奇数、r：奇数
                if (com % 2 != 0 && r > l) {
                    ans[j] = t, ans[j + 1] = t + 1;
                }

                // 共通：奇数、l：奇数
                if (com % 2 != 0 && r < l) {
                    ans[j] = t + 1, ans[j + 1] = t;
                }
            }

            l = 0, r = 1;
            prv = s[i];
        } else {
            if (s[i] == 'L') l++;
            if (s[i] == 'R') r++;
            prv = s[i];
        }
    }

    for (int i = 0; i < s.size() - 1; ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#abc105d
import sys
from collections import defaultdict

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
d=defaultdict(int)
res=0
s=0
d[0]=1
for i,x in enumerate(a):
 x%=m
 s+=x
 res+=d[s%m]
 d[s%m]+=1
print res


Measured memory_bytes: 11520
#include <stdio.h>
int a,w,t,r;
int main () {
  int n;
  char s[100];
  scanf("%d",&n);
  while(n--) {
    scanf("%s",s);
    if (s[0]=='A') a++;
    if (s[0]=='W') w++;
    if (s[0]=='T') t++;
    if (s[0]=='R') r++;
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
}

Measured memory_bytes: 1720
n, x, y = map(int, input().split())
x -= 1
y -= 1

List = [0 for i in range(n)]

for i in range(n - 1):
    for j in range(i + 1, n):
        distance = min(j - i, abs(x - i) + 1 + abs(j - y))
        List[distance] += 1

for index in range(1, len(List)):
    print(List[index])

Measured memory_bytes: 3444
/** Seek God..Trust God..Praise God..**/

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


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define endl            "\n";

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;
    int x;
    cin >> x;


    if(x==0)
    {
        cout << 1 << endl;
        return 0;
    }

    if(x==1)
    {
        cout << 0 << endl;
        return 0;
    }





    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ins insert
#define ll long long
#define Pair pair<int,int>
#define MT make_tuple
#define MP make_pair
#define INF 0x3f3f3f3f
#define lim 1e9
#define Bigint 3e8+1
#define MAX 3e5
#define NL '\n'
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, //for indexed_set
        tree_order_statistics_node_update> indexed_set;

/*ll A,B,X,N,c,key;

ll power(ll ko,ll io)
{
    ll y=ko;
    if(io==0) return 1;
    else{
        io--;
        while(io--)
        {
            ko = ko*y;
        }
        return ko;
    }
}
ll rec(ll l,ll r,ll beta)
{
    ll mid = (l+r)/2,a,b,k;
    a = A*l + beta;
    b = A*mid + beta;
    k = A*r + beta;

    cout << "echo "<< l <<" "<< a <<NL;
    cout << "echo "<< mid <<" "<< b <<NL;
    cout << "echo "<< r <<" "<< k <<NL;

    if(r==l+1)
    {
        if(a<=X) key = l;
        else key = r;
        cout << key <<" "<< a <<" "<< b <<" "<< k << NL;
        return key;
    }
    else if(a<=A && b>=A){
        cout << "L\n";
        return rec(l,mid,beta);
    }
    else if(b<=A && k>=A){
        cout << "R\n";
        return rec(mid,r,beta);
    }

}*/
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //freopen("input.txt","r",stdin);

   /* ll c,p,q,prmx,echo,k,mn,mx,l,r,bet;

    cin >> A >> B >> X;

    prmx = 0;
    for(int i=1 ; i<=18 ; i++){
        c = B*i;
        //cout << "c ="<<c<<" "<<i<<NL;
        p = power(10,i-1);
        q = (power(10,i)-1);
        mn = A*p+c;
        mx = A*q+c;
        //cout << p<<" "<<mn<<" "<<q<<" "<<mx<<NL;
        if( X>prmx && X<mn ){
          //  cout << prmx;
            return 0;
        }
        else if(X>mn && X<mx){
            l = p;
            r = q;
            bet = c;
            //cout << l <<" "<< r <<" "<<c<< NL;
            break;
        }
        else prmx = mx;
    }
    echo = rec(l,r,bet);

    cout << echo;
*/
    int n,a,c;
    string s;

    cin >> n >> s;
    if(n%2==1){
        cout << "No";
        return 0;
    }
    else
    {
        c = n/2;
        a = c;
        for(int i=0 ; i<a ; i++){
            if(s[i]!=s[c])
            {
                cout << "No";
                return 0;
            }
            c++;
        }
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int S,W;
    cin >> S >> W;

    if(S <= W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

vector<ll> ans_list;//Max is 3234566667
/*.....................DEFINE FUNCTIONS ......................*/

void dfs(ll n){
	if(n>=3234566667) return ;
	else if(n%10==0){
		ans_list.push_back(n*10+0);dfs(n*10+0);
		ans_list.push_back(n*10+1);dfs(n*10+1);
	}
	else if(n%10==9){
		ans_list.push_back(n*10+8);dfs(n*10+8);
		ans_list.push_back(n*10+9);dfs(n*10+9);
	}
	else{
		int d=n%10;
		ans_list.push_back(n*10+d-1);dfs(n*10+d-1);
		ans_list.push_back(n*10+d);dfs(n*10+d);
		ans_list.push_back(n*10+d+1);dfs(n*10+d+1);
	}
}

/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	int K;
	cin>>K;
	FOR(i,1,9){
		ans_list.PB(i);
		dfs(i);
	}
	sort(ALL(ans_list));
	cout<<ans_list[K-1]<<endl;
		return 0;
}


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

int n,ans=0,maxlen;
int a[200005],v[1000005];
bool b[1000005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		v[a[i]]++;
		maxlen=max(maxlen,a[i]);
	}
	if (n==1)  return cout<<1<<endl,0;
	
	for (int now=1;now<=n;now++)
	{
		int i=a[now],flag=1;
		v[i]--;
		for (register int j=1;j*j<=i;j++)
		{
			if (i%j!=0)  continue;
			
			if (v[j]>0||v[i/j]>0)
			{
				flag=0;
				break;
			}
		}
		if (flag==1)  b[i]=1;
		
		v[i]++;
	}
	for (int i=1;i<=n;i++)
	{
		if (b[a[i]]==1)  ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 13868
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int N = reader.readInt();
            int[][] squares = new int[2][];
            squares[0] = reader.readIntsSplitByDelimiter(" ");
            squares[1] = reader.readIntsSplitByDelimiter(" ");

            int max = 0;
            for (int i = 0; i < N; i++) {
                int count = 0;
                for (int j = 0; j < N; j++) {
                    if (i == j) {
                        count += squares[0][j];
                    }

                    if (i > j) {
                        count += squares[0][j];
                    } else {
                        count += squares[1][j];
                    }
                }

                max = Math.max(max, count);
            }

            writer.println(max);
            writer.flush();
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}

Measured memory_bytes: 21332
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
      //書かれている整数の個数
      int n = sc.nextInt();
      int a[] = new int[n];
      //カウンター
      int c = 0;
      for(int i = 0; i < n; i++){
        //黒板に書かれている整数
      	a[i] = sc.nextInt();
      }
      
      while(true){
        //奇数かどうかカウンターを立てる
        boolean odd = false;
        for(int i = 0; i < n; i++){
          if(a[i] % 2 != 0){
            odd = true;
          }
        }
        
        if(odd == true){
          break;
        }
        
        for(int i = 0; i < n; i++){
          a[i] = a[i] / 2;
        }
        c++;
      }
		System.out.println(c);
	}
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            int W = Integer.parseInt(inputString.get(0));
            int a = Integer.parseInt(inputString.get(1));
            int b = Integer.parseInt(inputString.get(2));
            int aW = a + W;
            int bW = b + W;

            int ans = 0;
            if (aW< b) {
                ans = b - aW;
            } else if (aW>= b && aW <= bW) {
                ans = 0;
            } else if (bW <= aW && bW >= a) {
                ans = 0;
            } else {
                ans = a - bW;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
import copy
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]
 
    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)

def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    from fractions import gcd
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()

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

int main(void) 
{
	int N;
	int ans=0;
	int arr1[100]={};
	int arr2[100]={};
	cin >> N;
	
	for(int i=0;i<N;i++)
	{
	    cin >>arr1[i];
	    if(i!=0)
	        arr1[i]+=arr1[i-1];
	}
	for(int i=0;i<N;i++)
	{
	    cin >> arr2[i];
        if(i!=0)
            arr2[i]+=arr2[i-1];
	}
    
    for(int i=0;i<N;i++)
    {
        if(i==0)
            ans=max(ans,arr1[i]+arr2[N-1]);
        else
            ans=max(ans,arr1[i]+arr2[N-1]-arr2[i-1]);
    }
	
	if(N==1)
	    ans=arr1[0]+arr2[0];
	
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
string a[100],b,c;
int e,d;
cin>>e>>d;
	for(int i=0;i<e;i++){
	cin>>a[i];
	}
	for(int i=0;i<(d+2);i++){
		c=c+"#";
	}
	cout<<c<<endl;
	for(int i=0;i<e;i++){
		a[i]="#"+a[i]+"#";
	cout<<a[i]<<endl;
	}
	cout<<c<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll ans = 0;
  ll n;
  cin>>n;
  vi a(n+1);
  vi b(n);
  rep(i,n+1){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  for (ll i = n - 1; i >= 0;i--){
    if(a[i]+a[i+1]<=b[i]){
      ans += a[i]+a[i+1];
      a[i] = 0;
    }
    else if(a[i+1]<=b[i]){
      a[i] -= b[i] - a[i + 1];
      ans += b[i];
    }
    else{
      ans += b[i];
    }
  }
  print(ans);
}

Measured memory_bytes: 1792
#include <stdio.h>
int ARR[101][101];
int Count[101];
int n;
void dfs(int cnt);
int used[101];
int Max;
int cnt;

int main(){

	int i,j;
	int route[101];
	int len,len_max;
	int p,q;
	for(i=0;i<101;i++)used[i]=0;
	
	while(1){
		scanf("%d\n",&n);
		if(!n)break;
		for(i=0;i<101;i++)Count[i]=0;

		for(i=0;i<n;i++){
			scanf("%d %d\n",&p,&q);
			Count[p]++;
			ARR[p][Count[p]-1]=q;
			Count[q]++;
			ARR[q][Count[q]-1]=p;
		}
		
		Max=0;
		for(i=0;i<101;i++){
			if(Count[i]==0)continue;
			used[i]=1;
			cnt=1;
			for(j=0;j<Count[i];j++){
				if(used[ARR[i][j]]==1)continue;
				used[ARR[i][j]]=1;
				cnt++;
				if(cnt>Max)Max=cnt;
				dfs(ARR[i][j]);
				cnt--;
				used[ARR[i][j]]=0;
			}
			cnt--;
			used[i]=0;
		}
		printf("%d\n",Max);
	}
	return 0;
}

void dfs(int now){
	int jj;
	for(jj=0;jj<Count[now];jj++){
		if(used[ARR[now][jj]]==1)continue;
		used[ARR[now][jj]]=1;
		cnt++;
		if(cnt>Max)Max=cnt;
		dfs(ARR[now][jj]);
		cnt--;
		used[ARR[now][jj]]=0;
	}
}

Measured memory_bytes: 644