akhauriyash/Code-Regression huggingface dataset:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
AB = [LI() for _ in range(N)]
AB = sorted(AB, key=lambda x:x[1])
time = 0
for a,b in AB:
    time += a
    if time>b:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 55216
#! -*- coding: utf-8-unix -*-
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0004
import sys

M=[True] * 1000000
M[0] = M[1] = False
for i in xrange(2, len(M)):
  # print i
  if M[i]:
    j = i + i
    while j < len(M):
      M[j] = False
      j += i

def main(lines):
  d = {}
  for line in lines:
    d[int(line)] = 0
  count = 0
  for i in range(len(M)):
    if M[i]:
      count += 1
    if d.has_key(i):
      d[i] = count
  for line in lines:
    print d[int(line)]

if __name__=='__main__':
  lines = [x.strip() for x in sys.stdin.readlines()]
  for line in sys.stdin:
    lines.append(line.strip())
  # print lines
  main(lines)

Measured memory_bytes: 43672
#include <stdarg.h>
#include <stdio.h>

long long max(int len, ...) {
    long long i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

long long min(int len, ...) {
    long long i, _min, num;
    va_list ap;
    va_start(ap, len);

    _min = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num < _min)
            _min = num;
    }
    va_end(ap);
    return _min;
}

int main(void) {
    int i, j, N;
    long long a[3010], dp[3010][3010] = {0LL};
    scanf("%d", &N);
    for (i=1;i<=N;i++) scanf("%lld", &a[i]);

    for (i=1;i<=N;i++) {
        for (j=1;j+i<=N+1;j++) {
            if ((N-i) % 2) { // white
                dp[j][j+i] = min( 2, -a[j] + dp[j+1][j+i], -a[j+i-1] + dp[j][j+i-1] );
            } else { // black
                dp[j][j+i] = max( 2, a[j] + dp[j+1][j+i], a[j+i-1] + dp[j][j+i-1] );
            }
        }
    }

    printf("%lld\n", dp[1][N+1]);
    return 0;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  if(n%k==0) cout<<0<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>

using namespace std;

typedef long long ll;

struct Node {
	ll hash;
	int l, r;
};

int N;

ll toHash(vector<int> v) {
	ll ret = 0;
	for (int i = 0; i < N; ++i) {
		ret *= 10;
		ret += v[i];
	}
	return ret;
}
vector<int> fromHash(ll hash) {
	vector<int> ret(N);
	for (int i = 0; i < N; ++i) {
		ret[N-i-1] = hash % 10;
		hash /= 10;
	}
	return ret;
}

int main() {
	cin >> N;

	vector<int> v(N);
	for (int i = 0; i < v.size(); ++i) {
		cin >> v[i]; --v[i];
	}

	vector<int> g = v;
	sort(g.begin(), g.end());

	map<ll, int> m;
	queue<Node> Q[10]; Q[0].push( (Node){ toHash(v), 0, 0 } );
	for (int step = 0; step < max(1, N/2); ++step) {
		while ( !Q[step].empty() ) {
			Node node = Q[step].front(); Q[step].pop();
			ll hash = node.hash;
			int l = node.l, r = node.r;

			if (m.find(hash) != m.end()) continue;
			m[hash] = step;

			vector<int> v = fromHash(hash);

			if (step+1 < N) {
				for (int i = 0; i < N; ++i) {
					for (int j = i+1; j < N; ++j) {
						if (l <= i && j <= r) continue;

						vector<int> nv = v;
						reverse(nv.begin()+i, nv.begin()+j+1);

/*
						bool f = true;
						for (int k = i+1; k < j; ++k) {
							if (nv[k] != k) f = false;
						}
						if (f) */
						Q[step+1].push( (Node){ toHash(nv), i, j } );
					}
				}
			}
		}
	}

	set<ll> s;
	for (int i = 0; i < N; ++i) {
		while ( !Q[i].empty() ) {
			Q[i].pop();
		}
	}
	Q[0].push( (Node){ toHash(g), 0, 0 } );
	for (int step = 0; step < N; ++step) {
		while ( !Q[step].empty() ) {
			Node node = Q[step].front(); Q[step].pop();
			ll hash = node.hash;
			int l = node.l, r = node.r;

			if (m.find(hash) != m.end()) {
				cout << m[hash]+step << endl;
				return 0;
			}
			if (s.find(hash) != s.end()) continue;
			s.insert(hash);

			vector<int> v = fromHash(hash);

			if (step+1 < N) {
				for (int i = 0; i < N; ++i) {
					for (int j = i+1; j < N; ++j) {
						if (l <= i && j <= r) continue;

						vector<int> nv = v;
						reverse(nv.begin()+i, nv.begin()+j+1);

/*
						bool f = true;
						for (int k = i+1; k < j; ++k) {
							if (nv[k] != k) f = false;
						}
						if (f) */
						Q[step+1].push( (Node){ toHash(nv), i, j } );
					}
				}
			}
		}
	}
}

Measured memory_bytes: 168984
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long n, s;

  std::cin >> n >> s;

  std::cerr << "n=" << n << " s=" << s << std::endl;

  if (n == s) {
    std::cout << n + 1 << std::endl;

    return 0;
  }

  for (int i = 2; i < 1111111; i ++) {
    long long S = 0;

    for (long long N = n; N; N /= i)
      S += N % i;

    if (S == s) {
      std::cout << i << std::endl;

      return 0;
    }
  }

  long long bm = INF;

  for (int i = 1; ; i ++) {
    long long l = n / (i + 1), u = n / i;

    if (u < 1000000)
      break;

    long long S = 0;

    for (long long N = n; N; N /= u)
      S += N % u;

    if (S == s) {
      bm = std::min(u, bm);
    }
    else if (s > S) {
      if ((s - S) % i == 0) {
        long long b = u - (s - S) / i;

        if (b > 1) {
          long long S = 0;

          for (long long N = n; N; N /= b)
            S += N % b;

          if (S == s)
            bm = std::min(b, bm);
        }
      }
    }
  }

  if (bm == INF)
    bm = -1;

  std::cout << bm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll int n,m;
  cin>>n>>m;
  ll int val=n*(n-1);
  val=val/2;
  ll int mal=m*(m-1);
  mal=mal/2;
  cout<<val+mal<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();
      
      int count =0;
      for(int i=L;i<=R;i++){
        if(i%d ==0){
          count++;
        }
      }
      
      System.out.println(String.valueOf(count));
    }
}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N, M;
  cin >> N >> M;
  priority_queue<int> option;       //残り日数に応じて実行できる仕事の報酬を追加いていく
  vector<pair<int, int>> work;     //仕事種類
  int profit = 0;                                        //報酬

  for(int i = 0; i < N; i++){            //計算量O(N)
    int t, p;
    cin >> t >> p;
    work.push_back(make_pair(t, p));
  }

  sort(work.begin(), work.end());       //時間を基準に昇順

  /*for(int i = 0; i < N; i++)
    cout << work[i].first << " " << work[i].second << endl;
  cout << "---------------------------------------" << endl;*/

  int i = 0;    //配列に格納されている仕事(日数少ない順)
  for(int t = 1; t <= M; t++){
    while(work[i].first == t){
      option.push(work[i].second);       //work[i].first日後に来る報酬を詰め込んでいく
      i++;
    }

    if(option.empty())
      continue;

    profit += option.top();                        //現状選択できる最大値を取得
    option.pop();                                            //その仕事はもう選べない  
   
  }

  cout << profit << endl;

}

