akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);
        int x= Reader.nextInt();
        int y = Reader.nextInt();
        int z = Reader.nextInt();

        System.out.println(z);
        System.out.println(x);
        System.out.println(y);
    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

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

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

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 22612
K = int(input())

def S(n):
    return sum(int(c) for c in str(n))

n9 = 0	# the number of 9s

count = 0
upper = 1
while count < K:
    n = int(str(upper) + ('9' * n9))
    if n <= S(n) * (10 ** n9):
        print(n)
        count += 1
        upper += 1
    else:
        n9 += 1
        upper //= 10


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=2002,mod=1e9+7;
int n,k,c[N][N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<=n+1;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(int i=1;i<=k;i++)
	{
		int ans=1ll*c[k-1][i-1]*c[n-k+1][i]%mod;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        
        b[a[i]]++;
    }

    ll r = 0;
    for (int j = 0; j < n; j++) {
        r += (ll)b[j] * (b[j] - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        ll t = r;
        int j = a[i];
        if (b[j] > 1) {
            int s = b[j] - 1;
            t -= (ll)b[j] * (b[j] - 1) / 2;
            t += (ll)s * (s - 1) / 2;
        }
        cout << t << '\n';
    }

    return 0;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

int w,h,x,y,r;

bool is_NG() {
    return (x-r<0 or y-r<0 or x+r>w or y+r>h);
}

int main() {
    while(cin>>w>>h>>x>>y>>r) {
        if(!is_NG()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1152
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    long double r;
    cin >> r;

    cout << r * 2 * pi << endl;

    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string str;
    cin >> str;
    reverse(str.begin(),str.end());
    for(int i=0;i<str.length();){
        if(str.substr(i,5) == "maerd" || str.substr(i,5) == "esare"){
            i += 5;
        }else if(str.substr(i,7) == "remaerd"){
            i += 7;
        }else if(str.substr(i,6) == "resare"){
            i += 6;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int n,x;
int a[2020];
int t[2020][2020];
signed main(){
    
    cin >> n >> x;
    rep(i,n)cin >> a[i];
    rep(i,n)t[i][0] = a[i];
    for(int i = 1;i < n;i++){
        rep(j,n){
            t[j][i] = min(t[j][i-1],a[(j-i+n)%n]);
        }
    }
    int ans = INF;
    rep(i,n){
        int res = i*x;
        rep(j,n)res += t[j][i];
        ans = min(ans,res);
    }
    cout << ans << endl;
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc004.contest.atcoder.jp/tasks/agc004_b

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

using namespace std;

double rast(int x1,int y1,int x2,int y2)
{
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

vector <pair<int,int> > graph[5000];
vector <int> graph2[5000];
bool backused[5000];

void dfs(int v)
{
    backused[v]=true;
    for (int i:graph2[v])
        if (!backused[i])
        dfs(i);
}
int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n,m,p;
    cin >> n >> m >> p;

    for (int i=0;i<m;i++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--,c-=p;
        graph[a].push_back({b,c});
        graph2[b].push_back(a);
    }

    dfs(n-1);

    vector <long long> dist(n);
    for (int i=0;i<n;i++)
        dist[i]=(long long)-1e18;
    dist[0]=0;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (dist[j]==(long long)-1e18) continue;
                for (int k=0;k<graph[j].size();k++)
            {
                int nxt=graph[j][k].first;
                int cost=graph[j][k].second;
                if (dist[nxt]<dist[j]+cost)
                    dist[nxt]=dist[j]+cost;
            }
        }
    }

    for (int i=0;i<n;i++)
        for (int j=0;j<graph[i].size();j++)
    {
        int k=graph[i][j].first;
        int cost=graph[i][j].second;
        if (dist[i]==(long long)-1e18 || dist[k]==(long long)-1e18) continue;
        if (dist[k]<dist[i]+cost && backused[k])
        {
            cout << -1;
            return 0;
        }
    }

    cout << max(dist[n-1],0LL);

}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
  
struct node 
{
  
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

typedef struct node* Node;
Node root;
  
Node treeSearch(Node x,int k) 
{
  if(x == NIL || k == x-> key)
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else return treeSearch(x->right,k );
}
  
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->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)
    inorder(u->right);
}
  
void preorder(Node u) 
{
  printf(" %d",u->key);
  if(u->left != NIL)
    preorder(u->left);
  if(u->right != NIL)
    preorder(u->right);
}
  
int main(void) 
{
    
  int i,n,x;
  char c[5];
    
  scanf("%d",&n);
    
  for(i=0;i<n;i++) 
    {
      scanf("%s",c);
      if(c[0] == 'f') {
	scanf("%d",&x);
	if(treeSearch(root,x) != NIL)
	  printf("yes\n");
	else printf("no\n");
      }
      else if(c[0] == 'i')
	{
	  scanf("%d",&x);
	  insert(x);
	}
      else if(c[0] == 'p')
	{
	  if(root != NIL) 
	    inorder(root);
	  printf("\n");
	  if(root != NIL)
	    preorder(root);
	  printf("\n");
	  
	}
    }
  return 0;
}

Measured memory_bytes: 24036
use std::io::*;
use std::io;
use std::str::FromStr;
fn read(s: &mut StdinLock) -> u32 {
    s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as u32 + a * 10)
}

fn main() {
    let stdin = io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| String::from_str(n).unwrap());
    let s = it.next().unwrap();
    let mut s: Vec<&str> = s.trim().split("").collect();
    s.sort();
    s.dedup();
    s.remove(0);
    //    let a = "abcdefghijklmnopqrstuvwxyz".to_string();

    let mut x: [u8; 27] = [0; 27];
    for i in 0..s.len() {
        let tmp = s[i].to_string().chars().nth(0).unwrap() as u8 - 'a' as u8;
        x[tmp as usize] += 1;
    }

    for i in 0..26 {
        if x[i] == 0 {
            println!("{}", (i as u8 + 'a' as u8) as char);
            return;
        }
    }
    println!("None");

}


Measured memory_bytes: 6396
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var ans = 0.0
    repeat(N) {
        val (x, u) = readLine()!!.split(" ")
        ans += if (u == "JPY") x.toDouble() else x.toDouble() * 380000.0
    }
    println(ans)
}

Measured memory_bytes: 36212
#include<bits/stdc++.h>
using namespace std;
int n,a,b,sum;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        sum+=b-a+1;
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(void) {
    ll A,B,C;cin>>A>>B>>C;
    if (A < B) swap(A, B);
    if (A < C) swap(A, C);
    if (A % 2 == 0) {
        cout << 0 << endl;
    } else {
        cout << B * C << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
static const int N = 1000;

int lcs(string x, string y);

int main() {
    int n;
    cin >> n;
    string x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        cout << lcs(x, y) << endl;
    }
    return 0;
}
int lcs(string x, string y) {
    int c[N + 1][N + 1];
    int m = (int)x.size(), n = (int)y.size();
    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int j = 1; j <= n; j++) c[0][j] = 0; //c[0][0] is prepared above
    int maxl = 0;
    x = ' ' + x;
    y = ' ' + y;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (x[i] == y[j]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i-1][j], c[i][j-1]);
            maxl = max(maxl, c[i][j]);
        }
    }
    /*for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }*/
    return maxl;
}




