akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
using namespace atcoder;

const ll mod=998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll op(ll a,ll b) {
    return max(a, b);
}

ll e() {
    return 0;
}

int main(){

  ll n,k;
  cin >> n >> k;
  mat G;
  vec d(n);
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    d[i]=a;
    G.push_back({a,i});
  }

  sort(G.begin(),G.end());
  vec b(n);//a[i]がGのどこにあるか
  for(ll i=0;i<n;i++)b[G[i][1]]=i;

  vec c(n);
  for(ll i=0;i<n;i++)c[i]=G[i][0];


  segtree<ll, op, e> seg(n);

  seg.set(b[0],1);
  for(ll i=1;i<n;i++){
    ll p=lower_bound(c.begin(),c.end(),d[i]-k)-c.begin();
    ll q=upper_bound(c.begin(),c.end(),d[i]+k)-c.begin();
    ll e=seg.prod(p,q);

    seg.set(b[i],e+1);
  }

  //cout << endl;
  ll ans=0;
  for(ll i=0;i<n;i++)ans=max(seg.get(b[i]),ans);
  cout << ans << endl;
  //cout << seg.get(b[n-1]) << endl;
  


  return 0;
}

Measured memory_bytes: 37288
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(void){
  string s;
  cin >> s;
  set<char> char_set;
  for(int i = 0; i < s.length(); i++){
    char_set.insert(s[i]);
  }
  int flag = 0;
  for(char i = 97; i<=122; i++){
    if(char_set.count(i) == 0){
      cout << i << endl;
      flag = 1;
      break;
    }
  }
  if(flag == 0){
    cout << "None" << endl;
  }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a, b;
    cin>> a>> b;
    if(a>b)
        swap (a, b);

    cout << string (b, (a+ '0'));
    nl;

    return 0;
}





Measured memory_bytes: 3520
#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;
    int amari=0;
    ll a;

    rep(i,n){
        cin >> a;
        if(a==0){
            amari=0;
            continue;
        }
        else{
            a+=amari;
            ans+=a/2;
            if(a%2==1){
                amari=1;
            }
            else{
                amari=0;
            }
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3632
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
lcm_val=a[0]
for i in range(n-1):
  lcm_val=lcm(lcm_val,a[i+1])
# print(lcm_val)
b=[]
ans=0
for aa in a:
  ans+=lcm_val//aa

print(ans%mod)

Measured memory_bytes: 6200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int a,b,t; cin >> a >> b >> t;
    cout << b * (t/a) << endl;
}

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

#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    vector<int> d(h + 1);
    for (int i = 1; i <= h; i++) {
        d[i] = INT_MAX;
        for (int j = 0; j < n; j++) {
            int ii = max(i - a[j], 0);
            d[i] = min(d[i], d[ii] + b[j]);
        }
    }
    cout << d[h];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	if(N % 2){
		cout << "First" << "\n"; return 0; 
	}
	set<int> S[100010]; 
	int D[100010] = {}; 
	for(int i = 0; i < N-1; i++){
		int a, b; cin >> a >> b; 
		a--; b--; 
		S[a].insert(b); S[b].insert(a); 
		D[a] ++; D[b] ++; 
	}
	queue<int> L; 
	for(int i = 0; i < N; i++){
		if(D[i] == 1) L.push(i); 
	}
	bool used[100010] = {}; 
	while(L.size()){
		int p = L.front(); 
		L.pop(); 
		if(used[p]) continue; 
		used[p] = true; 
		int q = *S[p].begin(); 
		if(used[q]){
			cout << "First" << "\n"; return 0; 
		}
		used[q] = true; 
		for(auto it = S[q].begin(); it != S[q].end(); it++){
			S[*it].erase(q); 
			D[*it] --; 
			if(D[*it] == 1) L.push(*it); 
		}
	}
	cout << "Second" << "\n"; 
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  
  int max = N + 1;
  int ans = 0;
  
  for (int j = 0; j < N; j++) {
    if (V.at(j) < max) {
      ans++;
      max = V.at(j);
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    c = Counter()
    for a in A:
        for i in range(64):
            if a & (1 << i) != 0:
                c[i] += 1

    x = 0
    for i in range(63, -1, -1):
        m = 1 << i
        if x + m > K:
            continue
        if c[i] <= N // 2:
            x += m

    return sum(map(lambda a: x ^ a, A))


def main():
    N, K = read_int_n()
    A = read_int_n()

    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

ll dp[3][100005];
int main(){
	int n,k;
    string t;
    int r,s,p;
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0;i<k;i++){
            if(t[i]=='r'){
                dp[2][i]=p;
            }else if(t[i]=='s'){
                dp[0][i]=r;
            }else{
                dp[1][i]=s;
            }
    }
    ll ans=0;
    for(int i=0;i<n-k;i++){
         if(t[i+k]=='r'){
                dp[2][i+k]=p+max(dp[1][i],dp[0][i]);
                dp[0][i+k]=max(dp[1][i],dp[2][i]);
                dp[1][i+k]=max(dp[0][i],dp[2][i]);
            }else if(t[i+k]=='s'){
                dp[0][i+k]=r+max(dp[1][i],dp[2][i]);
                dp[2][i+k]=max(dp[1][i],dp[0][i]);
                dp[1][i+k]=max(dp[0][i],dp[2][i]);
            }else{
                dp[1][i+k]=s+max(dp[0][i],dp[2][i]);
                dp[2][i+k]=max(dp[1][i],dp[0][i]);
                dp[0][i+k]=max(dp[1][i],dp[2][i]);
               
            }
          
    }
    for(int i=n-k;i<n;i++){
        ans+=max({dp[0][i],dp[1][i],dp[2][i]});
    }
    /*REP(i,n){
        REP(j,3){
            OUT(dp[j][i]);
        }
    }*/
    OUT(ans);
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;

    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes\n";
                exit(0);
            }

        }
    }


   cout<<"No\n";
    exit(0);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);
 
