akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    static int count = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] a = new int[count];
        for (int i = 0; i < count; i++) {
            a[i] = sc.nextInt();
        }

        shellSort(a);
        System.out.println(Main.count);
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
    }

    private static void shellSort(int[] a) {
        int[] gaps = new int[100];
        int idx = 0;
        for (int g = 1; g <= a.length && idx < 100; g = g * 3 + 1, idx++) {
            gaps[idx] = g;
        }
        System.out.println(idx);
        for (int i = idx - 1; i >= 0; i--) {
            System.out.print(gaps[i]);
            if (i != 0) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
            insertionSort(a, gaps[i]);
        }
    }

    private static void insertionSort(int[] a, int gap) {
        for (int i = gap; i < a.length; i++) {
            int target = a[i];
            int j = i - gap;
            while (j >= 0 && a[j] > target) {
                a[j + gap] = a[j];
                j -= gap;
                count++;
            }
            a[j + gap] = target;
        }
    }
}

Measured memory_bytes: 299460
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long count;
        static int[] B;
        static int[] ans;
        static int now;
        static bool possible = true;
        static long mod = 1000000007;
        
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var tmp = new long[N];
            long ans = 1;
            int sum = 0;
            for (int i = 0; i < N; i++)
            {
                if(B[i] == 0)
                {
                    tmp[0]++;
                    sum++;
                }
                else {
                    tmp[B[i]]++;
                    ans *= tmp[B[i]-1];
                    ans %= mod;
                    tmp[B[i] - 1]--;
                }
                
            }

            for (int i = 1; i <= sum; i++)
            {
                ans *= (4 - i);
                ans %= mod;
            }
            Console.WriteLine(ans%mod);

        }

        public static long Factorial(int n)
        {
            if (n == 0)
                return 1L;
            return n * Factorial(n - 1);
        }


    }
}


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