Measured memory_bytes: 7000
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}
int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16112
#include<bits/stdc++.h>
using namespace std;
int n,h[20],maxn=0,ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
		if(h[i]>=maxn)
		{
			ans++;
			maxn=h[i];
		}
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
// unsigned euclidean_gcd(unsigned a, unsigned b) {
//   while(1) {
//     if(a < b) swap(a, b);
//     if(!b) break;
//     a %= b;
//   }
//   return a;
// }

void solve() {
  int k;
  ll sum = 0;
  cin >> k;
  REP(a, k) {
    REP(b, k) {
      REP(c, k) { sum += euclidean_gcd(euclidean_gcd(a + 1, b + 1), c + 1); }
    }
  }
  cout << sum << endl;
}

signed main() {
  solve();

  return 0;
}

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

#define int long long 
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dbg(x) cerr << #x << ": " << x << '\n'
#define fast_io() ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second

signed main() {
    fast_io();
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k & 1) cout << b - a; else cout << a - b;
    return 0;
}


Measured memory_bytes: 3620
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve());
		Out.Flush();
	}
	int Solve()
	{
		var I = G();
		var N = I[0];
		long P = I[1];
		var w = new int[N];
		var b = new int[N];
		var d = new List<long>(N);
		var s = 0L;
		for (int i = 0; i < N; i++)
		{
			I = G();
			w[i] = I[0];
			b[i] = I[1];
			d.Add((100L - P) * w[i] + P * b[i]);
			s -= P * b[i];
		}
		d.Sort((x, y) => y.CompareTo(x));
		var c = 0;
		while (s < 0) s += d[c++];
		return c;
	}
}


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

