akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		string tmp = to_string(i);
		int a = tmp[0] - '0';
		int b = tmp[tmp.size() - 1] - '0';
		swap(a, b);
		if (a == 0)continue; 
		if (a == b)ans++;
		//cout << a << "  " << b << endl;
		int now = 1;
		rep(i, 7) {
			ans += max(0LL, min(now, (n-(a*now*10+b)+10)/10));
			now *= 10;
		}
		//cout << i << " "<< ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (A, B, C, D) = readLine()!!.split(" ").map { it.toLong() }
    println(B.notDividableCount(C, D) - (A - 1).notDividableCount(C, D))

}

fun Long.notDividableCount(divideBy1: Long, divideBy2: Long): Long {
    val count1 = this / divideBy1
    val count2 = this / divideBy2
    val count12 = this / (lcm(divideBy1, divideBy2))
    return this - (count1 + count2 - count12)
}

fun gcd(a: Long, b: Long): Long {
    if (a < b) return gcd(b, a)
    if (b == 0L) return a
    return gcd(b, a % b)
}

fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

Measured memory_bytes: 37996
import java.util.*;
public class Main{
  
  public static void main(String[] args){
    
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int C = in.nextInt();
    int tobeFilled = A-B>0?A-B:0;
    int remaining = C>tobeFilled?C-tobeFilled:0;
    System.out.println(remaining);
    
  }
  
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    llong x;
    cin >> x;

