akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int K,S;cin >> K >> S;
    int ans = 0;
    for(int i = 0;i<=K;i++){
        for(int j = 0;j<=K;j++){
            int Z = S-i-j;
            if(Z <= K && Z >= 0) ans++;
        }
    }

    cout << ans << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

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

s = STR()
n = len(s)
stack = deque()
for i in range(n):
    if not len(stack) or stack[len(stack)-1] == s[i]:
        stack.append(s[i])
    else:
        stack.pop()
print(n - len(stack))


Measured memory_bytes: 5972
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  LL A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  LL min = 1145141919;

  REP(ab,100001){
    LL yen = 0;
    yen += ab * C*2;
    yen += max(X - ab, (LL)0) * A;
    yen += max(Y - ab, (LL)0) * B;
    if(min>yen){
      min = yen;
    }
  }

  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

int main() {
	int64_t x;
	std::cin >> x;

	std::cout << (
		x % 11 != 0 && x % 11 <= 6
		? x / 11 * 2 + 1
		: (x + 10) / 11 * 2
		) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
const int N = 100010;
int v[N] = {},n = 0,dp[N] = {};

int fun(int idx)
{
	if(idx == n)
		return 0;
	if(dp[idx]!=-1)
		return dp[idx];
	int ans = 1e18;
	if(idx + 1 <= n)
		ans = min(ans,abs(v[idx+1] - v[idx]) + fun(idx+1));
	if(idx + 2 <= n)
		ans = min(ans,abs(v[idx+2] - v[idx]) + fun(idx+2));
	dp[idx] = ans;
	return ans;
}

int32_t main()
{
    IOS
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin >> n;
    memset(dp,-1,sizeof(dp));
    for(int i = 1;i<=n;i++)
    {
    	cin >> v[i];
    }
    cout << fun(1) << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void) {
  int a=0,b;
  char s[20],t[20];
    scanf("%s",s);
    scanf("%s",t);

  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      a++;
    }
  }
  printf("%d",a);
  return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll T[100005];
ll A[100005];

ll X[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> T[i];
    }
    REP(i, N)
    {
        cin >> A[i];
    }
    bool exist = true;
    REP(i, N)
    {
        if (i == 0 || T[i - 1] < T[i])
        {
            X[i] = 1;
            if (T[i] > A[i])
                exist = false;
        }
        else
        {
            X[i] = T[i];
        }
    }
    for (int i = N - 1; i >= 0; --i)
    {
        if (i == N - 1 || A[i] > A[i + 1])
        {
            X[i] = 1;
            if (A[i] > T[i])
                exist = false;
        }
        else
        {
            X[i] = std::min(X[i], A[i]);
        }
    }

    ll ans = exist ? 1 : 0;
    REP(i, N)
    {
        ans = (ans * X[i]) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int a,b,c;
  int x;
  int ans=0;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
      for(int k=0;k<c+1;k++){
        if(x==500*i+100*j+50*k){
          ans++;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1724
#include <cstdio>
#include <algorithm>
#include <set>

#define X first
#define Y second

using namespace std;

const int N = 1e5 + 500;

int dep[N], wn[N], a[N], n;
set < pair < int, int > > S;

int main(){
	scanf("%d", &n);
	for(int i = 2;i <= n;i++){
		scanf("%d", a + i);
		wn[a[i]]++;
	}
	for(int i = 1;i <= n;i++)
		if(!wn[i]) 	S.insert({dep[i], i});
	for(int i = 0;i < n - 1;i++){
		int cur = S.begin() -> Y; S.erase(S.begin());
		dep[a[cur]] = 1 + max(dep[a[cur]], dep[cur]);
		wn[a[cur]]--;
		if(!wn[a[cur]])
			S.insert({dep[a[cur]], a[cur]});
	}
	printf("%d\n", dep[1]);
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}
*/
Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    } else{
	x = x->right;
    }
  }
      z->parent = y;
    
    if(y==NIL){
      root = z;
    }
    else if(z->key < y->key){
      y->left =z;
    }
    else y-> right =z;
    

}