using namespace std;

const int MAXN=1e6+1;

string s;
int dp[MAXN][2]={0},len;

int main() {
	cin>>s;
	len=s.length()-1;
	dp[0][0]=s[len]-48,dp[0][1]=58-s[len];
	for(int i=1,no; i<=len; ++i) {
		no=s[len-i]-48;
		dp[i][0]=dp[i-1][0]+no;
		if(no!=9) dp[i][0]=min(dp[i][0],dp[i-1][1]+no+1);
		dp[i][1]=dp[i-1][0]+10-no;
		if(no==9) dp[i][1]=min(dp[i][1],dp[i-1][1]);
		else dp[i][1]=min(dp[i][1],dp[i-1][1]+9-no);
	}
	cout<<min(dp[len][0],dp[len][1]+1)<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int n,l;
  string s;
  cin>>n;
  pair<string, pair<int ,int> > p[n];
  for(int i=0;i<n;i++)
  {
    cin>>s>>l;
    p[i]=mp(s,mp(-1*l,i+1));
  }
  sort(p,p+n);
  for(auto i:p)
  {
    cout<<i.S.S<<nl;
  }
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
using namespace std;
double getDegree(double d){
    return d*M_PI/180;
}

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    double aS = 30*c+(double)d/2;
    double bS = 6*d;
    double lhs = a*sin(getDegree(aS)) - b*sin(getDegree(bS));
    double rhs = a*cos(getDegree(aS)) - b*cos(getDegree(bS));
    printf("%.20lf",sqrt(lhs*lhs + rhs*rhs));
    return 0;
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int R;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> R;

	int ans = 3 * R * R;
	cout << ans << endl;
}







Measured memory_bytes: 256
eval"H,W,D,*R="+`dd`.split*?,;d=[0]*-~D;x=[];0.upto(H*=W){|e|x[R[e]]=e};(D+1..H).map{|i|d[i]=d[j=i-D]+(x[i]/W-x[j]/W).abs+(x[i]%W-x[j]%W).abs};R[H+1..-1].each_slice(2){|a,b|p d[b]-d[a]}

Measured memory_bytes: 66020
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main(){
	long long N;
	cin>>N;
	string a=" ";
	while(N){
		N--;
		a+=(char)('a'+(N%26));
		N/=26;
	}
	reverse(a.begin(),a.end());
	cout<<a<<endl;
  return 0;
}

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

int comb(int x){
	if (x < 2){
		return 0;
	}
	return x * (x - 1) >> 1;
}

