akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >> N;
  
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;

    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == (N-1) ){
    	cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 20;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  if (pt_out > buf_size - 32) flush();
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int A[200000], B[200000];
  REP(i, N) scan(A[i]);
  REP(i, N) scan(B[N - 1 - i]);
  int ngs[200000];
  int ngp = 0;
  int ngx = -1;
  REP(i, N) {
    if (A[i] == B[i]) {
      ngs[ngp++] = i;
      ngx = A[i];
    }
  }
  int l = 0, r = N - 1, st = 0;
  REP(j, ngp) {
    int i = ngs[j];
    int target;
    if (st == 0) {
      if (A[l] != ngx && B[l] != ngx) {
        target = l++;
      } else {
        st = 1;
      }
    }
    if (st == 1) {
      if (A[r] != ngx && B[r] != ngx) {
        target = r--;
      } else {
        println("No");
        return 0;
      }
    }
    swap(B[i], B[target]);
  }
  println("Yes");
  REP(i, N) println(B[i]);
  return 0;
}

Measured memory_bytes: 7508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    char st = S[0];
    vector<int> A(S.size()+1);
    for(int i=0;i<S.size();i++){
       if(S[i]=='<'){
           A[i+1] = A[i]+1;
       }
    }
    for(int i=S.size()-1;i>=0;i--){
        if(S[i]=='>'){
            A[i] = max(A[i+1]+1,A[i]);
        }
    }
    ll ans = 0;
    rep(i,A.size()) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2019;
string s;
int c[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int x = 0, t = 1;
  c[0] = 1;
  ll ans = 0;
  FORR(i, sz(s)-1, 0){
    x = (x+t*(s[i]-'0'))%N;
    ans += c[x]++;
    t = t*10%N;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3804
#include <cstdio>
const int maxn = 200005;
long long sum;
int a[maxn];
int n;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		if(a[i] < a[i - 1]){
			sum += a[i - 1] - a[i];
			a[i] += a[i - 1] - a[i];
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 3932
def judge_reachable(graph,start,end,flag):
    flag[start]=1
    for vertex in graph[start]:
        if(flag[vertex]==1):
            continue
        if (vertex==end):
            return 1
        if(judge_reachable(graph,vertex,end,flag)):
            return 1
    return 0



graph_n=int(input())


edge_dict={}



for i in range(graph_n):
    tmp_row=list(map(int,input().split()))
    for j in range(graph_n):
        if(tmp_row[j]!=-1):
            try:
                edge_dict[tmp_row[j]].append([i,j])
            except:
                edge_dict[tmp_row[j]]=[[i,j]]


sorted_edge=sorted(edge_dict.items())


graph=[[] for i in range(graph_n)]

edge_num=0
cost=0

for edges in sorted_edge:
    for edge in edges[1]:
        flag=[0]*graph_n
        if(judge_reachable(graph,edge[0],edge[1],flag)==0):
            graph[edge[0]].append(edge[1])
            graph[edge[1]].append(edge[0])
            edge_num+=1
            cost+=edges[0]
            if(edge_num ==graph_n - 1):
                break    
    if(edge_num ==graph_n -1):
        break

print(cost)


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string s; cin>>s;
    int n = s.size();
    vector <int> data(26); 
    rep(i,n) data[s[i]-'a']++;
    if(n!=26){
        cout<<s;
        rep(i,26) if(!data[i]) {cout<<char(i+'a')<<endl; return 0;}
    }else{
        if(s == "zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
        else{
            string t = s;
            next_permutation(all(s));
            rep(i,n) {cout<<s[i]; if(t[i]!=s[i]) break;}
            cout<<endl;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] G = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int x = a[0];
        int y = a[1];
        if (G[x] == G[y])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 1e9+7 ;
const ld error = 1e-8;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
//mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll
//mt19937 rng(199);

inline ll MOD(ll x, ll m = mod){
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 1e5 + 10;
///===========================================  template  =======================================================

int main(){
    int x, y, z;
    cin>>x>>y>>z;
    swap(x, y);
    swap(x, z);
    
    cout<<x<<" "<<y<<" "<<z;
    return 0;
}

Measured memory_bytes: 256
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
now = sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1)
result = [str(sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1))]
for i in range(N-1):
  now = (A[i]*2 - now)
  result.append(str(now))
print(' '.join(result))
  


Measured memory_bytes: 17228
#include <iostream>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	if (x + r<=W && x >=r && y>=r && y+r<=H) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


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

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	int n, x, y; cin >> n >> x >> y;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1, INT_MAX));

	for (int i = 1; i <= n; i++) dp[i][i] = 0;
	vector<int> ans(n, 0);

	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) dp[i][j] = min({abs(i - j), abs(x - i) + 1 + abs(j - y), abs(x - j) + 1 + abs(i - y)}), ans[dp[i][j]]++;
	}

	for (int k = 1; k <= n - 1; k++) cout << ans[k] << "\n";

	return 0;
}