    int t = 0;
    int ans;
    for(; t * (t + 1) / 2 < x; ++t) {}

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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



int main(){
    std::string S; std::cin >> S;
    std::cout << (S=="ABC" ? "ARC" : "ABC") << std::endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool v[110], s[110];
int main()
{
	int H, W;
	string S[110];
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int i = 0; i < H; i++) {
		bool de = true;
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') de = false;
		}
		v[i] = de;
	}
	for (int j = 0; j < W; j++) {
		bool de = true;
		for (int i = 0; i < H; i++) {
			if (S[i][j] == '#') de = false;
		}
		s[j] = de;
	}
	for (int i = 0; i < H; i++) {
		if (!v[i]) {
			for (int j = 0; j < W; j++) {
				if (!s[j]) cout << S[i][j];
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#include <vector>

using namespace std;

int main()
{
  bitset<60001> is_prime;
  is_prime.set();
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i * i <= 60000; i++) {
    for (int j = i + i; j <= 60000; j += i) {
      is_prime[j] = false;
    }
  }
  vector<int> prime;
  for (int i = 0; i <= 60000; i++) {
    if (is_prime[i]) {prime.push_back(i);}
  }

  int n;
  while (scanf("%d ", &n) == 1) {
    if (n == 0) {break;}
    int c = 0;
    for (int i = 0; i < prime.size(); i++) {
      if (prime[i] > n / 2) {break;}
      if (is_prime[n - prime[i]]) {c++;}
    }
    printf("%d\n", c);
  }
  return 0;
}

Measured memory_bytes: 984
/*
 *  Author : Jun_SH
 *  Solution for ddcc2020-qual C
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
char s[310][310];
int a[310][310];
main(){
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=1;i<=h;++i){
        scanf("%s",s[i]+1);
    }
    int tot=0;
    memset(a,-1,sizeof(a));
    for(int i=1;i<=h;++i){
        int flag=0;
        for(int j=1;j<=w;++j){
            if(s[i][j]=='#'){
                flag=1;
                tot++;
            }
            if(flag){
                a[i][j]=tot;
            }
        }
        int tmp=-1;
        for(int j=w;j>=1;--j){
            if(a[i][j]!=-1)tmp=a[i][j];
            if(a[i][j]==-1)a[i][j]=tmp;
        }
    }
//    for(int i=1;i<=h;++i){
//        for(int j=1;j<=w;++j)
//            cout<<a[i][j]<<" ";
//        cout<<endl;
//    }
    for(int i=1;i<=h;++i){
        int flag=1;
        for(int j=1;j<=w;++j){
            if(a[i][j]!=-1)flag=0;
        }
        for(int j=1;flag&&j<=w;++j){
        if(a[i-1][j]!=-1){
            for(int j=1;j<=w;++j){
                a[i][j]=a[i-1][j];
            }
        }
        }
    }
    for(int i=h;i>=1;--i){
        int flag=1;
        for(int j=1;j<=w;++j){
            if(a[i][j]!=-1)flag=0;
        }
        for(int j=1;flag&&j<=w;++j){
        if(a[i+1][j]!=-1){
            for(int j=1;j<=w;++j){
                a[i][j]=a[i+1][j];
            }
        }
        }
    }
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j)
            cout<<a[i][j]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
  double x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;
  printf("%f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
  return (0);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int action(int a) {
  int result = 0;
  while (a % 2 == 0) {
    a /= 2;
    result++;
  }
  return result;
}

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

  int result = 999999;

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

    result = min(result, action(a));
  }

  cout << result << endl;
}

Measured memory_bytes: 256
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()

    var a = IntArray(4)
    var dp = Array(N+1, {IntArray(4)})

    for(i in 1..N) {
        for (j in 1..3) {
            a[j] = scn.nextInt()
        }
        for(j in 1..3){
            for(k in 1..3){
                if(j==k) continue
                dp[i][j] = max( dp[i][j], dp[i-1][k] + a[j])
            }
        }
    }

    println(max(max(dp[N][1], dp[N][2]), dp[N][3]))
}


Measured memory_bytes: 115052
#[allow(unused_imports)]
use std::collections::HashSet;

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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

//use lazy_static::lazy_static;

//lazy_static! {
//    static ref MOD :usize = 10usize.pow(9) + 7;
//}

use std::collections::HashMap;

static MOD: usize = 1000_000_007;

fn main() {
    let l: Vec<char> = read::<String>().chars().collect::<Vec<char>>();

    let mut pow2: HashMap<usize, usize> = HashMap::new();
    let mut pow3: HashMap<usize, usize> = HashMap::new();
    
    prepare(&l, &mut pow2, &mut pow3);
    let answer = solve(&l, &pow2, &pow3);
    println!("{}", answer);
}

fn prepare(l: &[char], m2: &mut HashMap<usize, usize>, m3: &mut HashMap<usize, usize>) {
    let n = l.len();

    let mut num_of_one = 0;
    let mut x2 = 1;
    let mut pos_of_one = n - 1;
    let mut x3 = 1;

    m2.insert(0, 1);
    m3.insert(0, 1);

    for i in (0..n).rev() {
        if l[i] == '0' {
            continue;
        }
        num_of_one += 1;
        x2 = x2 * 2 % MOD;
        m2.insert(num_of_one, x2);
        //println!("m2 {}, {}", num_of_one, x2);

        let r = pos_of_one - i;
        for j in 0..r {
            x3 = x3 * 3 % MOD;
        }
        m3.insert(n-i - 1, x3);
        pos_of_one = i;
        //println!("m3 {}, {}", r, x3);
    }
}

fn solve(l: &[char], m2: &HashMap<usize, usize>, m3: &HashMap<usize, usize>) -> usize {
    let n = l.len();

    let mut count = 0;
    let mut num_of_one = 0;
    for i in 0..n {
        if l[i] == '0' {
            continue;
        }
        let remaining = n - i - 1;
        // 0-1 or 1-0
        let c1 = m2[&num_of_one];

        //println!("XXX reamining={}", remaining);
        let c2 = m3[&remaining];
        let c3 = c1 * c2 % MOD;

        count = (count + c3) % MOD;
        num_of_one += 1;
    }
    let c1 = m2[&num_of_one];
    count = (count + c1) % MOD;
    return count;
}

Measured memory_bytes: 15936
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        k: usize,
    }
    println!("{}", n % k);
}

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

double a, b, x;

int main(){

    cin >> a >> b >> x;
    
    double l, theta;

    if (x <= a*a*b/2){
        l = (2*x)/(a*b);
        theta = (atan(b/l)*180)/3.141592;
    }
    else{
        l = (2*a*a*b - 2*x)/(a*a);
        theta = (atan(l/a)*180)/3.141592;
    }

    cout << fixed << setprecision(15);
    cout << theta << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll max_v;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  return ret%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
ll mns(ll x,ll y){
  x%=mod;
  y%=mod;
  ll ret=x-y;
  if(ret>=0) return ret;
  else return (ret+mod)%mod;
}
ll wd[1000005]={0},sumd[1000005]={0},cnt[1000005]={0};
void wd_set(){
  for(ll i=1;i<=max_v;i++){
    wd[i]=mns(gyaku(i),sumd[i]);
    for(int j=i;j<=max_v;j+=i){
      sumd[j]+=wd[i];
      sumd[j]%=mod;
    }
  }
}
int main(){
  ll n;
  cin>>n;
  max_v=0;
  for(ll i=1;i<=n;i++) {
    ll a;
    cin>>a;
    cnt[a]++;
    max_v=max(max_v,a);
  }
  wd_set();
  ll ans=0;
  for(ll i=1;i<=max_v;i++){
    ll kans=0,ksum=0;
    for(ll j=i;j<=max_v;j+=i){
      kans+=((ksum*cnt[j])%mod)*j%mod;
      kans+=(((j*j)%mod)*((cnt[j]*(cnt[j]-1)/2)%mod))%mod;
      ksum+=(cnt[j]*j)%mod;
      kans%=mod;
      ksum%=mod;
    }
    ans+=kans*wd[i]%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  int N;
  cin >> N;
  int A[N+2] = {};
  int64_t ans1 = 0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    ans1 += abs(A[i] - A[i-1]);
  }
  ans1 += abs(A[N+1]-A[N]);
  for(int i=1;i<=N;i++){
    int64_t ans = ans1;
    ans -= abs(A[i]-A[i-1]) + abs(A[i+1]-A[i]);
    ans += abs(A[i+1] - A[i-1]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(x[k - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> w(n);
    int right = 0;
    rep(i,n) cin >> w[i], right += w[i];
    int left = 0;
    int ans = 1001001001;
    for(int t = 0; t < n; t++){
        right -= w[t];
        left += w[t];
        ans = min(ans, abs(right - left));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N), C;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  int ans = 0;
  ll y = 0;
  rep(i, N)
  {
    int a = A[i] - B[i];
    if (a > 0)
      C.push_back(a);
    else if (a < 0)
    {
      ans++;
      y -= a;
    }
  }
  if (y == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(C.begin(), C.end(), greater<int>());
  rep(i, C.size())
  {
    y -= C[i];
    if (y <= 0)
    {
      ans += i + 1;
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;;
//我好菜啊（题题看题解）神仙结论https://img.atcoder.jp/agc032/editorial.pdf 
int a[maxn],n,m;
vector<int> edge[maxn];
int x,y,deg[maxn];
void dfs(int be,int u,int fa){
	for(auto v:edge[u]){
		if(v!=fa&&v!=y){
			if(v==be){puts("Yes");exit(0);}
			dfs(be,v,u);
		}
	}
}
int main(){
	n = read(),m = read();
	Rep(i,1,m){
		x=read(),y=read();
		edge[x].push_back(y);edge[y].push_back(x);
		deg[x]++,deg[y]++;
	}Rep(i,1,n)if(deg[i]&1){puts("No");return 0;}
	x=0;Rep(i,1,n)if(deg[i]>=6){puts("Yes");return 0;} else x+=deg[i]==4;
	if(x>=3){puts("Yes");return 0;}
	if(x<=1){puts("No");return 0;}
	x=0,y=0;
	Rep(i,1,n)if(deg[i]==4){if(x)y=i;else x=i;}
	dfs(x,x,-1);
	puts("No");
	return 0;
}
/*
wzporz 
zzdorz
clyorz
lyxorz
cljorz
zxorz
sxdorz
yzrorz
ykorz  ...9 people
qyorz ...9 people
Emmmmm这TM还想进省队，我是找死吗？
现实：小官人，该醒醒了，你文化课凉地很呀 
 
我有一个梦想
I have a dream.
	//I'd like to get AU in NOI
	//当然，我从来没有过上面这样的不切实际的幻想
	//Ofcourse,not such unrealistic dream.
我的梦想还是比较现实的，应该是
My dream is still more realistic, it should be
有学上 
I want to go to university.

啊，普爱的耶和华呀
啊，可敬的玉皇大帝呀
啊，慈悲的如来佛祖呀
啊，无上的元始天尊呀 
赐予我力量吧 
*/ 

Measured memory_bytes: 10240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main(){
	IOS;
	int n,x;cin>>n>>x;
	vector<int> l(n);
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	int d=l[0];
	int cnt=1;
	for(int i=1;i<n;i++){
		if(d<=x)
			cnt++;
		d+=l[i];
	}
	if(d<=x)cnt++;
	cout<<cnt;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 892
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a*b % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

H,W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    exit()

if H*W % 2 == 0:
    print(H*W // 2)
else:
    print((H*W+1) // 2) 

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
#define MAXN 100000
const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  int a[MAXN];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int c[3] = {}, ans = 1;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = 0; j < 3; j++) {
      if (a[i] == c[j]) {
        if (count == 0) c[j]++;
        count++;
      }
    }
    ans = 1LL * ans * count % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
<?php
$s = trim(fgets(STDIN));
$i = strlen($s);
$a = "";
$b = "";

while ($i > 1) {
  $i = $i - 1;

  if ($i % 2 === 1) {
    continue;
  }

  $a = substr($s, 0, $i / 2);
  $b = substr($s, $i / 2, $i / 2);

  if ($a === $b) {
    echo strlen($a) * 2 . "\n";
    return;
  }
}

echo 0 . "\n";

Measured memory_bytes: 4604
import java.util.*;
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int K = sc.nextInt();
    sc.nextLine();
    String S = sc.nextLine();
    if(K>=S.length()){
      System.out.println(S);
    }else{
      S = S.substring(0, K);
      System.out.println(S + "...");
    }
  }
}

Measured memory_bytes: 38684
// A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<stdio.h> 
#include<bits/stdc++.h>
using namespace std;
// A utility function that returns maximum of two integers 
long long  max(long long a, long long b) { return (a > b)? a : b; } 

// Returns the maximum value that can be put in a knapsack of capacity W 
long long knapSack(long long W, long long wt[], long long val[], long long n) 
{ 
long long i, w; 
long long K[n+1][W+1]; 

// Build table K[][] in bottom up manner 
for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 
int main() 
{  
	long long n,W;
    cin>>n>>W;
    long long val[n];
	long long wt[n];
    for(long long i=0;i<n;i++)
        cin>>wt[i]>>val[i];
	printf("%lld", knapSack(W, wt, val, n)); 
	return 0; 
} 


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

int main() {
  int n , k;
  cin >> n >> k;
  
  int a = 1;
  for (int i = 0; i < n; i++) {
    if (k < a) {
      a += k;
    } else {
      a *= 2;
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;

char ch[N];
char a[N];
char b[N];
int cnta, cntb;
bool rev;
signed main() {
	cin >> ch + 1;
	int n = strlen(ch + 1);
	int q;
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int op;
		cin >> op;
		if (op == 1) {
			rev = !rev;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (rev) {
				f = 3 - f;
			}
			if (f == 1) {
				a[++cnta] = c;
			}
			else {
				b[++cntb] = c;
			}
		}
	}

	if (rev) {
		for (int i = cntb; i >= 1; i--) {
			cout << b[i];
		}
		for (int i = n; i >= 1; i--) {
			cout << ch[i];
		}
		for (int i = 1; i <= cnta; i++) {
			cout << a[i];
		}
	}
	else {
		for (int i = cnta; i >= 1; i--) {
			cout << a[i];
		}
		for (int i = 1; i <= n; i++) {
			cout << ch[i];
		}
		for (int i = 1; i <= cntb; i++) {
			cout << b[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
let partition (a : int array) p r =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let i = ref p in
  for j = p to r - 1 do
    if a.(j) <= a.(r) then begin
      swap !i j;
      incr i;
    end
  done;
  swap !i r;
  !i

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri
    (fun i e ->
      if i = 0 then print_int e
      else if i = k then (print_string " ["; print_int e; print_string "]")
      else (print_string " "; print_int e))
    a;
  print_newline ()

Measured memory_bytes: 5364
import bisect,collections,copy,heapq,itertools,math,string
import sys
from decimal import Decimal
def S(): return sys.stdin.readline().rstrip()
def M(): return map(Decimal,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
ab = a*b
print(math.floor(ab))


Measured memory_bytes: 73096
#template
def inputlist(): return [int(k) for k in input().split()]
#template

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())
if N == 1:
    print(0)
    exit()
dp = [[0]*101 for _ in range(N+1)]
for i in range(2,N+1):
    li = factorization(i)
    n = len(li)
    li0 = [0]*n
    li1 = {}
    for k in range(n):
        li0[k] = li[k][0]
        li1[li[k][0]] = li[k][1]
    for j in range(2,101):
        if j in li0:
            dp[i][j] = dp[i-1][j] + li1[j]
            continue
        dp[i][j] = dp[i-1][j]

li = dp[N]
li.sort()
from bisect import bisect_right
indexa = bisect_right(li,0)
lia = li[indexa:]

na = len(lia)
c2 = 0
c4 = 0
c14 = 0
c24 = 0
c74 = 0
for i in range(na):
    if lia[i] >= 2:
        c2+=1
    if lia[i] >= 4:
        c4+=1
    if lia[i] >= 14:
        c14 +=1
    if lia[i] >= 24:
        c24+=1
    if lia[i] >= 74:
        c74+=1
d4_2 = c2-c4
d14_4 = c4 - c14
d24_2 = c2 - c24

def comb2(i):
    return i*(i-1)//2
def comb3(i):
    return i*(i-1)*(i-2)//6

ans = d4_2*comb2(c4) + 3*comb3(c4) + d14_4*c14 + 2*comb2(c14) + d24_2*c24 + 2*comb2(c24) +c74
print(ans)

Measured memory_bytes: 3316
n = int(input())
info = []
for i in range(n):
    x,y,h = map(int,input().split())
    info.append((x,y,h))
info.sort(key=lambda x:x[2], reverse=True)

for i in range(0,101):
    for j in range(0,101):
        crt_h = info[0][2] + abs(info[0][0]-i) + abs(info[0][1]-j)
        flag = True
        for k in range(1, n):
            tar_x = info[k][0]
            tar_y = info[k][1]
            tar_h = info[k][2]
            H = tar_h + abs(tar_x - i) + abs(tar_y - j)
            if tar_h != 0:
                if H != crt_h:
                    flag = False
            else:
                if crt_h > H:
                    flag = False
        if flag:
            print(i,j,crt_h)






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

using namespace std;

int main(){
    int n,sum = 0;
    cin >> n;

    vector<int>v(n);
    vector<int>c(n);

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

    for(int i = 0;i < n;i++){
        int n;
        cin >> n;
        c[i] = v[i] - n;
        sum += c[i];
    }

    for(int i = 0;i < n;i++){
        if(c[i] < 0) sum -= c[i];
    }

    cout << sum << endl;


    return 0;
}

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

using namespace std;

int N;
int A;
int rem;

int main()
{
	scanf("%d %d", &N, &A);

	rem = N % 500;
	if(rem <= A)
	{
		printf("Yes\n");
	}	
	else
	{
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int r; cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
grid =[]
for i in range(2):
    grid.append(list(map(int, input().split())))

candies = []
for i in range(N):
    num = sum(grid[0][:i + 1]) + sum(grid[1][i:])
    candies.append(num)

# print(grid)
print(max(candies))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	int ans=0;
	while(a[1]+2<=a[2]) a[1]+=2,ans++;
	while(a[0]+2<=a[2]) a[0]+=2,ans++;
	int k1=a[1]==a[2],k2=a[0]==a[2];
	if(k1==0&&k2==0) ans++;
	else if(k1^k2) ans+=2;
	cout<<ans;
	return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=1e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, k, ans, res[maxn];

int binpow(int a, int n)
{
	int res = 1;
	while(n)
	{
		if(n&1)
		{
			res *= a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		n/=2;
	}
	return res;
}

main()
{
	cin >> n >> k;
	nfor(1, g, k)
	{
		res[g] = binpow(k / g, n);
		for(int i = 2; g*i <= k; i++)
		{
			res[g] -= res[g*i];
			res[g] %= mod;
			res[g] += mod;
			res[g] %= mod;
		}
		ans += res[g] * g % mod;
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 4332
#include<stdio.h>
	int main(void)
{
	int a=0,n,x,t,i;
	scanf("%d%d%d",&n,&x,&t);
	for(i=0;i<n;i+=x){
		a+=t;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 1724
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] red = new int[n][2];
		int[][] blue = new int[n][2];
		for(int i = 0; i <n; i++) for(int j = 0; j<2; j++) red[i][j] = sc.nextInt();
		for(int i = 0; i <n; i++) for(int j = 0; j<2; j++) blue[i][j] = sc.nextInt();
		Arrays.sort(red,(array1, array2) -> array1[1] - array2[1]);
		Arrays.sort(blue, (array1, array2) -> array1[0] - array2[0]);
//		for(int[] a : red) System.out.println(a[0] +", " + a[1]);
//		for(int[] a : blue) System.out.println(a[0] + ", " + a[1]);
		Set<Integer> usedSet = new HashSet<>();
		for(int[] b : blue){
			int max = -1;
			for(int i = 0; i < red.length; i++){
				if(usedSet.contains(i) || red[i][0] >= b[0]) continue;
				if(red[i][1] >= b[1]) break;
				if(max == -1 || red[max][1] < red[i][1]) max = i;
			}
			if(max != -1) usedSet.add(max);
		}
		System.out.println(usedSet.size());
	}
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ans += n/11*2;
    if(n%11 != 0) ans += (n%11-1)/6 + 1;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    vector<int> v(3);
    int ans = 301;

    for (int i = 0; i < 3; i++)
    {
        cin >> v[i];
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = i+1; j < 3; j++)
        {
            if(v[i]+v[j]<ans){
                ans = v[i]+v[j];
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std ;
int sumDigit(int n){
   int sum =0 ;
   while(n!=0){
      sum+=n%10 ;
      n/=10 ;
   }
   return sum ;

}

int main(){
 int n ; cin >> n ;
 if(n%sumDigit(n)==0 ){
    cout<<"Yes" ;

 }
 else
 cout<<"No";


return 0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] ps = new int[N];
        for (int i = 0; i < N; i++) {
            ps[i] = sc.nextInt();
        }
        Path[] paths = new Path[M];
        for (int i = 0; i < M; i++) {
            paths[i] = new Path(sc.nextInt(), sc.nextInt());
        }

        System.out.println( solve(N, M, ps, paths) );
    }

    private static int solve(int N, int M, int[] ps, Path[] paths) {
        UnionFind uf = new UnionFind(N);
        for (Path path : paths) {
            uf.unite(path.x, path.y);
        }

        int result = 0;
        for (int i = 1; i <= N; i++) {
            int p = ps[i - 1];

            if( i == p || uf.isSame(i, p) ) {
                result++;
            }
        }
        return result;
    }

    // Union-Find
    // 1-origin
    private static class UnionFind {
        private final int[] par;

        public UnionFind(int size) {
            par = new int[size + 1];
            for (int i = 1; i <= size; i++) {
                par[i] = i;
            }
        }

        public int root(int n) {
            if( par[n] == n ) {
                return n;
            } else {
                par[n] = root(par[n]);
                return par[n];
            }
        }

        public void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if( rx == ry ) return;

            par[rx] = ry;
        }

        public boolean isSame(int x, int y) {
            return root(x) == root(y);
        }
    }

    private static void show(int[] array) {
        StringJoiner j = new StringJoiner(" ");
        for (int i : array) {
            j.add("" + i);
        }
        System.err.println(j.toString());
    }

    static class Path {
        final int x;
        final int y;

        public Path(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 90436
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};


int main() {
	int n, m; cin >> n >> m;
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int s, t; cin >> s >> t;
		s--; t--;
		uf.unite(s, t);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4060
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll a= -1,z=0;
	string S;
	cin >> S;
	rep(i, S.size()) {
		if (S.at(i) == 'A'&& a==-1) {
		
			a = i;
			
		}
		else if(S.at(i)=='Z'){
			z = i;
		}
	}
	
	cout << z-a +1<< endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  ll w_min = inf;
  ll w_max = -inf;
  ll z_min = inf;
  ll z_max = -inf;
  
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    ll z = x - y;
    ll w = x + y;
    w_min = min(w_min,w);
    w_max = max(w_max,w);
    z_min = min(z_min,z);
    z_max = max(z_max,z);
  }
  cout << max(z_max-z_min, w_max-w_min) << endl;
}


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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	 cin>>n;

	 ll a=1000-n%1000;

	 if(n%1000==0)
	 	cout<<0<<"\n";
	 else
	 	cout<<a<<"\n";
	return 0;
}

Measured memory_bytes: 3640
import numpy as np


def f(nc, nt, nq):
    t = [list(map(int, input().split())) for _ in range(nt)]
    q = [list(map(int, input().split())) for _ in range(nq)]
    dp = np.zeros((nc + 1, nc + 1), dtype="i8")
    for l, r in t:
        dp[l][r] += 1
    dp = np.cumsum(np.cumsum(dp, axis=0), axis=1)
    for l, r in q:
        print(dp[r][r] - dp[l - 1][r] - dp[r][l - 1] + dp[l - 1][l - 1])


nc, nt, nq = map(int, input().split())
f(nc, nt, nq)


Measured memory_bytes: 81304
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 
 
 
int main()
{
    long long int n,m,k;
    cin>>n>>m>>k;
    vector<long long int>a(n),prefa(n);
    vector<long long int>b(m),prefb(m);
    
    long long int sum1 = 0, sum2 = 0,maxm = 0;
    
    for(long long int i=0;i<n;i=i+1){cin>>a[i];sum1=sum1+a[i];prefa[i]=sum1;}
    for(long long int i=0;i<m;i=i+1){cin>>b[i];sum2=sum2+b[i];prefb[i]=sum2;}
    
    if(k>=prefa[n-1] + prefb[m-1])cout<<m+n<<endl;
    
    else
    {
        for(long long int i=0;i<m;i=i+1)
        {
            long long int k1 = k - prefb[i];
            if(k1<0){break;}
            else if(k1==0){maxm=max(maxm,i+1);break;}
            long long int lower = upper_bound(prefa.begin(),prefa.end(),k1)-prefa.begin();
            if(lower==n){lower=lower-1;}
            maxm = max(maxm,i+lower+1);
        }
        
        for(long long int i=0;i<n;i=i+1)
        {
            
            long long int k1 = k - prefa[i];
            if(k1<0){break;}
            else if(k1==0){maxm=max(maxm,i+1);break;}
            long long int lower = upper_bound(prefb.begin(),prefb.end(),k1)-prefb.begin();
            if(lower==m){lower=lower-1;}
            maxm = max(maxm,i+lower+1);
        }
        
        cout<<maxm<<endl;
    }
    
   
   
    
}


 


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

using ll = long long;
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;


string S;
string ans = "Yes";

int main()
{
	cin >> S;
	rep(i, S.length())
	{
		if (!(i % 2) && S[i] == 'L')
		{
			ans = "No";
		}
		else if (i % 2 && S[i] == 'R')
		{
			ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

ll k;
vvi G;
ll ans = 1LL;

void dfs(int v = 0, int p = -1, ll col = k){
  ans *= col;
  ans %= MOD;

  ll cnt;
  if(v == 0) cnt = k-1;
  else cnt = k-2;
  for(auto nv : G[v]) {
    if(nv == p) continue;
    dfs(nv, v, cnt);
    cnt--;
  }
}

int main(){
  int n; cin >> n >> k;
  G.resize(n);
  rep(i,n-1) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b); G[b].pb(a);
  }

  dfs();

  cout << ans << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    int N; cin >> N;
    vei t(N);
    rep(i,N) cin >> t[i];
    int M; cin >> M;
    vei p(M), x(M);
    rep(i,M) cin >> p[i] >> x[i];

    rep(i,M){
        int sum = 0;
        rep(j,N){
            if((p[i]-1) == j) sum += x[i];
            else sum += t[j]; 
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;
int INF=1<<29;

//約数の全列挙
vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i); //計算量を減らすため
        }
    }
    sort(res.begin(),res.end());
    return res;
}

int main(){
	ios::sync_with_stdio(false);
	ll N,Ans=0;
	cin>>N;
	vector<ll> arr=divisor(N);
	for(int i=0;i<arr.size();i++){
		if((arr[i]/N)>=N) arr[i]=0;
		if(arr[i]<0) arr[i]=0;
	}
	for(int i=0;i<arr.size();i++) arr[i]--;
	for(int i=0;i<arr.size();i++){
		if(arr[i]<=0) continue;
		if(N/arr[i]==N%arr[i]) Ans+=arr[i];
	}
	cout<<Ans<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i=0 ; i<n ; i++)
    cin >> h.at(i);
  
  int ans = 1;
  for (int i=1 ; i<n ; i++){
    int a = 1;
    for (int j=0 ; j<i ; j++){
      if (h.at(j) > h.at(i)){
        a = 0;
        break;
      }
    }
    if (a == 0)
      continue;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
N = int(input())
x,y = map(int,input().split(" "))
papb = [x,y]
pamb = [x,y]
mapb = [x,y]
mamb = [x,y]
for i in range(N - 1):
    x,y = map(int,input().split(" "))
    if x + y > papb[0] + papb[1]:papb = [x,y]
    if x - y > pamb[0] - pamb[1]:pamb = [x,y]
    if 0 - x + y > 0 - mapb[0] + mapb[1]:mapb = [x,y]
    if 0 - x - y > 0 - mamb[0] - mamb[1]:mamb = [x,y]
print(max(abs(papb[0] - mamb[0]) + abs(papb[1] - mamb[1]),abs(pamb[0] - mapb[0]) + abs(pamb[1] - mapb[1])))

Measured memory_bytes: 71464
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,y
else:
  print('Yes')
  

Measured memory_bytes: 3060