int main(){
	int k, s;
	scanf("%d%d", &k, &s);
	return printf("%d\n", comb(s + 2) - 3 * comb(s - k + 1) + 3 * comb(s - 2 * k) - comb(s - 3 * k - 1)), 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

l_s = sorted(l)

for i in l:
    if i != l_s[-1]:
        print(l_s[-1])
    else:
        print(l_s[-2])
        

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

using namespace std;

long double a[3000],dp[3000][3000];
int n,vis[3000][3000];

long double go(int i,int k)
{
	if(i==n)
	  {
	  	 if(k>n/2)
	  	   return 1;
	  	 else
	  	   return 0;
	  }
	else
	  { if(vis[i][k]==-1)
	  	 {  vis[i][k]=1;
	  	 	dp[i][k]=a[i]*go(i+1,k+1)+(1-a[i])*go(i+1,k);
	  	 }
	  	return dp[i][k]; 
	  }
}

int main()
{   cin>>n;
	memset(vis,-1,sizeof(vis));
	for(int i=0;i<n;i++)
	 {
	 	cin>>a[i];
	 }
	 cout<<setprecision(11)<<go(0,0)<<'\n';
	return 0;
}

Measured memory_bytes: 176256
#include<bits/stdc++.h>
#define F first
#define S second
#define mod 1000000007
using namespace std;
    int dpp[5001][5001];int dps[5001][5001];

int main()
{
    int n,k;
    cin>>n>>k;
    int i;
    
    int arr[5000];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dpp[0][0]=1;
    if(arr[0]<=k)
    dpp[0][arr[0]]=1;
    for(i=1;i<n;i++)
    {   dpp[i][0]=1;
        for(int j=1;j<=k;j++)
        {   dpp[i][j]= dpp[i-1][j];
           if(j>=arr[i])
           {
               dpp[i][j]=(dpp[i][j] || dpp[i-1][j-arr[i]]);
           }
           
          // cout<<dpp[i][j]<<" "<<i<<" "<<j<<endl;
        }
    }
    
    if(arr[n-1]<=k)
    dps[n-1][arr[n-1]]=1;
    dps[n-1][0]=1;
    
    
    for(i=n-2;i>=0;i--)
    {   dps[i][0]=1;
        for(int j=1;j<=k;j++)
        {   dps[i][j]= dps[i+1][j];
           if(j>=arr[i])
           {
               dps[i][j]= dps[i][j] || dps[i+1][j-arr[i]];
           }
        }
        
    }
    for(i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            dps[i][j]+=dps[i][j-1];
        }
    }
    
    int cnt=0;
    for(i=0;i<n;i++)
    {   if(arr[i]>=k)continue;
        int j;
        if(i==0)
        {   
            if(dps[i+1][k-1]-dps[i+1][k-arr[i]-1]==0)cnt++;
        }
        else if(i==n-1)
        {
            for( j=k-arr[i];j<k;j++)
            {
                if(dpp[i-1][j]==1)break;
            }
            if(j==k)cnt++;
        }
        else{
            for(j=0;j<k;j++)
            {   
                if(j<k-arr[i])
                {if(dpp[i-1][j]==1&&dps[i+1][k-1-j]-dps[i+1][k-arr[i]-j-1]>0)break;}
                
                else{
                    if(dpp[i-1][j]==1&&dps[i+1][k-1-j]>0)break;
                }
            }
            if(j==k)cnt++;
        }
    }
    cout<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 195584
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m,k, s, t, q, ans, sum, a, d[1000000], last;
struct Edge { LL to,cost; };
vector<Edge>vec[100010];
string str, ss;
void DIUX(LL s) {
	for (int i = 0; i < 1000000; i++)
		d[i] = INF;
	d[s] = 0;
	priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
	pq.push(make_pair(d[s], s)); // (cost,頂点番号) 
	while (!pq.empty()) {
		Pll pp;
		pp = pq.top();
		LL cos = pp.first, vv = pp.second;
		pq.pop();
		if (d[vv] < pp.first)continue;
		for (int i = 0; i < vec[vv].size(); i++) {
			if (vec[vv][i].cost + d[vv] < d[vec[vv][i].to]) {
				d[vec[vv][i].to] = vec[vv][i].cost + d[vv];
				pq.push(make_pair(d[vec[vv][i].to], vec[vv][i].to));
			}
		}
	}
}
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n - 1) {
		LL x, y, z;
		cin >> x >> y >> z;
		vec[x].push_back(Edge{ y, z });
		vec[y].push_back(Edge{ x, z });
	}
	cin >> q >> k;
	DIUX(k);
	rep(i, q) {
		LL x, y;
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}
	return 0;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, M, X; cin >> N >> M >> X;
	vint C(N);
	vector<vint> A(N, vint(M));
	REP(i, N){
		cin >> C[i];
		REP(j, M) cin >> A[i][j];
	}
	int ans = BIG;
	REP(bit, (1<<N)){
		if(bit == 0) continue;
		vint pt(M, 0);
		int sum = 0;
		REP(i, N){
			if((bit>>i) & 1){
				sum += C[i];
				REP(j, M){
					pt[j] += A[i][j];
				}
			}
		}
		bool yes = 1;
		REP(i, M){
			yes &= (pt[i] >= X);
		}
		if(yes) chmin(ans, sum);
	}
	if(ans == BIG) cout << -1 << ln;
	else cout << ans << ln;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int mod=1000000007;
