akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

#include<string>

#include<cmath>

using namespace std;

int main(){

  int n;

  while(cin>>n){

    if(n==0)break;

    int ans=0;

    for(int i=1;i<=n/2+1;i++){

      for(int j=1;j<=n/2+1;j++){

    int a=i*(j+1)+j*(j+1)/2;

    if(a<n)  continue;

    else if(a==n){

      ans++;

    }else if(a>n){

      break;

    }      

      }  

    }

    cout<<ans<<endl;

  }

  return 0;

}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	int tot = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		tot ^= a[i];
	}
	for(int i = 0; i < n; i++) {
		cout << (tot ^ a[i]) << " ";
	}

	return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P =pair<ll,ll>;
using PP = pair<ll,P>;
const ll INF = ll(1e18)+5;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<P>> graph(N);
    for(int i=0;i<M;i++){
        ll a,b,c;
        cin >> a >> b >>c;
        --a;--b;
        graph[a].emplace_back(b,c);
        graph[b].emplace_back(a,c);
    }

    set<P> ans;
    for(int i=0;i<N;i++){
        priority_queue<PP,vector<PP>,greater<PP>> pq;
        pq.push(PP(0,P(-1,i)));
        vector<ll> d(N,INF);
        d[i] = 0;
        while(!pq.empty()){
            PP pp = pq.top();pq.pop();
            ll pcost = pp.first;
            ll pfrom = pp.second.first;
            ll p = pp.second.second;  
            if(pcost > d[p]){
                continue;
            }
            if(ans.find(P(p,pfrom)) == ans.end()){
                ans.insert(P(pfrom,p));
            }
            for(P child:graph[p]){
                if(d[child.first] > d[p] + child.second){
                    // cerr <<"child=" << child.first << endl;
                    d[child.first] = d[p] + child.second;
                    pq.push(PP(d[child.first],P(p,child.first)));
                }
            }

        }
    }
    // cerr << ans.size() << endl;
    cout << M-(ans.size()-N) << endl;

    return 0;
}

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

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

    if( (a[1] == a[2]) && ( (a[0] == a[1]) || (a[2] == a[3]) ))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
int main(void) {
  int n;
  int ans=0;
  int z=1;
  cin>>n;
  for(int i=1; i<=n; i++) {
    int x=i;
    int y=0;
    while(x%2==0) {
      x=x/2;
      y++;
    }
    if(ans<y) {
      ans=y;
      z=i;
    }
  } 
  cout<<z<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

using P = tuple<int,int>;
const int NMAX = 100008;

int main() {
  int N; cin >> N;
  vector<int> vec(NMAX, 0);
  REP(i, N) {
    int A, B; cin >> A >> B;
    ++vec[A - 1];
    --vec[B];
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    vec[i] += vec[i - 1];
    if (vec[i] >= i) {
      ans = max(ans, min(i, vec[i]));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3116
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * (n + 1)
for i in a:
    dp[i] = -1
for i in range(n + 1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        if i >= 2:
            dp[i] = (dp[i-1] + dp[i-2]) % (10 ** 9 + 7)
        else:
            if dp[i] == -1:
                dp[i] = 0
            else:
                dp[i] = 1
print(dp[-1])


Measured memory_bytes: 7824
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define pb push_back()
using namespace std;
const int mo=1e9+7;
int n,k;
long long sum1,sum2,ans;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=0;i<=n;i++)
	{
		sum1+=i; sum2+=n-i;
		if (i+1>=k) ans=(ans+sum2-sum1+1)%mo;
	}
	printf("%lld\n",ans);
return 0;
}

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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		char[] S = sc.next().toCharArray();
		final char OPEN = '(';
		final char CLOSE = ')';

		StringBuilder a = new StringBuilder();
		int o = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			if (S[i] == OPEN) {
				o++;
			} else {
				o--;
				if (o < 0) {
					a.append(OPEN);
					o++;
				}
			}
		}
		a.append(S);

		while (o-- > 0) {
			a.append(CLOSE);
		}

		System.out.println(a.toString());
	}
}


Measured memory_bytes: 22612
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
 
int n,dp[100005],a[100005],k; 
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=2;i<=n;i++){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for (int j=max(1,i-k);j<i;j++){
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j])); 
		}
	}
	printf("%d\n",dp[n]);
	return 0;
} 

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

