akhauriyash/Code-Regression huggingface dataset:
import math
li =[int(input()) for i in range(5)]
min_t=999
time=0
sum_t=0
for i in range(5):
    sum_t += math.ceil(li[i]*0.1)*10
for i in range(5):
    time = sum_t - (math.ceil(li[i]*0.1)*10-li[i])
    if time<min_t:
        min_t=time
print(min_t)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    n--;
    ll dd=abs(a-b);
    if(n%2==0){
        if((n/2)*(d-c)==dd){cout<<"YES"<<endl;return 0;}
    }
    for(int i=0;i<=(n-1)/2;i++){
        if(abs(d*(n-i)-c*i)>=dd&&dd>=((n-1)*c-d*i>=0)*abs((n-i)*c-d*i)){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int t, n, ok;
ll a[205];
char s[205];
int main(){
	scanf("%d", &t);
	rep(o,t){
		scanf("%d", &n);
		rep(i,n) scanf("%lld", a+i);
		scanf("\n%s", s);
		ok = 0;
		for(int i=n-1; i>=0; i--) if(a[i]){
			if(s[i] == '1'){
				ok = 1;
				break;
			}
			rep(k,64) if(a[i]>>k&1){
				for(int j=i-1; j>=0; j--) if(a[j]>>k&1) a[j] ^= a[i];
				break;
			}
		}
		printf("%d\n", ok);
	}
}

Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    long long a; cin >> a;
    int b[10] = {0};
    int cnt = 0;
    while (a) {
        b[cnt] = a % 10;
        a /= 10;
        cnt++;
    }
    if (cnt == 1) {
        cout << b[0] << endl;
        return 0;
    }
    long long sum = 0;
    int flg = 0;
    for (int i = 0; i < (1 << (cnt - 1)); ++i) { //数字の間に+入れるか
        long long tmp = b[0];
        //cout << tmp << endl;
        for (int j = 0; j < cnt - 1; ++j) { //間に+入るか
            if (i & (1 << j)) {
                sum += tmp; //ex. 1 7 6
                tmp = b[j + 1];
                if (j == cnt - 2) sum += tmp;
                flg = 0;
            } else {
                flg++;
                tmp += pow(10, flg) * b[j + 1];
                if (j == cnt - 2) {
                    sum += tmp;
                    flg = 0;
                }
            }
            //cout << tmp << endl;
            //cout << "sum " << sum << endl;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
typedef long long ll;

int main(void){
    ll N;
    cin>>N;
    rep1(a,3500)rep1(b,a){
        if(4*a*b-N*a-N*b <= 0) continue;
        if((N*a*b)%(4*a*b-N*a-N*b)==0){
            cout<<a<<" "<<b<<" "<<(N*a*b)/(4*a*b-N*a-N*b)<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
ll n;vvi adj;pll dp[1+(int)1e5];
pll getans(int x,int parent)
{
    if(dp[x].ff!=-1)return dp[x];
    pll ans=mp(1,1);
    forn(i,adj[x].size())
    {
        if(adj[x][i]==parent)continue;
        pll child=getans(adj[x][i],x);
        ans.ff=(ans.ff*((child.ff+child.ss)%mod))%mod;
        ans.ss=(ans.ss*child.ff)%mod;
    }
    dp[x]=ans;
    return ans;
}
void solve()
{
    cin>>n;adj.resize(n+1);forn(i,n+1)adj[i].clear();
    forn(i,n-1){int x,y;cin>>x>>y;adj[x].pb(y);adj[y].pb(x);}
    forn(i,n+1)dp[i]=mp(-1,-1);
    pll ans=getans(1,-1);
    cout<<(ans.ff+ans.ss)%mod<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    ll zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 17044
#ceilevenoddformula
import math
from queue import PriorityQueue
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
n=int(input())
l=[int(x) for x in input().split()]
c=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k]:
				if l[i]+l[j]<=l[k] or l[k]+l[j]<=l[i] or l[i]+l[k]<=l[j] :
					continue
				else:
					c+=1

print(c)













 
          





























Measured memory_bytes: 75804
#include <iostream>
#include <map>

using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define out(v) cout<<v<<"\n"
const int MOD = 1e9+7;
const int MAX = 1e5 + 10;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long comb(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;

  COMinit();
  int a[N];
  map<int, int> m;
  int left, right;
  rep(i, N+1) {
    cin >> a[i];
    if (m[a[i]-1] != 0) {
      left = m[a[i]-1] - 1;
      right = N + 1 - (i+1);
    }
    m[a[i]-1] = i+1;
  }
  fromto(k, 1, N+1) {
    int ans = (comb(N+1, k) - comb(left+right, k-1) + MOD) % MOD;
    cout << ans << "\n";
  }
  return 0;
}


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

int main()
{
    //freopen("in.txt","r",stdin);
    ll N,x,y,sum;
    cin >> N;
    for(ll i=(int)(sqrt(N));i>=1;i--){
        if(N%i==0){
            x = i;
            y = N/i;
            sum = x + y - 2;
            cout << sum << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}

void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		auto taxed= iota(s).map!(i => tax(x,i)).array.assumeSorted;
		foreach(i;1..s){			
			foreach(j;i..s){
				if (taxed[i] + taxed[j] == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}
int tax(int per,int yen) {return yen * (100 +per) / 100;}

Measured memory_bytes: 2892
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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(a) (a).begin(), (a).end()

int main() {
    int N, A[100001] = {};
    cin >> N;
    FOR(i, 1, N) {
        string s = to_string(i);
        int count = 0;
        REP(j, s.size()) {
            count += s[j] - '0';
        }
        A[i] = count;
    }

    int ans = 100000;
    FOR(i, 1, N) {
        ans = min(ans, A[i] + A[N - i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
<?php
    fscanf(STDIN, "%s", $s);
    $result = '';
    if($s === 'Sunny'){
        $result = 'Cloudy';
    }elseif($s === 'Cloudy'){
        $result =  'Rainy';
    }elseif($s === 'Rainy'){
        $result = 'Sunny';
    }
    echo $result;
  ?>

Measured memory_bytes: 3700
a,b,c,d = map(int, input().split())
if max(a,b)<=min(c,d) or min(a,b)>=max(c,d):
  print(0)
elif min(a,b)>=min(c,d) and max(a,b)<=max(c,d):
  print(max(a,b)-min(a,b))
elif min(a,b)<=min(c,d) and max(a,b)>=max(c,d):
  print(max(c,d)-min(c,d))
elif min(a,b)<=min(c,d) and max(a,b)<=max(c,d):
  print(max(a,b)-min(c,d))
elif min(a,b)>=min(c,d) and max(a,b)>=max(c,d):
  print(max(c,d)-min(a,b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, pair <int, ll> > PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 1e5 + 5;
int n, m;

vector <int> v[maxn];
bool odw[maxn];
vector <int> od;
bool jest[maxn];
int p[maxn];

void dfs(int x)
{
	odw[x] = 1;
	jest[p[x]] = 1;
	od.pb(x);
	for (auto u : v[x])
		if (!odw[u]) dfs(u);
}

int main()
{
	boost;
	cin >> n >> m;
	FOR(i, 1, n) cin >> p[i];
	FOR(i, 1, m)
	{
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	
	int result = 0;
	
	FOR(i, 1, n)
		if (!odw[i])
		{
			od.clear();
			dfs(i);
			for (auto u : od)
				if (jest[u]) ++result;
			
			for (auto u : od) jest[p[u]] = 0;
		}
	
	cout << result;
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a<b) swap(a,b); if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

long long N, M, K, H, W, L, R;

int main(){
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
string s;
 int main()
 {
     long long  t, n, k, x;
     long long sum = 0;
     cin>>s;
     for(int i=0; i < s.size(); i++)
     {
         int c = (s[i] - '0');
         sum = sum + c;
     }
     if(sum % 9 == 0)
         cout<<"Yes"<<"\n";
     else
         cout<<"No"<<"\n";
     return 0;

 }

Measured memory_bytes: 3716
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    byte a = scan.nextByte();
    byte b = scan.nextByte();
    byte c = scan.nextByte();
    if ((b - a) == (c - b)) {
      System.out.println("YES");
    }else {
      System.out.println("NO");
    }
  }
}


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

int main()
{
    string s;
    cin >> s;
    string ref = s;

    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << ((s.length() == ref.length()) ? "yes" : "no");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int A, B; cin>>A>>B;
  cout << A*B << endl;
  return 0;
}


Measured memory_bytes: 3148
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
 
public class Main
{
    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        String s=in.next();
        if(s.equals("SSS"))
            System.out.println("0");
        if(s.equals("SSR"))
            System.out.println("1");
        if(s.equals("SRS"))
            System.out.println("1");
        if(s.equals("RSS"))
            System.out.println("1");
        if(s.equals("SRR"))
            System.out.println("2");
        if(s.equals("RSR"))
            System.out.println("1");
        if(s.equals("RRS"))
            System.out.println("2");
        if(s.equals("RRR"))
            System.out.println("3");
        
        
    }
}


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

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

    int N, K, S, T; cin >> N >> K >> S >> T;
    vector<int> bit;
    bool ok = true;
    for (int i = 0; i < 18; i++) {
        bool s = S & (1 << i);
        bool t = T & (1 << i);
        if (s && !t) ok = false;
        if (!s && t) bit.emplace_back(i);
    }

    if (!ok) {
        cout << 0 << "\n";
        return 0;
    }

    const int B = bit.size();
    vector<int> X;
    for (int i = 0; i < N; i++) {
        int A; cin >> A;
        if ((A & S) == S && (A | T) == T) {
            int c = 0;
            for (int i = 0; i < B; i++) {
                if (A & (1 << bit[i])) c |= 1 << i; 
            }
            X.emplace_back(c);
        }
    }
    
    long long Bicom[51][51];
    memset(Bicom, 0, sizeof(Bicom));
    Bicom[0][0] = 1;
    for (int n = 0; n < 50; n++) {
        for (int r = 0; r <= n; r++) {
            Bicom[n+1][r] += Bicom[n][r];
            Bicom[n+1][r+1] += Bicom[n][r];
        }
    }

    const int M = X.size();
    const int mask = (1 << B) - 1;
    
    long long Ans = 0;
    for (int k = 1; k <= K; k++) Ans += Bicom[M][k];
    
    for (int first = 0; first < M; first++) {
        vector<long long> C(1 << B, 0);
        for (int i = first+1; i < M; i++) {
            int same = (X[first] ^ X[i]) ^ mask;
            C[same]++;
        }
        
        for (int i = B-1; i >= 0; i--) {
            for (int j = 0; j < (1 << B); j++) {
                if ((1<<i) & j) C[j^(1<<i)] += C[j];
            }
        }

        for (int i = 0; i < (1 << B); i++) {
            int x = C[i]; C[i] = 0;
            for (int k = 1; k < K; k++) {
                C[i] += Bicom[x][k];
            }
        }

        for (int i = B-1; i >= 0; i--) {
            for (int j = 0; j < (1 << B); j++) {
                if ((1<<i) & j) C[j^(1<<i)] -= C[j];
            }
        }
        
        for (int i = 1; i < (1 << B); i++) Ans -= C[i];
        if (!(X[first] == 0 && B == 0)) Ans--; // X[first] + {empty}
    }

    cout << Ans << "\n";

    return 0;
}

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

namespace Happy {
    class Program {
        static void exc (ref int a, ref int b) {
            int t = a;
            a = b;
            b = t;
        }
        static void Main (string[] args) {
            string[] uinp;
            uinp = Console.ReadLine ().Split (new char[] { ' ' });
            int a, b, c;
            int.TryParse (uinp[0], out a);
            int.TryParse (uinp[1], out b);
            int.TryParse (uinp[2], out c);
            if (a > b) exc (ref a, ref b);
            if (b > c) exc (ref b, ref c);
            if (a > b) exc (ref a, ref b);
            if ((a == 5) && (b == 5) && (c == 7)) Console.WriteLine ("YES");
            else Console.WriteLine ("NO");

            Console.ReadLine ();
        }
    }
}


Measured memory_bytes: 13140
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,t = inm()
ab = []
for i in range(n):
    aa,bb = inm()
    ab.append((aa,-bb))
ab.sort()
d = [ [-1]*(t+1) for i in range(n+1) ]
for i in range(n+1):
    d[i][0] = 0
#ddprint(d)
for i in range(n):
    for j in range(t+1):
        d[i+1][j] = max(d[i+1][j], d[i][j])
        if j<t and d[i][j]>=0:
            s = min(t,j+ab[i][0])
            d[i+1][s] = max(d[i+1][s], d[i][j]-ab[i][1])
if DBG:
    for i in range(n):
        printn(i)
        ddprint(d[i])
mx = 0
for j in range(t,-1,-1):
    if d[n][j]>=0:
        mx = max(mx,d[n][j])
print(mx)


Measured memory_bytes: 119000
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200001];
long long ans[200001]={0};
int dfs(int v, int p=-1)
{
    for(int u : g[v])
    {
        if(u==p) continue;
        ans[u]+=ans[v],dfs(u, v);
    }
}
int main()
{
    int n, q, i, p, a, b, x; cin >> n >> q;
    for(i=0;i<n-1 && cin >> a >> b;i++)
        g[a-1].push_back(b-1),g[b-1].push_back(a-1);
    for(i=0;i<q && cin >> p >> x;i++)
        ans[p-1] += x;
    dfs(0);
    for(i=0;i<n;i++)
        cout << ans[i] << " ";
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

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

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


Measured memory_bytes: 256
object Main extends App {
  val line1 = readLine.split(" ").map(_.toInt)
  val line2 = readLine.split(" ").map(_.toInt)
  val line3 = readLine.split(" ").map(_.toInt)
  val tr = line1(0) + line2(1) + line3(2)
  val sum1 = line1(0) + line2(2) + line3(1)
  val sum2 = line1(1) + line2(2) + line3(0)
  val sum3 = line1(1) + line2(0) + line3(2)
  val sum4 = line1(2) + line2(1) + line3(0)
  val sum5 = line1(2) + line2(0) + line3(1)
  var b = true
  b = b && tr == sum1
  b = b && tr == sum2
  b = b && tr == sum3
  b = b && tr == sum4
  b = b && tr == sum5
  println(if(b) "Yes" else "No")
}


Measured memory_bytes: 27208
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
x = list(map(int, input().split()))
count = 1
machi = 0
machi_list = [0]
next_machi = x[machi] - 1
machi_dict = {}
while True:
    if next_machi in machi_dict:
        break
    count += 1
    machi_dict[next_machi] = 1
    machi_list.append(next_machi)
    machi = next_machi
    next_machi = x[machi] - 1

z = 0
for i in range(0, count):
    if machi_list[i] == next_machi:
        z = i
        break
loop_machi_list = machi_list[z:]
if k < z:
    machi = machi_list[k] + 1
    print(machi)
else:
    k = k - z
    machi = loop_machi_list[k % len(loop_machi_list)] + 1
    print(machi)

Measured memory_bytes: 39220
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <cassert>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

// 逆
static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
// right up left down
static const char dir[4] = {'r','u','l','d'};

int MDT[N2][N2];

struct Puzzle {
    int f[N2];
    int space;
    int MD;
};

Puzzle state;
int limit;
int path[LIMIT];

/**
    マンハッタンkを測る
*/
int getAllMD(Puzzle pu){
    int sum = 0;
    for(int i = 0;i < N2;++i){
        if(pu.f[i] == N2){
            continue;
        }
        sum += MDT[i][pu.f[i] - 1];
    }
    return sum;
}

bool isSolved(){
    for(int i = 0;i < N2;++i){
        // 最初の数字が1から始まるので
        if(state.f[i] != i + 1){
            return false;
        }
    }
    return true;
}

bool dfs(int depth,int prev){
    if(state.MD == 0){
        return true;
    }
    // 現在の深さにヒューリスティックを足して制限を超えたら枝を狩る
    if( depth + state.MD > limit){
        return false;
    }
    
    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;
    
    for(int r = 0;r < 4;++r){
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        
        // 範囲外チェック
        if(tx < 0 || ty < 0 || tx >= N || ty >= N){
            continue;
        }
        if(max(prev,r) - min(prev,r) == 2){
            continue;
        }
        tmp = state;
        // マンハッタン距離の差分を計算しつつ、ピースを入れ替える
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        // 入れ替え
        swap(state.f[tx * N + ty],state.f[sx * N + sy]);
        state.space = tx * N + ty;
        
        if(dfs(depth + 1,r)){
            path[depth] = r;
            return true;
        }
        state = tmp;
    }
    return false;
}

string iterativeDeepening(Puzzle in){
    // 初期状態のマンハッタン距離
    in.MD = getAllMD(in);
    
    for(limit = in.MD;limit <= LIMIT;++limit){
        state = in;
        if(dfs(0,-100)){
            string ans = "";
            for(int i = 0;i < limit;++i){
                ans += dir[path[i]];
            }
            return ans;
        }
    }
    return "unsolvable";
}

int main(){
    for(int i = 0;i < N2;++i){
        for(int j = 0;j < N2;++j){
            MDT[i][j] = fabs(i / N - j / N) + fabs(i % N - j % N);
        }
    }
    
    Puzzle in;
    
    for(int i = 0;i < N2;++i){
        cin >> in.f[i];
        if(in.f[i] == 0){
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = iterativeDeepening(in);
    cout << ans.size() << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include<string.h>
using namespace std;
int main ()
{
	int n;
	
	cin>>n;
	int a[1010];
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x==y)
		{
			sum++;
		}else
		{
			sum+=(y-x+1);
		}
		
		
	 } 
	cout<<sum<<endl;
	
	
	
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; 
	cin >> n ; 
	vector<pair<string,int>> v;
	rep(i,0,n){
		string s ;
		int x ; 
		cin >> s >> x ; 
		v.pb({s,-1*x});
	}
	vi idx(n);
	iota(all(idx),0);
	auto cmp= [&](int i , int j){
		return v[i]<v[j];
	};
	sort(all(idx),cmp);
	trav(i,idx) cout << i + 1 << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a>>b;
    cout << gcd(max(a, b), min(a, b)) << endl;
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=50000005;
int s,len[N],p[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    p[0]=1;
    scanf("%d",&s);
    ll ans=0;
    int sum=0;
    for(int l=1,r=0;l<10000000;l++)
    {
        while(sum<s)
        {
            r++;
            p[r]=p[r-1];
            len[r]=len[r-1];
            if(r/p[r]!=0) p[r]*=10,len[r]++;
            sum+=len[r];
        }
        if(sum==s) ans++;
        sum-=len[l];
    }
    for(int t=1;t<=s/8;t++)
    {
        if(s%t) ans=(ans+1)%mod;
        else ans=(ans+(qpow(10,s/t)-qpow(10,s/t-1)-t+1))%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 178432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC158
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long n = s[0];
            long a = s[1];
            long b = s[2];
            long ab= a+b;
            if(ab==0){
                WriteLine(0);
                return;
            }
            long ans = n / ab;
            
            ans = ans * a;
            long dif = n % ab;
            if(dif <=a){
                ans +=dif;

            }else{
                ans +=a;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> A;
	for (int i = 0; i < 3; i++)
	{
		int x;
		cin >> x;
		A.push_back(x);
	}
	for (int i = 1; i < N; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a = a + ((A[1] > A[2]) ? A[1] : A[2]);
		b = b + ((A[0] > A[2]) ? A[0] : A[2]);
		c = c + ((A[0] > A[1]) ? A[0] : A[1]);
		A[0] = a;
		A[1] = b;
		A[2] = c;
	}
	int max = -1;
	for (int i = 0; i < 3; i++)
	{
		if (max < A[i])
		{
			max = A[i];
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REP(j,m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair


int main() {
	int n,a=0;
	cin >> n;
	while (a*a <= n) {
		a++;
	}
        a--;
	int ans = a*a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>	
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define ld long double
#define put(x) printf("%d\n",x)
#define min(x,y) ((x)>(y)?(y):(x))
#define max(x,y) ((x)>(y)?(x):(y))
#define EPS 1e-8
#define mod 1000000007
#define INF 10000000000000000ll
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
	return x*f;
}
const ll MAXN=100010;
int n,k;
ll b[MAXN],fac[MAXN];
ll ans;
ll a[MAXN],inv[MAXN];
inline ll fast_pow(ll b,ll p)
{
	ll cnt=1;
	while(p)
	{
		if(p&1)cnt=cnt*b%mod;
		b=b*b%mod;
		p=p>>1;
	}
	return cnt;
}
inline void prepare()
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[n]=fast_pow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%mod;
}
inline ll C(ll x,ll y)
{
	if(x<y||y<0||x<0)return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();k=read();prepare();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<=n;++i)
	{
		//当前必选a[i]
		ans=(ans-a[i]*C(n-i,k-1))%mod;
		ans=(ans+a[i]*C(i-1,k-1))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 210
ll dp[N][N][N];
int main(){
	ll n;
	vector<bool> v;
	cin>>n;
	rep(i,n){
		char c; cin>>c;
		if(c=='D')v.push_back(0);
		if(c=='U')v.push_back(1);
	}
	n=v.size();
	rep(i,N)rep(j,N)rep(k,N)dp[i][j][k]=0;
	dp[0][0][0]=1;
	rep(i,n){
		rep(x,N)rep(y,N){
			if(v[i]==0){
				if(x>=1)mad(dp[i+1][x][y],dp[i][x][y]*x);
				if(x>=1&&y>=1)mad(dp[i+1][x-1][y-1],dp[i][x][y]*x*y);
			}
			if(v[i]==1){
				mad(dp[i+1][x+1][y+1],dp[i][x][y]);
				if(y>=1)mad(dp[i+1][x][y],dp[i][x][y]*y);
			}
		}
	}
	cout<<dp[n][0][0]<<endl;
}




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

int main() {
	int n;
	scanf("%d", &n);
	int a[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int b[n];
	for (int i = 0; i < n; i++) {
		b[a[i]-1] = i+1;
	}
	for (int i = 0; i < n-1; i++) {
		printf("%d ", b[i]);
	}printf("%d", b[n-1]);
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> maze(h);
  for (int i = 0; i < h; ++i) {
    cin >> maze[i];
  }
  int mx = 0;
  int movei[] = {1, 0, -1, 0};
  int movej[] = {0, 1, 0, -1};
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (maze[i][j] != '.') continue;
      vector<vector<int>> d(h, vector<int>(w, -1));
      d[i][j] = 0;
      queue<pair<int, int>> q;
      q.emplace(i, j);
      while (!q.empty()) {
        int ii = q.front().first;
        int jj = q.front().second;
        q.pop();
        for (int move = 0; move < 4; ++move) {
          int iii = ii + movei[move];
          int jjj = jj + movej[move];
          if (iii < 0 || jjj < 0 || iii >= h || jjj >= w || maze[iii][jjj] != '.' || d[iii][jjj] != -1) continue;
          d[iii][jjj] = d[ii][jj] + 1;
          q.emplace(iii, jjj);
        }
      }
      for (int k = 0; k < h; ++k) {
        for (int l = 0; l < w; ++l) {
          if (d[k][l] > mx) mx = d[k][l];
        }
      }
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

int main(){
  int n;
  std::cin >> n;
  std::cout << n << ":";
  
  int div = 2;
  int sq = (int)sqrt(n);
  while(div <= sq){
    if(n % div == 0){
      std::cout << " " << div;
      n /= div;
      sq = (int)sqrt(n);
    }else{
      if(div == 2) div = 3;
      else div += 2;
    }
  }
  std::cout << " " << n << std::endl;

  return 0;
}



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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i,M)cin >> p[i] >> S[i];
    vector<int> qWA(N);
    vector<bool> qAC(N);
    int ansAC = 0,ansWA = 0;
    rep(i,M){
        if(S[i]=="WA"){
            qWA[p[i]]++;
        }else{
            if(!qAC[p[i]]){
                qAC[p[i]]=true;
                ansAC++;
                ansWA += qWA[p[i]];
            }
        }
    }
    cout << ansAC << " " << ansWA << endl;

    return 0;
}

Measured memory_bytes: 6528
n = int(input())
rule = []
w = input()
rule.append(w)
now = w[-1]
for i in range(n - 1):
    w = input()
    if w in rule:
        print("No")
        exit()
    elif now != w[0]:
        print("No")
        exit()
    else:
        rule.append(w)
        now = w[-1]
print("Yes")




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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();

        int answer = 1;
        for (int i = 0; i < n; i++)
        {
            answer = Math.Min(answer * 2, answer + k);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
// file name: 求两个集合的差(A - B), 并不是所有AB不同的元素
// Written by: by_sknight
// Date: 2019/6/12

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

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

	set<int> A, B, result;
	set<int>::iterator it;
	int n, m, x;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		A.insert(x);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		B.insert(x);
	}

	for (it = A.begin(); it != A.end(); it++) {
		if (B.find(*it) == B.end()) {
			result.insert(*it);
		}
	}
	
	for (it = result.begin(); it != result.end(); it++) {
		cout << *it << endl;
	}

	return 0;
}


Measured memory_bytes: 31276
n = gets.chop.to_i
h = gets.chop.split.map(&:to_i)


dp = [10**4]*(n)


dp[0] = 0

dp[1] = dp[0] + (h[1]-h[0]).abs

2.upto(n-1) do|i|
  dp[i] = [dp[i-2] + (h[i]-h[i-2]).abs, dp[i-1] + (h[i]-h[i-1]).abs].min
end

p dp[n-1]

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

int main() {
    float x1, x2, x3, y1, y2, y3, xp, yp;
    float a, b, c;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp) {
        a = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
        b = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
        c = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
        
        if((a>=0 && b>=0 && c>=0) || (a<=0 && b<=0 && c<= 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
<?php

fscanf(STDIN, "%d", $n);

$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));

$arg = [];
$minuscount;
$minus = 0;
$plus  = 0;
foreach ($a as $key => $value) {
	$arg[$key] = $a[$key] - $b[$key];
	if ($arg[$key] < 0) {
		$minus += $arg[$key];
		$minuscount++;
	}else{
		$plus += $arg[$key];
	}
}
if ($plus + $minus < 0) {
	echo "-1";
	exit;
}
rsort($arg);
for ($i=0; $minus < 0; $i++) { 
	$minus += $arg[$i];
}
echo $i + $minuscount;

Measured memory_bytes: 27248
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(ll, n, t);
    Cins(ll, n, ts);
    ll ans = 0;
    For(i, n-1) ans += min(t, ts[i+1] - ts[i]);
    Cout(ans + t);
}


Measured memory_bytes: 1792
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		int max4 = n / 4;
		int max7 = n / 7;
		
		String ans = "No";
		for (int i = 0; i <= max4; i++) {
			for (int j = 0; j <= max7; j++) {
				if (i * 4 + j * 7 == n) {
					ans = "Yes";
					
				}
			}
			
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    
    var ans = 0L
    
    val enemies = new Array[Int](n + 1)
    for (i <- enemies.indices) {
      enemies(i) = sc.nextInt()
    }
    
    val hero = new Array[Int](n)
    for (i <- hero.indices) {
      hero(i) = sc.nextInt()
      
    }
    
    for (i <- hero.indices) {
      if (hero(i) <= enemies(i)) {
        ans += hero(i)
      } else {
        ans += enemies(i)
        val m = hero(i) - enemies(i)
        val n = math.min(enemies(i + 1), m)
        ans += n
        enemies(i + 1) -= n
      }
    }
    
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}

Measured memory_bytes: 68056
#D
X,Y=map(int,input().split())
mod=10**9+7
N=10**6

fact=[1 for i in range(N+1)]
for i in range(1,N):
    fact[i+1]=(fact[i]*(i+1))%mod

def nCk(n,k):
    return fact[n]*pow(fact[n-k]*fact[k],mod-2,mod)

ans=0
if (2*Y-X)%3==0 and (2*X-Y)%3==0 and (2*Y-X)>=0 and (2*X-Y)>=0:
    cntx=(2*Y-X)//3
    cnty=(2*X-Y)//3
    
    ans=nCk(cntx+cnty,cntx)%mod

print(ans)

Measured memory_bytes: 139880
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 200;

int n;

int A[MAXN + 5], K[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) A[i] = read<int>(), K[i] = read<int>();
}

inline int f(int x, int y)
{
	if(x % y == 0) return x / y;
	int t = x / y + 1;
	return f(x - max(x % y / t, 1) * t, y);
}

inline void solve()
{
	int ans = 0;
	for(int i = 1; i <= n; ++i) ans ^= f(A[i], K[i]);
	puts(ans ? "Takahashi" : "Aoki");
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif
	input();
	solve();

	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  const ll LIMIT = pow(10, 18);
  ll x, y;
  scanf("%lld %lld", &x, &y);
  if (x%y == 0) {
    puts("-1");
    return 0;
  }
  for (ll i=2; x*i<LIMIT; ++i) {
    if (x*i % y != 0) {
      printf("%lld\n", x*i);
      return 0;
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//int dp[3001][3001];
const int mod=1e9+7;
#define ll long long
//int dp[100][2],dp1[100][2];
void add_self(int &a,int b)
{
    a=(a+b)%mod;
}
int main()
{
    string s;
    int d;
    cin>>s;
   // cout<<s<<endl;
    cin>>d;
     vector<vector<int> > dp(100,vector<int>(2));
    dp[0][0]=1;
   
    //dp[0][1]=0;
    for(int i=0;i<s.length();i++)
    {
        vector<vector<int> > dp1(100,vector<int>(2));
        for(int j=0;j<d;j++)
        {
           add_self( dp1[(j+(int)(s[i]-'0'))%d][0],dp[j][0]);
            for(int k=0;k<=9;k++)
            {
                add_self(dp1[(j+k)%d][1],dp[j][1]);
                if(k<(int)(s[i]-'0'))
                {
                     add_self( dp1[(j+k)%d][1],dp[j][0]);
                   //   cout<< dp[0][1]<<endl;

                }
            }
        }
       // memcpy(dp,dp1,sizeof(dp));
        dp=dp1;
    }
    ll ans=(dp[0][0]+dp[0][1]-1);
    if(ans<0) ans+=mod;
    cout<<ans%mod;
    // for(int i=0;i<d;i++)
    // {
    //     for(int j=0;j<2;j++)
    //     {
    //         cout<<dp[i][j]<<" ";

    //     }
    //     cout<<endl;
    // }
    

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int kinds = sc.nextInt();
    int select = sc.nextInt();
    List<Integer> priceList = new ArrayList<Integer>();
    while (sc.hasNext()) {
      priceList.add(sc.nextInt());
    }
       
    Collections.sort(priceList);
    System.out.println(priceList.subList(0,select)
                       .stream()
                       .mapToInt(v -> v)
                       .sum());
  }
}

Measured memory_bytes: 39364
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int n, a;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    scanf("%d", &a);
    int sum = a;
    int max_sum = a;
    for (int i = 1; i < n; ++i) {
      scanf("%d", &a);
      sum = max(sum + a, a);
      max_sum = max(max_sum , sum);
    }
    printf("%d\n", max_sum);
  }
}


Measured memory_bytes: 2572
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, d; cin >> m >> d;
	cin >> m >> d;
	if (d == 1) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
_n,_m,x,y = gets.split.map(&:to_i)
xrray = gets.split.map(&:to_i)
yrray =gets.split.map(&:to_i)
xxrray = xrray.push(x)
yyrray = yrray.push(y)
if xxrray.max < yyrray.min
  puts "No War"
else
  puts "War"
end


Measured memory_bytes: 1788