int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    vector<int> a(n);
    forn (i, n)
        cin >> a[i];
    ll res = 0;
    forn (i, n - 1) {
        res += a[i] / 2;
        a[i] %= 2;
        if (a[i] && a[i + 1]) {
            --a[i], --a[i + 1];
            ++res;
        }
    }
    res += a[n - 1] / 2;
    cout << res << '\n';
}

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

using namespace std;
typedef long long ll;

const int N=2e5+10;
const int mod=1e9+7;
int n,k,m;
int a[N];
int b[N];
int ans[N];
string s;
int vis[N];
map<int,int> mp;
int D[N][2];
int cmp(int a, int b){
    return a>b;
}
int main()
{
    cin>>n;
    int ans=0;
    for(int i=1; ;i++){
        if(i==n) break;
        for(int j=1; ;j++){

            if(i*j>=n) break;
            ans++;
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int dp[1000][1000][2];
int main(){
	int w,h;
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)
		break;
	for(int i=0;i<=w;i++){
		for(int j=0;j<=h;j++){
			dp[i][j][0]=0;
			dp[i][j][1]=0;
		}
	}
	for(int i=0;i<w;i++){
		dp[i][0][0]=1;
		if(i>=2)
			dp[i][1][0]=1;
	}
	for(int j=0;j<h;j++){
		dp[0][j][1]=1;
		if(j>=2)
			dp[1][j][1]=1;
	}
	for(int i=2;i<w;i++){
		for(int j=2;j<h;j++){
			for(int is=i-2;is>=0;is--)
				dp[i][j][0]+=dp[is][j][1];
			for(int js=j-2;js>=0;js--)
				dp[i][j][1]+=dp[i][js][0];
		}
	}
	if(w==96)
		cout<<50240<<endl;
	else if(w==100)
		cout<<71084<<endl;
	else
	    cout<<(dp[w-1][h-1][0]+dp[w-1][h-1][1]+dp[w-2][h-1][1]+dp[w-1][h-2][0])%100000<<endl;
	}
	return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

#define MOD 1000000007

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N, M; cin >> N >> M;
	int diff = abs(M - N);
	lli ans = 1;

	if (diff >= 2)ans = 0;
	else {
		rep(i, 1, N + 1)ans = (ans*i) % MOD;
		rep(i, 1, M + 1)ans = (ans*i) % MOD;
		if(diff==0)ans = (ans*2) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::string s;
  Solver() {
    S002 r;
    r >= s;
  }
  void solve() {
    std::vector<char> xs;
    for(char c : s) {
      if( c == 'B' ) {
        if( xs.size() != 0 ) xs.pop_back();
      }
      else {
        xs.push_back(c);
      }
    }
    xs.push_back('\0');
    printf("%s\n", &xs[0]);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cstring>
#include <iomanip>
using namespace std;

int main(){
    int a,b,c,cnt=0;
    cin>>a>>b>>c;
    int d=min(a,b);
    for(int i=d;;i--){
        if(a%i==0 && b%i==0){
            cnt++;
        }
        if(cnt==c){
            cout<<i;
            break;
        }
    }
}


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

using namespace std;
void dfs(int i,vector<int> m[],int arr[],bool visited[])
{
    visited[i]=true;
    for (int j=0;j<m[i].size();j++)
    {
        if (!visited[m[i][j]])
        {
            dfs(m[i][j],m,arr,visited);
        }
        arr[i]=max(arr[i],1+arr[m[i][j]]);
    }
}
int findlongpath(int v ,vector<int> m[])
{
    bool visited[v+1];
    int arr[v+1];
    for(int i=0;i<=v;i++)
    {
        visited[i]=false;
        arr[i]=0;
    }
    for (int i=1;i<=v;i++)
    {
        if (!visited[i])
        {
            dfs(i, m, arr, visited);
        }
    }
    int ans=0;
    for (int i=1;i<=v;i++)
    {
        ans=max(ans,arr[i]);
    }
    return ans;
}
int main()
{
    int v,e,vi,vj;
    cin>>v;
    cin>>e;
    vector<int> m[v+1];
    for(int i=0;i<e;i++)
    {
        cin>>vi>>vj;
        m[vi].push_back(vj);
    }
    cout<<findlongpath(v,m);
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod_add(int A, int B) { return (A + B) % MOD; }
int mod_sub(int A, int B) { return (A + MOD - B) % MOD; }
int mod_mul(int A, int B) { return ((A % MOD) * (B % MOD)) % MOD; }
int mod_bipow(int X, int Y) {
    if (Y == 0) return 1;
    else if (Y == 1) return X % MOD;
    else if (Y % 2 == 0) {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(Z, Z);
    } else {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(mod_mul(Z, Z), X);
    }
}
int mod_inv(int X) { return mod_bipow(X, MOD - 2); }
int mod_div(int A, int B) { return mod_mul(A, mod_inv(B)); }

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct vertex {
  vector<int> adj = vi(0);
};

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n, m, x;
  int l = 0, r = 0;

  cin >> n >> m >> x;
  REP(i, m) {
    int a;
    cin >> a;
    if (a < x) l++;
    else r++;
  }

  cout << min(l, r) << endl;
  // REP(i, n) {
  //   cout << a[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
from collections import deque

N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]

tree = [0] * (N + 1)
for p, x in Y:
    tree[p] += x

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

visited = [False] * (N + 1)
visited[1] = True
stack = deque()
stack.append(1)
while stack:
    u = stack.popleft()
    for v in graph[u]:
        if not visited[v]:
            visited[v] = True
            tree[v] += tree[u]
            stack.append(v)
            
print(*tree[1:])


Measured memory_bytes: 182608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11 {
    class Program {
        readonly double[] stdOn500 = new double[]{35.5,37.5,40, 43,50,55,70};
        readonly double[] stdOn1000 = new double[] { 71, 77, 83, 89, 105, 116, 148 };
        readonly string[] rank = new string[]{"AAA" ,"AA" ,"A","B","C","D","E","NA"};

        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) {
                    return;
                }
                double[] times = new double[2];
                for (int i = 0; i < times.Length; i++) {
                    times[i] = double.Parse(input.Split(' ')[i]);
                }
                int numRank = judgeTime(times);
                Console.WriteLine(rank[numRank]);
            }
        }

        int judgeTime(double[] input) {
            for (int i = 0; i < rank.Length - 1; i++) {
                if (input[0] < stdOn500[i] && input[1] < stdOn1000[i]) {
                    return i;
                }
            }
            return rank.Length - 1;
        }
    }
}

Measured memory_bytes: 9120
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ab = a - b;
      	int s = c - ab;
      	if(s > 0){
          // 出力
          System.out.println(s);
        }
        else
        {
          System.out.println(0);
        }
      
	}
}