Measured memory_bytes: 1908
S=input()
for i in range(2**3):
    ans=S[0]
    for j in range(3):
        if (i>>j)&1:
            ans+='+'+S[j+1]
        else:
            ans+='-'+S[j+1]
    if eval(ans)==7:
        print(ans+'=7')
        break

Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][4], a[2000000], b[2000000];
//string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<Pll, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	string str[7] = {"mon","tue","wed","thu","fri","sat","sun"};
	cout << str[(n+3) % 7] << endl;
	return 0;
}


Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> P(N), Q(N);
  rep(i,N) cin >> P[i];
  rep(i,N) cin >> Q[i];
  vector <int> a(N);
  rep(i,N) a[i] = i + 1;
  map <vector<int>, int> mp;
  do {
    mp[a] = mp.size();  //0-indexedで順番を格納
  } while (next_permutation(a.begin(), a.end()));

  int ans = abs(mp[P] - mp[Q]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8672
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        x: usize,
    }

    let mut x_tmp = x-1;
    let mut d = 1;
    let mut a = 2;
    let mut is_prime: bool = false;
    while(is_prime==false) {
        x_tmp += 1;
        while(d!=0){
            d = x_tmp % a; 
            if a==x_tmp {
                is_prime = true;
                break;
            }
            a += 1;
        }
        d = 1;
        a = 2;
        //println!("hoge");
    }   

    println!("{}", x_tmp);

}