int dp[10000000];
int mat[21][21];
int n;
int recur(int a,int g,int k){
	if(k==n){
		if(a==g){
			return 1;
		}
		return 0;
	}
	if(dp[a]!=-1){
		return dp[a];
	}
	dp[a]=0;
	for(int i=0;i<n;i++){
		if(mat[k][i]==1){
			if((a&(1<<i))==0){
				dp[a]=(dp[a]%mod+recur((a^(1<<i)),g,k+1)%mod)%mod;
			}
		}
	}
	return dp[a];
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>mat[i][j];  
		}
	}
	int g=(1<<n)-1;
	//cout<<g<<" ";
	for(int i=0;i<=g;i++){
		dp[i]=-1;
	}
	cout<<recur(0,g,0);
}

Measured memory_bytes: 10496
#include <cstdio>
using namespace std;
int a,b;
bool u[1260];

int main(){
	scanf("%d%d",&a,&b);
	for(int i=1;i<=1250;i++)if(i*8/100==a)u[i]=1;
	for(int i=1;i<=1250;i++)
		if(u[i] && i/10==b){
			printf("%d\n",i);
			return 0;
		}
	puts("-1");
	return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
a = []
for i in range(k):
  d = int(input())
  if d == 1:
    tmp = int(input())
    a.append(tmp)
  else:
    b = [int(i) for i in input().split()]
    for item in b:
    	a.append(item)
result = 0
for i in range(n):
  if i+1 not in a:
    result += 1

print(result)

Measured memory_bytes: 9196
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ans=0
for i in range(n):
    if (i+1)%2==0:
        continue
    cnt=0
    for j in range(i+1):
        if (i+1)%(j+1)==0:
            cnt+=1
    if cnt==8:
        ans+=1
print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define whyqx
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n,d,x[15][15],ans;
inline int Dis(int a,int b)
{
	rg int res=0;
	for(int i=1;i<=d;i++)
		res+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
	return res;
}
int main()
{
#ifdef JE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
	rg int tmp,sq;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
			scanf("%d",&x[i][j]);
		for(int j=1;j<i;j++)
		{
			tmp=Dis(i,j);
			sq=sqrt(tmp);
			if(sq*sq==tmp)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#define MAXN 55
using namespace std;
int gems[MAXN], cost[MAXN];
int main()
{
	int n;
	cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>gems[i];
	}
	for(int i = 0; i < n; i++)
	{
		cin>>cost[i];
	}
	int z = 0;
		for(int i = 0; i < n; i++)
	{
		if(gems[i] > cost[i])
		{
			z += gems[i] - cost[i];
		}
	}
	cout<<z<<endl;
	return 0;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            var ans = 0;
            
            if (13 <= a)
                ans = b;
            else if (5 < a)
                ans = b / 2;

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    // 今まで見つかった数
    int cnt = 0;

    for (int i = min(a, b); i >= 1; i--)
    {
        // if(A && B) は、AもBも条件を満たす時
        if (a % i == 0 && b % i == 0)
        {
            // cnt を1増やす
            cnt++;
            // もし割り切れる数が見つかったのが、K番目だったら
            if (cnt == k)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;

bool cmp(tuple<int,int,int> a, tuple<int,int,int> b){
    return get<0>(a) < get<0>(b);
}


int main(){

    int n,m;
    cin >> n >> m;

    vector<tuple<int,int,int>> vv(m);   // year, prefecture, index;
    string ans[m];
    for(int i=0;i<m;i++){
        int p,y;
        cin >> p >> y;
        vv[i] = make_tuple(y,p,i);
    }

    sort(vv.begin(),vv.end(),cmp);

    unordered_map<int,int> mp;

    for(int i=0;i<m;i++){

        if(i==0) {
            int p = get<1>(vv[i]);
            string str1 = "", str2 = "";
            str1 = to_string(p);
            str2.append((6-str1.size()),'0');
            str2 += str1;
            str2 += "000001";
            ans[get<2>(vv[i])] = str2;
            mp[p]++;
        }
        else {
            int p = get<1>(vv[i]);
            string str1 = "", str2 = "";
            str1 = to_string(p);
            str2.append((6-str1.size()),'0');
            str2 += str1;
            int id = 1;
            if(mp[p]>0) id = mp[p]+1;

            str1 = to_string(id);

            str2.append((6-str1.size()),'0');
            str2 += str1;

            ans[get<2>(vv[i])] = str2;
            mp[p]++;
        }

    }


    for(int i=0;i<m;i++) cout << ans[i] << endl;



    return 0;
}


Measured memory_bytes: 12196
#include <cstdio>

using namespace std;

int a[109];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    tot += a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] * 4 * m >= tot) {
      ++cnt;
    }
  }
  puts(cnt >= m ? "Yes" : "No");
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int H, A;
    cin >> H >> A;
    int d = H % A == 0 ? 0 : 1;
    cout << (H / A) + d << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int solve(int ,int );
 
int A[2000],n,Mi[2000];
 
int main(){
  int i, q;
   
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&Mi[i]);
  }
   
  for(i = 0; i < q; i++){
    if(solve(0,Mi[i]) == 1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}
 
int solve(int i,int m){
  if(A[i] == m){
    return 1;
  }
  if(i+1 == n){
    return 0;
  }
  if(solve(i+1,m-A[i])||solve(i+1,m)){
    return 1;
  }
  return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> c1, cN;
	rep(i,M) {
		int a, b;
		cin >> a >> b;
		if (a == 1) c1.push_back(b);
		if (b == N) cN.push_back(a);
	}

	vector<int> islands(N+1);
	for (int i: c1) islands[i] = 1;
	for (int i: cN) {
		if (islands[i] == 1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


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

int main(){
  int a=7,k,ans=1;
  
  scanf("%d",&k);
  if(k%2==0||k%5==0){
    printf("-1");
    return 0;
  }
  while(a%k){
    a=(a*10+7)%k;
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>

int main(){
    
    int counter = 0;
    int test_case;
    
    while(1){
        scanf("%d", &test_case);
        if(test_case == 0) break;
        else printf("Case %d: %d\n", counter+1, test_case);
        counter++;
    }
}
 


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

int main()
{
  int N,M;scanf("%d %d",&N,&M);
  pair<int,int> endstart[M];
  for(int a,b,i=0;i<M;i++)
  {
    scanf("%d %d",&a,&b);
    if(a>b)swap(a,b);
    endstart[i].first=b;endstart[i].second=a;
  }
  sort(endstart,endstart+M);
  int ans=1,t=endstart[0].first;
  for(int i=1;i<M;i++)if(t<=endstart[i].second){ans++;t=endstart[i].first;}
  printf("%d\n",ans);
}

Measured memory_bytes: 4560
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		try (Scanner sc = new Scanner(System.in)){
			int times = 1;
			while (true) {
				int input = sc.nextInt();
				if (input == 0) break;
				System.out.println("Case " + times + ": " + input);
				times++;
			}
		}
	}
}



Measured memory_bytes: 41284
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y>>s,x){
		int max_zeigo = 0;
		for(int i=1;i<1000;i++)
			for(int j=1;j<1000;j++){
				int tmp = i * (100 + x)/100 + j * (100+x)/100;
				if(tmp == s)max_zeigo = max(i*(100+y)/100+j*(100+y)/100,max_zeigo);
			}
		cout << max_zeigo << "\n";
	}
	return 0;
}

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

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

    vector<vector<int>> G(N); // 隣接リスト表現によるグラフ
    vector<pair<int, int>> E_in;

    for (int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        pair<int, int> p = make_pair(a, b);
        E_in.emplace_back(p);
    }

    queue<int> que;
    vector<int> used(N, 0);
    vector<int> parent(N, 0); // 親との間にある辺の数値
    int max_color = 0;
    map<pair<int, int>, int> E_num;
    que.emplace(0); // 最初のものは何でも良いので0からにする

    while (que.size() != 0) {
        int state = que.front(); // 現在の状態
        used[state] = 1;
        que.pop();
        int color_num = 0;
        for (auto i : G[state]) {
            if (used[i] != 1) {
                color_num++;
                if (color_num == parent[state]) {
                    color_num++;
                }
                pair<int, int> p = make_pair(state, i);
                E_num[p] = color_num; //辺彩色
                parent[i] = color_num;
                que.push(i); //次の状態をqueueへ格納
            }
        }
        max_color = max(max_color, color_num);
    }

    cout << max_color << "\n";
    for (auto i : E_in) {
        cout << E_num[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 13812
import sys
n = int(input())
A = list(map(int, input().split()))

T = 10**18

for i in A:
    if i == 0:
        print(0)
        sys.exit()

ans = 1
for a in A:
    ans *= a
    if ans > T:
        print(-1)
        sys.exit()

print(ans)


Measured memory_bytes: 21788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int h=in(),w=in(),i,j,t;
	char s[55][55];
	getchar();
	rep(i,h){
		rep(j,w)s[i+1][j+1]=getchar();
		getchar();
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(s[i][j]=='#')putchar(s[i][j]);
			else{
				t=0;
				if(s[i-1][j-1]=='#')t++;
				if(s[i-1][j]=='#')t++;
				if(s[i-1][j+1]=='#')t++;
				if(s[i][j-1]=='#')t++;
				if(s[i][j+1]=='#')t++;
				if(s[i+1][j-1]=='#')t++;
				if(s[i+1][j]=='#')t++;
				if(s[i+1][j+1]=='#')t++;
				printf("%d",t);
			}
		}
		puts("");
	}
	return 0;
}

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

using namespace std;

int main(void){
    int x, n;
    cin >> x >> n;
    
    if (n == 0){
        cout << x << endl;
        return 0;
    }
    
    bool isX = true;
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
        if (p[i] == x) isX = false;
    }
    
    if (isX){
        cout << x << endl;
        return 0;
    }
    
    sort(p.begin(),p.end());
    
    int smallest = p[0];
    int largest = p[n-1];
    
    int dist = 1000000;
    int ans = 10000;
    
    for (int i = smallest-1; i <= largest+1; i++){
        bool bad = false;
        for (int j = 0; j < n; j++){
            if (i == p[j]) bad = true;
        }
        
        if (bad) continue;
        
        if (abs(x - i) < dist){
            dist = abs(x-i);
            ans = i;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
	string S;
	cin >> S;
	set<char> char_set;
	char last = 'a' - 1;
	while(true){
		for(char c=last+1; c<='z';++c){
			char_set.insert(c);
		}
		for(const auto& c : S){
			char_set.erase(c);
		}
		if(char_set.size()){
			cout << S + *char_set.begin();
			return 0;
		}else{
			if(S.size()==0){
				break;
			}
			last = *(S.end() - 1);
			S = S.substr(0, S.size() - 1);
		}
	}
	cout << -1;
}


Measured memory_bytes: 256
def main():
	n = int(input())
	d = list(map(int, input().split()))
	dic = {}
	for i in d:
		if i in dic:
			dic[i] = dic[i]+1
		else:
			dic[i] = 1
	m = int(input())
	t = list(map(int, input().split()))
	for i in t:
		if not(i in dic) or dic[i] == 0:
			print("NO")
			return
		else:
			dic[i] = dic[i] - 1
	print("YES")
	return
main()

Measured memory_bytes: 46304
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];

    bool ans=true;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3!=0 && A[i]%5!=0){
                ans = false;
            }
        }
    }

    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;