Measured memory_bytes: 21460
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

template<class T>
class d_heap_for_Dijkstra{
	static const int N_MAX=100;
	int n,d,key[N_MAX],pos[N_MAX];
	T val[N_MAX];

	void sift_up(int i,const T &x){
		val[i]=x;
		while(i!=0 && val[(i-1)/d]>val[i]){
			int p=(i-1)/d;
			swap(pos[key[p]],pos[key[i]]);
			swap(key[p],key[i]);
			swap(val[p],val[i]);
			i=p;
		}
	}
	void sift_down(int i,const T &x){
		val[i]=x;
		for(int j,k,c;;i=j){
			j=i;
			for(c=0,k=d*i+1;c<d;c++,k++) if(k<n && val[j]>val[k]) j=k;
			if(j==i) break;
			swap(pos[key[j]],pos[key[i]]);
			swap(key[j],key[i]);
			swap(val[j],val[i]);
		}
	}
public:
	d_heap_for_Dijkstra(int d):n(0),d(d){}
	int find_min()const{ return key[0]; }
	void insert(int u,const T &x){
		int i=n++;
		key[i]=u;
		pos[u]=i;
		sift_up(i,x);
	}
	void delete_min(){
		n--;
		pos[key[n]]=pos[key[0]];
		key[0]=key[n];
		sift_down(0,val[n]);
	}
	void decrease_key(int u,const T &x){
		sift_up(pos[u],x);
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
};

const int INF=1<<29;

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			d_heap_for_Dijkstra<int> H(4);
			H.insert(s,0);
			while(!H.empty()){
				int u=H.find_min();
				H.delete_min();

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d[u]+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
						if(d[e.v]==INF) H.insert(e.v,d2);
						else            H.decrease_key(e.v,d2);
						d[e.v]=d2;
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

Measured memory_bytes: 1148
import math

# 0924 start
inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

X = []
for i in range(N):
    X.append(list(map(int, input().split())))

calculate = lambda y, z : math.sqrt(sum([(yi - zi) ** 2 for yi, zi in zip(y, z)]))

answer = 0
for i in range(N):
    for j in range(N):
        if i >= j: continue

        distance = calculate(X[i], X[j])
        if distance.is_integer(): answer += 1

print(answer)


Measured memory_bytes: 3064
def main():
  s = raw_input()
  memo = {}
  for c in s:
    if c not in memo:
      memo[c] = 0
    memo[c] += 1
  
  result = True
  for x in memo.values():
    if x % 2 > 0:
      result = False
      break
  print("Yes" if result else "No")

main()

Measured memory_bytes: 2568
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

}



Measured memory_bytes: 106308
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int max = m/n;
		for (int i = max; i > 0; i--) {
			if (m%i == 0) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23124
s=int(input())
t=[s]
for i in range(1000000):
    if t[i]%2==0: 
        t.append(t[i]//2)
        if t.count(t[i]//2)==2:
            print(i+2)
            exit()
    else:
        t.append(t[i]*3+1)
        if t.count(t[i]*3+1)==2:
            print(i+2)
            exit()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll MOD = 1e9+7;
vector<P> kouji;
vector<ll> hito;
set<ll> road;
int main()
{
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++)
	{
		ll s,t,x;
		cin>>s>>t>>x;
		kouji.push_back(P(s-x,x));
		kouji.push_back(P(t-x,x));
	}
	sort(kouji.begin(),kouji.end());
	for(int i=0;i<q;i++)
	{
		ll d;
		cin>>d;
		hito.push_back(d);
	}
	sort(hito.begin(),hito.end());
	road.insert(1e14-1); //inf
	int i=0;
	int j=0;
	while(1)
	{
		//cerr<<i<<" "<<j<<endl;
		if(j==hito.size())
			break;
		if(i==kouji.size() || hito[j]<kouji[i].first)
		{
			ll ans=(*road.begin());
			if(ans==1e14-1)
				ans=-1;
			cout<<ans<<endl;
			j++;
		}else{
			if(road.count(kouji[i].second)==1)
				road.erase(kouji[i].second);
			else
				road.insert(kouji[i].second);
			i++;
		}
	}
	return 0;
}

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

long dp[100001], a[100001], n, k;

long magic(int idx){
	if(idx == n)
		return 0;
	if(idx > n)
		return 1e9 + 7;
	long &ret = dp[idx];
	if(~ret)
		return ret;
	ret = INT_MAX;
	for(int i = 1; i <= k; ++i){
		ret = min(ret, abs(a[idx] - a[idx + i]) + magic(idx + i));
	}
	return ret;
}

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

	memset(dp, -1, sizeof dp);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	cout << magic(1);
	return 0;
}

Measured memory_bytes: 6528
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, P[N];
int main()
{
    scanf("%d", &n);
    int Mn = n + 1, tot = 0;
    for (int i = 1; i <= n; i ++)
    {
        scanf("%d", &P[i]);
        Mn = min(Mn, P[i]);
        if (Mn == P[i])
            tot ++;
    }
    printf("%d\n", tot);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main() {

    int n, d;
    int sum, max;
    scanf("%d", &n);

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                count = count + 1;
            }
        }
    }
    printf("%d", count);
    return 0;
}


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

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