int main() {
  vector<int> vec(3);
  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    if (vec.at(0) < vec.at(1) && vec.at(1) < vec.at(2)) {
      break;
    }
    else if (vec.at(0) >= vec.at(1)) {
      vec.at(1) *= 2;
    }
    else if (vec.at(1) >= vec.at(2)) {
      vec.at(2) *= 2;
    }
  }
  if (vec.at(0) < vec.at(1) && vec.at(1) < vec.at(2)) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
  
}


Measured memory_bytes: 3616
N,Q = list(map(int,input().split()))

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N
for i in range(Q):
    p,x = list(map(int,input().split()))
    p-=1
    c[p] += x

stack=[0]
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.append(u)


ans = ' '.join([str(x) for x in c])

print(ans)

Measured memory_bytes: 121236
#include <stdio.h>

int main(){
    int a, b, x;
    
    scanf("%d%d",&a,&b);
    if(a<3 | b>20)return 0;

    if(a>b){
        x=a;
        a=a-1;
    }
    else if(b>a){
        x=b;
        b=b-1;
    }
    else if(a==b){
        x=a;
        a=a-1;
    }

    if(a>b)x=x+a;
    else if(b>a)x=x+b;
    else if(a==b)x=x+a;

    printf("%d",x);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int A, B, K;
  cin >> A >> B >> K;
  rep(i, 0, K) {
    if (i % 2 == 0) {
      B += A/2;
      A /= 2;
    } else {
      A += B/2;
      B /= 2;
    }
  }
  cout << A << " " << B << endl;

  return 0;
}

Measured memory_bytes: 256
// Problem : F - Removing Robots
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MOD 998244353

void add(int &a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

int st[800000];

int rightMost(int p, int l, int r, int range) {
    if (l == r)
        return l;
    
    int m = (l + r) / 2;
    if (st[2*p+1] < range)
        return rightMost(2*p+1, m+1, r, range);
    return rightMost(2*p, l, m, range);
}

int query(int p, int l, int r, int i, int j, int range) {
    if (i > r || j < l)
        return -1;
    if (i <= l && r <= j) {
        if (st[p] >= range)
            return -1;
        return rightMost(p, l, r, range);
    }
    
    int m = (l + r) / 2, ret = query(2*p+1, m+1, r, i, j, range);
    if (ret == -1)
        ret = query(2*p, l, m, i, j, range);
    return ret;
}

void update(int p, int l, int r, int idx, int val) {
    if (l == r) {
        st[p] = val;
        return;
    }
    
    int m = (l + r) / 2;
    if (idx <= m)
        update(2*p, l, m, idx, val);
    else
        update(2*p+1, m+1, r, idx, val);
    st[p] = min(st[2*p], st[2*p+1]);
}

int dp[200000];
pair<int, int> robot[200001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> robot[i].first >> robot[i].second;
    
    memset(st, 127, sizeof(st));
    sort(robot, robot + n);
    
    dp[n] = 1;
    for (int i=n-1; i>=0; i--) {
        dp[i] = dp[i+1];
        int r = query(1, 0, n-1, i, n-1, robot[i].first + robot[i].second);
        if (r == -1) r = i;
        add(dp[i], dp[r+1]);
        update(1, 0, n-1, r, robot[i].first);
    }
    
    cout << dp[0] << "\n";

    return 0;
}


Measured memory_bytes: 5760
var cc : array [-1..100001] of longint ;
    max,n,a,b,c,d,e,f,g : longint ;
begin
 readln(n);
 for a:=1 to n do
  begin
   read(g);
   cc[g-1]:=cc[g-1]+1;
   cc[g]:=cc[g]+1;
   cc[g+1]:=cc[g+1]+1;
  end;
 for a:=-1 to 100001 do
  if cc[a]>max then
   max:=cc[a];
 writeln(max); 
end.


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int a=in(),b=in();
	print((a+b)/2);
	return 0;
}

Measured memory_bytes: 1860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans  = 0;
		if(A>B&&A-B>1){
			ans = A + A - 1;
		}else if(B>A&&B-A>1){
			ans = B + B - 1;
		}else{
			ans = A + B;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    vector<int> x;
    for (int i = 1; i <= n; i++){
        int a;
        cin >> a;
        x.push_back(a - i);
    }

    sort(x.begin(), x.end());
    int b = n / 2;
    ll sum = 0;
    for (int i = 0; i < n; i++){
        sum += abs(x[i] - x[b]);
    }

    cout << sum << endl;

    return 0;
}

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

