akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		long[] s=sc.La;
		long ans=0,i=s[0];
		for(;i%4!=0;i++) {ans^=i;}
		for(long j = s[1];j%4!=3&&j!=i-1;j--) {ans^=j;}
		Console.WriteLine(ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K,A[101010];
ll Kp;
ll i,j,x,ans;
int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i, 0,N){
        scanf("%lld",&A[i]);
    }
    
    for (Kp = 0; (1ll << Kp) <= K;Kp++)
        ;
    fornum(i, 0, Kp)
    {
        ll k = (1ll << (Kp - i - 1));
        ll ct = 0;
        if(x+k>K)
            continue;

        fornum(j,0,N){
            if((A[j]&k)==0){
                ct ++;
            }
        }
        if(N/2<ct){
            x += k;
        }
    }
    fornum(i,0,N){
        ans+=(x^A[i]);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll dp[100010][2];
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

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




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

int main() {
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;
    int allValues = (A1 + A2 + A3);

    if (allValues >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 3092
N,Y=map(int,input().split())
Y//=1000
for i in range(N+1):
	a = Y-10*i
	for j in range(N+1-i):
		b = a-5*j
		if b == N-i-j:
			print(i,j,b)
			exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
def Countingsort(A, k, n):
    index = 0
    Out = []
    Count = [0 for i in range(k + 1)]
    for i in range(n):
        Count[A[i]] += 1
    while index <= k:
        if Count[index] > 0:
            Out.append(index)
            Count[index] -= 1
        else:
            index += 1
    print(*Out)

max = -1
n = int(input())
A = list(map(int,input().split()))
for i in range(n):
    if A[i] > max:
        max = A[i]
Countingsort(A, max, n)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(3);
    a.at(0) = n/100;
    a.at(1) = n/10 - a.at(0)*10;
    a.at(2) = n%10;
    int i;

    for(i=0;i<3;i++){
        if(a.at(i)==1){
            a.at(i) = 9;
        }
        else if(a.at(i)==9){
            a.at(i) =1;
        }
    }

    cout << a.at(0)*100+a.at(1)*10+a.at(2) << endl;
    return 0;
}

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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,M;
vector <vector <int> > G;
list<int> path;
vector <int> A;


int main()
{

	cin >> N >> M;

	G.resize(N+1);
	A.resize(N);
	REP(i,N+1){
		A[i] = 0;
	}
	int s = 1;
	REP(i,M){
		int a,b;
		cin >> a;
		cin >> b;
		G[a].push_back(b);
		G[b].push_back(a);
		if(s == 1){
			path.push_front(a);
			path.push_back(b);
			s = 0;
			A[a] = 1;
			A[b] = 1;
		}
	}


	while(1){
		list<int>::iterator itr_p = path.begin();

		int flag = 0;
		for(vector<int>::iterator itr_g = G[*itr_p].begin();itr_g!=G[*itr_p].end();++itr_g){
			if(A[*itr_g] == 0){
				path.push_front(*itr_g);
				A[*itr_g] = 1;
				flag = 1;
				break;
			}
		}
		if(flag == 0)
			break;
	}

	while(1){
		list<int>::iterator itr_p = path.end();
		--itr_p;
		int flag = 0;
		for(vector<int>::iterator itr_g = G[*itr_p].begin();itr_g!=G[*itr_p].end();++itr_g){
			if(A[*itr_g] == 0){
				path.push_back(*itr_g);
				A[*itr_g] = 1;
				flag = 1;
				break;
			}
		}
		if(flag == 0)
			break;
	}
	int count=0;
	for(list<int>::iterator itr = path.begin();itr!=path.end();++itr){
		count++;
	}
	cout << count << endl;
	for(list<int>::iterator itr = path.begin();itr!=path.end();++itr){
		cout << *itr << " ";
	}


}

Measured memory_bytes: 9856
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int check =0;
    for (int i =1; i <=9; i++) {
      for (int j =1; j <=9; j++) {
        if (i * j == N) check++;
      }
    }
    if (check == 0) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h> 
    using namespace std;
    typedef long long ll;
    typedef pair<ll,ll> p;
    const int inf=(1<<30);
    #define rep(i,a,n)	for(int i=a;i<n;i++)
    #define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
    	
    int main(){
    	ll n;
    	ll a[5];
    	cin>>n;
    	rep(i,0,5)cin>>a[i];
    	sort(a,a+5);
     ll ans=4+(n/a[0]);
      if(n%a[0]!=0)ans++;
    	cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int n;
vector<vector<pair<int, int>>> tree(100010);
int ans[100010] = {};

void dfs(int color, int now, int p) {
  ans[now] = color;
  for(auto elem : tree[now]) {
    if(elem.first == p) continue;
    if(elem.second%2 == 0) dfs(color, elem.first, now);
    else dfs(1-color, elem.first, now);
  }
}

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

  cin >> n;
  for(int i = 1; i < n; ++i) {
    int u, v, w; cin >> u >> v >> w;
    u--, v--;
    tree[u].push_back({v, w});
    tree[v].push_back({u, w});
  }
  dfs(0, 0, -1);
  rep(i, n) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 9216
#import <bits/stdc++.h>
using namespace std;typedef int l;
#define rp(i,n) for(l i=0;i<n;++i)
l main(){l n;cin>>n;l v[99];for(char c='A';c<='C';++c)cin>>v[c];string s[220000];rp(i,n)cin>>s[i];char a[220000];rp(i,n){char x=s[i][0],y=s[i][1],M=(v[x]>=v[y]?x:y),m=x^y^M;if(v[x]==v[y]&&i+1<n&&(s[i+1][0]==x||s[i+1][1]==x))swap(M,m);if(v[M]==0){puts("No");return 0;}v[M]--,v[m]++;a[i]=m;}puts("Yes");rp(i,n)cout<<a[i]<<'\n';}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int h,a;
    cin>>h>>a;
    int b[a],sum=0;
    for(int i=0;i<a;i++)
    {
        cin>>b[i];
        sum=sum+b[i];
    }
    if(sum>=h)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = 100*a + 10*b + c;
        if(x%4==0) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
import qualified Data.Vector as V
main=print.solve.map read.words=<<getLine
solve[n,m]=foldr h 1$f 2 m where
  h k s=foldr(\i s->s*(n+k-i)`mod`mo*inv V.! i`mod`mo)s[1..k]
  inv=V.generate 30 $ \i->if i<2 then 1 else inv V.!(mo`mod`i)*(mo-mo`div`i)`mod`mo
f k i
  |i<2=[]
  |k*k>i=[1]
  |c/=0=c:f(k+1)j
  |otherwise=f(k+1)i
  where
    (j,c)=g i 0
    g i c=if r/=0 then(i,c)else g a(c+1)where(a,r)=divMod i k
mo=10^9+7::Int

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

int main(){
  int x1,y1,r1,x2,y2,r2;
  cin>>x1>>y1>>r1>>x2>>y2>>r2;
  int x=(x1-x2),y=(y1-y2),r=r1+r2,rd=r1-r2;
  int ans=0;
  if(x*x+y*y>r*r)ans=4;
  else if(x*x+y*y==r*r)ans=3;
  else if(x*x+y*y>rd*rd)ans=2;
  else if(x*x+y*y==rd*rd)ans=1;
  cout<<ans<<endl;
  return 0;
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

const int N = 1e6 + 7;
vector<int> g[N];

const int T = 1003;
int s[T][T];

int r(int x, int y) {
    if (x > y) {
        swap(x, y);
    }
    //cout << '!' << x << ' ' << y << endl;
    return s[x][y];
}

vector<int> top;
int used[N];

void dfs(int v) {
    used[v] = 1;
    for (int u : g[v]) {
        if (!used[u]) {
            dfs(u);
        } else if (used[u] == 1) {
            cout << -1;
            exit(0);
        }
    }
    used[v] = 2;
    top.eb(v);
}

int d[N];

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

    int n;
    cin >> n;
    int c = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            s[i][j] = c;
            //cout << i << ' ' << j << ' ' << c << endl;
            ++c;
        }
    }
    for (int i = 1; i <= n; ++i) {
        int p;
        cin >> p;
        for (int j = 0; j < n - 2; ++j) {
            int x;
            cin >> x;
            g[r(i, p)].eb(r(i, x));
            p = x;
        }
    }
    for (int i = 0; i < c; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    reverse(all(top));
    int mx = 0;
    for (int v : top) {
        if (!d[v]) {
            d[v] = 1;
        }
        for (int u : g[v]) {
            xmax(d[u], d[v] + 1);
            xmax(mx, d[u]);
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 53108
a, b, c, d = list(map(int,input().split()))
a = a - 1

def gcd(i, j):
    while j:
        i, j = j, i % j
    return i

def num_d(x, y, z):
    l, m, n = x//y, x//z, x//(y*z//(gcd(y, z)))
    return l + m - n


X = b - num_d(b, c, d)
Y = a - num_d(a, c, d)

print(X - Y)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
 
public class Solution
{
    public static void Main()
    {
      string str = Console.ReadLine();
      string[] num = str.Split(' ');
      int A = int.Parse(num[0]);
      int B = int.Parse(num[1]);
      if (A == B)
      {
        Console.WriteLine("0");
      }
      else
      {
        if ((A+B) % 2 == 0)
        {
          int K = (A+B) / 2;
          Console.WriteLine(K);
        }
        else
        {
          Console.WriteLine("IMPOSSIBLE");
        }
      }
      
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            int iT = int.Parse(sS[0]) * 1000;
            int iA = int.Parse(sS[1]) * 1000;
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<ClsPos> lstH = new List<ClsPos>();
            for (int i = 0; i < sS.Length; i++)
            {
                ClsPos oneUsr = new ClsPos();
                oneUsr.iX = i + 1;                                  // 地点No
                oneUsr.iH = int.Parse(sS[i]);                       // 標高
                oneUsr.iT = iT - oneUsr.iH * 6;                     // 度
                oneUsr.iD = Math.Abs(iA - oneUsr.iT);               // 度差
                lstH.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstH.Sort(delegate (ClsPos mca1, ClsPos mca2) { return (int)(mca1.iD - mca2.iD); });   // 度差で昇順

            // 出力
            System.Console.WriteLine("{0}", lstH[0].iX.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 情報
        private class ClsPos
        {
            public int iX { get; set; } = 0;                    // 地点No
            public int iH { get; set; } = 0;                    // 標高
            public int iT { get; set; } = 0;                    // 度
            public int iD { get; set; } = 0;                    // 度差
        }

}


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

int main(){
  vector<int> v(3);
  for(int i = 0; i<3;i++) cin >> v.at(i);
  sort(v.begin(),v.end());
  int n_min = v.at(0);
  int n_mid = v.at(1);
  int n_max = v.at(2);
  int ans = 0;
  if((n_max - n_mid) % 2 != (n_max - n_min) % 2) {
    n_max++;
    n_mid++;
    ans++;
  }
  ans += (n_max - n_mid);
  ans += (n_mid - n_min) % 2 == 0 ? (n_mid - n_min) / 2 : (n_mid - n_min) / 2 + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,k;cin>>n>>k;
  map<int,bool> b;
  map<int,int> m;
  int x;string y;
  int d=0,e=0;
  rep(i,k){
    cin>>x>>y;
    if(b[x])continue;
    if(y=="AC"){
      b[x]=true;
      d++;
    }else{
      m[x]++;
    }
  }
  rep(i,n+1){
    if(b[i])e+=m[i];
  }
  cout<<d<<" "<<e;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v;
  int a;
  for(int i = 0; i < 3; scanf("%d", &a), v.push_back(a), i++);
  sort(v.begin(), v.end());
  printf("%d\n", v[0] + v[1]);
  return 0;
}


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


int main(){
  int N;
  cin >> N;
  string result;
  vector<int> stat(4);

  for( int i=0; i<N; i++){
    cin >> result;
    if(result =="AC"){
      stat.at(0)++;
    }else if(result=="WA"){
      stat.at(1)++;
    }else if(result=="TLE"){
      stat.at(2)++;
    }else if(result=="RE"){
      stat.at(3)++;
    }
  }

  cout<< "AC x " << stat.at(0)<< endl;
  cout<< "WA x " << stat.at(1)<< endl;
  cout<< "TLE x " << stat.at(2)<< endl;
  cout<< "RE x " << stat.at(3)<< endl;

  return 0;

}


Measured memory_bytes: 3628
N, X = map(int, input().split())


def f(N, X):
    result = 0

    if X >= 1:
        X -= 1
    else:
        return result

    if X >= 2 ** ((N - 1) + 2) - 3:
        X -= 2 ** ((N - 1) + 2) - 3
        result += 2 ** ((N - 1) + 1) - 1
    else:
        return result + f(N - 1, X)

    if X >= 1:
        X -= 1
        result += 1
    else:
        return result

    if X >= 2 ** ((N - 1) + 2) - 3:
        X -= 2 ** ((N - 1) + 2) - 3
        result += 2 ** ((N - 1) + 1) - 1
    else:
        return result + f(N - 1, X)

    if X >= 1:
        X -= 1
    else:
        return result

    return result


print(f(N, X))


Measured memory_bytes: 3064
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int K = s.nextInt();
		
		PriorityQueue<Integer> Q = new PriorityQueue<Integer>();
		
		for(int i = 0; i < N; i++) {
			Q.add(Integer.valueOf(s.next()));
		}
		
		int ret = 0;
		for(int i = 0; i < K; i++) {
			ret += Q.poll();
		}
		System.out.println(ret);
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  for(int i = 0;i < N;i++){
    cin >> W.at(i);
  }
  int min = 10000000;
  for(int j = 0;j < N;j++){
    int S1 = 0,S2 = 0;
    for(int k = 0;k < j;k++){
      S1 += W.at(k);
    }
    for(int u = j;u < N;u++){
      S2 += W.at(u);
    }
    if(min > abs(S1 - S2)){
      min = abs(S1 - S2);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int pref[105];

int arr[105];

char s[105];

int n, ans;

void solve() {                   
	scanf("%s", s);    

	for (n = 0; s[n]; ++n);
	ans = n - 1;

	for (char aim = 'a'; aim <= 'z'; ++aim) {
		for (int i = 0; i < n; ++i) {
			arr[i] = 10000000;
		}

		for (int i = n - 1, cur = 10000000; i >= 0; --i) {
			if (s[i] == aim) {
				cur = 0;
			}			
			else {
				++cur;
			}

			arr[i] = cur;
		}

		pref[0] = arr[0];

		for (int i = 1; i < n; ++i) {
			pref[i] = max(arr[i], pref[i - 1]);
		}

		for (int x = 0; x < n; ++x) {
			if (pref[n - x - 1] <= x) {
				ans = min(ans, x);
			}
		}
	}

	printf("%d\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<int, vector<int>, greater<int> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
//const ll inf = 1e18;
const int inf = 1e9 + 7;
const int mxn = 2e5;


ll n;
void input() {

	cin >> n;

}

vl sum(12);

string fin(ll cnt, int l, int i) {
	if (i + 1 == l) {
		string ret = "";
		ret += (char)(cnt - 1 + 'a');
		return ret;
	}

	ll c = cnt / sum[l - i - 1];
	string ret;
	ll rem = cnt % sum[l - i - 1];
	if (!rem) {
		rem = sum[l - i - 1];
		c--;
	}
	ret += (char)(c + 'a');
	ret = ret + fin(rem, l, i + 1);
	return ret;
}

void solve() {
	sum[0] = 1;
	for (int i = 1; i < 12; ++i) {
		sum[i] = sum[i - 1] * 26;
	}

	ll t = 0, l = 0;
	while (t < n) {
		l++;
		t += sum[l];
	}

	t -= 26;
	t /= 26;
	n -= t;

	auto ans = fin(n, l, 0);

	cout << ans;
	return;
}

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

	input();
	solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string a,b,c;cin>>a>>b>>c;
  string abc="abc";
  abc[0]=a[0];
  abc[1]=b[0];
  abc[2]=c[0];
  cout<<abc<<endl;
  return 0;
}


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

using namespace std;


int main()
{
    size_t N;
    cin >> N;

    vector<long> A(N, 0);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    vector<long> base(N, 0);
    for (int i = 0; i < N; ++i)
        base[i] = A[i] - (i + 1);
    sort(base.begin(), base.end());

    long b = base[N / 2];
    size_t out(0);
    
    for (auto x : base)
        out += static_cast<size_t>(abs(x - b));

    cout << out << endl;
}


Measured memory_bytes: 3328
/* *********************************
Author        :Scau.ion
Created Time  :2016/09/04 21:07:59
File Name     :ion.cpp
********************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;

VI son[maxn],kson[maxn],lik;
int N,K,ans;

int dfs(int seat,int fa)
{
    int ma=0;
    for (int j=0;j<son[seat].size();++j)
    {
        if (son[seat][j]==fa) continue;
        ma=max(ma,dfs(son[seat][j],seat));
    }
    ++ma;
    if (ma==K&&fa!=1)
    {
        ++ans;
        return 0;
    }
    return ma;
}

int main()
{
    scanf("%d%d",&N,&K);
    ans=0;
    int a1;
    scanf("%d",&a1);
    if (a1!=1) ++ans;
    for (int j=2;j<=N;++j)
    {
        int x;
        scanf("%d",&x);
        son[x].PB(j);
    }
    for (int j=0;j<son[1].size();++j)
    {
        dfs(son[1][j],1);
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int h, w, m;
char field[100][100];
ll cont[100][100];
ll on[100][100];
ll off[100][100];
int prev[100][100];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

void Input(ll mat[100][100]) {
  REP(y, h) {
    REP(x, w) {
      scanf("%lld", &mat[y][x]);
    }
  }
}

bool dfs(int x, int y, int px, int py, int gx, int gy, stack<pair<int, int> > &st) {
  if (x == gx && y == gy) { return true; }
  REP(dir, 4) {
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if (nx == px && ny == py) { continue; }
    if (nx < 0 || nx >= w || ny < 0 || ny >= h) { continue; }
    if (field[ny][nx] == '#') { continue; }
    if (dfs(nx, ny, x, y, gx, gy, st)) {
      st.push(make_pair(nx, ny));
      return true;
    }
  }
  return false;
}

ll In(int x, int y, int &t) {
  ll ret = 1LL << 60;;
  ret = on[y][x] + off[y][x];
  if (prev[y][x] != -1) {
    ret = min(ret, (t - prev[y][x]) * cont[y][x]);
  }
  prev[y][x] = t;
  t++;
  return ret;
}

int main() {
  while (scanf("%d %d %d", &h, &w, &m) > 0) {
    MEMSET(prev, -1);
    REP(y, h) {
      scanf("%s", field[y]);
    }
    Input(cont);
    Input(on);
    Input(off);
    int px, py;
    scanf("%d %d", &py, &px);
    int t = 0;
    ll ans = 0;
    ans += In(px, py, t);
    REP(iter, m - 1) {
      int nx, ny;
      scanf("%d %d", &ny, &nx);
      stack<pair<int, int> > st;
      dfs(px, py, px, py, nx, ny, st);
      while (!st.empty()) {
        int x = st.top().first;
        int y = st.top().second;
        st.pop();
        ans += In(x, y, t);
      }
      px = nx;
      py = ny;
    }
    printf("%lld\n", ans);
  }
}

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

int main(){
  int N,M;
  vector<int> A(M);
  
  cin>>N>>M;
  for(int i=0; i<M; i++){
    cin>>A.at(i);}
  
  int sum=0;
  for(int i=0; i<M; i++){
    sum+=A.at(i);
  }
  
  int ans = N-sum;
  if(ans<0){ans=-1;}
  cout<<ans<<endl;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
  int N;
  int W;
  cin>>N>>W;
  
  long long dp[W+1];
  for(int i=0;i<W+1;i++){
    dp[i]=0;
  }
  
  long long w[N];
  long long v[N];
  
  for(int i=0;i<N;i++){
    long long w;
    long long v;
    cin>>w>>v;
    
    for(int j=W-w;j>=0;j--){
      if(dp[j+w]<dp[j]+v){
        dp[j+w]=dp[j]+v;
      }
    }
  }
  long long ans=0;
  for(int i=0;i<W;i++){
    if(ans<dp[W]){
      ans=dp[W];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, x;
	cin >> n >> x;
	if(n == 2){
		if(x == 2){
			cout << "Yes" << '\n';
			cout << 1 << '\n';
			cout << 2 << '\n';
			cout << 3 << '\n';
		}
		else cout << "No" << '\n';
		return 0;
	}
	int num = (1 + (n * 2)) / 2;
	if(num == x){
		cout << "Yes" << '\n';
		rep(i, 2 * n - 1) cout << i + 1 << '\n';
	}
	else{
		int off = num - x;
		if(off < 0){
			off = abs(off);
			if(n > (off + 1)){
				cout << "Yes" << '\n';
				repn(i, off, 2 * n - 1) cout << i + 1 << '\n';
				rep(i, off) cout << i + 1 << '\n';
				return 0;
			}
			cout << "No" << endl;
		}
		else{
			if(n > (abs(off) + 1)){
				cout << "Yes" << '\n';
				for(int i = 2 * n - 1, cnt = 0; cnt < abs(off); i--, cnt++){
					cout << i << '\n';
				} 
				repn(i, 0, 2 * n - 1 - abs(off)) cout << i + 1 << '\n';
				return 0;
			}
			cout << "No" << endl;
		}
		return 0;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

set<int> s;

signed main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (min(a, b) + min(c, d)) << endl;
}



Measured memory_bytes: 3172
#include<stdio.h>
int main()
{
	int n,a,i,r;
	while(1){
		r=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i+=4){
			scanf("%d",&a);
			r+=a;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2576
dxy = zip([1, 1, 0, -1, -1, -1, 0, 1], [0, 1, 1, 1, 0, -1, -1, -1])
H, W = map(int, raw_input().split())    
S = [list(raw_input()) for i in xrange(H)]

for y in xrange(H):
    for x in xrange(W):
        if S[y][x] == "#": continue
        tmp = 0
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if not (0 <= nx < W and 0 <= ny < H): continue
            tmp += 1 if S[ny][nx] == "#" else 0
        S[y][x] = str(tmp)

for s in S:
    print "".join(s)


Measured memory_bytes: 2692
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int a;
  int b;
  int c;
  int d;
  char buf[30];

  //標準入力から1行bufに格納
  fgets(buf,sizeof(buf),stdin);
  a = atoi(buf);
  b = a*a;
  c =a*a*a;
  d = a+b+c;
  printf("%d\n",d);
}

Measured memory_bytes: 1708
N, M = map(int, input().split())
C = set()
D = set()
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        C.add(b)
    if b == 1:
        C.add(a)
    if a == N:
        D.add(b)
    if b == N:
        D.add(a)
print('POSSIBLE' if C & D else 'IMPOSSIBLE')


Measured memory_bytes: 18892
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    rrrep(i,Size(s)-1,0){
        if(s[i]=='Z'){
            b=i;
            break;
        }
    }
    Cout(b-a+1);
    return 0;
}


Measured memory_bytes: 720
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            int[] a = ILongs();
            int xor = a[0];
            for(int i=1;i<n;i++){
                xor ^= a[i];
            }
            Console.WriteLine(xor==0?"Yes":"No");
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static int[] ILongs(){
            string[] s = ReadLine().Split();
            int[] re = new int[s.Length];
            for(int i=0;i<s.Length;i++){
                re[i] = int.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 18144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt(),c=scan.nextInt();
		System.out.println(Math.min(a+b, Math.min(a+c, b+c)));

	}

}

Measured memory_bytes: 35588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=2019;
ll l,r,tmp,Min=0x3f3f3f3f;
int main()
{
	scanf("%lld%lld",&l,&r);//i<j
	if(l/mod==r/mod)
	{
		l%=mod;
		r%=mod;
		for(ll i=l;i<r;i++)
			for(ll j=i+1;j<=r;j++)
				Min=min(Min,(i*j)%mod);
		printf("%lld\n",Min);
	}
	else
		printf("0\n");
	return 0;
}

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

#define int long long

const int N = 1e7 + 10 ;
int a[N] ;
int32_t main(){
	for(int i = 1 ; i < N ; i++){
		for(int j = i ; j < N ; j += i){
			a[j]++ ;
		}
	}
	int n ; cin >> n ;
	int ans = 0 ;
	for(int i = 1 ; i <= n ; i++){
		ans += i*a[i] ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 81748
local k, n = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local z = a[1] + k - a[n]
for i = 1, n - 1 do
  z = math.max(z, a[i + 1] - a[i])
end
print(k - z)


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int n,m;
char s[10000];

int palin( int l, int r ){
	while ( l < r ){
		if ( s[l] != s[r] ) return false;
		l++;
		r--;
	}
	return true;
}

int main(){
	
	scanf("%s",&s);
	n = strlen(s);
	if ( palin(0,n-1) && palin(0,(n/2)-1) && palin((n/2)+1, n-1) ){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


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

// m[i][j]はM_i...M_jの最小コスト
vector<vector<int> > m(101, vector<int>(101));
// M_iはP[i-1]xP[i]行列
vector<int> P(101);

int n;

void solve()
{
  // M_iの最小コストをメモ
  for (int i = 1; i <= n; i++)
  {
    m.at(i).at(i) = 0;
  }
  for (int l = 2; l <= n; l++)
  {
    // 長さlの行列積の最小コストをメモ
    for (int i = 1; i <= n - l + 1; i++)
    {
      int j = i + l - 1;
      // M_i...M_jの最小コストを、M_i...M_kの最小コストとM_k...M_jの最小コストを参照して計算する
      m.at(i).at(j) = (1 << 21); // 2の21乗
      for (int k = i; k <= j - 1; k++)
      {
        m.at(i).at(j) = min(m.at(i).at(j), m.at(i).at(k) + m.at(k + 1).at(j) + P.at(i - 1) * P.at(k) * P.at(j));
      }
    }
  }
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int r, c;
    if (i == 0)
    {
      cin >> r >> c;
      P.at(0) = r;
      P.at(1) = c;
    }
    else
    {
      cin >> r >> c;
      P.at(i + 1) = c;
    }
  }

  solve();

  cout << m.at(1).at(n) << endl;
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final int p = 1;
        switch (p) {
        case 1:
            A.answer();
            break;
        }
    }
}

class A {
    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int res = calc(n);
        System.out.println(res);
    }

    static int calc(final int n) {
        return n * n * n;
    }
}

Measured memory_bytes: 23636
// SeeAlso: https://atcoder.jp/contests/abc125/tasks/abc125_a

#include <bits/stdc++.h>

typedef long long ll;
#define MAX 4

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

using namespace std;

int A, B, T;
int main() {

    cin >> A >> B >> T;

    int ans;
    int temp = (T + 0.5) / A;
    ans = temp * B;
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[0]
for i in range(n):
  B.append((B[-1]+A[i])%m)
C=defaultdict(int)
for i in range(n+1):
  C[B[i]]+=1
ans=0
for key in C.values():
  ans+=key*(key-1)//2
print(ans)

Measured memory_bytes: 17368
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k = int(read())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        n = math.gcd(a, b)
        for c in range(1, k + 1):
            ans += math.gcd(n, c)
print(ans)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  long long mo = 1000;
  int flag = 0;
  long long cnt = 0;
  for(int i = 0; i < N - 1; i++){
    if(flag == 0 && A[i + 1] > A[i]){
      cnt = mo / A[i];
      mo -= mo / A[i] * A[i];
      flag = 1;
    }
    if(flag == 1 && A[i + 1] < A[i]){
      mo += cnt * A[i];
      cnt = 0;
      flag = 0;
    }
  }
  if(flag == 1){
    mo += A[N - 1] * cnt;
  }
  cout << mo << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>

using namespace std;

int main(){
int N;
double T,A;
cin >> N >> T >> A;
double H[N];
for(int i = 0;i < N;i++){
  cin >> H[i];
}
int min_pos = 1;
double min=abs((T - H[0]*0.006) - A);
double x;
for(int i = 0;i < N;i++){
  x = abs((T - H[i]*0.006) - A);
  if(min >= x){
    min  = x ;
    min_pos = i+1;
  }
}
cout << min_pos << endl;

return 0;
}


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

int main(){
  int n;
  int x;
  cin >> n;

  for(int i=1; i <=n; i++){
    x  = i;
    if(x%3 == 0)
      cout << " " << i;
    else{
      do{
        if(x%10 == 3){
          cout << " " << i;
          break;
        }
        x /= 10;
        }while(x>0);
      }
   } 
   cout << "\n";
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int keta(int n)
{
  int c = 0;
  while(n > 0) {
    n /= 10;
    c++;
  }
  return c;
}
int main()
{
  int n;
  cin >> n;

  int cnt = 0;
  re(i, n+1) {
    if(keta(i) % 2 == 1) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

const int INF = 1e9 + 5;
int dp[1000005][2];

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    rep(i,n+1)rep(j,2) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n)rep(j,2){
        int x = s[i] - '0';
        x += j;
        if(x < 10) chmin(dp[i+1][0], dp[i][j] + x);
        if(x > 0) chmin(dp[i+1][1], dp[i][j] + (10 - x));
    }
    int ans = dp[n][0];
    cout << ans << endl;
}

Measured memory_bytes: 12144
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    A, B, C, D = MI()
    i = 0

    while A > 0 and C > 0:
        if i % 2 == 0:
            C -= B
        else:
            A -= D
        i += 1
        # print('A', A)
        # print('C', C)

    if A <= 0:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,K;
    cin >> N >> K;

    i64 x;
    if(K%2==0){
        x=N/(K/2);
        i64 y=x/2,z=x-y;
        cout << z*z*z+y*y*y << endl;
    }else{
        x=N/K;
        cout << x*x*x << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int qmax(int a, int b){
	return (a > b) ? a : b;
}
const ll Mod = 998244353;

int n;
pair<int, int> robot[200200];
int nxt[200200];
int dat[800800];
void update(int pos, int val, int l, int r, int k){
	if(l == pos && r == pos){
		dat[k] = val;
		return ;
	}
	int mid = (l+r) >> 1;
	if(pos <= mid) update(pos, val, l, mid, k*2);
	else update(pos, val, mid+1, r, k*2 + 1);
	dat[k] = qmax(dat[k*2], dat[k*2 + 1]);
}
int query(int tl, int tr, int l, int r, int k){
	if(tl > r || tr < l){
		return 0;
	}
	if(tl <= l && r <= tr){
		return dat[k];
	}
	int mid = (l+r) >> 1;
	return qmax(query(tl, tr, l, mid, k*2), query(tl, tr, mid+1, r, k*2 + 1));
}

ll dp[200200];

int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d%d", &robot[i].first, &robot[i].second);
	}
	sort(robot, robot+n);
	for(int i = n-1; i >= 0; i--){
		int val = robot[i].first + robot[i].second; // last <
		int lb = i, ub = n-1;
		while(lb <= ub){
			int mid = (lb + ub) >> 1;
			if(robot[mid].first < val) lb = mid + 1;
			else ub = mid-1;
		}
		nxt[i] = qmax(i+1, query(i+1, ub, 0, n-1, 1));
		update(i, nxt[i], 0, n-1, 1);
	}
	dp[n] = 1;
	for(int i = n-1; i >= 0; i--){
		dp[i] = (dp[i+1] + dp[nxt[i]]) % Mod;
	}
	cout << dp[0] << endl;
	return 0;
} 

Measured memory_bytes: 7296
#include <stdio.h>

int main(void)
{
    double n[6];
	double x,y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&n[0],&n[1],&n[2],&n[3],&n[4],&n[5])!=EOF){
		y=((n[2]*n[3])-(n[0]*n[5]))/((n[1]*n[3])-(n[0]*n[4]));
		x=(n[2]-(n[1]*y))/n[0];

		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

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

int main(){
  int a[3][3];
  bool bingo[3][3] = {0};
  int n;
  int b[10];
  int memo[10];
  int count = 0;
  bool hantei = false;

  /*入力*/
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cin >> a[i][j];
    }
  }
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> b[i];
    /*判定*/
    for(int k = 0;k < 3;k++){
      for(int j = 0;j < 3;j++){
	if(b[i] == a[k][j]){
	  bingo[k][j] = true;
	  memo[count] = k*10 + j;
	  count++;
	}
      }
    }
  }

  /*表示*/
  /*
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cout << bingo[i][j] << " ";
    }
    printf("\n");
  }
  */
  
  for(int i = 0;i < 3;i++){
    if((bingo[i][0] == 1)&&(bingo[i][1] == 1)&&(bingo[i][2] == 1)){
      hantei = true;
    }
    else if((bingo[0][i] == 1)&&(bingo[1][i] == 1)&&(bingo[2][i] == 1)){
      hantei = true;
    }
  }

  if((bingo[0][0] == 1)&&(bingo[1][1] == 1)&&(bingo[2][2] == 1)){
    hantei = true;
  }
  else if((bingo[0][2] == 1)&&(bingo[1][1] == 1)&&(bingo[2][0] == 1)){
    hantei = true;
  }

  if(hantei){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  


  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma optimize ("O3")
#pragma target ("sse4")
const int MAXN=35;
const int INF=1e9+17;
const int MOD=1000000021;
using namespace std;

void mainp()
{
    int a, b;
    cin>>a>>b;
    int ans=a;
    if(b<a) ans--;
    cout<<ans<<endl;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mainp();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      long x = (long) k*(long)Math.pow(k-1,n-1);
      System.out.println(x);
    }
}

Measured memory_bytes: 21844