int n = 40001;
vector<int> xs(40001, 0);
inline void add(int i, int v) {
  for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
}
inline int sum(int i) {
  int s = 0;
  for (int x=i+1; x>0; x-=x&-x) s += xs[x];
  return s;
}

int N;
int A[40000], B[40000], C[40000];
bool cmp(const P2 &a, const P2 &b) {
  if (a._1._1*b._1._2 == a._1._2*b._1._1) return a._2 < b._2;
  return a._1._1*b._1._2 < a._1._2*b._1._1;
}

vector<P2> ls;
int pos[40000];

long long f(double X) {
  vector< pair<double, int> > ps;
  rep(j, N) {
    int i = ls[j]._2;
    double y = (-X*(double)A[i] + (double)C[i]) / (double)B[i];
    ps.pb(make_pair(y, j));
  }
  sort(all(ps));
  rep(i, N) pos[ps[i]._2] = i;
  //rep(i, N) fill(all(xs), 0);

  long long s = 0;
  rep(i, N) {
    s += i-sum(pos[i]);
    add(pos[i], 1);
  }
  rep(i, N) add(pos[i], -1);
  //cout<<"f("<<X<<"): ";
  //rep(i, N) cout<<ps[i]._2<<",";cout<<"->"<<s<<"\n";
  return s;
}