void inorder(Node u){
  if( u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u !=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
   char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

Measured memory_bytes: 19364
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define mp make_pair
typedef pair<int,int> pi;

const int inf=1<<28;
int dy[]={0,1,0,-1},dx[]={-1,0,1,0};

int n,a,s,g;
vector<vector<pair<int,string> > > e;
string dp[40][500];

struct Node{
	string str; int cur;
	Node(int a,string b):cur(a),str(b){}
	Node(){}
	bool operator<(const Node &r)const{
		return str>r.str;
	}
};

int main(){
	while(cin>>n>>a>>s>>g,n)
	{
		e.clear(); e.resize(n);
		rep(i,a)
		{
			string str;
			int x,y; cin>>x>>y>>str;
			e[x].push_back(mp(y,str));
		}
		
		rep(i,n)rep(j,500)dp[i][j]="";
		priority_queue<Node> Q; Q.push(Node(s,""));
		while(!Q.empty())
		{
			int cur=Q.top().cur; string cstr=Q.top().str; Q.pop();
			if(cstr.size()>=500)continue;
			if(cur==g)
			{
				if(cstr.size()>=400)goto FAIL;
				cout<<cstr<<endl; goto END;
			}
			
			fr(i,e[cur])
			{
				int nxt=i->first; string nstr=cstr+i->second;
				if(nstr.size()>=500)continue;
				if(dp[nxt][nstr.size()]!=""&&dp[nxt][nstr.size()]<=nstr)continue;
				dp[nxt][nstr.size()]=nstr; Q.push(Node(nxt,nstr));
			}
		}
		FAIL:cout<<"NO"<<endl; END:;
	}
	return 0;
}

Measured memory_bytes: 19000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
 
  sort(L.begin(), L.end());
  for (int i = 0; i < N - 1; i++) {
    L.at(N - 1) -= L.at(i);
  }
 
  cout << (L.at(N - 1) < 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//　セグメント木
const mod = 998244353

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K := getInt(), getInt()
	l := make([]int, K)
	r := make([]int, K)
	for i := 0; i < K; i++ {
		l[i], r[i] = getInt(), getInt()
	}

	dp := make([]int, N+10)
	tot := make([]int, N+10)
	dp[1] = 1
	tot[1] = 1
	for i := 2; i <= N; i++ {
		for k := 0; k < K; k++ {
			lp := max(1, i-r[k])
			rp := i - l[k]
			if rp < 0 {
				continue
			}
			dp[i] += tot[rp] - tot[lp-1]
			if dp[i] < 0 {
				dp[i] += mod
			}
			dp[i] %= mod
		}
		tot[i] = tot[i-1] + dp[i]
		tot[i] %= mod
	}
	out(dp[N])
}


Measured memory_bytes: 5016
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    while (true) {
      var h = new List<int>();
      for (int i = 0; i < 5; i++) {
        var t = int.Parse(Console.ReadLine());
        if (t == 0) return;
        h.Add(t);
      }
      var r = new List<int>();
      if ((h.Any(x => x == 1) && h.Any(x => x == 2) && h.Any(x => x == 3))||
          (h.All(x => x == 1) || h.All(x => x == 2) || h.All(x => x == 3))) {
        Enumerable.Repeat(3, 5).ToList().ForEach(Console.WriteLine);
      } else if (!h.Any(x => x == 3)) {
        foreach (var item in h) r.Add(item == 1 ? 1 : 2);
      } else if (!h.Any(x => x == 1)) {
        foreach (var item in h) r.Add(item == 2 ? 1 : 2);
      } else if (!h.Any(x => x == 2)) {
        foreach (var item in h) r.Add(item == 3 ? 1 : 2);
      }
      r.ForEach(Console.WriteLine);
    }
  }
}