Measured memory_bytes: 4352
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*int t;
	cin >> t;
	while (t--){
		int n;
		cin >> n;
		vector<int>v(n);
		for (int i = 0; i < n; i++){
			cin >> v[i];
		}
		if (n % 2){
			reverse(v.begin(), v.end());
			swap(v[n / 2], v[n / 2 - 1]);
		}
		else reverse(v.begin(), v.end());
		for (int i : v)cout << i << " ";
		cout << '\n';
	}*/
	double a, b, c;
	cin >> a >> b >> c;
	int count = ceil(a/b)*c;
	cout << count << '\n';
	//system("pause");
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500005];
ll x[800005],y[800005],z[900005];

int main(){	
	cin>>s;
	n = strlen(s);
	ans = n;
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1]){
			a = max(i+1,n-i-1);
			ans = min(ans,a);
		}
	}
	if(n==1){
		ans=1;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n;
vector<int> g[200100];
int dist[200100];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n)dist[i]=INF;
    dist[0]=0;
    queue<int> que;
    que.push(0);
    int vfar=0,dfar=0;
    while(que.size()){
        int v=que.front(); que.pop();
        if(chmax(dfar, dist[v]))vfar=v;
        rep(i,g[v].size()){
            if(dist[g[v].at(i)]>dist[v]+1){
                dist[g[v].at(i)]=dist[v]+1;
                que.push(g[v].at(i));
            }
        }
    }
    rep(i,n)dist[i]=INF;
    dist[vfar]=0;
    queue<int> que2;
    que2.push(vfar);
    dfar=0;
    while(que2.size()){
        int v=que2.front(); que2.pop();
        chmax(dfar, dist[v]);
        rep(i,g[v].size()){
            if(dist[g[v].at(i)]>dist[v]+1){
                dist[g[v].at(i)]=dist[v]+1;
                que2.push(g[v].at(i));
            }
        }
    }
    cout<<(dfar%3!=1?"First":"Second")<<endl;
}

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

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