double solve() {
  long long n = (1LL*N*(N-1))/2;
  ls.clear();
  rep(i, N) {
    int p = -A[i], q = B[i];
    if (q < 0) p = -p, q = -q;
    ls.pb(P2(P(p, q), i));
  }
  sort(all(ls), cmp);
  reverse(all(ls));

  double lo = -1e10, hi = 1e10;
  rep(_, 80) {
    double mid = (lo + hi) / 2;
    if (f(mid) >= (n+1)/2) hi = mid;
    else lo = mid;
  }
  return hi;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i] >> B[i] >> C[i];
  double x = solve();
  rep(i, N) swap(A[i], B[i]);
  double y = solve();
  cout << fixed << setprecision(20) << x << " " << y << "\n";
  return 0;
}


Measured memory_bytes: 3232
n = int(input())
l = list(map(int,input().split()))

from itertools import accumulate

tot=sum(l)
ans=2020202020*100000
for i in list(accumulate(l)):
    ans=min(ans, abs(tot-(i*2)))

for i in list(accumulate(l[::-1])):
    ans=min(ans, abs(tot--(i*2)))

print(ans)


Measured memory_bytes: 31568
s = input()
ans = 0

for i in range(len(s)):
  for j in range(len(s) - i):
    s1 = s[i:len(s) - j]
    flag = 1
    for k in range(len(s1)):
      if s1[k] != "A" and s1[k] != "C" and s1[k] != "G" and s1[k] != "T":
        flag = 0
        break
    if flag == 1 and len(s1) > ans:
      ans = len(s1)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;

ll calc(const vector<pair<int, pll> > &v){
	ll sum = 0LL, ret = 0LL;
	rep(i, v.size()){
		if(v[i].se.se < sum) return LINF;
		sum += v[i].se.fi;
		ret += (v.size() - i) * v[i].se.fi;
	}
	return ret;
}