Measured memory_bytes: 18848
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

c = Counter(S)
max_c = max(c.values())
#キーの昇順でソート
c_sorted = sorted(c.items(), key = lambda x:x[0])
for v in c_sorted:
    if v[1] == max_c:
        print(v[0])

Measured memory_bytes: 48404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	int ans = 180 * (N-2);
	
	cout<<ans<<endl;
}

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

int main(){

  string s1, s2;
  cin >> s1 >> s2;
  string ans = "YES";
  for(int i=0; i<3; i++){
    if(s1[i] != s2[2-i]){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
S = list(map(int, input().split()))
N = S[0]
K = S[1]
Q = S[2]

point = [K] * N
A = []
for q in range(Q):
    A.append(int(input()) - 1)

for a in A:
    point[a] += 1

for ans in point:
    if ans <= Q:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 10472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var cin = GetIntArray();
            var ans = 0;
            while (cin[0] != cin[1] || cin[1] != cin[2] || cin[2] != cin[0])
            {
                Array.Sort(cin);
                if (cin[1]==cin[0])
                {
                    cin[0]++;
                    cin[1]++;
                    ans++;
                }
                else
                {
                    cin[0] += 2;
                    ans++;
                }
            }
            

            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13396
function Main(input) {
    var num = parseInt(input.split("\n")[0]);
    var sideLength = input.split("\n")[1].split(" ");
    
    for(var a=0; a<num; a++){
        sideLength[a] = parseInt(sideLength[a]);
    }
   
   sideLength.sort(
       function(a,b){
           if(a>b){
               return 1;
           }else if(a<b){
               return -1;
           }else{
               return 0;
           }
       }
   )
   
   var count = 0;

   function deltacheck(a,b,c){
       var aINT = parseInt(a);
       var bINT = parseInt(b);
       var cINT = parseInt(c);
       return (aINT+bINT)>cINT && (aINT+cINT)>bINT && (bINT+cINT)>aINT && aINT!==bINT && aINT!==cINT && bINT!==cINT;
   }
   
   if(num<3){
       console.log(0);
   }else{
       for(var i=0; i<num; i++){
           for(var j=i+1; j<num; j++){
               for(var k=j+1; k<num; k++){
                   if(deltacheck(sideLength[i],sideLength[j],sideLength[k])){
                       count+=1;
                   }
               }
           }
       }
       console.log(count);
   }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31552
N = int(input())
L = list(map(int, input().split()))
#print(L)
Ans = 0

for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        if max(L[i],L[j],L[k]) < (L[i]+L[j]+L[k]) - max(L[i],L[j],L[k]):
          Ans += 1
#          print(str(L[i]) + " " + str(L[j]) + " " + str(L[k]))

print(Ans)


Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;long K;cin>>N>>K;
    long A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }long optim=0;int bit=0;
    while((1ull<<bit)<=K){
        int count_one=0,count_zero=0;
        for(int i=0;i<N;i++){
            if(A[i]&(1ull<<bit)){
                count_one++;
            }else{
                count_zero++;
            }
        }if(count_zero>count_one){
            optim=optim|(1ull<<bit);
        }bit++;
    }long temp,sum,result=0;
    for(int i=bit;i>=0;i--){
        temp=0;
        for(int j=bit;j>=0;j--){
            if(j>i&&(K+1)&(1ull<<j)){
                temp=temp|(1ull<<j);
            }else if(j==i&&!((K+1)&(1ull<<j))){
                temp=0;
                break;
            }else if(j<i&&optim&(1ull<<j)){
                temp=temp|(1ull<<j);
            }
        }sum=0;//cout<<temp<<endl;
        for(int k=0;k<N;k++){
            sum+=temp^A[k];
        }result=max(result,sum);
    }cout<<result<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

ll dist(pair<ll,ll> a, pair<ll,ll> b){
    return abs(a.first-b.first)+abs(a.second-b.second);
}

bool comp1(pair<ll,ll> a, pair<ll,ll> b){
    return a.first+a.second>b.first+b.second;
}
bool comp2(pair<ll,ll> a, pair<ll,ll> b){
    return a.first-a.second>b.first-b.second;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll n;
    cin>>n;
    vector<pair<ll,ll>> p(n);
    for(ll i=0;i<n;i++)
        cin>>p[i].first>>p[i].second;
    ll ans=0;
    sort(p.begin(),p.end(),comp1);
    ans=max(ans,dist(p[0],p[n-1]));
    sort(p.begin(),p.end(),comp2);
    ans=max(ans,dist(p[0],p[n-1]));
    cout<<ans;


 
 
    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 6404
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;

signed main(){
  int n,a;cin>>n>>a;
  vector<int> x(n);
  rep(i,n)cin>>x[i];
  int res=0;
  vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(n+1,vector<int>(3000,0)));
  dp[0][0][0]=1;dp[0][1][x[0]]=1;
  rep1(i,n-1){
    dp[i][0][0]=dp[i-1][0][0];
    rep1(j,n){
      rep(k,3000){
        dp[i][j][k]=dp[i-1][j][k];
        if(k-x[i]>=0){
          dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
        }
      }
    }
  }
  rep1(i,n){
    res+=dp[n-1][i][i*a];
    //cout<<dp[n-1][i][i*a]<<endl;
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 62592
#include <stdio.h>

int main()
{
	long n;
	scanf("%ld", &n);
	long a[n + 1];
	long b[n + 1];
	long i,j;
	i = 1;
	while (i <= n)
		b[i++] = 0;
	i = 1;
	while (i < n)
	{
		scanf("%ld", &a[i]);
		b[a[i]] += 1;
		i++;
	}
	i = 1;
	while (i <= n)
		printf("%ld\n", b[i++]);
}


Measured memory_bytes: 5260
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q;
	cin >> n >> q;
	string name[n];
	int time[n];
	vector <pair <string,int> > ans;
	queue <pair <string,int> > queue;
	for(int i=0;i<n;i++){
		cin >> name[i] >> time[i];
		queue.push(make_pair(name[i],time[i]));
	}
	int sum_time=0;
	while(!queue.empty()){
		string kari=queue.front().first;
		int va=queue.front().second;
		queue.pop();
		if(va-q<=0){
			sum_time+=va;
			ans.push_back(make_pair(kari,sum_time));
		}
		else{
			sum_time+=q;
			queue.push(make_pair(kari,va-q));
		}
	}
	for(int i=0;i<n;i++)
		cout << ans[i].first << " " << ans[i].second << endl;
	return 0;
}

Measured memory_bytes: 7572
#include <stdio.h>

#define max(a,b) ((a)>(b))?a:b
#define min(a,b) ((a)<(b))?a:b

int main(void)
{
  int K, X;
  int i;

  scanf("%d %d",&K,&X);

  int a=max(-1000000,X-K+1),b=min(1000000,X+K-1);
  for(i=a;i<=b;i++)printf("%d ",i);
  putchar('\n');

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
string str;
ll a;
int main()
{
	cin>>str;
	for(register int i=0;i<str.length();i++)
	{
		if(str[i]=='1')
		{
			a++;
		}
	}
	cout<<a;
}
	

Measured memory_bytes: 256
N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans)    
    

Measured memory_bytes: 21100
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string N;
    cin >> N;
    if ((N[0] == N[1] && N[0] == N[2]) ||
        (N[1] == N[2] && N[1] == N[3]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n;
	cin>>n;

	vi ans(n+1,0);

	FOR(x,1,sqrt(n)+1){
		FOR(y,1,sqrt(n)+1){
			FOR(z,1,sqrt(n)+1){
				int u=x*x+y*y+z*z+x*y+y*z+z*x;
				if(u<=n){
					ans[u]++;
				}
			}
		}
	}
	FOR(i,1,n){
		cout<<ans[i]<<endl;
	}

}



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

int main()
{
    int arr[3];

    cin >> arr[0] >> arr[1] >> arr[2];

    for (int i = 0; i < 3 ; i++) {
        for (int j = i+1; j < 3; j++) {
                if(arr[i] > arr[j]) {
                int kari = arr[i];
                arr[i] = arr[j];
                arr[j] = kari;
            }
        }
    }
    
    for (int k = 0; k < 2; k++) {
        cout << arr[k] << " ";
    }
    cout << arr[2] << endl;

    return 0;
    }



Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {



	int n;
	int m;
	int l;
	int a[100][100] = { 0 };
	int b[100][100] = { 0 };

	scanf("%d %d %d", &n, &m, &l);

	int i = 0;
	int j = 0;

	for (; i < n; i++) { // 行列A
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	int k = 0;
	for (j = 0; j < m; j++) { //行列B
		for (k = 0; k < l; k++) {
			scanf("%d", &b[j][k]);
		}

	}

	long long c[100][100] = { 0 };

	long long temp_sum = 0;

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++) {

				temp_sum += a[i][k] * b[k][j];
			}

			c[i][j] = temp_sum;
			temp_sum = 0;
		}
	}

	//c[i][l] = a[i][1] * b[1][1] 
//	c[i][l] += a[i][2]*b[2][1l];

//	c[i][l] = a[i][1] * b[1][2];
//	c[i][l] += a[i][2] * b[2][2];

//	c[i][l] = a[i][1] + b[1][3];
//	c[i][l] = a[i][2] * b[2][3]
//c[2][1] = a[2]



	for (i = 0; i < n; i++) {
		for (k = 0; k < l - 1; k++) {
			printf("%lld ", c[i][k]);
		}
		printf("%lld\n", c[i][l - 1]);
	}


	return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
int gcd(int x, int y){
    return (x%y>0) ? gcd(y, x%y) : y;
}
int main(){
    int x, y;
    int w;
    scanf("%d %d", &x, &y);
    w = gcd(x, y);
    printf("%d\n", w);
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  deque<int> d;

  int flg = n%2;
  REP(i,n){
    if(i%2 == flg) d.push_back(a[i]);
    else d.push_front(a[i]);
  }

  //if(n%2) reverse(d);

  for(auto x : d) cout << x << " ";
  cout << endl;

  return 0;
}

// int main(){
//   int n;
//   cin >> n;
//   vector<int> a(n);
//   REP(i,n) cin >> a[i];
//   vector<int> b;
//   vector<int> c;

//   if(n == 1){
//     cout << a[0] << endl;
//     return 0;
//   }

//   REP(i,n){
//     if(i%2) b.push_back(a[i]);
//     else c.push_back(a[i]);
//   }

//   if(n%2 == 1) swap(b,c);

//   reverse(ALL(b));
//   for(auto x : b) cout << x << " ";
//   for(auto x : c) cout << x << " ";
//   return 0;
// }

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

int main() {
  int l,r;
  cin>>l>>r;
  r=min(r,l+2018);
  int ans=2018*2018;
  for(int i=l;i<=r;i++){
    for(int j=i+1;j<=r;j++){
      int x=i%2019;
      int y=j%2019;
      ans=min(ans,(x*y)%2019);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int N, A, B, C, D;
string S;
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	A--, B--, C--, D--;
	for (int i = min(A, B); i < max(C, D);i++) {
		if (S.substr(i, 2) == "##") {
			print("No"); return 0;
		}
	}
	//Bが先
	if (D > C) {
		//Bが右側
		if (B > A) {
			S[D] == '#';
			for (int i = A; i < C; i++) {
				if (S.substr(i, 2) == "##") {
					print("No"); return 0;
				}
			}
			print("Yes"); return 0;
		}
		//Bが左側
		else {
			//"..."の真ん中にAを置けばok
			for (int i = max((ll)0,A - 1); i <= C - 1; i++) {
				bool found = false;
				for (int j = i; j < i + 3; j++) {
					if (S[j] == '#')found = true;
				}
				if (!found) {
					print("Yes"); return 0;
				}
			}
			print("No"); return 0;
		}
	}
	//Aが先
	else {
		//Aが右側
		if (A > B) {
			S[C] == '#';
			for (int i = B; i < D; i++) {
				if (S.substr(i, 2) == "##") {
					print("No"); return 0;
				}
			}
			print("Yes"); return 0;
		}
		//Aが左側
		else {
			//"..."の真ん中にBを置けばok
			for (int i = max((ll)0,B - 1); i <= D - 1; i++) {
				bool found = false;
				for (int j = i; j < i + 3; j++) {
					if (S[j] == '#')found = true;
				}
				if (!found) {
					print("Yes"); return 0;
				}
			}
			print("No"); return 0;
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

bool isAbleToEatEarierThanX(vector<ll> a,vector<ll>f,ll x,ll n,ll k){
    ll cost = 0;
    REP(i,n){
        cost+=max((ll)0,a[i]-x/f[i]);
    }
    return (cost <= k);
}
 
ll binarysearch(ll ok, ll ng,vector<ll>a,vector<ll>f,ll n,ll k){
    while(llabs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(isAbleToEatEarierThanX(a,f,mid,n,k)){
            ok = mid;
        }
        else{
            ng = mid;
        }
        
    }
    return ok;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),f(n),ans(n);
    REP(i,n)cin >> a[i];
    REP(i,n)cin >> f[i];
    sort(ALL(a));
    sort(ALL(f));
    reverse(ALL(f));

    ll total=0;
    ll costs=0;
    REP(i,n){
        total += a[i]*f[i];
        costs +=a[i];
    }
    if(costs<=k){
        cout << 0 << endl;
        return 0;
    }
    cout << binarysearch(total,0,a,f,n,k) << endl;
    return 0;
}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

int x[202020];
int l[202020][20], r[202020][20];
int dpl[1 << 20], dpr[1 << 20];

void solve() {
        int n, v;
        cin >> n >> v;
        for (int i = 0; i < n; i ++) cin >> x[i];
        int p;
        for (int i = 0; ; i ++) if ((1 << i) > v) {
                p = i + 1;
                break;
        }
        for (int i = 0; i < n; i ++) {
                int vv = v;
                for (int j = 0; j < p; j ++) {
                        if (i == 0 || x[i] - x[i - 1] > vv) l[i][j] = i;
                        else l[i][j] = l[i - 1][j];
                        vv /= 2;
                }    
        }
        for (int i = n - 1; i >= 0; i --) {
                int vv = v;
                for (int j = 0; j < p; j ++) {
                        if (i == n - 1 || x[i + 1] - x[i] > vv) r[i][j] = i;
                        else r[i][j] = r[i + 1][j];
                        vv /= 2;
                }
        }
        for (int i = 0; i < (1 << p); i ++) {
                if (i & 1) continue;
                for (int j = 1; j < p; j ++) {
                        if ((i >> j) & 1) continue;
                        if (dpr[i] == n) dpr[i | (1 << j)] = n;
                        else dpr[i | (1 << j)] = max(dpr[i | (1 << j)], r[dpr[i]][j] + 1);
                }
        }
        for (int i = 0; i < (1 << p); i ++) dpl[i] = n - 1;
        for (int i = 0; i < (1 << p); i ++) {
                if (i & 1) continue;
                for (int j = 1; j < p; j ++) {
                        if ((i >> j) & 1) continue;
                        if (dpl[i] == -1) dpl[i | (1 << j)] = -1;
                        else dpl[i | (1 << j)] = min(dpl[i | (1 << j)], l[dpl[i]][j] - 1);
                }
        }
        bool ok = false;
        for (int i = 0; i < n; i ++) {
                if (l[i][0] == i) {
                        int c = 0;
                        for (int j = 0; j < (1 << p); j ++) {
                                c ++;
                                if (j & 1) continue;
                                if (i > 0 && dpr[j] < i) continue;
                                if (r[i][0] < n - 1 && dpl[(1 << p) - 2 - j] > r[i][0]) continue;
                                break;
                        }
                        if (c < (1 << p)) ok = true;
                        else ok = false;
                }
                if (ok) cout << "Possible" << endl;
                else cout << "Impossible" << endl;
        }
        return;
}

int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        //int T;
        //freopen("a.in", "r", stdin);
        //cin >> T;
        //while (T --) solve();
        solve();
        return 0;
}



Measured memory_bytes: 42752
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    int flag = 0;
    if(a == b) {
        if(4*a < c) {
            flag = 1;
        }else {
            flag = 0;
        }
    }else {
        if(2*(a+b) <= c) {
            flag = 1;
        }else {
            flag = 0;
        }
    }
    if(2*min(a,b) >= c) {
        flag = 0;
    }else if(sqrt(a)+sqrt(b) < sqrt(c)){
        flag = 1;
    }
    
    if(flag == 1) {
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
/*
	Author: An_sh
	Created: 08-12-2019 17:21:23
*/

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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inn freopen("input.txt", "r", stdin) 
#define outt freopen("output.txt", "w",stdout)


int main()
{
	IOS;
	//inn; outt;
	int a, b, c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust";
	else
		cout<<"win";

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.nextLine();

        switch (s) {
            case "Sunny":
                System.out.println("Cloudy");
                return;
            case "Cloudy":
                System.out.println("Rainy");
                return;
            default:
                System.out.println("Sunny");
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

using namespace std;

int main(){
int N; cin >> N;
  vector<vector<int>> A(2,vector<int>(N,0));
  
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      cin >> A[i][j];}}
    
    int max_sum = 0;
    
    for(int i = 0; i < N; i++){ int sum = 0;
      for(int j = 0; j <= i; j++){ sum += A[0][j];}
      for(int k = i; k < N; k++){ sum += A[1][k];}
           max_sum = max(max_sum,sum);}
    
    cout << max_sum << endl; return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

long long int chmin(long long int a, long long int b)
{
	if (a > b)
		return b;
	else
		return a;
}

int main(int argc, char const *argv[])
{
	long long int n;
	scanf("%lld", &n);
	long long int dp[n];
	long long int h[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &h[i]);
	}
	dp[0] = 0;
	dp[1] = llabs(h[1] - h[0]);
	for (int i = 2; i < n; ++i)
		dp[i] = chmin(dp[i - 1] + llabs(h[i] - h[i-1]), dp[i - 2] + llabs(h[i] - h[i - 2]));
	printf("%lld", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int deg[103];
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		for(int i=0;i<103;i++)deg[i]=0;
		deg[a]++;
		deg[b]++;
		while(scanf("%d%d",&a,&b),a){
			deg[a]++;
			deg[b]++;
		}
		int p=0;
		for(int i=3;i<103;i++)p+=deg[i]%2;
		if(p==0&&deg[2]%2&&deg[1]%2)printf("OK\n");
		else printf("NG\n");
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == b) cout << "Draw" << endl;
  else if(a == 1) cout << "Alice" << endl;
  else if(b == 1) cout << "Bob" << endl;
  else if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define F first
#define S second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a[3];
    cin >> a[0] >> a[1] >> a[2];
    int n[3]={};
    int t=0;
    while(true){
      if(a[t].size() <= n[t]) break;
      int tt = a[t][n[t]]-'a';
      n[t]++;
      t = tt;
    }
    cout << (char)(t+'A') << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   int t_1,t_2;
   int a_1,a_2,b_1,b_2;
   cin>>t_1>>t_2>>a_1>>a_2>>b_1>>b_2;
   if(a_1*t_1+a_2*t_2==b_1*t_1+b_2*t_2){
       cout<<"infinity"<<endl;
    return 0;
   }
   int start=a_1*t_1-b_1*t_1;
   if(start>0){
       if(a_1*t_1+a_2*t_2>b_1*t_1+b_2*t_2){
           cout<<0<<endl;
           return 0;
       }
        int maxdis=start;
        int mindis=abs(a_1*t_1+a_2*t_2-(b_1*t_1+b_2*t_2));
        if(maxdis%mindis==0){
            cout<<2*((maxdis)/mindis)<<endl;
        }
        else{
            cout<<2*((maxdis+mindis-1)/mindis)-1<<endl;
        }
        
   }
   if(start<0){
       if(a_1*t_1+a_2*t_2<b_1*t_1+b_2*t_2){
           cout<<0<<endl;
           return 0;
       }
        int maxdis=abs(start);
        int mindis=abs(a_1*t_1+a_2*t_2-(b_1*t_1+b_2*t_2));
       if(maxdis%mindis==0){
            cout<<2*((maxdis)/mindis)<<endl;
        }
        else{
            cout<<2*((maxdis+mindis-1)/mindis)-1<<endl;
        }

   }
   
   
   

   
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

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

    rep3(a, n) {

        rep3(b, n) {
            int c = n - a - b;
            if (c < 0 || c > n) break;
            if (10000 * a + 5000 * b + 1000 * c == y) {
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }

    }

    cout << "-1 -1 -1" << endl;

    return 0;
}



Measured memory_bytes: 256
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]

# if __name__ == '__main__':


k, a, b = map(int, input().split())

ans = 1
## a枚に達するまでは+1
ans += a - 1
k = k - ans + 1

## b-a >= 2 ならば exchange法
if (b - a >= 2):
	if (k % 2 == 1):
		ans += (k//2) * (b - a) + 1
	else:
		ans += (k//2) * (b - a)
else:
	ans += k

print(ans)




Measured memory_bytes: 3188
from collections import deque

SA = input()
SB = input()
SC = input()

count_a = len(SA)
count_b = len(SB)
count_c = len(SC)

da = deque()
db = deque()
dc = deque()

for i in range(len(SA)):
    da.append(SA[i])
for j in range(len(SB)):
    db.append(SB[j])
for k in range(len(SC)):
    dc.append(SC[k])

turn = 0
times = count_a+count_b+count_c
for i in range(times):
    if turn == 0:
        if count_a== 0:
            print("A")
            exit()
        a = da.popleft()
        count_a -= 1
        if a == "a":
            continue
        elif a =="b":
            turn = 1
            continue
        else:
            turn = 2
            continue
    elif turn == 1:
        if count_b == 0:
            print("B")
            exit()
        b = db.popleft()
        count_b -= 1
        if b == "b":
            continue
        elif b =="a":
            turn = 0
            continue
        else:
            turn = 2
            continue
    elif turn == 2:
        if count_c == 0:
            print("C")
            exit()
        c = dc.popleft()
        count_c -=1
        if c == "c":
            continue
        elif c == "a":
            turn = 0
            continue
        else:
            turn = 1
            continue

Measured memory_bytes: 3316
n=int(input())
l = []

for i in range(1,n+1):
  if i % 3 != 0:
    if i % 5 != 0:
        l.append(i)
  elif i % 5 != 0:
      if i % 3 != 0:
          l.append(i)

print(sum(l))
    

Measured memory_bytes: 30004
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < s.length; i++) {
            if(s[i] != t[i]) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main() {
  int N; cin >> N;
  cout << 0 << endl;
  string zero; cin >> zero;
  if (zero == "Vacant") return 0;
  string s;
  int left = 0, right = N;
  for (int i = 0; i < 19; i++) {
    int mid = (left + right) / 2;
    cout << mid << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    if (mid % 2 == 0) {
      if (s == zero) left = mid;
      else right = mid;
    }
    else {
      if (s == zero) right = mid;
      else left = mid;
    }
  }
  return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x,i,c=0,s=0;
    cin>>n>>x;
    long long a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        s+=a[i];
        if(s>x)
            break;
        else c++;
    }
    if(n!=1 && i==n && s!=x) c--;
    cout<<c;
}

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

const int MOD = (int)1e9+7;

int main(){
	long long N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);
	
	long long ans=0;
	int l=0,r=0;
	int now=0;
	for(r=0;r<N;r++){
		if((now&A.at(r))==0){
			now+=A.at(r);
		}
		else{
			while((now&A.at(r))!=0){
				long long x=r-l;
				ans+=x;
				now-=A.at(l);
				l++;
			}
			now+=A.at(r);
		}
	}
	long long x=r-l;
	ans+=x*(x+1)/2;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // int -> ll

int main(){
    ll sum = 100;
    ll year=0;
    ll x;
    cin >> x;
    for(ll i=0; sum<x; i++) {
        sum = sum * 1.01 / 1;
        year++;
    }
    cout << year << endl;


}


Measured memory_bytes: 3604