template <class BI>

bool next_partial_permutation(BI first, BI middle, BI last) {
  reverse(middle, last);
  return next_permutation(first, last);
}

int main(){
#define int ll
  int n,c; cin >> n >> c;
  vvi d(c,vi(c));
  rep(i,c) rep(j,c){
    cin >> d[i][j];
    d[i][j];
  }
  vvi mp(3,vi(c));
  FOR(i,1,n+1) FOR(j,1,n+1){
    int x; cin >> x;
    mp[(i+j)%3][x-1]++;
  }

  vi to(c);
  rep(i,c) to[i] = i;
  int ans = inf;
  do{
    int tmp = 0;
    rep(i,3) rep(j,c){
      tmp += mp[i][j] * d[j][to[i]];
    }
    ans = min(ans, tmp); 
  }while(next_partial_permutation(to.begin(),to.begin()+3,to.end()));
  cout << ans << endl;
}

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

namespace AtTest.AGC_032
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            for(int i = 0; i < n; i++)
            {
                if (array[i] > i + 1)
                {
                    WriteLine(-1);
                    return;
                }
            }
            List<int> list = new List<int>();
            list.AddRange(array);
            int[] res = new int[n];
            for(int i = 0; i < n; i++)
            {
                for(int j = list.Count - 1; j >= 0; j--)
                {
                    if (list[j] == j + 1)
                    {
                        res[i] = list[j];
                        list.RemoveAt(j);
                        break;
                    }
                }
            }
            Array.Reverse(res);
            for(int i = 0; i < n; i++)
            {
                WriteLine(res[i]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268