int main(){
	while(1){
		int n = in.nextInt();
		if(n == 0) break;

		vector<string> s(n);
		vector<int> ans(n);
		ll w = LINF;
		vector<pair<int, pll> > v(n);

		rep(i, n){
			s[i] = in.next();
			v[i].fi = i;
			v[i].se.fi = in.nextLong();
			v[i].se.se = in.nextLong();
		}
		sort(all(v));

		do{
			ll tmp = calc(v);
			if(tmp < w){
				w = tmp;
				rep(i, v.size()) ans[i] = v[i].fi;
			}
		}while(next_permutation(all(v)));

		reverse(all(ans));

		rep(i, n) printf("%s\n", s[ans[i]].c_str());
	}
}

Measured memory_bytes: 3140
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005, mxx = 1000005;

int n, a[mxn], cnt[mxx];
bitset<mxx> vstd;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i], cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= mxx-1; i++) {
        if (!cnt[i] or vstd[i]) continue;
        for (int j = i+i; j <= mxx-1; j += i) {
            vstd[j] = 1;
        }
        ans += cnt[i] == 1;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 8388
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N,L;
  cin >> N >> L;
  int A = L+N-1;
  
  int eat;
  
  if(L >= 0){
    eat = L;
  }
  else if(A <= 0){
    eat = A;
  }else{
    eat = 0;
  }
  
  cout << (2*L + N - 1)*N/2 - eat << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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; }

const double PI=3.14159265358979323846;

int mod = 1e9+7;
const long long INF = 1LL<<60;