int main() {
	ll n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	ll ans = 0;
	if (10 % p == 0) {
		rep(i, n) {
			if ((s[i] - '0') % p == 0) ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}
	ll ten = 1;
	reverse(s.begin(), s.end());
	vector<ll> m(n + 1, 0);
	REP(i, n) {
		m[i] = m[i - 1] + ten * (s[i - 1] - '0');
		m[i] %= p;
		ten *= 10;
		ten %= p;
	}
	vector<ll> t(p, 0);
	rep(i, n + 1) {
		t[m[i]]++;
	}
	rep(i, p) {
		ans += t[i] * (t[i] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
long int dp[100001]={0};
int main()
{
  long int n,i;
  cin>>n;
  long int arr[n];
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(i=2;i<n;i++)                                            
  {
      dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

vvi value(4, vi(0));
i64 ans = 0;

void func(int i, int j, int k, int l) {
	i64 sum = 0;
	rep(a, 0, i) sum += value[0][a];
	rep(a, 0, j) sum += value[1][a];
	rep(a, 0, k) sum += value[2][a];
	rep(a, 0, l) sum += value[3][a];
	ans = max(ans, sum);
}

int main() {
	int n;
	i64 w;
	cin >> n >> w;
	vi cou(4, 0);
	vector<i64> weight(n);
	rep(i, 0, n) {
		int v;
		cin >> weight[i] >> v;
		cou[weight[i] - weight[0]]++;
		value[weight[i] - weight[0]].push_back(v);
	}
	sort(rall(value[0]));
	sort(rall(value[1]));
	sort(rall(value[2]));
	sort(rall(value[3]));

	erep(i, 0, cou[0]) {
		i64 a = weight[0] * i;
		if (a > w) break;

		erep(j, 0, cou[1]) {
			i64 b = (weight[0] + 1)*j;
			if (a + b > w) break;

			erep(k, 0, cou[2]) {
				i64 c = (weight[0] + 2)*k;
				if (a + b + c > w) break;
				
				erep(l, 0, cou[3]) {
					i64 d = (weight[0] + 3)*l;
					if (a + b + c + d > w) break;
					func(i, j, k, l);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ Volume 0 Problem 0069

#include <stdio.h>
#include <string.h>

int radder[30][11];
int lines;
int start;
int end;
int steps;

int check_hit(void)
{
	int line[11];
	int i, j;
	int tmp;
	
	for (i = 1; i <= lines; i++){
		line[i] = i;
	}
	
	for (i = 0; i < steps; i++){
		for (j = 1; j < lines; j++){
			if (radder[i][j] == 1){
				tmp = line[j];
				line[j] = line[j + 1];
				line[j + 1] = tmp;
			}
		}
	}
	
	if (start == line[end]){
		return (1);
	}
	return (0);
}


int main(void)
{
	char str[10];
	int i, j;
	
	while (1){
		scanf("%d", &lines);
		if (lines == 0){
			break;
		}
		
		scanf("%d%d%d", &start, &end, &steps);
		
		memset(radder, 0, sizeof(radder));
		
		for (i = 0; i < steps; i++){
			scanf("%s", str);
			for (j = 1; j < lines; j++){
				radder[i][j] = str[j - 1] - '0';
			}
		}
	
		if (check_hit() == 1){
			printf("0\n");
			goto end;
		}
		
		for (i = 0; i < steps; i++){
			for (j = 1; j < lines; j++){
				if (radder[i][j] == 0 &&
				    radder[i][j - 1] == 0 &&
					radder[i][j + 1] == 0){
						
					radder[i][j] = 1;

					if (check_hit() == 1){
						printf("%d %d\n", i + 1, j);
						goto end;
					}
					radder[i][j] = 0;
				}
			}
		}
		
		printf("1\n");
end:;
	}
	
	return (0);
}

Measured memory_bytes: 0
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ln '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;
#define int ll

int32_t main() {
	ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

#ifdef _DEBUG
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int n, k; cin >> n >>k;
	int ar[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> ar[i];
	}
	sort(ar, ar + n, greater<int>());

	int ans{};
	for(int i = k; i < n; i++) {
		ans+= ar[i];
	}
	cout << ans << ln;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
using namespace std;
 
int g1[81][81];
int g2[81][81];
bool dp[81][81][6480];
 
 
int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;
 
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k < 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i < 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}

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

int ans=-1,a,b;

int main()
{
    cin >> a >> b;
    for (int i=1;i<=100*b;i++)
    {
        if (i*8/100==a&&i/10==b)
        {
            ans=i;break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import scala.io.Source.stdin
object Main {
   
  def main(args: Array[String]): Unit = {
    var Lines =for{
      input <- stdin.getLines.toList
    }yield input.map(chara => chara.toLower)
    println(if((Lines(0)+Lines(0)).contains(Lines(1))) "Yes" else "No")
  }
}

Measured memory_bytes: 44084
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from functools import lru_cache
INF = float("inf")

MOD = 998244353  # type: int


def main():
    A, B, C, D = map(int, input().split())
    DP = [[1]*(D-B+1) for _ in range(C-A+1)]

    for i in range(C-A+1):
        for j in range(D-B+1):
            if i == j == 0:
                continue
            DP[i][j] = 0
            if 0 <= i-1:
                DP[i][j] += (DP[i-1][j]*(j+B)) % MOD
                DP[i][j] %= MOD
            if 0 <= j-1:
                DP[i][j] += (DP[i][j-1]*(i+A)) % MOD
                DP[i][j] %= MOD
            if 0 <= i-1 and 0 <= j-1:
                DP[i][j] -= (DP[i-1][j-1]*(i+A-1)*(j+B-1)) % MOD
                DP[i][j] %= MOD
            # print(i, j, DP[i][j])
    print(DP[-1][-1] % MOD)
    # print(DP)

    # @lru_cache(maxsize=None)
    # def f(a, b):
    #     if a < A or b < B:
    #         return 0
    #     if a == A and b == B:
    #         return 1
    #     elif a == A:
    #         return pow(A, b-B, MOD)
    #     elif b == B:
    #         return pow(B, a-A, MOD)
    #     ans = (f(a-1, b)*b) % MOD
    #     ans += (f(a, b-1)*a) % MOD
    #     ans -= (f(a-1, b-1)*(a-1)*(b-1)) % MOD
    #     ans %= MOD
    #     return ans

    # print(f(C, D))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 139224
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

int n,m,i;
long long int sum;
int main()
{
	cin>>n>>m;
	if(abs(n-m)>=2)
	{
		cout<<0<<endl;
		return 0;
	}
	sum=1;
	for(i=1;i<=n;i++)
	{
		sum=(sum*i)%1000000007;
	}
	for(i=1;i<=m;i++)
	{
		sum=(sum*i)%1000000007;;
			
	}
	if(n==m)
	{
		sum=(sum*2)%1000000007;;
	
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const long double PI=3.141592653589793238462643383279;
const int N=500005;
int n,i,j,k,mn[100005],mx[100005],ans,lmn[100005],lmx[100005];
struct str{
	int l,r;
}a[100005];
bool cmp(str a,str b)
{
	if(a.r==b.r)
		return a.l>b.l;
	return a.r>b.r;
}
bool cmp2(str a,str b)
{
	if(a.r==b.r)
		return a.l<b.l;
	return a.r>b.r;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d %d",&a[i].l,&a[i].r);
	sort(a+1,a+1+n,cmp);
	lmn[0]=mn[n+1]=1<<30;
	for(i=n;i>=1;--i)
	{
		mx[i]=max(mx[i+1],a[i].l);
		mn[i]=min(mn[i+1],a[i].r);
	}
	for(i=1;i<n;++i)
	{
		lmn[i]=min(lmn[i-1],a[i].r);
		lmx[i]=max(lmx[i-1],a[i].l);
		ans=max(ans,max(lmn[i]-lmx[i]+1,0)+max(mn[i+1]-mx[i+1]+1,0));
	}
	for(i=1;i<=n;++i)
		ans=max(ans,a[i].r-a[i].l+1+max(min(lmn[i-1],mn[i+1])-max(lmx[i-1],mx[i+1])+1,0)); 
	sort(a+1,a+1+n,cmp2);
	lmn[0]=mn[n+1]=1<<30;
	for(i=n;i>=1;--i)
	{
		mx[i]=max(mx[i+1],a[i].l);
		mn[i]=min(mn[i+1],a[i].r);
	}
	for(i=1;i<n;++i)
	{
		lmn[i]=min(lmn[i-1],a[i].r);
		lmx[i]=max(lmx[i-1],a[i].l);
		ans=max(ans,max(lmn[i]-lmx[i]+1,0)+max(mn[i+1]-mx[i+1]+1,0));
	}
	cout<<ans;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	vector<int>len(1000, 0);
	int e[4];
	for (int i = 0; i < 4; i++) {
		cin >> e[i];
		len[e[i]]++;
	}

	if (len[e[0]] == 2 && len[e[1]] == 2 && len[e[2]] == 2 && len[e[3]] == 2)cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int b[100001]={0};
	long long int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		b[a[i]]++;
	}
	int k;
	cin>>k;
	for(int i=0;i<k;i++)
	{
		int x,y;
		cin>>x>>y;
		sum+=b[x]*y-b[x]*x;
		b[y]=b[y]+b[x];
		b[x]=0;
		cout<<sum<<endl;
	}
	
}

Measured memory_bytes: 4416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.parseInt;

/**
 * Monday-Saturday Prime Factors
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		boolean[] ns = new boolean[300000];
		for (int i = 0; ; i++) {
			int m = i * 7 + 1;
			int s = i * 7 + 6;
			if (m < ns.length) ns[m] = true;
			else break;
			if (s < ns.length) ns[s] = true;
			else break;
		}
		ns[1] = false;

		for (int i = 6; i < ns.length; i++) {
			if (ns[i]) {
				for (int j = 2; j <= ns.length / i; j++) {
					if (i * j < ns.length) ns[i * j] = false;
				}
			}
		}

		List<Integer> ps = new ArrayList<>();
		for (int i = 0; i < ns.length; i++) {
			if (ns[i]) ps.add(i);
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 1) break;

			StringBuilder sb = new StringBuilder();
			sb.append(n + ":");

			for (int i : ps) {
				if (n % i == 0) sb.append(" " + i);
			}
			System.out.println(sb.toString());

		}//end while
	}//end main
}

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


int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main()
{
    int N;
    cin >> N;
    
    int h[N+1];
    for(int i = 1; i <= N; i++) cin >> h[i];
    
    int A[N+1];
    A[1] = 0;
    A[2] = abs(h[2] - h[1]);
    for(int i = 3; i <= N; i++) A[i] = min(A[i-1] + abs(h[i] - h[i-1]), A[i-2] + abs(h[i] - h[i-2]));
    
    cout << A[N] << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  int l[n];
  for(int i = 0; i < n; i++) cin >> l[i];

  sort(l, l + n);

  int sum = 0;
  for(int i = 0; i < n; i++){
    int a = l[i];
    for(int j = i + 1; j < n; j++){
      int b = l[j];
      auto t = lower_bound(l + j + 1, l + n, a + b);
      auto s = upper_bound(l + j + 1, l + n, b - a);
      sum += distance(s, t);
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();




		System.out.println(B%A==0?A+B:B-A);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
//string marks = "abcdefghijklmnopqrstuvwxyz";
int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes";
        return 0;
    }else{
        cout << "No";
        return 0;

    }
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int m,d,ans;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
		cin >> m >> d;
		for(int i=1;i<=m;i++){
			for(int j=22;j<=d;j++){
				int d1 = j%10;
				int d2 = j/10;
				if( d1*d2 == i && d1>=2 && d2>=2 ){ans++;;}
			}
		}
		cout << ans << endl;


return 0;
}
///....


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

int main()
{
    const int MAX_N = 2000000;
    const int MAX_K = 10000;
    int n;
    cin >> n;
    int *A = new int[n];
    int *B = new int[n];
    int C[MAX_K] = {};
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        C[A[i]]++;
    }
    for(int i = 1; i < MAX_K; i++) C[i] += C[i - 1];
    for(int i = n - 1; i >= 0; i--)
    {
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
    for(int i = 0; i < n; i++)
    {
        if(i != 0) cout << " ";
        cout << B[i];
    }
    cout << endl;
}

Measured memory_bytes: 18756
#include <stdio.h>
int main(void){
    int a,b;
    char c;
    
    for(;;){
        scanf("%d %c %d",&a,&c,&b);
        if(c=='?'){
            break;
        }else if(c=='+'){
            printf("%d\n",a+b);
        }else if(c=='-'){
            printf("%d\n",a-b);
        }else if(c=='*'){
            printf("%d\n",a*b);
        }else if(c=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 600
import sys

def main():
    n = int(sys.stdin.readline())
    s = sys.stdin.readline().rstrip()

    level = 0 #level個の(括弧が開いている
    left_paren_app_num = 0
    right_paren_app_num = 0

    #イキナリ)括弧が出てくるか、
    #(括弧で終わっているとマズい

    for ch in s:
        if ch == '(':
            if level < 0:
                left_paren_app_num += - level
                level = 0
            level += 1
        elif ch == ')':
            level -= 1

    if level > 0:
            right_paren_app_num += level
            level = 0
    elif level < 0:
        left_paren_app_num += - level


    l_s = "".join(['(' for i in range(left_paren_app_num)])
    r_s = "".join([')' for i in range(right_paren_app_num)])
    print("%s%s%s" % (l_s, s, r_s))
    return 0

if __name__ == '__main__':
    sys.exit(main())


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}

#define int ll


void _main() {
        int n, m; cin >> n >> m;



        auto solve2r = [](int n, int m) -> array<ll, 2> {
                int a = n / 2, b = n - n / 2;
                return array<ll, 2>{(ll)a * m, (ll)b * m};
        };


        auto solve3 = [&](int n, int m) -> ll {
                ll ans = n * m;
                for (ll row = 1; row <= n-1; row++) {
                        ll up = row * m;
                        ll d1 = solve2r(n - row, m)[0], d2 = solve2r(n - row, m)[1];
                        ans = min(ans, max({up, d1, d2}) - min({up, d1, d2}));
                        assert(up + d1 + d2 == (ll)n * m);
                        d1 = solve2r(m, n - row)[0], d2 = solve2r(m, n - row)[1];
                        ans = min(ans, max({up, d1, d2}) - min({up, d1, d2}));
                        assert(up + d1 + d2 == (ll)n * m);
                }
                return ans;
        };


        cout << min(solve3(m, n), solve3(n, m)) << '\n';
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
const int N = 20;
int c[1 + N];
int a[1 + N][1 + N];
int g[1 + N];

int main() {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int n, m, x;
    cin >> n >> m >> x;
    int ans = - 1;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int j = 0; j < m; j++)
            g[j] = 0;
        int cost = 0;
        for (int i = 0; i < n; i++)
            if (mask & (1 << i)) {
                cost += c[i];
                for (int j = 0; j < m; j++)
                    g[j] += a[i][j];
            }
        bool ok = true;
        for (int j = 0; j < m; j++)
            if (g[j] < x)
                ok = false;
        if (ok) {
            if (ans == -1 || ans > cost)
                ans = cost;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
bool prime[1001000];
void eratos()
{
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i*i<=1000000;i++)if(prime[i])
	{
		for(int j=i*2;j<=1000000;j+=i)
		{
			prime[j]=false;
		}
	}
	return;
}
int main()
{
	eratos();
	while(1)
	{
		int a,d,n;
		scanf("%d %d %d",&a,&d,&n);
		if(a==0&&d==0&&n==0)break;
		int cnt=0;
		for(int i=0;;i++)
		{
			if(prime[a+d*i])cnt++;
			if(cnt==n)
			{
				printf("%d\n",a+d*i);
				goto end;
			}
		}
		end:;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>
 
char x[1000],y[1000];
 
int LCS()
{
 int i,j;
 int n=strlen(x),m=strlen(y);
 int a[n+1][m+1];
 
 for(i=1;i<=n;i++){
   a[i][0]=0;
 }
 
 for(i=0;i<=m;i++){
   a[0][i]=0;
 }
 
 for(i=1;i<=n;i++){
  for(j=1;j<=m;j++){
   if(x[i-1]==y[j-1]){
     a[i][j]=a[i-1][j-1]+1;
   }else if(a[i-1][j]>=a[i][j-1]){
     a[i][j]=a[i-1][j];
   }else{
     a[i][j]=a[i][j-1];
   }
  }
 }
 return a[n][m];
}
 
int main(void)
{
 int i,n;
 
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
   scanf("%s%s",x,y);
   printf("%d\n",LCS());
 }
 
 return 0;
}


Measured memory_bytes: 5708
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
 string a,b;
  cin>>a>>b;
  map<string, int> mp;
  cin >> mp[a] >> mp[b];
  string c;
  cin>>c;
  mp[c]--;
  cout<<mp[a]<<" "<<mp[b]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a % 2 || b % 2 || c % 2) {
    cout << 0 << endl;
    return 0;
  }
  int count = 0;
  for ( ; count <= 2000000; count++) {
    if (a % 2 || b % 2 || c % 2) {
      cout << count << endl;
      return 0;
    }
    int ta, tb, tc;
    ta = (b + c) / 2;
    tb = (a + c) / 2;
    tc = (a + b) / 2;
    a = ta;
    b = tb;
    c = tc;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    cin >> s;

    vector<vector<int>> step(h, vector<int>(w, INF));
    queue<pair<int, int>> q;
    q.emplace(0, 0);
    step[0][0] = s[0][0]=='#';
    while(!q.empty()){
        pair<int, int> xy = q.front(); q.pop();
        int x, y;
        tie(x, y) = xy;
        for(int i = 0; i < 2; ++i){
            int X = x+dx[i], Y = y+dy[i];
            if(X >= w or Y >= h) continue;
            int d = s[y][x]=='.' and s[Y][X]=='#';
            if(chmin(step[Y][X], step[y][x]+d))
                q.emplace(X, Y);
        }
    }
    cout << step[h-1][w-1] << '\n';

    
    
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
	int a[4],b[4];
	int i,j;
	int hit=0; int blow=0;

	while( scanf("%d %d %d %d", &a[0],&a[1],&a[2],&a[3]) != EOF){
	scanf("%d %d %d %d", &b[0],&b[1],&b[2],&b[3]);
	for(i=0; i<4; i++)
		if(a[i]==b[i]) hit++;
	
	for(i=0; i<4; i++){
		for(j=0; j<4; j++)
			if(a[i]==b[j]) blow++;
	};
	blow -= hit;
	printf("%d %d\n", hit, blow);
	hit=blow=0;
	};
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h> 
using namespace std; 
#define rep(i,a,b)		for(int i=a;i<=b;i++)

int n,ans=0,cnt=0;
int main() 
{ 

	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    if(n<105)
    {
    	cout<<0;
    }
    else
    {
    	for(int i=105;i<=n;i++)
	    {
	    	if(i&1)
	    	{
		    	cnt=0;
		    	for(int j=1;j<=i;j++)
		    	{
		    		if(i%j==0)
		    			cnt++;
		    	}
		    	if(cnt==8)
		    		ans+=1;
	    	}
	    }
	    cout<<ans;
    }
} 


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n, e, T, q[N], h, t;
using ll = long long;
ll f[N], a[N], p[N], d[N];

int main () {
	scanf("%d%d%d", &n, &e, &T); p[0] = -0x3f3f3f3f3f3f3f3f;
	for (int i = h = 1, k = 0; i <= n; ++i) {
		scanf("%lld", &a[i]); f[i] = 0x3f3f3f3f3f3f3f3f;
		d[i] = f[i - 1] - a[i - 1];
		while (h <= t && d[i] < d[q[t]]) --t; q[++t] = i;
		while (2 * (a[i] - a[k]) > T) if (q[h] == k++) ++h;
		f[i] = min(f[i], T + a[i] + d[q[h]]);
		if (k > 1) f[i] = min(f[i], 3ll * a[i] - p[k - 1]);
		p[i] = max(p[i - 1], 2ll * a[i] + a[i - 1] - f[i - 1]);
	}
	printf("%lld\n", f[n] + e - a[n]);
	return 0;
}

Measured memory_bytes: 3712
n = int(input())
ans = [0 for _ in range(10001)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            v = x**2+y**2+z**2+x*y+y*z+x*z
            if v < 10001:
                ans[v] += 1

for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, k, sum = 0, x = 0;
	cin >> n;
	x = log2(n);
	sum = 1;
	for (int i = 0; i <= x; ++i)
		{
			sum = sum * 2 * 1LL;
		}
	cout << sum - 1 << endl;
	//main();
}
/*
1-1
2-3
3-3
4-7
5-7
6-7
7-7
8-15
9-15
10-15
11-15
12-15
13-15
14-15
15-15
16-31

*/

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

typedef pair< int, int > Pi;
typedef pair< int, Pi > Pii;

int main(){
  int N, d;
  Pii data[200000];
  multiset< int > X, Y;
  scanf("%d %d", &N, &d);
  for(int i = 0; i < N; i++){
    scanf("%d %d %d", &data[i].second.first, &data[i].second.second, &data[i].first);
  }
  sort( data, data + N);
  int64 ret = 0, low = 0;
  for(int i = 0; i < N; i++){
    while(data[low].first < data[i].first - d){
      X.erase( X.find(data[low].second.first));
      Y.erase( Y.find(data[low].second.second));
      low++;
    }
    X.insert( data[i].second.first);
    Y.insert( data[i].second.second);

    ret = max( ret, (int64)(*--X.end() - *X.begin()) * (*--Y.end() - *Y.begin()));
  }
  printf("%lld\n", ret);
}

Measured memory_bytes: 22284
N, K = map(int, input().split())

res = 0

if K % 2 == 0:
  count = 0
  n = K//2
  while n <= N:
    count += 1
    n += K
  res += count**3

count = 0
n = K
while n <= N:
  count += 1
  n += K

res += count**3
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	std::vector<int> a(n);
	int flag = 0;
	rep(i,n) {
		cin >> a[i];
		if(a[i] == 1) flag = 1;
	}

	if(flag == 0) {
		cout << "-1" << endl;
		return 0;
	}

	int k=0;
	int index = 1;
	rep(i,n){
		if(a[i] == index) {
			index++;
			continue;
		}
		k++;
	}
	cout << k << endl;


  return 0;
}


Measured memory_bytes: 1024