Measured memory_bytes: 16240
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=n+1;i<=2*n;i++){
			int f=0;
			for(int j=2;j*j<=i;j++){
				if(i%j==0){
					f=1;
					break;
				}
			}
			if(f==0 && i!=1)
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main () {
    int H, W;
    
    while ( 1 ) {
        cin >> H >> W ;
        if ( H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W ; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl ;
    }
    
    return 0;
}


Measured memory_bytes: 3088
def dfs(N, ops, nums, Sum):
    if N == 3:
        if Sum == 7:
            print(str(nums[0])+ops[0]+str(nums[1])+ops[1]+str(nums[2])+ops[2]+str(nums[3])+"=7")
            return True
        else:
            return False
    else:
        ops[N]="+"
        if dfs(N+1, ops, nums, Sum+nums[N+1]):
            return True
        ops[N]="-"
        if dfs(N+1, ops, nums, Sum-nums[N+1]):
            return True

nums=[int(i) for i in input()]
ops=["" for i in range(3)]
dfs(0, ops, nums, nums[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main() {
	ll n;
	cin>>n;
	ll c[550],s[550],f[550];
	rep(i,0,n-1)cin>>c[i]>>s[i]>>f[i];
	rep(i,0,n-1){
		ll b=c[i]+s[i];
		rep(j,i,n-2){
			if(b>s[j+1]&& b%f[j+1]!=0)b+=f[j+1]-b%f[j+1];
			b=max(b,s[j+1])+c[j+1];
		}
		cout<<b<<endl;
		b=0;
	}
	cout<<"0"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::map<string, int> map;
    int n,m;
    string s,t;
    cin>>n;
    std::deque<string> deq;
    for (int i=0;i<n;i++) {
        cin>>s;
        if (find(deq.begin(),deq.end(),s)==deq.end()) {
            map.insert(make_pair(s,1));
            deq.emplace_back(s);
        } else {
            map.at(s)++;
        }
    }
    cin>>m;
    for (int j=0;j<m;j++) {
        cin>>t;
        if (find(deq.begin(),deq.end(),t)!=deq.end()) {
            map.at(t)--;
        }
    }
    int tmp=-10000000;
    for (auto itr=map.begin();itr!=map.end();itr++) {
        if (tmp<itr->second) {
            tmp=itr->second;
        }
    }
    if (tmp<0) {
        cout<<0<<endl;
    } else {
        cout<<tmp<<endl;
    }
}


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;
using P = pair<int, int>;

int main() {

    int N;
    cin >> N;

    vector<int> a(N);
    rep(i, N) cin >> a[i];


    int mi = a[0], ma = a[0];
    for (int i = 1; i < N; ++i) {
        mi = min(mi, a[i]);
        ma = max(ma, a[i]);
    }

    cout << ma - mi << endl;

    return 0;
}

Measured memory_bytes: 3596
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    long start = System.currentTimeMillis();
	    Scanner sn = new Scanner(System.in);
	    String[] s = sn.nextLine().split(" ");
	    int[] cookies = new int[3];
	    for(int i = 0;i<s.length;i++){
	        cookies[i] = Integer.parseInt(s[i]);
	    }
	    
	    long current = System.currentTimeMillis();
	    int[] temp = new int[cookies.length];
	    int count = 0;
	    boolean flag = true;
	    
	    while(flag){
	        current = System.currentTimeMillis();
	        if(current - start > 1000){
	            System.out.println("-1");
	            flag = false;
	        }
	        for(int i = 0;i<cookies.length;i++){
	            if(cookies[i] % 2 == 1){
	                System.out.println(count);
	                flag = false;
	                break;
	            }
	            temp[i] = cookies[i];
	        }
	        
	        cookies[0] = (temp[1] / 2) + (temp[2] / 2);
	        cookies[1] = (temp[0] / 2) + (temp[2] / 2);
	        cookies[2] = (temp[0] / 2) + (temp[1] / 2);
	        count++;
	    }
	    
	}
}

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

struct ModInt {
    using M = ModInt;
    long long v;
    ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
    M &norm() {
        v = (v < MOD) ? v : v - MOD;
        return *this;
    }
    M operator+(const M &x) const { return M(v + x.v); }
    M operator-(const M &x) const { return M(v + MOD - x.v); }
    M operator*(const M &x) const { return M(v * x.v % MOD); }
    M operator/(const M &x) const { return M(v * x.inv().v); }
    M &operator+=(const M &x) { return *this = *this + x; }
    M &operator-=(const M &x) { return *this = *this - x; }
    M &operator*=(const M &x) { return *this = *this * x; }
    M &operator/=(const M &x) { return *this = *this / x; }
    friend istream &operator>>(istream &input, M &x) {
        return input >> x.v, x.norm(), input;
    }
    friend ostream &operator<<(ostream &output, const M &x) {
        return output << x.v;
    }
    M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1)
                res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    M inv() const { return this->pow(MOD - 2); }

    static long long MOD;
    static vector<M> fact, finv;
    static void build(int n) {
        fact.assign(n + 1, 1);
        finv.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++)
            fact[i] = fact[i - 1] * M(i);
        for (int i = 0; i < n + 1; i++)
            finv[i] = fact[i].inv();
    }
    static M comb(int n, int k) {
        if (n < k || k < 0)
            return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int *x, int *y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            *y -= (a / b) * *x;
        } else {
            *x = 1, *y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

const int maxn = 101;
const int maxk = 100001;
ModInt dp[maxn][maxk];

// i番目以降の人にk個のアメを配る、という状態を考えてDPをする。
// ただ、愚直にDPをするとO(Nk^2)になるのでTLEしてしまう。
// なので、遷移式を式変形してループを含まない形にする。
// やり方は等比数列の一般項の求め方みたいな感じに、dp[i][k] と dp[i][k-1]を考える。
// dp[i][k] - dp[i][k-1] をやるとキャンセルしまくって真ん中らへんの項が消えてくれる。
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n+1) dp[i][0] = 1;
    for(int i = n - 1; i >= 0; i--) {
        for(int j = 1; j <= k; j++) {
            // 元の式：dp[i][j] = dp[i+1][j] + dp[i+1][j-1] +...+ dp[i+1][j-a[i]]
            // dp[i][j] - dp[i][j-1] = (dp[i+1][j] + dp[i+1][j-1] +...+ dp[i+1][j-a[i]]) -
            //                         (dp[i+1][j-1] + dp[i+1][j-2] +...+ dp[i+1][j-a[i]] + dp[i+1][j-a[i]-1])
            // dp[i][j] = dp[i][j-1] + dp[i+1][j] - dp[i+1][j-a[i]-1]
            dp[i][j] = dp[i][j - 1] + dp[i + 1][j];
            if (j - a[i] - 1 >= 0) dp[i][j] -= dp[i + 1][j - a[i] - 1];
        }
    }
    cout << dp[0][k] << endl;
    return 0;
}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int Case = 1;
		while(true){
			int W_Bag = stdIn.nextInt();
			if(W_Bag==0){
				return;
			}
			int N_Count = stdIn.nextInt();
			int[] value = new int[N_Count+1];
			int[] weight = new int[N_Count+1];
			for(int i=1;i<=N_Count;i++){
				String[] s = stdIn.next().split(",");
				value[i] = Integer.parseInt(s[0]);
				weight[i] = Integer.parseInt(s[1]);
			}
			int[][] dp = new int[N_Count+1][W_Bag+1];
			int maxValue = 0;
			int minWeight = Integer.MAX_VALUE;
			for(int i=1;i<=N_Count;i++){
				for(int j=1;j<=W_Bag;j++){
					if(j-weight[i]>=0){
						dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-weight[i]]+value[i]);
						if(maxValue<dp[i][j]){
							maxValue = dp[i][j];
							minWeight = j;
						}
						else if(maxValue==dp[i][j]){
							minWeight = Math.min(minWeight, j);
						}
					}
					else{
						dp[i][j] = dp[i-1][j];
					}
				}
			}
			System.out.println("Case "+Case+++":");
			System.out.println(maxValue);
			System.out.println(minWeight);
		}
	}
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int x,y,z,r;
  x=a+b;
  y=a-b;
  z=a*b;
  int ans=max({x,z,y});
  cout<<ans<<endl;
            
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,e,f;
  double x,y;
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
    y=(double)(c*d-f*a)/(b*d-e*a);
    x=(double)(c-(b*y))/a;
  printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1064
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
used = [0] * N
def dfs(s):
    st = [s]
    used[s] = 1
    res = 0
    while st:
        s = st.pop()
        res += 1
        for t in G[s]:
            if not used[t]:
                used[t] = 1
                st.append(t)
    return res