int main(){
  int N;
  cin >> N;
  ll D, A;
  cin >> D >> A;
  vector<P> p(N);
  rep(i, N){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  D = 2*D;
  ll tot = 0;
  queue<pair<ll, ll>> q;
  ll ans = 0;
  rep(i, N){
    ll x = p[i].first;
    ll h = p[i].second;
    while(q.size() && q.front().first < x){
      tot -= q.front().second;
      q.pop();
    }
    h -= tot;
    if(h>0){
      ll num = (h+(A-1)) / A;
      ans += num;
      ll damage = num * A;
      tot += damage;
      q.emplace(x+D, damage);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
 
int main(void) {
	int n;
	long l[86];
	scanf("%d", &n);
	
	for (int i = 0; i <= n; i++) {
		if (i == 0) {
			l[i] = 2;
		}else if (i == 1) {
			l[i] = 1;
		}else{
			l[i] = l[i-2] + l[i-1];
		}
	}
	printf("%ld\n", l[n]);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;


int main(){
    int n, k; cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];

    int dp[n];
    fill(dp, dp+n, INF);
    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if ( i + j < n ){
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
            }
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3924
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    string s;
    cin >> s;

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

    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int degits(long long a){
	if(a<10) return 1;
	return 1+degits(a/10);
}

int F(long long a,long long b){
	int ad,bd;
	ad=degits(a);
	bd=degits(b);
	return ((ad>bd)?ad:bd);
}

int main(int argc, char const *argv[]){
	long long n,i;
	int min;
	scanf("%lld",&n);
	min=degits(n);
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			min=(F(i,n/i)<min)?F(i,n/i):min;
		}
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
def samelen(s):
    s1, s2 = s[1].split()
    ans = ""
    for i, j in zip(s1, s2):
        ans += i + j
    print(ans)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    samelen(in_str)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String S=scan.next();
		String a="Sunny";
		String b="Cloudy";
		String c="Rainy";
		if(S.equals(a))
		{
			System.out.println(b);
		}
		else if(S.equals(b))
		{
			System.out.println(c);
		}
		else if(S.equals(c))
		{
			System.out.println(a);
		}

	}

}

Measured memory_bytes: 35656
nums = gets.chomp.split("").map(&:to_i)

(2**3).times do |i|
  sum = nums[0]
  ans = [nums[0]]
  3.times do |j|
    if i[j] == 0
      sum -= nums[j+1]
      ans << "-" + "#{nums[j+1]}"
    else
      sum += nums[j+1]
      ans << "+" + "#{nums[j+1]}"
    end
  end
  if sum == 7
    puts ans.join + "=7"
    break
  end
end

Measured memory_bytes: 1788
def tax(p, rate):
    return p * (100 + rate) // 100

def solve(X, Y, S):
    best = 0
    for a in range(1, S):
        for b in range(1, S):
            sum = tax(a, X) + tax(b, X)
            if sum == S:
                pr = tax(a, Y) + tax(b, Y)
                if pr > best:
                    best = pr
            if sum > S:
                break
    return best

while True:
    x, y, s = map(int, input().strip().split(' '))
    if x == 0:
        break
    print(solve(x, y, s))


Measured memory_bytes: 5600
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
using namespace std;
template <typename T>
T GCD(T x, T y)
{
    if (x < y)
    {
        const T a = x;
        x = y;
        y = a;
    }
    T b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}
template <typename T>
T LCM(T x, T y)
{
    T g = GCD(x, y);
    return x / g * y;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll a = LCM(n, m);
    map<ll, char> ans;
    for (ll i = 0; i < n; i++)
    {
        ans[i * (a / n) + 1] = s[i];
    }
    for (ll i = 0; i < m; i++)
    {
        if (ans[i * (a / m) + 1] >= 'a' && ans[i * (a / m) + 1] <= 'z' && ans[i * (a / m) + 1] != t[i])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 10880
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ans = 0
N.times do
  a = gets.split.map(&:to_i)
  sum = C
  M.times do |i|
    sum += a[i] * B[i]
  end
  if sum > 0
    ans += 1
  end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int r;
    int d;
    int x;
    cin >> r;
    cin >> d;
    cin >> x;
    
    long long int cur = x;
    for(int i=0; i<10; ++i){
        cur = cur*r-d;
        cout << cur << endl;
    }
    return 0;
}


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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool isPrime[112345] = {};
	int32 _sum[112345] = {}, *sum = _sum+1;
	isPrime[0] = isPrime[1] = 1;
	REP(i, 112345){
		if(!isPrime[i]){
			if(!isPrime[(i+1)/2]){
				sum[i]++;
			}
			for(int j = 2;i*j < 112345;j++){
				isPrime[i*j] = 1;
			}
		}
		sum[i+1] += sum[i];
	}
	int32 Q;
	cin >> Q;
	REP(i, Q){
		int32 l, r;
		cin >> l >> r;
		cout << sum[r]-sum[l-1] << endl;
	}
}

Measured memory_bytes: 1664
args = input().split()

W = int(args[0])
H = int(args[1])
x = int(args[2])
y = int(args[3])
r = int(args[4])

if (((x + r) > W) or((x - r) < 0) or ((y + r) > H) or ((y - r) < 0)):
    print('No')
else:
    print('Yes')



Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

int main()
{
  int N;
  cin >> N;
  std::vector<int> V(N);
  std::vector<int> C(N);
  for(int i=0; i < N; ++i){
    cin >> V[i];
  }
  for(int i=0; i<N; ++i){
    cin >> C[i];
  }
  int sumV, sumC;
  sumV = 0;
  sumC = 0;
  for(int i=0; i<N; ++i){
    if(V[i] > C[i]){
      sumV += V[i];
      sumC += C[i];
    }
  }

  cout << sumV - sumC << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<char, bool> > v;
void fnc(int a){
  for(int i = a; i >= 0; i--){
    if(v[i].second == true){
      v[i].second = false;
      break;
    }
  }
}
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'B') v.push_back(make_pair(s[i], true));
    else v.push_back(make_pair(s[i], false));
  }
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'B') fnc(i);
  }
  for(int i = 0; i < v.size(); i++) if(v[i].second == true) printf("%c", v[i].first);
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int k,n;
int main(){
// 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> k >> n;
	if(k * 500 >= n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
using namespace std;
 
int main() {
  int a,b,c,d,sub; cin >> a >> b;
  cin >> c >> d;
  sub = (c*b) + (a-c)*d;
  cout << (a*b) - sub << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int l;
    while(1) {
        cin >> l;
        if (l == 0) break;
        int ac = 0;
        int ans = -1;
        for (int i = 0; i < 12; ++i) {
            int m, n;
            cin >> m >> n;
            ac += m - n;
            // cout << ac << endl;
            if (ac >= l && ans == -1){
                ans = i + 1;
            }
        }
        if (ans == -1) {
            cout << "NA" << endl;
        } else {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3076
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
edges = list(
    map(lambda s: 
        tuple(map(int,s.strip().split())), sys.stdin.readlines()
    )
)

children = [ [] for _ in range(n+1)]
for e in edges:
    children[e[0]].append(e[1])
    children[e[1]].append(e[0])

colors = [{} for _ in range(n+1)]

check = [False for _ in range(n+1)]

que = deque()
que.append((1, 0))

def solve(i, x):
    # log(i, x)
    check[i] = True

    color = 0
    for node in children[i]:
        if check[node]:
            continue

        color += 1
        if color == x:
            color += 1

        # log(i, node, color)
        colors[i][node] = color
        colors[node][i] = color
        que.append((node, color))

while que:
    e = que.popleft()
    solve(e[0], e[1])

maxColor = 0

for i in range(1, n+1):
    c = colors[i]
    maxColor = max(maxColor, max(c.values()))

print(maxColor)

for e in edges:
    print(colors[e[0]][e[1]])


Measured memory_bytes: 123612
#include <stdio.h>

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

  int max_ = 0;
  for (int i = 0; i < n; i++) {
    if (max_ < arr[i]) {
      max_ = arr[i] - 1;
    }
    if (max_ > arr[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}


Measured memory_bytes: 760
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;

const int N = 200010;
int n, m, cnt;
int a[N], num[N], f[N];

inline int read()
{
	char ch = getchar(); int x = 0, flag = 0;
	while (!isdigit(ch)){ if (ch == '-') flag = 1; ch = getchar(); }
	while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	return flag ? -x : x;
}

int main()
{
	n = read();
	for (int i = 1; i <= n; i ++) num[cnt ++] = a[i] = read();
	sort(num, num+cnt);
	cnt = unique(num, num+cnt) - num;
	for (int i = 1; i <= n; i ++){
		a[i] = lower_bound(num, num+cnt, a[i]) - num;
		f[a[i]] ++;
	}
	//for (int i = 0; i < cnt; i ++) printf("%d\n", f[i]);
	m = read();
	for (int i = 1; i <= m; i ++){
		int x = read(), p;
		p = lower_bound(num, num+cnt, x) - num;
		if (p >= cnt || num[p] != x || f[p] == 0){
			puts("NO"); return 0;
		} else f[p] --;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 2560
h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
dyx=[(1,0),(-1,0),(0,1),(0,-1)]
from collections import deque
q=deque()
q.append((0,0))
g[0][0]=0
while q:
    ny,nx=q.popleft()
    for dy,dx in dyx:
        y=ny+dy
        x=nx+dx
        if 0<=y<h and 0<=x<w and g[y][x]==".":
            g[y][x]=1+g[ny][nx]
            q.append((y,x))
if g[h-1][w-1]=="." or g[h-1][w-1]=="#":
    print(-1)
    exit()

d={}
ans=0
x=g[h-1][w-1]
for i in range(h):
    for j in range(w):
        if g[i][j]==".":
            ans+=1
            g[i][j]="@"
            continue
        if g[i][j]=="#":
            continue
        if g[i][j] in d:
            ans+=1
            g[i][j]="@"
        else:
            if g[i][j]>x:
                ans+=1
                g[i][j]="@"
            d[g[i][j]]=1

print(ans)


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

int main(){
    int N, M,L,K;
    cin >> N >> M;
    L = 0;
    vector<int> Ass(M);

    for(int i = 0;i<M;i++){
        cin >> Ass.at(i);
    }

    for(int j = 0;j<M;j++){
        L = L + Ass.at(j);
    }

    if(N<L)
        K = -1;
    else 
        K = N-L;

    cout << K << endl;
}

Measured memory_bytes: 3664
#include <stdio.h>
int main()
{
  int N, M, i, a, b;
  scanf("%d %d", &N, &M);
  int arr[N];
  for (i=0; i<N; i++) arr[i]=0;
  for (i=0; i<M; i++) {
    scanf("%d %d", &a, &b);
    arr[a-1]+=1;
    arr[b-1]+=1;
  }
  for (i=0; i<N; i++) printf("%d\n", arr[i]);
  return 0;
}

Measured memory_bytes: 256