int main(){
    string S; cin >> S;
    int N = S.length();
    string T1="", T2="";
    for(int i=0; i<N; i++){
        if(i%2==0){
            T1 += "0";
            T2 += "1";
        }else{
            T1 += "1";
            T2 += "0";
        }
    }

    int cnt1 = 0, cnt2 = 0;
    for(int i=0; i<N; i++){
        if(S[i]!=T1[i]) cnt1++;
        if(S[i]!=T2[i]) cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 768
import itertools

n,m = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(m)]
pair = [[] for _ in range(n+1)]
for i in range(m):
    a = A[i][0]
    b = A[i][1]
    pair[a].append(b)
    pair[b].append(a)

ans = 0
li = [i for i in range(2,n+1)]
orders = list(itertools.permutations(li))

for order in orders:
    flag = True
    pre = 1
    for i in range(n-1):
        if not order[i] in pair[pre]:
            flag = False
        pre = order[i]
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#define MN 401000

std::set<int> st;

struct xxx{
	int t, o, w;
	xxx(){}
	xxx(int a, int b, int c) {t = a; o = b; w = c;}
}b[MN];

bool cmp(xxx a, xxx b) {return a.t == b.t ? a.o < b.o : a.t < b.t;}

int main()
{
	int n, q; scanf("%d%d", &n, &q);
	int m = 0;
	for(int i = 1; i <= n; i++)
	{
		int s, t, c; scanf("%d%d%d", &s, &t, &c);
		s -= c; t -= c;
		b[++m] = xxx(s, 1, c);
		b[++m] = xxx(t, 0, c);
	}
	std::sort(b + 1, b + m + 1, cmp);
	int j = 1;
	for(int i = 1; i <= q; i++)
	{
		int d; scanf("%d", &d);
		while(j <= m && d >= b[j].t)
		{
			if(!b[j].o) st.erase(b[j].w);
			else st.insert(b[j].w);
			j++;
		}
		if(st.size() == 0) puts("-1");
		else printf("%d\n", *st.begin());
	}
	return 0;
}

Measured memory_bytes: 15360
function Main(input) {
  var inp = input.split(" ");
  var a = parseInt(inp[0]);
  var b = parseInt(inp[1]);
  var c = (a * b) % 2;
  var result = null;
  if (c == 0) {
    result = 'Even';
  } else {
    result = 'Odd';
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
// problem: "https://atcoder.jp/contests/abc154/tasks/abc154_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll nCr(ll n,ll r)
{
    if(r == 0)
        return 1;
    else if(r == 1)
        return n;

    return n*(n-1)/2;
}

ll numPossib(ll n,ll k)
{
    ll ans = 0,i;
    for(i=k;i!=n+1;i++)
        ans += nCr(i-1,k-1);        // define

    if(k == 3)
        return ans*9*9*9;
    else if(k == 2)
        return ans*9*9;

    return ans*9;
}

ll lastPossib(ll n,ll k,string &num)
{
    ll p1 = stoi(num.substr(0,1));

    if(k == 1)
        return p1;

    else if(k == 2)
    {
        ll i,ans;
        ans = 0;
        for(i=1;i!=n;i++)
            if(num[i] != '0')
                break;

        if(i < n)
            ans = stoi(num.substr(i,1)) + nCr(n-i-1,1) * 9;

        return ans + (p1-1)*9*nCr(n-1,1);
    }

    else
    {
        ll i,j,ans;
        ans = 0;
        for(i=1;i!=n-1;i++)
        {
            if(num[i] == '0')
                continue;

            ans += (stoi(num.substr(i,1))-1) * nCr(n-1-i,1) * 9;

            for(j=i+1;j!=n;j++)
                if(num[j] != '0')
                    break;

            if(j < n)
                ans += stoi(num.substr(j,1)) + nCr(n-j-1,1) * 9;

            break;
        }

        if(i < n-2)
            ans += nCr(n-i-1,2)*9*9;

        return (p1-1)*9*9*nCr(n-1,2) + ans;
    }

    return 0;
}

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

    ll n = num.size();

    ll k;
    cin>>k;

    if(n < k)
    {
        cout<<0;
        exit(0);
    }

    ll ans = numPossib(n-1,k);      // define

    ans += lastPossib(n,k,num);     // define

    cout<<ans;

    return 0;
}


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

template<typename T>
struct SegmentTree{
private:
    int n;
    vector<T> node;
    using F=function<T(T,T)>;
    F op;
    T id;
    T get(int a,int b,int k,int l,int r){
        if(b<=l||r<=a)return id;
        if(a<=l&&r<=b){
            return node[k];
        }
        else{
            return op(get(a,b,2*k+1,l,(l+r)/2),get(a,b,2*k+2,(l+r)/2,r));
        }
    }
public:
    SegmentTree(int sz,F op,T id):op(op),id(id){
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1,id);
    }
    SegmentTree(const vector<T> & v, F op,T id):SegmentTree(v.size(),op,id){
        for(int i=0;i<v.size();++i){
            node[i+n-1]=v[i];
        }
        for(int i=n-2;i>=0;--i){
            node[i]=op(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int a,T x){
        a+=n-1;
        node[a]=x;
        while(a>0){
            a=(a-1)/2;
            node[a]=op(node[2*a+1],node[2*a+2]);
        }
    }
    T get(int a){
        return node[a+n-1];
    }
    T get(int a,int b){
        return get(a,b,0,0,n);
    }
};

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    auto op=[](int x,int y)->int{return gcd(x,y);};
    SegmentTree<int> seg(a,op,0);
    int ans=-1;
    for(int i=0;i<n;++i){
        int tmp=seg.get(i);
        seg.update(i,0);
        ans=max(ans,seg.get(0,n));
        seg.update(i,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1664
s=input()
t=input()
count=0
list01 = list(s)
list02 = list(t)
list01.sort()
list02 = list(t)
list02.sort()

if len(s)<len(t):
    for i in range(len(s)):
        if list01[i]>list02[len(t)-1-i]:
            print("No")
            break
        elif list01[i]<list02[len(t)-1-i]:
            print("Yes")
            break
    else:
            print("Yes")            

else:
    for i in range(len(t)):
        if list01[i]>list02[len(t)-1-i]:
            print("No")
            break

        elif list01[i]<list02[len(t)-1-i]:
            print("Yes")
            break
    else:
            print("No")          


Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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

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

    return arr

N = ni()
res = factorization(N)
ans = 0
sum_ = [x for x in range(1, 200)]
for i in range(len(sum_)-1):
    sum_[i+1] += sum_[i]
for k, v in res:
    ans += bisect.bisect_right(sum_, v)
if N == 1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 10912
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::pair;
using std::vector;
const int Maxn = 1e5 + 1, mod = 1e9 + 7;
int n, a[ Maxn ], b[ Maxn ];
int main( )
{
 std::ios::sync_with_stdio( false );
 cin.tie( NULL );
 cout.tie( NULL );
 cin >> n;
 if( n & 1 )
  for( int i = 1; i <= n / 2; ++i )
   a[ i * 2 ] = a[ i * 2 + 1 ] = n + 1 - 2 * ( n / 2 - i + 1 );
 else
  for( int i = 1; i <= n / 2; ++i )
   a[ i * 2 - 1 ] = a[ i * 2 ] =  n + 1 - 2 * ( n / 2 - i + 1 );
 for( int i = 1; i <= n; ++i )
  cin >> b[ i ];
 std::sort( b + 1, b + 1 + n, std::less < int > ( ) );
 for( int i = 1; i <= n; ++i )
  if( a[ i ] ^ b[ i ] )
  {
   cout << 0;
   return 0;
  }
 int u = 1;
 for( int i = 1; i <= n / 2; ++i )
  u = u * 2 % mod;
 cout << u;
 return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include <string>

using namespace std;

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

	int N = n;

	int sum = 0;

	while (n != 0)
	{
		int x = n % 10;
		sum += x;

		n /= 10;
	}

	if (N % sum == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String text;
		while(!(text = scan.next()).equals("-")){
			int num = scan.nextInt();
			for (int i = 0; i < num; i++) {
				int c = scan.nextInt();
				text = text.substring(c, text.length()) + text.substring(0 , c);
			}
			System.out.println(text);

		}

	}
}



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

int main() {
  ll X;
  cin >> X;
  int t = 1;
  while (true) {
    if (t*(t+1)/2>=X) {
      cout << t << endl;
      break;
    }
    else t++;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    string s;
    cin>>s;
    string t = "ATCG";
    ll ans = 0;
    ll now = 0;
    for (ll i = 0; i < s.size(); i++){
        bool isATCG = false;
        for (ll j = 0; j < t.size(); j++){
            if(s[i] == t[j])isATCG = true;
        }
        if(!isATCG)now = 0;
        else now++;
        ans = max(now,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int m1,d1;
int m2,d2;

int main(void){
	scanf("%d%d",&m1,&d1);
	scanf("%d%d",&m2,&d2);
	if(m1!=m2){
		printf("%d\n",1);
	}else{
		printf("%d\n",0);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v[i]={a,b};
    }

    for(int i=0;i<n-2;i++)
    {
        if(v[i].first==v[i].second)
        {
            int j;
            for(j=1;j<=2;j++)
            {
                if(v[i+j].first!=v[i+j].second)
                break;
            }
            if(j==3)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int k;
    cin >> k;

    int ans = 0;
    REP(i, 1, k+1){
        REP(j, 1, k+1){
            REP(m, 1, k+1){
                ans += gcd(i, gcd(j, m));
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DIV_NUM (1000000007)

using namespace std;

int main()
{

	/*--------------------------------*/
		/* 数字宣言と入力*/
		
		
//    string iS,iT,iU;
	string S ,T;
	cin >> S >> T;

		
	int a, b;
	
	cin >> a >>b;
	
	string u ;
	
	cin >>u;
	
	if(u==S){
//		tmpX = a-1;
		cout << a-1 <<" " << b << endl;
	}
	
	else if(u==T){
		cout << a << " " << b-1 << endl;
	}
	else{
		cout << a << " " << b << endl;
		
	}



	/*---------------------------------*/
		/* 出力 */
//	cout << tmpX << endl;


	/*----------------------------------*/
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include<stdio.h>
using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int a, b, c, d, e, k;
    io.read(a, b, c, d, e, k);
    string ans = ":(";
    if(e - a <= k) ans = "Yay!";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
typedef long long ll;
typedef __int128 LL;
ll sum[200005];
int arr[200005];
int main()
{
	// freopen("AGC027-B.in", "r", stdin);
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", arr + i);
		sum[i] = sum[i - 1] + arr[i];
	}
	LL ans = 1e36;
	for (int k = 1; k <= n; k++)
	{
		LL res = (ll)k * x;
		int cur = n, coef = 3;
		while (cur)
		{
			int real = coef + (coef == 3) * 2;
			if (cur <= k)
			{
				res += (LL)real * sum[cur];
				break;
			}
			res += (LL)real * (sum[cur] - sum[cur - k]);
			cur -= k;
			coef += 2;
		}
		ans = std::min(ans, res);
	}
	printf("%lld\n", (ll)ans + (ll)n * x);
	return 0;
}


Measured memory_bytes: 2560
n = int(input())

dic = {}
for i in range(n) :
    s = input()
    if s in dic :
        dic[s] += 1
    else :
        dic[s] = 1

#print(max(dic.values()))

sDic = sorted(dic.items(), key=lambda x:(-x[1],x[0]))

mValue = max(dic.values())

for e in sDic :
    #print(e[0])
    if e[1] != mValue :
        break
    print(e[0])


Measured memory_bytes: 59224
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ll n,m; cin >> n >> m;
    if(n==1&&m==1) cout << 1 << endl;
    else if(n==1||m==1) cout << max({0LL,n-2LL,m-2LL}) << endl;
    else cout << (n-2LL)*(m-2LL) << endl;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

void solve(){
    int n;
    cin >> n;
    char s[n+10];
    rep(i,n){
        cin >> s[i];
    }
    set<char> st;
    rep(i,n){
        st.insert(s[i]);
    }
    if(st.size()==4) cout << "Four" << endl;
    else cout << "Three" << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=300002;
bool is_prime[max_n];
int sieve(int n){
    int p=0;
    rep(i,n+1) is_prime[i]=true;
    rep(i,6)is_prime[i]=false;
    FOR(i,6,n+1){
        if(i%7!=1&&i%7!=6){
            is_prime[i]=false;
            continue;
        }
        if(is_prime[i]){
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int main(){
    int n;
    sieve(300001);
    while(cin>>n,n!=1){
        cout<<n<<": ";
        vector<int> v;
        for(int i=6;i<=n;++i){
            if(n%i==0&&is_prime[i]) v.pb(i);
        }
        rep(i,v.size()) cout<<v[i]<<(i+1==v.size()?"":" ");
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	string a,b,c;
	a="Sunny";
	b="Cloudy";
	c="Rainy";
	cin>>s;
	if(s==a){
		cout << b;
	}
	else if(s==b){
		cout <<c;
	}
	else{
		cout <<a;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << min(A, B) + min(C, D) << endl;
  
  return 0;
}


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

n, k = map(int, readline().split())

modk = [0] * k
for i in range(1, n + 1):
    modk[i % k] += 1

ans = 0
for am in range(0, k):
    bm = (k - am) % k
    cm = (k - am) % k
    if (bm + cm) % k == 0:
        ans += modk[am] * modk[bm] * modk[cm]
print(ans)


Measured memory_bytes: 10252
import java.util.*;
public class Main {
	
	static int mod = (int)1e9+7;
	
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for(int i=0;i<N;i++)A[i]=sc.nextLong();
		sc.close();
		
//		//test modpow
//		System.out.println(modpow(7,0));
//		System.out.println(modpow(2,4));
//		System.out.println(modpow(3,5));
//		if(true)return;
		
		long ans = 0;
		for(int i=0;i<60;i++) {
			int cnt = 0;
			for(int j=0;j<N;j++) {
				if(((A[j]>>i)&1)==1) cnt++;
			}
			long tmp = (long)cnt*(N-cnt) %mod;
			//ans += tmp<<i;
			long mul = modpow(2, i);
			ans += (tmp * mul % mod);
			ans %= mod;	
		}
		System.out.println(ans);
	}
	
	static long modpow(long x, long y) {
		if(y==0) return 1;
		if(y%2==0) {	
			long halfY = y/2;
			long root = modpow(x, halfY);
			return root*root %mod;
		}else {
			return x * modpow(x, y-1) % mod;
		}
	}
	
}

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

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll A=a*a,B=b*b,C=c*c;
	if(C-A-B<0)cout<<"No"<<endl;
	else if(0<A+B+C-2*a*c-2*a*b-2*b*c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  T res = e;
  while (n) {
    if (n & 1) res = op(res, a);
    if (n >>= 1) a = op(a, a);
  }
  return res;
}

template <unsigned Mod> struct Modular {
  using M = Modular;
  unsigned v;
  Modular(long long a = 0) : v((a %= Mod) < 0 ? a + Mod : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod) v -= Mod; return *this; }
  M& operator-=(M r) { if ((v += Mod - r.v) >= Mod) v -= Mod; return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod; return *this; }
  M& operator/=(M r) { return *this *= power(r, Mod - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using Mint = Modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> c(n);
  for (auto&& e : c) {
    cin >> e;
  }
  sort(begin(c), end(c));
  Mint res;
  for (int i = 0; i < n; ++i) {
    res += c[i] * (1 + Mint(n - i - 1) / 2);
  }
  res *= power(Mint(2), 2 * n - 1);
  cout << res.v << '\n';
}


Measured memory_bytes: 1024
//bismillah
//created by anaksoleh
//24 Dec 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int N,W;
ll dp[2][100005];
ll w[103];
ll v[103];

void solve()
{
    for(int i = 1 ; i <= N ; i++){
        ll iNow = i % 2;
        ll iPrev = 1 - iNow;
        for(int c = 0 ; c <= W ; c++){
            ll best = dp[iPrev][c];
            if(c >= w[i]){
                best = max(best,dp[iPrev][c - w[i]] + v[i]);
            }
            dp[iNow][c] = best;
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> W;
    for(int i = 1 ; i <= N ; i++){
        cin >> w[i] >> v[i];
    }
    solve();
    cout << dp[N%2][W] << '\n';

    return 0;
}

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

int main() {
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a;
    cin >> a;
    int b = a - 1;
    cout << A[b];

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
#define m 1000000000000000000
int main() {
    int n;
    cin>>n;
    ll a[n];int c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        c++;
    }
    if(c!=0) cout<<0;
    if(c==0)
    {
    ll p=1;bool ok=true;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=m/p)
        {
            p*=a[i];
        }
        else
        {
            ok=false;
            break;
        }
    }
    if(ok) cout<<p;
    else cout<<-1;
    }
	return 0;
}

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

using namespace std;
typedef long long LL;
#define MOD 1000000007

int N;
vector<string> v(2);

int memo[60][4][4];

// number of ways to color [p..N) given that two colors describe the rows to the left of p, that we cannot use.
int f(int p, int tcol, int bcol) {
	if (p == N) {
		return 1;
	}
	int &res = memo[p][tcol][bcol];
	if (res != -1) {
		return res;
	}
	// two possibilities, we either have to place a vertical domino next or two horizontal dominos

	res = 0;
	if (v[0][p] == v[1][p]) {
		for (int color = 1; color <= 3; color++) {
			if (color == tcol || color == bcol) continue;
			res = (res + f(p+1, color, color))%MOD;
		}
	}
	else {
		for (int tcol2 = 1; tcol2 <= 3; tcol2++) {
			for (int bcol2 = 1; bcol2 <= 3; bcol2++) {
				if (tcol2 == tcol || bcol2 == bcol || tcol2 == bcol2) continue;
				res = (res + f(p+2, tcol2, bcol2))%MOD;
			}
		}
	}
	return res;
}

int main()
{

	cin >> N;
	cin >> v[0] >> v[1];
	memset(memo, -1, sizeof(memo));
	cout << f(0, 0, 0) << endl;
	exit(0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vst A={"dream","dreamer","erase","eraser"};
  st s;
  	ci(s);
  REV(s);
  FOR(i,0,4){
    REV(A[i]);
  }
  bl can=true;
  FOR(i,0,s.sz){
    bl can2=true;
    FOR(j,0,4){
      if(s.substr(i,A[j].sz)==A[j]){
        i+=A[j].sz-1;
        can2=false;
      }
    }
    if(can2){
      can=false;
      break;
    }
  }
  if(can) co("YES")
    else co("NO")
    }


Measured memory_bytes: 512
from collections import defaultdict
if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = [0]*M
    ID = [0]*M
    for i in range(M):
        PY[i] = list(map(int, input().split()))
        PY[i].append(i)
    
    PY.sort(key=lambda x: x[1])
    count = defaultdict(int)
    for i in range(M):
        count[PY[i][0]] += 1
        ID[i] = [str(PY[i][0]).zfill(6) + str(count[PY[i][0]]).zfill(6), PY[i][2]]
    ID.sort(key=lambda x: x[1])
    for i in range(M):
        print(ID[i][0])

Measured memory_bytes: 53212
import sys
readline = sys.stdin.readline
 
MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD
N, M = map(int, input().split())
X = 0
for i in range(N+1):
    t = comb(N, i)*frac[M-i]*fraci[M-N]%MOD
    if i%2:
        X -= t
    else:
        X += t
    X%=MOD
print(X*frac[M]*fraci[M-N]%MOD)


Measured memory_bytes: 123992
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1 = h1 * 60 + m1;
    int time2 = h2 * 60 + m2;
    int diff = time2 - time1;
    cout << max(0, diff - k) << endl; 
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    String S = in.readLine();
    String T = in.readLine();

    System.out.println(solve(S, T));

    in.close();
  }

  private static int solve(String S, String T) {
    int maxNumCommonChars = 0;

    for (int i = 0; i + T.length() <= S.length(); ++i) {
      maxNumCommonChars = Math.max(maxNumCommonChars, getNumCommonChars(S, T, i));
    }

    return T.length() - maxNumCommonChars;
  }

  private static int getNumCommonChars(String S, String T, int start) {
    int numCommonChars = 0;

    for (int i = 0; i < T.length(); ++i) {
      if (S.charAt(start + i) == T.charAt(i)) {
        numCommonChars++;
      }
    }

    return numCommonChars;
  }
}

Measured memory_bytes: 32732
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


h, n = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]

INF = 2 ** 64
dprint(INF)
dp = [INF] * (h + 10 ** 4)
dp[0] = 0

for j in range(h):
  for a, b in ab:
    dp[j + a] = min(dp[j + a], dp[j] + b)

dprint(dp[:10])
print(min(dp[h:]))


Measured memory_bytes: 44956
n, k = io.read("*n", "*n")
ds = {}
for i = 1, k do ds[io.read("*n")] = true end
digits = {}
while(0 < n) do
    a = n % 10
    table.insert(digits, a)
    n = math.floor(n / 10)
end
needrestart = true
while(needrestart) do
    needrestart = false
    len = #digits
    for i = 1, len + 1 do
        val = digits[i]
        if(val == nil) then break end
        isok = (ds[val % 10] == nil)
        while(not isok)do
            needrestart = true
            for j = 1, i - 1 do digits[j] = 0 end
            val = val + 1
            isok = (ds[val % 10] == nil)
        end
        if(10 <= val) then
            needrestart = true
            for j = 1, i - 1 do digits[j] = 0 end
            val = val - 10
            if(i ~= len) then digits[i + 1] = digits[i + 1] + 1 else digits[i + 1] = 1 end
        end
        digits[i] = val
        if(needrestart) then break end
    end
end
len = #digits
for i = len , 1, -1 do
    io.write(digits[i])
end
io.write("\n")

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = int.Parse(line[0]);
        var a = int.Parse(line[1]) * 1000;
        line = Console.ReadLine().Trim().Split(' ');
        var h = Array.ConvertAll(line, int.Parse);
        int ans = Abs( 1000 *  t - 6 * h[0] - a); var ansi = 0;
        for (int i = 1; i < n; i++)
        {
           int avt = 1000 * t - 6 * h[i];
            if (Abs(avt - a) < ans) { ans = Abs(avt - a); ansi = i; }
        }
        Console.WriteLine(ansi + 1);
    }
}


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

int main(){
  ll n,x,m[110];
  cin>>n>>x;
  fr(i,n){cin>>m[i];x-=m[i];}
  sort(m,m+n);
  cout<<n+x/m[0]<<endl;
}

Measured memory_bytes: 256
s1=raw_input()
s2=raw_input()
d=[0]*(len(s1)+1)
for i in range(len(s1)+1):
    if i==0:
        d[i]=range(len(s2)+1)
    else:
        d[i]=[i]+[0]*len(s2)

for i in range(1,len(s1)+1,1):
    for j in range(1,len(s2)+1,1):
        d[i][j]=min(d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+(0 if (s1[i-1]==s2[j-1]) else 1))

print(d[len(s1)][len(s2)])

Measured memory_bytes: 34944
import sys
input = sys.stdin.readline

mod = 10**9+7

def dfs(graph, N):
    ans = 0
    Par = [-1]*N
    Childs = [[] for _ in range(N)]
    stack = [0]
    while stack:
        p = stack.pop()
        if p >= 0:
            stack.append(~p)
            for np in graph[p]:
                if np != 0 and Par[np] == -1:
                    stack.append(np)
                    Par[np] = p
        else:
            p = ~p
            score = pow(2, N-1, mod) - 1
            upper = N-1
            for a in Childs[p]:
                upper -= a
                score = (score - pow(2, a, mod) + 1) % mod
            if p != 0:
                score = (score - pow(2, upper, mod) + 1) % mod
            ans = (ans + score) % mod
            Childs[Par[p]].append(N-1-upper+1)
    
    return ans * pow(2, N*(mod-2), mod) % mod

def main():
    N = int(input())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    print(dfs(graph, N))


if __name__ == "__main__":
    main()

Measured memory_bytes: 69700
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	K, T := nextInt(), nextInt()
	a := make([]int, T)
	for i := 0; i < T; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)
	out(max(0, 2*a[T-1]-K-1))
}


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

int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  return 0;
}

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

int main(){
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  for(int i = 0; i < Q; ++i){
    int K;
    cin >> K;
    long long dm = 0, ans = 0, d = 0, m = 0;
    int l = 0;
    for(int j = 0; j < N; ++j){
      if(l == j - K){
        if(S[l] == 'D'){
          --d;
          dm -= m;
        }
        if(S[l] == 'M'){
          --m;
        }
        ++l;
      }
      //cerr << j << " " << d << " " << dm << " " << m << " " << ans << endl;
      if(S[j] == 'D') ++d;
      if(S[j] == 'M') ++m, dm += d;
      if(S[j] == 'C') ans += dm;
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main() {
	int h,w,k;cin>>h>>w>>k;
	vector<vector<char>> a(h,vector<char>(w));
	vector<vector<int>> r(h,vector<int>(w,-1));
	vector<pair<int,int>> p,pex;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
			if(a[i][j]=='S'){
				pex.push_back(make_pair(i,j));
				r[i][j]=0;
			}
			if(a[i][j]=='#'){
				r[i][j]=-2;
			}
		}
	}
//	for(int i=0;i<h;i++){
//		for(int j=0;j<w;j++){
//			cout<<r[i][j];
//		}
//		cout<<endl;
//	}
	for(int i=0;i<k;i++){
		for(int j=0;j<pex.size();j++){
			pair<int,int> temp=pex[j];
			int x=temp.first;
			int y=temp.second;
			if(temp.first!=0){
				if(r[x-1][y]==-1){
					r[x-1][y]=0;
					p.push_back(make_pair(x-1,y));
				}
			}
			if(temp.first!=h-1){
				if(r[x+1][y]==-1){
					r[x+1][y]=0;
					p.push_back(make_pair(x+1,y));
				}
			}
			if(y!=0){
				if(r[x][y-1]==-1){
					r[x][y-1]=0;
					p.push_back(make_pair(x,y-1));

				}
			}
			if(y!=w-1){
				if(r[x][y+1]==-1){
					r[x][y+1]=0;
					p.push_back(make_pair(x,y+1));
				}
			}
		}
		pex=p;

		if(p.size()==0)break;
		p.clear();
	}
//	for(int i=0;i<h;i++){
//		for(int j=0;j<w;j++){
//			cout<<r[i][j];
//		}
//		cout<<endl;
//	}
	int mind=800;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(r[i][j]==0){
//				cout<<'a';
			int xp=h-1-i;
			int xm=i;
			int yp=w-1-j;
			int ym=j;
			int mint=xp;
			if(mint>xm)mint=xm;
			if(mint>yp)mint=yp;
			if(mint>ym)mint=ym;
			if(mind>mint)mind=mint;
			}
		}
	}
//	cout<<mind<<endl;
	if(mind){
	cout<<1+(mind-1)/k+1<<endl;
	}else{
		cout<<1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3456
import numpy as np

a, b, h, m = map(int,input().split())

h_r = (h/12)*360+(30*(m/60))
m_r = (m/60)*360

r = abs(h_r - m_r)

if r > 180:
    r = 360 - r


cos = np.cos(np.deg2rad(r))


print(np.sqrt((a**2)+(b**2)-(2*a*b*cos)))

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

int main()
{
	ll l,r,d,i,ans(0);
	cin>>l>>r>>d;
	for(i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			ans++;
		}
	}
	cout<<ans;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    ll N; cin >> N;
    vec v;
    while(N>0){
        N--;
        v.push_back(N%26);
        N /= 26;
    }
    reverse(all(v));
    rep(i, v.size()){
        cout << char(v[i]+'a');
    }
    cout << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7744
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, z, w int
	fmt.Scan(&n, &z, &w)
	arrA := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arrA[i])
	}
	ans := math.Abs(float64(arrA[n-1] - w))
	if n > 1 {
		if math.Abs(float64(arrA[n-2]-arrA[n-1])) > ans {
			ans = math.Abs(float64(arrA[n-2] - arrA[n-1]))
		}
	}

	fmt.Println(int(ans))
}


Measured memory_bytes: 640
n=int(input())
table=[100]*26
for i in range(n):
    k=[0]*26
    s=input()
    for j in s:
        k[ord(j)-97]+=1
    for j in range(26):
        table[j]=min(table[j],k[j])
ans=""
for i in range(26):
    ans+=chr(i+97)*table[i]
print(ans)

Measured memory_bytes: 8984
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int A, B, C;
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C;

    FOR(i, 1, 200) {
        int a = i*A;
        if(a%B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def aaa(a, b):
    return a // b

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)


c1 = aaa(A-1, C)
c2 = aaa(B, C)
c = c2 - c1

d1 = aaa(A-1, D)
d2 = aaa(B, D)
d = d2 - d1

cd1 = aaa(A-1, lcm(C, D))
cd2 = aaa(B, lcm(C, D))
cd = cd2 - cd1

print(B - A + 1 - (c + d - cd))


Measured memory_bytes: 38256
//ALDS1_2_B_19140837_Ojima_Yukiya.cpp
//
//提出日 2020/07/01 wednesday
//
//プログラミング基礎演習2 CS 第8回課題 ALDS1_2_B
//
//学修番号 19140837　小島優希也

#include <iostream>
#include <vector>
using namespace std;

void display(vector<int> v) {
    for (int i = 0; i < v.size() - 1; i++) {
        cout << v.at(i) << " ";
    }
    cout << v.at(v.size() - 1) << endl;
}

void swap(int& a, int& b) {
    int temp = a;
    a = b;
    b = temp;
}

void selectionsort(vector<int> a) {
    int counta = 0;
    for (int i = 0; i < a.size(); i++) {
        int minj = i;
        for (int j = i; j < a.size(); j++) {
            if (a.at(j) < a.at(minj)) {
                minj = j;
            }
        }
        if (minj != i) {
            swap(a.at(i), a.at(minj));
            counta++;
        }
    }
    display(a);
    cout << counta << endl;
}

int main(void) {
    vector<int> vec;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int value;
        cin >> value;
        vec.push_back(value);
    }
    selectionsort(vec);
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size()-1; i++) {
    if (S[i] == S[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
}



Measured memory_bytes: 26476
import java.util.Scanner;

public class Main {
    public int odd(int []a){
        int count=0;
        for (int i = 0; i < a.length; i++) {int b=0;
            b=i+1;
            if (b%2!=0&&a[i]%2!=0){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        Main obj=new Main();
        while (tan.hasNext()){
            int n=tan.nextInt();
            int []a=new int[n];
            for (int i = 0; i < n; i++) {
                a[i]=tan.nextInt();
            }
            int result=obj.odd(a);
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 35792