int main () {
  int n, d;
  double a, b;
  cin >> n >> d;
  
  int res = 0;
  
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    if (pow(pow(a, 2) + pow(b, 2), 0.5) <= d) {
      res++;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 4484
#include<stdio.h>

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

  for(int i=0; i<9; i++){
    if(A != 0){
      X = X + A % 10;
      A = A / 10;
    }else{

    }
  }

  if(N % X == 0){
    printf("Yes");
  }else{
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<ll> a;

int main() {
	while (cin >> n&&n) {
		a.resize(n);
		rep(i, n) {
			cin >> a[i];
		}
		sort(ALL(a));
		ll ans = INF;
		rep(i, n - 1) {
			ans = min(ans, a[i + 1] - a[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1LL << 62;

void solve()
{
  int64_t n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  vector<pair<int, int64_t>> vp;
  vp.emplace_back(2, a);
  vp.emplace_back(3, b);
  vp.emplace_back(5, c);
  map<int64_t, int64_t> mp;
  mp[0] = 0;
  mp[1] = d;
  function<int64_t(int64_t)> dfs = [&](int64_t x) {
    if (mp.find(x) != mp.end())
    {
      return mp[x];
    }
    int64_t ret = INF;
    long long tmp = d * x;
    if (!__builtin_smulll_overflow(d, x, &tmp))
    {
      ret = d * x;
    }
    for (auto &p : vp)
    {
      int64_t num, cost;
      tie(num, cost) = p;
      ret = min(ret, dfs(x / num) + cost + d * (x % num));
      if (x % num != 0)
      {
        ret = min(ret, dfs(x / num + 1) + cost + d * (num - x % num));
      }
    }
    return mp[x] = ret;
  };
  cout << dfs(n) << endl;
}

int main()
{
  int64_t T;
  cin >> T;
  for (int i = 0; i < T; i++)
  {
    solve();
  }
}


Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vint score(n, 0);
    int a;
    rep(i, q) {
        cin >> a;
        --a;
        score[a]++;
    }
    rep(i, n) {
        if (k - q + score[i] > 0) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin >> n && n)
    {
    int m;
    cin >> m;
    int t[n], h[m]; 
    int p, q;
    p = 0;
    q = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
        p = p + t[i];
    }
    for(int j = 0; j < m; j++)
    {
        cin >> h[j];
        q = q + h[j];
    }
    int x = 0; 
    for(int k = 0; k < n; k++) 
    {
        if(x == 0)
        {
            for(int l = 0; l < m; l++)
            {
                if(p-t[k]+h[l] == q+t[k]-h[l])
                {
                    x = 1;
                    cout << t[k] << " " << h[l] << endl;
                    break;
                }
            }
        }
    }
    if(x == 0)
    {
        cout << -1 << endl;
    }
    }
}

Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, m, A[CMax];
long long fib[CMax];

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

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    scanf("%d %d", &n, &m);

    fib[0] = 1; fib[1] = 1;
    for (int i = 2; i <= n; i++) fib[i] = (fib[i-2] + fib[i-1]) % CMod;


    for (int i = 0; i < m; i++) {
        scanf("%d", &A[i]);
    }

    sort(A, A+m);
    A[m] = n+1;
    m++;

    long long res = 0;
    int tmp;

    for (int i = 0; i < m; i++) {
        if (i == 0) {
            res = fib[A[i]-1];
        } else {
            tmp = A[i] - A[i-1];
            if (tmp == 1) {
                printf("0\n");
                return 0;
            }

            res *= fib[tmp - 2];
        }

        res %= CMod;
    }



    printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 1408
// #include <iostream>
// #include <vector>
// #include <unordered_map>
// #include <unordered_set>
// #include <algorithm>
// #include <numeric>
// #include <math.h>
// #include <utility>
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
// typedef vector<int> vi;
// typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = a; i <= b; i++)

void solution() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if (a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

    solution();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, tmp;
    long long cnt = 0;
    cin>>n;
    int a[n+1], b[n];
    rep(i, n+1){
        cin>>a[i];
        cnt += a[i];
    }
    rep(i, n)
        cin>>b[i];

    if(a[0] <= b[0]){
        b[0] -= a[0];
        a[0] = 0;
    }
    else{
        a[0] -= b[0];
        b[0] = 0;
    }

    for(int i = 1; i < n; i++){
        if(a[i] <= b[i-1]){
            b[i-1] -= a[i];
            a[i] = 0;
        }
        else{
            a[i] -= b[i-1];
            b[i-1] = 0;
        }
        if(a[i] <= b[i]){
            b[i] -= a[i];
            a[i] = 0;
        }
        else{
            a[i] -= b[i];
            b[i] = 0;
        }
    }

    if(a[n] <= b[n-1]){
        b[n-1] -= a[n];
        a[n] = 0;
    }
    else{
        a[n] -= b[n-1];
        b[n-1] = 0;
    }
    long long ans = 0;
    rep(i, n+1)
        ans += a[i];
    cout<<cnt-ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define inf (int)(1e9)
#define INF 1LL<<60
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+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)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int a,b;cin>>a>>b;
    int d=b-a;
    int ans=0;
    REP(i,d){
        ans+=i;
    }
    cout<<ans-b<<endl;
}






Measured memory_bytes: 256
number=input().rstrip()
number=int(number)
destination=[]
#destination.append(input().rstrip().split() for i in range(number))
destination=[input().rstrip().split() for i in range(number)]
destination.insert(0,['0','0','0'])
count=0
for i in range(number):
    time=int(destination[i+1][0])-int(destination[i][0])
    length=abs(int(destination[i][1])-int(destination[i+1][1]))+abs(int(destination[i][2])-int(destination[i+1][2]))
    if time<length:
        break
    elif time==length:
        count+=1
    else:
        a=time-length
        if a%2==0:
            count+=1
        else:
            break
if count==number:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 32152
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

LL gcd(LL x,LL y){
	if(y==0)	return x;
	else	return gcd(y,x%y);
}
LL lcm(LL x,LL y){
	return x*y/gcd(x,y);
}

int main(void){
    LL N,X;
    cin>>N>>X;
    cout<<(N-gcd(N,X))*3<<endl;
     return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        int ans = 0, digit1, digit2, digit4, digit5, temp;
        
        
        for (int i = a; i <= b; i++) {
            temp = i;
            digit5 = temp % 10;
            temp /= 10;
            digit4 = temp % 10;
            temp /= 10;
            temp /= 10;
            digit2 = temp % 10;
            temp /= 10;
            digit1 = temp % 10;
            
            if (digit1 == digit5 && digit2 == digit4) ans++;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  for (ll i = 0; i < 100; i++) {
    if (N-i*4 >= 0 && (N-i*4)%7==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
// LightOj Pass : qavajxyq

#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << x << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7 ;
const ll INF = 1e18;

ll powmod(ll a, ll b, ll mod = MOD){
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

ll findxor(ll n){
	if(n%4 == 0)	return n;
	else if(n%4 == 1)	return 1;
	else if(n%4 == 2)	return n + 1;
	return 0;
}

int main(){	

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

	set<ll> st;
	int n;
	cin >> n;

	pair<int, int> red[n], blue[n];
	for(int i = 0; i < n;  i++)	cin >> red[i].first >> red[i].second;
	for(int i = 0; i < n;  i++)	cin >> blue[i].first >> blue[i].second;

	sort(red, red + n), sort(blue, blue + n);

	int cur = 0, ans  = 0;
	for(int i = 0; i < n; i++){
		while(cur < n and red[cur].first < blue[i].first){
			st.insert(red[cur].second);
			cur++;
		}

		if(*st.begin() < blue[i].second and st.lower_bound(blue[i].second) != st.begin())	st.erase(*prev(st.lower_bound(blue[i].second))), ans++;
	}

	cout << ans;	
}

Measured memory_bytes: 256
while(1):
    try:
        n = int(input())
    except:
        break

    cnt = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - a - b - c
                if 0 <= d < 10:
                    cnt += 1
    print(cnt)



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

int main() {
    int a, b;
    cin >> a >> b;
    rep(i, 1010) {
        if(floor(double(i) * 0.08) == a and floor(double(i) * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

//#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int a, b, c; cin >> a >> b >> c;
	set<int> x{ a,b,c };
	cout << x.size() << endl;
	system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int s=0;
    for(int i=n;i>=0;i--){
        int co=0;
        for(int j=0;j<n;j++){
            if(a[j]>=i) co++;
            else break;
        }
        if(co>=i){
            s=i;
            break;
        }
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
ll dp[100005][4];
// dp[i+1][0] := i文字目まで見た時にABCとの照合をスタートしていないものの個数
// dp[i+1][1] := i文字目まで見た時にABCとの照合においてAまでは照合させたようなものの個数
// dp[i+1][2] := i文字目まで見た時にABCとの照合においてBまでは照合させたようなものの個数
// dp[i+1][3] := i文字目まで見た時にABCとの照合においてCまでは照合させたようなものの個数

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	dp[0][0] = 1;
	
	for(int i=0;i<S.size();i++){
		for(int j=0;j<4;j++){
			if(S[i] == '?') dp[i+1][j] = dp[i][j] * 3;
			else dp[i+1][j] += dp[i][j];
			dp[i+1][j] %= mod;
		}
		if(S[i] =='A' || S[i] == '?')dp[i+1][1] += dp[i][0];
		if(S[i] =='B' || S[i] == '?')dp[i+1][2] += dp[i][1];
		if(S[i] =='C' || S[i] == '?')dp[i+1][3] += dp[i][2];
	}
	cout << dp[S.size()][3]%mod << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M;

  ll ans = 1;
  for(int i=0;i<M;i++){
    ans *= 2;
  }
  cout << ans *	(1900 * M + 100 * (N - M)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define en "\n"
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n,k,len,tm,ans=0;
    cin>>n>>k;
    k--;
    for(int i=0;i<n;i++)
    {
        cin>>tm;
        if(tm==1)len=i;
    }
    ans+=(len/k+(n-len-1)/k);
    if(len%k+(n-len-1)%k<=k&&len%k+(n-len-1)%k)ans++;
    else if(len%k+(n-len-1)%k>k)ans+=2;

    cout<<ans<<endl;
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<int> V(10000,0);
	V[0]=2;
	for(int i=1;i<10000;i++){
		V[i] = V[i-1]+i+1;
	}

	int N;
	while(cin>>N){
		out(V[N-1]);
	}
	
	return 0;
}


Measured memory_bytes: 3188
MOD = 10**9+7

s=input()
Anum = 0
ABnum = 0
ABCnum = 0
q = 0
for c in s:
    if c == 'A':
        Anum = (Anum+pow(3,q,MOD))%MOD
    elif c == 'B':
        ABnum = (ABnum+Anum)%MOD
    elif c == 'C':
        ABCnum = (ABCnum+ABnum)%MOD
    else:
        Anum,ABnum,ABCnum = 3*Anum+pow(3,q,MOD),3*ABnum+Anum,3*ABCnum+ABnum
        Anum,ABnum,ABCnum = Anum%MOD,ABnum%MOD,ABCnum%MOD
        q += 1
print(ABCnum)


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
char s[MAXN];

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int a = 0, b = 0, m = 0;
	cin >> a >> b >> m;
	vector<int> r(a);
	vector<int> mi(b);
	for(int i = 0; i < a; ++i){
		cin >> r[i];
	}
	for(int i = 0; i < b; ++i){
		cin >> mi[i];
	}
	int minf = *min_element(r.begin(), r.end());
	int minm = *min_element(mi.begin(), mi.end());
	int ans = minf + minm;
	int x = 0, y = 0, c = 0;
	for(int i = 0; i < m; ++i){
		cin >> x >> y >> c;
		x--,y--;
		ans = min(ans,r[x]+mi[y]-c);
	}
	cout << ans << endl;


	

	

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=100005;
#define M 1000000021
#define double long double
#define BINF 1000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
const int LG = 22;



#undef int
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#define int long long int

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

	int gg=0;
	for(auto i:a) gg=__gcd(gg,i);

	int x=a[0];
	int c=0;
	for(int i=0;i<n;i++)
		if(a[i]%gg==0) c++;
	if(c==n) cout<<gg<<endl;
	else cout<<1<<endl;


return 0;
}

Measured memory_bytes: 1024
s=input()

t1='maerd'
t2='remaerd'
t3='esare'
t4='resare'
t=[t1,t2,t3,t4]

s=s[::-1]

ans=0

while True:
    if s.startswith(t1):
        s=s[5::]
    
    elif s.startswith(t2):
        s=s[7::]
      
    elif s.startswith(t3):
        s=s[5::]
 
    elif s.startswith(t4):
        s=s[6::]
        
    elif len(s)==0:
        break
        
    else:
        print('NO')
        ans=1
        break
        
    
        
if ans==0:
    print('YES')
        

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll n,m,k,a[300005],b[300005];

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>k;
rep(i,0,n-1)cin>>a[i];
rep(i,0,m-1)cin>>b[i];

rep(i,1,m-1)b[i]+=b[i-1];
rep(i,1,n-1)a[i]+=a[i-1];

ll ans=0;

int id=upper_bound(b,b+m,k)-b;
ans=id;

rep(i,0,n-1)
{
	if(k-a[i]<0)break;
	ll id=upper_bound(b,b+m,k-a[i])-b;
	ans=max(ans,id+i+1);
}
ol(ans);

return 0;
}



Measured memory_bytes: 6764
#include <iostream>

#define MAX_N (2*100000)

int main() {
  int N;
  std::cin >> N;

  int Aim1 = 0, Ai, t[MAX_N+1];
  int Ci2num[MAX_N+1] = {};
  for (int i = 0; i < N; i++, Aim1 = Ai) {
    std::cin >> Ai;
    for (int j = Aim1; j <= Ai-1; j++) {
      t[j] = i;
    }
    Ci2num[Ai]++;
  }
  for (int i = Aim1; i <= N; i++) {
    t[i] = N;
  }

  int B[MAX_N], u[MAX_N+1];
  for (int i = 0; i < N; i++) {
    std::cin >> B[i];
    for (int j = (i==0?0:B[i-1])+1; j <= B[i]; j++) {
      u[j] = i;
    }
    Ci2num[B[i]]++;
    if (Ci2num[B[i]] > N) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  for (int i = B[N-1]+1; i <= N; i++) {
    u[i] = N;
  }

  int w = -N;
  for (int i = 1; i <= N; i++) {
    w = std::max(w, t[i] - u[i]);
  }

  for (int i = 0; i < N-1; i++) {
    std::cout << B[(N+i-w)%N] << " ";
  }
  std::cout << B[(N+N-1-w)%N] << std::endl;

  return 0;
}


Measured memory_bytes: 6288
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

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

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

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

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
ans = []
while n > 0:
    tmp = n % 26
    ans.append(tmp)
    n = n // 26
    if tmp == 0:
        n-=1
a = []
for i, num in enumerate(ans):
    if num == 0:
        a.append('z')
    else:
        a.append(chr(ord('a') + num - 1))
a.reverse()
print(*a, sep='')

Measured memory_bytes: 72772
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		int a = h1 * 60 + m1;
		int b = h2 * 60 + m2;
		System.out.println(Math.max(b - a - k, 0));
	}
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;
const double PI = acos(-1.0);

double DEG_to_RAD(double d) { return d * PI / 180.0; }

int n;
int a[123456];
map<int,int > mb;
map<int, int > ma;

int main(){
  //  freopen("test.txt","r",stdin);
    cin >> n;
    for (int i =1 ;i <= n; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    int ans =0 ;
    for (int i =1 ; i <= n ; i++) {
        if ( mb[a[i]] == 0) {
            if ( ma[a[i]] >= a[i]) {
                mb[a[i]] = 1;
                ans += abs(ma[a[i]] - a[i]);
            } else {
                mb[a[i]] = 1;
                ans += ma[a[i]];
            }
        }
    }
    cout << ans << endl;
}


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

int main(void)
{
	vector<long long>res;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		long long temp;
		cin >> temp;
		res.push_back(temp);
	}
	int q;
	cin >> q;
	while (q--)
	{
		long long b, e, k;
		cin >> b >> e >> k;
		cout << count(res.begin() + b, res.begin() + e, k) << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
}card;

card Left[MAX/2+2],Right[MAX/2+2];

void merge(card ary[],int n,int left,int mid,int right){
  int i,j,k;
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)Left[i]=ary[left+i];
  for(i=0;i<n2;i++)Right[i]=ary[mid+i];
  Left[n1].value=Right[n2].value=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(Left[i].value<=Right[j].value){
      ary[k]=Left[i++];
    }
    else{
      ary[k]=Right[j++];
    }
  }
}

void mergesort(card ary[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(ary,n,left,mid);
    mergesort(ary,n,mid,right);
    merge(ary,n,left,mid,right);
  }
}

int partition(card a[],int n,int p,int r){
  int i,j;
  card t,x;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j].value<=x.value){
      i++;
      t=a[i];
      a[i]=a[j];
      a[j]=t;
    }
  }
  t=a[i+1];
  a[i+1]=a[r];
  a[r]=t;
  return i+1;
}

void quicksort(card a[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(a,n,p,r);
    quicksort(a,n,p,q-1);
    quicksort(a,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  card a[MAX],b[MAX];
  char s[10];
  int flag=1;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%d",s,&v);
    a[i].suit=b[i].suit=s[0];
    a[i].value=b[i].value=v;
  }

  mergesort(a,n,0,n);
  quicksort(b,n,0,n-1);

  for(i=0;i<n;i++){
    if(a[i].suit!=b[i].suit)flag=0;
  }
  if(flag==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",b[i].suit,b[i].value);
  }
  return 0;
}



Measured memory_bytes: 4084
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
A = []
while True:
  try:
    tmp = list(map(int,input().split()))
    A.append(tmp)
  except:
    break
correct = 0
for i in range(n):
  eq = 0
  for j in range(len(B)):
    eq += A[i][j]*B[j]
  if eq>-c:
    correct +=1
print(correct)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
const int MAX_V=101;
const int MAX_E=501;
int cost[MAX_V][MAX_V];
int d[MAX_V][11];
bool used[MAX_V][11];

int main(){
    int c,n,m,s,g;
    while(cin>>c>>n>>m>>s>>g){
        if(c==0&&n==0&&m==0&&s==0&&g==0) break;
        for(int i=1; i<=n; ++i){
            for(int j=0; j<=c; ++j){
            	d[i][j]=INF;
            	used[i][j]=false;
            }
            for(int j=1; j<=n; ++j){
                cost[i][j]=INF;
                cost[j][i]=INF;
            }
        }
        for(int i=0; i<m; ++i){
            int a,b,f;
            cin >> a >> b >> f;
            cost[a][b]=f;
            cost[b][a]=f;
        }
        d[s][0]=0;
        while(true){
            int v=-1;
            int cnt=-1;
            for(int u=1; u<=n; ++u){
            	for(int i=0; i<=c; ++i){
                	if(!used[u][i]&&(v==-1||d[u][i]<d[v][cnt])) {
                		v=u;
               			cnt=i;
                	}
                }
            }
            if(v==-1) break;
            used[v][cnt]=true;
            for(int u=1; u<=n; ++u){
            	if(cnt<c) d[u][cnt+1]=min(d[u][cnt+1],d[v][cnt]+cost[v][u]/2);
            	d[u][cnt]=min(d[u][cnt],d[v][cnt]+cost[v][u]);
            }
        }
        int ans=INF;
        for(int i=1; i<=n; ++i){
        	for(int j=1; j<=c; ++j){
        		ans=min(ans,d[g][j]);
        	}
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 1204
let id x = x
module XString = struct
  let to_list str =
    let rec loop i limit =
      if i = limit then []
      else (String.get str i) :: (loop (i + 1) limit)
    in loop 0 (String.length str)

  let of_list s =
    let rec loop s n =
      match s with
        [] -> String.make n '?'
      | car :: cdr ->
         let result = loop cdr (n + 1) in
         Bytes.set result n car;
         result
    in
    Bytes.to_string (loop s 0)
  let rev s =
    of_list (List.rev (to_list s))
end

let f n s t =
  let len = ref 0 in
  for i = 1 to n do
    let s_sub = String.sub s (n - i) i in
    let t_sub = String.sub t 0 i in
    if s_sub = t_sub
    then len := i
  done;
  n + (n - !len)

let main () =
  let n = Scanf.scanf "%d\n" id in
  let s = Scanf.scanf "%s\n" id in
  let t = Scanf.scanf "%s\n" id in
  Printf.printf "%d\n" (f n s t)

let () = main ()


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	double a, b, c;
	int rect, hisi;
	
	rect = hisi = 0;
	
	while (scanf("%lf%*c%lf%*c%lf", &a, &b, &c) != EOF){
		if (a * a + b * b == c * c){
			rect++;
		}
		if (a == b && (a * a) - (c / 2) * (c / 2) > 0){
			hisi++;
		}
	}
	
	printf("%d\n%d\n", rect, hisi);
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c / b;
    if (c % b != 0) {
        x += 1;
    }
    int y = a / d;
    if (a % d != 0) {
        y += 1;
    }
    if (x <= y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3552