g = min(dfs(0), dfs(1))
print(N*(N-1)//2 - g*(N - g) - M)


Measured memory_bytes: 60320
#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>;

const int MAX_N = 300;
ll dp[MAX_N][MAX_N];
ll num[MAX_N][MAX_N];
int n, m;

const ll INF = 1e11;
void wf() {
  rep(i, n) rep(j, n) rep(k, n) {
    if (dp[j][i] != INF && dp[i][k] != INF)
      dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
  }
}
void wf_num() {
  rep(i, n) rep(j, n) rep(k, n) {
    if (num[j][i] != INF && num[i][k] != INF)
      num[j][k] = min(num[j][k], num[j][i] + num[i][k]);
  }
}

int main() {
  int l;
  cin >> n >> m >> l;
  rep(i, n) rep(j, n) {
    if (i != j) {
      dp[i][j] = INF;
      num[i][j] = INF;
    }
  }

  rep(i, m) {
    int s, t, d;
    cin >> s >> t >> d;
    s--;
    t--;
    if (d <= l) {
      dp[s][t] = d;
      dp[t][s] = d;
    }
  }
  wf();
  rep(i, n) rep(j, n) {
    if (dp[i][j] <= l) num[i][j] = 1;
  }
  wf_num();

  int q;
  cin >> q;
  rep(i, q) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (num[s][t] == INF)
      cout << -1 << endl;
    else
      cout << num[s][t] - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1920
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input_text      = System.Console.ReadLine();
            var input_number    = 0;

            if(!int.TryParse(input_text, out input_number))
                return;
                
            if(input_number < 22
                || input_number > 25)
                return;
                
            if(input_number == 25)
                System.Console.WriteLine("Christmas");
            else if(input_number == 24)
                System.Console.WriteLine("Christmas Eve");
            else if(input_number == 23)
                System.Console.WriteLine("Christmas Eve Eve");
            else if(input_number == 22)
                System.Console.WriteLine("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main (void) {
	char w1[101];
	char w2[101];

	char max2 = 0, min1 = 123;

	fill(w1, w1 + 101, 0);
	fill(w2, w2 + 101, 0);
	scanf("%s %s", w1, w2);

	for (int it = 0; it < 101; ++it) {
		if (w1[it] != 0 && w1[it] < min1) min1 = w1[it];
		if (w2[it] > max2) max2 = w2[it];
	}

	if (max2 > min1) cout << "Yes\n";
	else if (strcmp(w2, w1) > 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3144
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int P;
int A[50];
long long dp[2];
long long nx[2];
int main(){
  int i;
  rd(N);
  rd(P);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  dp[0] = 1;
  for(i=(0);i<(N);i++){
    int j;
    for(j=(0);j<(2);j++){
      nx[j] = dp[j] + dp[(j+A[i])%2];
    }
    for(j=(0);j<(2);j++){
      dp[j] = nx[j];
    }
  }
  wt_L(dp[P]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N, P, A[50];
// ll dp[2], nx[2];
// {
//   rd(N,P,A(N));
//   dp[0] = 1;
//   rep(i,N){
//     rep(j,2) nx[j] = dp[j] + dp[(j+A[i])%2];
//     rep(j,2) dp[j] = nx[j];
//   }
//   wt(dp[P]);
// }


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

int main(void)
{
  int n;
  int k1, i, j;


  scanf("%d", &n);

  for(i=0;4*i<=n;i++){
    for(j=1;j<100;j++){

      if((n - (4*i)) % (7*j) == 0){
        k1 = 1;
        break;
      }
      k1 = 0;
    }
    if(k1 == 1){
    break;
    }
  }

  if(k1 == 1)
    printf("Yes");
  else
    printf("No");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define N 10

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int csum[ N ] = { 0 }, sum = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( j = 0; j < n; ++j )
    {
      int rsum = 0;

      for ( i = 0; i < n; ++i )
      {
        int d;

        scanf ( "%d", &d );
        csum[ i ] += d;
        rsum      += d;
        printf ( "%5d", d );
      }

      printf ( "%5d\n", rsum );
    }

    for ( i = 0; i < n; ++i )
    {
      sum += csum[ i ];
      printf ( "%5d", csum[ i ] );
    }
    printf ( "%5d\n", sum );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b,c,d,e;
  ll food[5];
  vector<int> f_mod(5);
  ll odd=10;
  ll index=8;
  ll ans=0;
  rep(i,5){
    cin>>food[i];
    if( food[i]%10 != 0 &&  food[i]%10 < odd  ){
      odd=food[i]%10;
      index=i;
    }
    else{
      //ans+= (food[i]/10 +1)*10;
    }
  }

  rep(i,5){
    if(i==index || food[i]%10==0) ans += food[i];
    else ans+= (food[i]/10 +1)*10;
  }

  //ans += food[index];

  //cout << odd << "," << index << << endl;
  cout << ans << endl;

  return 0;

}


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

int main(){
	string ss;
	while(cin>>ss){
		int dt[10];
		for(int i=0;i<10;i++){
			dt[i]=ss[i]-'0';
		}
		for(int j=9;j>=1;j--){
			int pt[j];
			for(int k=0;k<=j-1;k++){
				pt[k]=(dt[k]+dt[k+1])%10;
			}
			for(int l=0;l<=j;l++){
				dt[l]=pt[l];
			}
		}
		cout<<dt[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      string yes_no[]={"No","Yes"};
      cout<<yes_no[(abs(b-a)<=d && abs(c-b)<=d) || abs(c-a)<=d]<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  int f=1;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>=n)f=0;
  }
  if(f){
    cout<<0<<endl;
    return 0;
  }

  ll ans=0;
  
  ll A=0;
  for(int i=0;i<n;i++){
    ll t=a[i];
    ll ok=t,ng=-1,mid;
    while(ok-ng>1){
	 mid=(ok+ng)/2;
	 if(t-(mid*(n+1))<n)ok=mid;
	 else ng=mid;
    }
    a[i]-=ok*(n+1);
    A+=ok;
    ans+=ok;
  }

  if(A>n){
    ans+=(A-n)*n;
    A=n;
  }
  
  for(int i=0;i<n;i++)a[i]+=A;

  while(1){
    int f=1;
    ll ma=0;
    ll t;
    for(int i=0;i<n;i++){
	 if(a[i]>=n)f=0;
	 if(ma<a[i]){
	   t=i;
	   ma=a[i];
	 }
	 a[i]++;
    }
    if(f)break;
    ans++;
    a[t]-=n+1;
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string arr[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string S;
  cin >> S;
  for(int i = 0;i < 7; i++){
    if(S == arr[i]){
        cout << 7 - i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main(){
    vector<int> A(3);
    for(int&a:A)
        cin >> a;
    
    sort(A.begin(), A.end());
    if(3*A[2]%2==(A[0]+A[1]+A[2])%2){
        cout << (3*A[2] - A[0]-A[1]-A[2])/2 << endl;
    }else{
        A[2]++;
        A[0]++;
        cout << (3*A[2] - A[0]-A[1]-A[2])/2 + 1<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc120/tasks/abc120_a


def calc(a, b, c):
    rest = b
    count = 0
    while True:
        if count >= c:
            break
        if rest < a:
            break
        count += 1
        rest -= a
    return count


a, b, c = map(int, input().split())
print(calc(a, b, c))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>

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

    int n;
    cin>>n;
    int ar[n],s=0;
    for(int i=0;i<n;++i)
    {
        cin>>ar[i];
        s+=ar[i]-1;
    }
    cout<<s;

return(0);
}

Measured memory_bytes: 256
import sys
from heapq import heappush,heapify,heappop
def input(): return sys.stdin.readline().strip()

a = []

while 1:
    
    order = input()
    
    if order == "end":
        exit()
    elif order == "extract":
        b = heappop(a)
        print(-b)

    else:
        order,value = order.split()
        heappush(a,-1*int(value))


Measured memory_bytes: 45564
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long int				int32;
typedef unsigned long int		uint32;
typedef long long int			int64;
typedef unsigned long long int  uint64;
typedef pair<int, int>			PII;
typedef vector<int>				VI;
typedef vector<long long>		VLL;
typedef vector<string>			VS;
typedef vector<PII>				VII;
typedef vector<VI>				VVI;

#define MEM(a, b)				memset(a, (b), sizeof(a))
#define calctime				std::cout << setprecision(5) << fixed << "Time to completed program: " << (double)(clock() - start)/(CLOCKS_PER_SEC) << "s.\n";
#define FOR(i, j, k, in)		for (int i = (j); i < (k); i += (in))
#define FORW(i, j, k, in)		for (int i = (j); i <= (k); i += (in))
#define RFOR(i, j, k, in)		for (int i = (j); i >= (k); i -= (in))
#define RFORW(i, j, k, in)		for (int i = (j); i > (k); i -= (in))
#define aint64(cont)			cont.begin(), cont.end()
#define raint64(cont)			cont.end(), cont.begin()
#define sz(cont)				int((cont).size())
#define PB						push_back
#define MP						make_pair
#define EPS						1e-9
#define MOD						1000000007
#define PI						3.1415926535897932384626433832795
#define Ff						first
#define Ss						second
#define FastIO					ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define fileIO(name)			ifstream iFs(name".inp"); ofstream oFs(name".out");
#define fileio(name)			ifstream cin(name".inp"); ofstream cout(name".out");
#define endl					'\n'

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

int dp[3005][3005] = {};

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	fileio("input");		//Remember to change this
#endif

	string s, t; cin >> s >> t;
	int n = sz(s), m = sz(t);
	FORW(i, 0, n, 1)
		FORW(j, 0, m, 1) {
		if (i == 0 || j == 0) dp[i][j] = 0;
		else if (s[i - 1] == t[j - 1])
			dp[i][j] = dp[i - 1][j - 1] + 1;
		else
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	}

	int len = dp[n][m];
	string ans(len, '?');
	int i = n, j = m;
	while (i && j) {
		if (s[i - 1] == t[j - 1]) {
			ans[--len] = s[i - 1];
			i--, j--;
		}
		else if (dp[i - 1][j] > dp[i][j - 1]) i--;
		else j--;
	}
	
	cout << ans << endl;

	//calctime
	return 0;
}

Measured memory_bytes: 38904
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int ans = 0;
  int mn = 1001001001, mx = 0;
  rep(i, n){
    mn = min(mn, a.at(i));
    mx = max(mx, a.at(i));
  }
  ans = mx - mn;
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    int ans = v[0]; int tmp = v[0];
    for (int i = 1; i < n; i++) {
        if (v[i] < tmp) {
            tmp = v[i];
        } else {
            ans += v[i] - tmp;
            tmp = v[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    string s;
    int ans = 0;

    cin >> n >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#include<algorithm>
char a[30] {'a','b','c','d','e','f','g'
,'h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v',
'w','x','y','z'};
 int main()
   {
     ll N,X,i=0;
     string s;
     cin>>N;
     while(N)
       
       {
         X= N%26;
         if(X==0){X=26;}
         s+= a[X-1];
         N=(N-1)/26;
         
       }
       reverse(s.begin(),s.end());
       cout<<s<<endl;
   }
   

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int A,B,C,D , area1 , area2;
	cin>>A>>B>>C>>D ;
	int max =0;
	area1 =A*B;
	area2 =C*D;
	if(area1==area2)
	cout<<area1;
	else if(area1 > area2)
	{
		max = area1;
		cout<<max;
	}
	else
	{
     	max = area2;
		cout<<max;	
	}
	
}

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

int dp[223456][3];
bool used[223445][3];
long long n, a[3123123], b[312312], c[312312];
vector <int> g[3123123];
int tin[3123123], tout[3123123];
int timer;
int q;
string s, t;
vector <int> v[30];

void dfs(int u, int p = 0) {
	tin[u] = ++timer;
	for(int i = 0; i < g[u].size(); i++) {
		int to = g[u][i];
		if(to == p) continue;
		dfs(to, u);

	}
	tout[u] = timer;
}
int main() {
    ios_base::sync_with_stdio(0);
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++) {
		v[s[i] - 'a'].push_back(i);
	}
	long long cnt = 0;
	int last = -1;
	for(int i = 0; i < t.size(); i++) {
		if(v[t[i] - 'a'].empty()) return cout << -1, 0;
		int z = t[i] - 'a';
		int r = lower_bound(v[z].begin(), v[z].end(), last + 1) - v[z].begin();
		if(r == v[z].size()) {
			cnt++;
			last = v[z][0];
		} else {
			last = v[z][r];
		}
	}
	cout << cnt * (int)(s.size()) + last + 1; 
}



Measured memory_bytes: 77004
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100009;
ll a[N],k,n;
ll mem[60][3],P[60],bt[60][2];
ll solve(ll id,ll fl){

     if(id==50){
        return 0;
     }
     ll &ret=mem[id][fl];
     if(ret!=-1)
        return ret;
    ll ans=0;

    ans=max(ans,bt[50-id-1][1]*P[50-id-1]+solve(id+1,fl||(getBit(k,50-id-1)==1)));
    if((getBit(k,50-id-1)==1)||fl){
        ans=max(ans,bt[50-id-1][0]*P[50-id-1]+solve(id+1,fl));
    }
   return ret=ans;
}
int main(){
    GO();

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    P[0]=1;
    for(int i=1;i<=50;i++) P[i]=P[i-1]*2;

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

        for(int j=0;j<50;j++){
            if(getBit(a[i],j)==1){
                bt[j][1]++;
            }
            else{
                bt[j][0]++;
            }
        }
    }
   // for(int j=0;j<50;j++) cout<<bt[j][1]<<" ";
    //cout<<endl;
    clr(mem,-1);
    cout<<solve(0,0)<<endl;
}






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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int gcd(int x, int y)
{
    int r;
    while((r = x % y) != 0)  
    {
        x = y;
        y = r;
    }
    return y;
}

int main(){
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll result = -1;
  ll i;
  ll g = gcd(n, m);
  ll l;
  if(n == m){
    if(s == t)
      result = n;
    else result = -1;
    
  }
  else
  {
    for(i = 0; i < g; i++){
      if(s[n / g * i] != t[m / g * i])
        break;
      if(i == g - 1)
        result = n * m / g;
      
    }
  }
      
          
          
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

long long int count_patty(int N, long long int X, long long int *total_num, long long int *patty_num);

int main(){
  
  /* read input */
  int N;
  long long int X;
  scanf("%d", &N);
  scanf("%lld", &X);
  
  /*make table of reference*/
  long long int total_num[51];
  long long int patty_num[51];
  total_num[0] = 1;
  patty_num[0] = 1;
  for(int i = 1; i <= 50; i++){
    total_num[i] = 2*total_num[i-1]+3;
    patty_num[i] = 2*patty_num[i-1]+1;
  }
  
  printf("%lld", count_patty(N, X, total_num, patty_num));
  
  return 0;
}

long long int count_patty(int N, long long int X, long long int *total_num, long long int *patty_num){

  long long int tot_num = total_num[N];
  // X == tot_num
  if(X == tot_num){
    return patty_num[N];
  }
  // X == 0
  else if(X == 0){
    return 0;
  }
  // (tot_num+1)/2 < X < tot_num
  else if((tot_num+1)/2 < X && X < tot_num){
    return patty_num[N-1] + 1 + count_patty(N-1, X-(tot_num+1)/2, total_num, patty_num);
  }
  // X == (tot_num+1)/2
  else if(X == (tot_num+1)/2){
    return patty_num[N-1]+1;
  }
  // 1 < X == (tot_num+1)/2
  else if(X > 1 && X < (tot_num+1)/2){
    return count_patty(N-1, X-1, total_num, patty_num);
  }
  else if(X == 1){
    return 0;
  }
  return 0;
}


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

int main(void){
    string S;
    cin >> S;
    int num{0};
    char kouho1, kouho2;
    int kouho1n{0};
    int kouho2n{0};
    for(int i{0}; i<S.size(); ++i){
        kouho1 = char(i%2+'0');
        kouho2 = char((i+1)%2+'0');
        if(kouho1 != S[i])
            ++kouho1n;
        if(kouho2 != S[i])
            ++kouho2n;
    }

    cout << min(kouho1n, kouho2n) << endl;
}


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

using namespace std;

typedef unsigned long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll energy(ll i,ll x){
	if(i == 1) return 5*x;
	else return (2*i+1)*x;
}


int main()
{
	ll N,X;
	cin >> N >> X;
	vector<ll> x(N);
	for(ll i = 0; i < N; i++){
		cin >> x[i];
	}

	vector<ll> sum(N);
	for(ll i = 0; i < N; i++){
		sum[i] = x[i] + (i!=0 ? sum[i-1]:0);
	}


	ll ans = 1e18;
	for(ll i = 1; i <= N; i++){
		ll res = (i+N)*X;
		//cout << "i = " << i << endl;
		for(ll j = 1; j <= (N+i-1)/i; j++){
			if(N<(j-1)*i+1) break;
			res += energy(j,sum[N-(j-1)*i-1]-(N>=j*i+1 ? sum[N-j*i-1]:0));

			//cout << N-(j-1)*i-1 << "   " << ((N-j*i-1>=0) ? N-j*i-1:0) <<   endl;
		}
		ans = min(res,ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
	int n, k, x, y, a, total = 0,b=0,c=0;
	cin >> n >> k >> x >> y;
	if (n > k) {
		a = n - k;
		c = y * a;
		b = x * k;
		total = b + c;
	}
	else
		total = n * x;
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int x[100001],y[100001];

void bfs(vector<int> *edges,int s,int n, int x[])
{
    bool v[n+1]={0};
    queue<int> q;
    q.push(s); v[s]=1; x[s]=0;
    while(!q.empty())
    {
        int z=q.front(); q.pop();
        for(int i=0; i<edges[z].size(); i++)
        if(!v[edges[z][i]])
        {
            q.push(edges[z][i]);
            v[edges[z][i]]=1;
            x[edges[z][i]]=x[z]+1;
        }
    }
}

int main()
{
    int n,u,v,ans=0,q=0;
    cin>>n>>u>>v; u--; v--;
    vector<int> edges[n+1];
    for(int i=0; i<n-1; i++)
    {
        int a,b;
        cin>>a>>b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    bfs(edges,u,n,x);
    bfs(edges,v,n,y);
    for(int i=0; i<n; i++)
        if(x[i]<y[i])
            ans=max(ans,y[i]-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6784