akhauriyash/Code-Regression huggingface dataset:
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func reverse(s string) string {
	ret := ""
	for _, v := range s {
		ret = string(v) + ret
	}
	return ret
}

func main() {
	N := parseInt(nextLine())

	if N == 0 {
		fmt.Println(N)
		return
	}
	res := ""

	divs := 1
	for N != 0 {
		if N%(2*intAbs(divs)) != 0 {
			res += "1"
			N -= divs
		} else {
			res += "0"
		}
		divs *= -2
	}
	fmt.Println(reverse(res))
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<double> dp(N+1);
    // 0.30 0.60 0.80
    
    // 0    1    2 (tails)
    // 0.70 0.30
    // 0.28 0.54 0.18
    
    dp[0] = 1;
    for (int coin=0; coin<N; coin++) {
        double p_heads;
        cin >> p_heads;
        for (int i=coin+1; i>=0; i--) {
            dp[i] = (i == 0 ? 0 : dp[i-1] * p_heads) + dp[i] * (1 - p_heads);
        }
    }
    
    double answer = 0;
    for (int heads = 0; heads <= N; heads++) {
        int tails = N - heads;
        if (heads > tails) {
            answer += dp[heads];
        }
    }
    
    printf("%.10lf\n", answer);
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger; 

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends

//......................................@uthor_Alx..............................................


//  (Binary lifting)LCS implementation <O(NlogN,logN)>...<preprocessing,query>
//static int l,time;
//static int[][] f; // f[n][l]..
//static int[] tin, tout;
//static List<Integer>[] adj;
/*	return tin[u]<=tin[v]&&tout[u]>=tout[v]; 
}
static void dfs(int u, int p){
	tin[u]=time++;
	f[u][0]=p;
	for(int i=1;i<=l;i++){
		f[u][i]= f[f[u][i-1]][i-1];
	}

	for(int v: adj[u]){
		if(v!=p) dfs(v,u);
	}
	tout[u]=time++;
}
static int lca(int u, int v){
	if(ok(u,v)){return u;}
	if(ok(v,u)){return v;}

	for(int i=l;i>=0;i--){
		if(!ok(f[u][i],v)){
			u=f[u][i];
		}
	}
	return f[u][0];
}*/

public static void main(String[] args) throws  IOException{
	        		  assign();
              int[] arr=int_arr();
              int x=arr[0],y=arr[1],a=arr[2],b=arr[3],c=arr[4];
              int[] p=int_arr();
              int[] q=int_arr();
              int[] r=int_arr();
              Arrays.sort(p);
              Arrays.sort(q);
              Arrays.sort(r);
              int c1=0,i=a-1,j=b-1,k=c-1,rc=0,gc=0;
              long res=0;
              while(c1<x+y){
              	int r1=i>=0?p[i]:0;
              	int g=j>=0?q[j]:0;
              	int ca=k>=0?r[k]:0;
              	if(a-i>x){r1=0;}
              	if(b-j>y){g=0;}
              	if(r1>=g&&r1>=ca){
              		res+=r1;i--;
              	}
              	else if(g>=r1&&g>=ca){
              		res+=g;j--;
              	}
              	else{
              		res+=ca;k--;
              	}
              	c1++;
              }
              out.write(res+"");
              out.flush();
	        		 
	        	}
	       
	          
	        }

	    

	
  





Measured memory_bytes: 57112
import java.util.Scanner;
class Main{
    int a,b,c,d,e,f,g;
    public void Germany() {
        Scanner sc = new Scanner(System.in);
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            if(a<b){
            	if(a<c){
            		if(b<c){
            			System.out.println(a + " " + b + " " + c);
            		}else{
            			System.out.println(a + " " + c + " " + b);
            		}
            	}else{
            		System.out.println(c + " " + a + " " + b);
            	}
            }else{
            	if(b<c){
            		if(a<c){
            			System.out.println(b + " " + a + " " + b);
            		}else{
            			System.out.println(b + " " + c + " " + a);
            		}
            	}else{
            		System.out.println(c + " " + b + " " + a);
            	}
            }
    	}
            
    public static void main(String[] args) {
        new Main().Germany();
    }
}

Measured memory_bytes: 17288
N = int(input())
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[i])
  elif i == N-1:
    A.append(B[i-1])
  else:
    if B[i-1]>B[i]:
      A.append(B[i])
    else:
      A.append(B[i-1])
print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int K,X;
   cin>>K>>X;
   for(int i=X-K+1;i<X+K;i++){
   cout<<i;
   if(i<X+K){cout<<" ";}
   }
   cout<<endl;
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <iostream>
#include <utility>
#include <map>

using namespace std;

typedef std::pair<long long, long long> pii;

vector<vector<int> > arr;
vector<bool> visited;
constexpr size_t MOD = (int)1e9 + 7;

pii func(size_t idx) {
    visited[idx] = true;
    if (arr[idx].size() == 1 && visited[arr[idx][0]]) return pii(2, 1);
    pii res(1, 1), tmp;
    for (int i = 0; i < arr[idx].size(); i++) {
        if (!visited[arr[idx][i]]) {
            tmp = func(arr[idx][i]);
            res.second *= tmp.first;
            res.first *= tmp.second;
            res.first %= MOD;
            res.second %= MOD;
        }
    }
    res.first += res.second;
    res.first %= MOD;
    return res;
}


int main() {
//    freopen("out.txt", "w", stdout);

    size_t N; scanf("%u", &N);
    arr.resize(N+1);
    visited.resize(N+1);
    for (size_t i = 0 ; i<=N ; i++) visited[i] = false;
    int u, v;
    for (int i = 1 ; i<N ;i++) {
        scanf("%d %d", &u, &v);
        arr[u].push_back(v);
        arr[v].push_back(u);
    }

    std::cout << func(1).first;
    return 0;
}

Measured memory_bytes: 9856
#include <stdio.h>
int main(void){
	int a,b,c,i,j,k,n[101][101],m[101][101];
	long sum;

	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			scanf("%d",&n[i][j]);
		}
	}
	for(i=0;i<b;i++){
		for(j=0;j<c;j++){
			scanf("%d",&m[i][j]);
		}
	}
	for(i=0;i<a;i++){
		for(j=0;j<c;j++){
			for(k=0;k<b;k++){
				sum += m[k][j]*n[i][k];
				if(k == b-1){
					printf("%ld",sum);
					if(j != c-1)
						printf(" ");}
			}
			sum=0;
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
	// sengen
	char c,ans;
	int n;
	// nyuryoku
	cin >> c;
	n = c - 'A';
	// keisan
	if(n > 27){
		cout << 'a';
	}else{
		cout << 'A';
	}
	// syutsuryoku
}

Measured memory_bytes: 3604
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    if x[i]*x[i+k-1]>=0:
        ans = min(ans, max(abs(x[i]), abs(x[i+k-1])))
    else:
        a = min(abs(x[i]), abs(x[i+k-1]))
        b = max(abs(x[i]), abs(x[i+k-1]))
        ans = min(ans, a*2+b)
print(ans)

Measured memory_bytes: 14532
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<int>mA(n);
	for(i=0;i<n;i++){cin>>mA[i];}
	//まずは1のスタート地点を見つけて、ずらす
	int stat=-1;
	for(i=0;i<n-1;i++){
		if(mA[i]!=1&&mA[i+1]==1){stat=i+1;break;}
	}
	if(mA[n-1]!=1&&mA[0]==1){stat=0;}
	
	if(stat==-1){
		if(mA[0]!=1){cout<<0<<endl;}//1がない
		else{//1しかない
			llint aaa=1;
			for(i=1;i<=n;i++){aaa*=i;aaa%=mod;}
			cout<<aaa<<endl;
		}
		return 0;
	}
	vector<int>A(n+1);
	for(i=0;i<n;i++){A[i]=mA[(i+stat)%n];}
	A[n]=A[0];
	vector<int>L(n+1,-1);
	vector<int>R(n+1,-1);
	for(i=0;i<n;i++){
		if(L[A[i]]==-1){L[A[i]]=i;}
		R[A[i]]=i;
	}
	
	int kaz=0;
	for(i=1;i<=n;i++){if(L[i]!=-1){kaz+=R[i]+1-L[i];}}
	if(kaz!=n){cout<<0<<endl;return 0;}
	int sla=R[1]-L[1]+1;
	llint ans=1;
	vector<int>ren(n,-1);
	ren[0]=sla;
	ren[sla-1]=sla;
	int oke=0;
	for(i=2;i<=n;i++){
		
		if(L[i]==-1){ans*=oke;ans%=mod;oke--;continue;}
		int nga=R[i]-L[i]+1;
		if(nga>sla){cout<<0<<endl;return 0;}
		int zL=L[i],zR=R[i];
		
			
		if(ren[L[i]-1]!=-1){
			oke-=max(0,ren[L[i]-1]+1-sla);
			zL=L[i]-ren[L[i]-1];
		}
		if(ren[(R[i]+1)%n]!=-1){
			oke-=max(0,ren[(R[i]+1)%n]+1-sla);
			zR=R[i]+ren[(R[i]+1)%n];
		}
		int nn=min(n,zR-zL+1);
		oke+=max(0,nn+1-sla);
		if(ren[L[i]-1]+nga==n){oke=n-i+1;}
		ren[(zL+n)%n]=nn;ren[(zR+n)%n]=nn;
		//zL...L...R...zR
		//zLやzRは範囲外かもしれない
		ans*=max(0,min(L[i]+sla-1,zR)-max(R[i],zL+sla-1)+1);
		ans%=mod;oke--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>

using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a < b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  } else {
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  return 0;
}

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

struct node{
    int x,y,t;
};
int n,m,ans=0,cnt=0;
char gra[1005][1005];
int d[4][2]={1,0,0,1,-1,0,0,-1};
bool can(int x,int y){
    if(x<0||x>=n||y<0||y>=m)return false;
    if(gra[x][y]=='#')return false;
    return true;
}
int main(){

    cin>>n>>m;
    for(int i=0;i<n;i++)
        scanf("%s",gra[i]);
    queue<node> q;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(gra[i][j]=='#'){
            node t;
            t.x=i;
            t.y=j;
            t.t=0;
            q.push(t);
            cnt++;
        }
    }
    while(!q.empty()){
        node t=q.front();
        q.pop();
        if(cnt==n*m)break;
        for(int i=0;i<4;i++){
            node nn;
            nn.x=t.x+d[i][0];
            nn.y=t.y+d[i][1];
            nn.t=t.t+1;
            if(can(nn.x,nn.y)){
                gra[nn.x][nn.y]='#';
                ans=max(ans,nn.t);
                cnt++;
                q.push(nn);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13328
N, L = map(int,input().split())

def taste(i):
  return L + i
m = 1e+10
t = 0
appleN = [taste(i) for i in range(N)]
for n in range(N):
  appleN_1 = [taste(i) for i in range(N) if i != n]
  m = min(m, abs(sum(appleN) - sum(appleN_1)))
  if m == abs(sum(appleN) - sum(appleN_1)):
    t = sum(appleN_1)
print(t)

Measured memory_bytes: 3060
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
vector<int>g[2600];
vector<int>rev[2600];
int x[5100];
int y[5100];
int z[5100];
int v[2][2600];
long long cur[2600];
int upd[2600];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++){
		scanf("%d%d%d",x+i,y+i,z+i);x[i]--;y[i]--;
		z[i]=z[i]-c;
		g[x[i]].push_back(y[i]);
		rev[y[i]].push_back(x[i]);
	}
	queue<int>Q;
	Q.push(0);
	v[0][0]=1;
	while(Q.size()){
		int at=Q.front();
		Q.pop();
		for(int i=0;i<g[at].size();i++){
			if(v[0][g[at][i]])continue;
			v[0][g[at][i]]=1;
			Q.push(g[at][i]);
		}
	}
	Q.push(a-1);
	v[1][a-1]=1;
	while(Q.size()){
		int at=Q.front();
		Q.pop();
		for(int i=0;i<rev[at].size();i++){
			if(v[1][rev[at][i]])continue;
			v[1][rev[at][i]]=1;
			Q.push(rev[at][i]);
		}
	}
	for(int i=0;i<a;i++)cur[i]=-inf;
	cur[0]=0;
	for(int i=0;i<a*2;i++){
		for(int j=0;j<b;j++){
			if(cur[y[j]]<cur[x[j]]+z[j]){
				cur[y[j]]=cur[x[j]]+z[j];
				upd[y[j]]=i;
			}
		}
	}
	long long ret=max(0LL,cur[a-1]);
	for(int i=0;i<a;i++){
		if(upd[i]>=a&&v[0][i]&&v[1][i])ret=-1;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <long long MOD = 1000000007> //MODを適宜設定すること
struct Mint
{
   using M = Mint;
   ll a;
   Mint(ll x=0){a=x%MOD;if(a<0) a+=MOD;}//Mintで

   M pow(ll n){
      M b=*this,r=1%MOD;
      while(n){
         if(n&1)r*=b;
         b*=b;
         n>>=1;
      }
      return r;
   }

   M inv(){return pow(MOD-2);}

   M& operator+=(M r){a+=r.a;if(a>=MOD)a-=MOD;return *this;}
   M& operator-=(M r){a+=MOD-r.a;if(a>=MOD)a-=MOD;return *this;}
   M& operator*=(M r){a=1LL*a*r.a%MOD;return *this;}
   M& operator/=(M r){return (*this)*=r.inv();}
   M operator+(M r) const{return M(a)+=r;};
   M operator-(M r) const{return M(a)-=r;};
   M operator*(M r) const{return M(a)*=r;};
   M operator/(M r) const{return M(a)/=r;};//const いる？

   friend ostream& operator<<(ostream& os,const M& r){return os<<r.a;}
};
using M = Mint<mod>;


template<typename T>
vector<T> finddivisor(T x){//整数xの約数が入ったvectorを返すよ(xを含む)  
    vector<T> divisor;
    for(T i=1; (i*i)<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
            if(i*i!=x){
                divisor.push_back(x/i);
            }//約数はペアを持つことを利用

        }
    }
    sort(divisor.begin(),divisor.end());
    //divisor.push_back(x);

    //if(x==1)divisor.pop_back();
    return divisor;
}


signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>n>>k;
  V<M> coe(k+10,0);

  M ans=0,sum;
  V<int> div;
  
  rep(i,1,k+1){
    sum=0;
    div=finddivisor((int)i);
    rep(j,0,siz(div)-1){
      sum+=coe[div[j]];
    }

    ans+=(M(k/i).pow(n))*(M(i)-sum);
    coe[i]=M(i)-sum;
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3992
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge {
    int from, to, cost;
};

int main(void) {
    int N, M, P; cin >> N >> M >> P;
    vector<vector<Edge>> G(N+1);
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        G[a].push_back({a, b, c});
    }

    long long INF = 10000000000000000;
    vector<vector<long long>> v(10001, vector<long long>(N+1, -INF));
    v[0][0] = 0;
    for (int time = 0; time < 10000; time++) {
        for (int i = 0; i < N; i++) {
            if (v[time][i] == -INF) continue;

            for (int j = 0; j < G[i].size(); j++) {
                Edge e = G[i][j];
                v[time+1][e.to] = max(v[time][e.from] + e.cost, v[time+1][e.to]);
            }
            v[time+1][i] = max(v[time][i], v[time+1][i]);
            if (i == N-1) {
                v[time+1][N] = max(v[time][N-1], v[time+1][N]);
            }
        }
        if (time > 5000 && v[time+1][N] > v[time][N]) {
            cout << -1 << endl;
            return 0;
        }   
    }
    cout << max(v[10000][N-1], 0LL) << endl;
}

Measured memory_bytes: 196224
#

import itertools
from collections import Counter
import bisect

def main():
    N = int(input())
    H = list(map(int, input().split()))
    ans = 1
    prev = 0
    for i in range(1, N):
        can_see = True
        for j in range(0, i):
            if H[j] > H[i]:
                can_see = False
        if can_see:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
	if(n % 2) return (mod_pow(x,n-1) * x) % mod;
  else{  
  	long long buf = mod_pow(x, n/2);
    return (buf * buf) % mod;
  }
}

int main(){
  int n;
  cin >> n;
  long long ans = 0;
  long long azs = 0, bzs = 0;
  
  map<pair<long long,long long>,long long> mp;
  
  for(int i = 0; n > i; i++){
	long long a,b;
    cin >> a >> b;
    if(a == 0 && b == 0) ans++;
  	else if( a == 0) azs++;
    else if( b == 0) bzs++;
    else {
      long long g = __gcd(abs(a),abs(b));
      a = a/g;
      b = b/g;
      if(b < 0) b = -b, a = -a;	
      mp[{a,b}]++;
      if(a < 0) b = -b, a = -a;	
      mp[{-b,a}] = mp[{-b,a}];
    }
    ans %= mod;
  }
  
  long long buf = 1;
  buf *= mod_pow(2, azs) + mod_pow(2, bzs) - 1;
  buf %=mod;
  for(auto itr : mp){
     if(itr.first.first < 0){
     	buf *= (mod_pow(2, itr.second) + mod_pow(2, mp[{itr.first.second,-itr.first.first}]) - 1);
       buf %=mod;
     }
  }
  ans += mod+buf-1;
  ans %= mod;
  cout << ans << endl;
  
}

Measured memory_bytes: 28412
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef long long ll;
ll N, M;
ll a[100010][3];

ll maxn = -(1LL << 60);

int main() {
   cin >> N >> M;
   for (ll i=1;i<=N;i++) {
      cin >> a[i][0] >> a[i][1] >> a[i][2];
   }
   for (int i=0;i<8;i++) {
      vector<ll> v;
      for (ll j=1;j<=N;j++) {
         ll S=0;
         rep(k,0,3) {
            if ((i / (1<<k)) % 2==0) {
               S += a[j][k];
            } else {
               S -= a[j][k];
            }
         }
         v.push_back(S);
      }
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      ll ans = 0;
      for (int j=0;j<M;j++) ans += v[j];
      maxn = max(maxn, ans);
   }
   cout << maxn << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

ll dp[10010];
ll dp2[10010];

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

    ll n, m, tmp;
    ll b[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<ll> a;

    cin >> n >> m;
    rep(i, m){
        cin >> tmp;
        a.push_back(tmp);
    }

    vsortr(a);

    dp[0] = 0;
    reps(i, 1, n){
        dp[i] = -inf;
        rep(j, a.size()){
            int num = b[a[j]];
            if(i >= num) dp[i] = max(dp[i], dp[i-num]+1);
        }
        //cout << dp[i] << " ";
    }

    string res = "";
    while(n > 0){
        for(auto aa : a){
            int num = b[aa];
            if(dp[n]-1 == dp[n-num] && n >= num){
                //cout << dp[n-num] sp n sp num << endl;
                res += to_string(aa);
                n -= num;
                break;
            }
        }
        //cout << n << endl;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,m;cin >> n >>m;
    vvl g(n);
    vl h(n);rep(i,n)cin >> h[i];
    rep(i,m){
        ll x,y;cin >> x >>y;x--;y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    ll ans=0;
    rep(i,n){
        bool check=true;
        for(auto nv:g[i]){
            if(h[nv]>=h[i])check=false;
        }
        if(check)ans++;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 1005;
ll nCk[MAX][MAX];
ll dp[MAX];

ll pow_mod(ll k, ll n) {
    ll ret = 1;
    rep(i, n) {
        ret *= k;
        ret %= MOD;
    }
    return ret;
}

ll mod(ll a, ll b) {
    return (a%b + b) % b;
}

int main() {
    int n, k; cin >> n >> k;

    if (n < k) {
        cout << 0 << endl;
        return 0;
    }

    // nCkを求める
    for (int i = 0; i < MAX; i++) nCk[i][0] = nCk[i][i] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= i-1; j++) {
            nCk[i][j] = nCk[i-1][j-1] + nCk[i-1][j];
            nCk[i][j] %= MOD;
        }
    }

    dp[0] = 0;
    dp[1] = 1;
    for (int i = 2; i <= k; i++) {
        ll tmp = pow_mod(i, n);
        for (int j = i-1; j >= 1; j--) {
            tmp -= nCk[i][j] * dp[j];
            tmp = mod(tmp, MOD);
        }
        dp[i] = tmp;
    }

    cout << dp[k] << endl;
}



Measured memory_bytes: 10044
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		D, G int
	)
	fmt.Scan(&D, &G)
	p := make([]int, D)
	c := make([]int, D)
	for i := 0; i < D; i++ {
		fmt.Scan(&p[i], &c[i])
	}
	ans := 9223372036854775807
	for mask := 0; mask < (1 << uint64(D)); mask++ {
		var score, num int
		restMax := -1
		for i := 0; i < D; i++ {
			if mask >> uint64(i) & 1 != 0 {
				score += 100 * (i+1) * p[i] + c[i]
				num += p[i]
			} else {
				restMax = i
			}
		}
		if score < G {
			nextScore := 100 * (restMax + 1)
			remainNum := (G - score + nextScore - 1) / nextScore
			if remainNum >= p[restMax] {
				continue
			}
			num += remainNum
		}
		ans = int(math.Min(float64(ans), float64(num)))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dat[10200];
bool yatta[5000];

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


	int N, K;
	cin >> N >> K;
	int P[5000], C[5000];
	rep(i, N) {
		cin >> P[i];
		P[i]--;
	}
	rep(i, N) {
		cin >> C[i];
	}

	ll kotae = -2e18;
	rep(i, N) if (!yatta[i]) {
		int L = 0;
		auto kari = dat;
		kari[0] = 0;
		int j = i;
		while (!yatta[j]) {
			yatta[j] = 1;
			kari[L + 1] = kari[L] + C[j];
			L++;
			j = P[j];
		}
		ll hue = kari[L];
		for (int j = L + 1; j <= L + L; j++) {
			kari[j] = kari[j - L] + hue;
		}
		ll amari = K % L;
		ll wari = K / L;
		if (hue > 0) {
			if (amari > 0) {
				deque<int> dq;
				rep1(i, L + amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
					dq.push_back(i);
					if (i < amari) continue;
					while (dq.size() && dq.front() <= i - amari) dq.pop_front();
					chmax(kotae, hue * wari + kari[dq.front()] - kari[i - amari]);
				}
			}			
			if (wari > 0) {
				deque<int> dq;
				rep1(i, L + L - amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i + amari]) dq.pop_back();
					dq.push_back(i + amari);
					if (i < L - amari) continue;
					while (dq.size() && dq.front() <= i + amari - L) dq.pop_front();
					chmax(kotae, hue * (wari - 1) + kari[dq.front()] - kari[i + amari - L]);
				}
			}
		}
		else {
			deque<int> dq;
			int are = min(K, L);
			rep1(i, L + are - 1) {
				while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
				dq.push_back(i);
				if (i < are) continue;
				while (dq.size() && dq.front() <= i - are) dq.pop_front();
				chmax(kotae, kari[dq.front()] - kari[i - are]);
			}
		}
	}

	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
struct Point{
     int x, y;
     Point(int x = 0, int y = 0) : x(x), y(y) {}
};
typedef Point Vector;
#define INF (int)1e9
#define EPS (1.0e-8)
LL gcd(LL a, LL b) {return !b ? a : gcd(b, a % b);}
LL lcm(LL a, LL b) {return a / gcd(a,b) * b;}
LL qpow(LL a, LL b) {
    LL res = 1;
    while (b > 0) {
        if (b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
LL qpow(LL a, LL b, LL mod) {
    a %= mod;
    LL res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
// ------------------

set<LL> st;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    LL N; cin >> N;
    int res = 0;
    if (N == 2) {
        std::cout << 1 << endl;
        return 0;
    }
    for (LL i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            LL tmp = N;
            while (tmp % i == 0) {
                tmp  /= i;
                if ((tmp - 1) % i == 0)  {
                    st.insert(i);
                    break;
                }
            }
            if (tmp == 1) {
                st.insert(i);
            } 
        }
        if ((N-1) % i == 0) {
            st.insert(i);
            if (i * i != (N-1)) {
                st.insert((N-1)/i);
            }
        }

    }
    st.insert(N-1);
    st.insert(N);
    std::cout << st.size() << endl;
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
array = [input() for i in range(3)]
dic_data = {}
color = array[0].split(" ")
total = array[1].split(" ")
sub   = array[2]

dic_data[color[0]] = int(total[0])
dic_data[color[1]] = int(total[1])

if sub == color[0]:
    dic_data[color[0]] = dic_data[color[0]] - 1
elif sub == color[1]:
    dic_data[color[1]] = dic_data[color[1]] - 1

print(dic_data[color[0]], dic_data[color[1]])


Measured memory_bytes: 3064
def solve():
    R, G, B, N = map(int, input().split())
    ans = 0
    for r in range(N + 1):
        cnt1 = R * r
        if cnt1 > N:
            break
        for g in range(N + 1):
            cnt2 = cnt1 + G * g
            if cnt2 > N:
                break
            if (N - cnt2) % B == 0:
                ans += 1
    print(ans)
solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int m, mn, mx;
	while (cin >> m >> mn >> mx, m)
	{
		vi v(m);
		REP(i, m) cin >> v[i];
		pii ans(-1, -1);
		FOR(i, mn, mx + 1)
		{
			chmax(ans, pii(v[i - 1] - v[i], i));
		}
		cout << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
import java.io.*;
  
class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        StringBuilder sb = new StringBuilder();
          
        int num = 0;
        for(int j=3; j<=n; j++){
            if(j%3==0){
                sb.append(" "+j);
            } else {
                num = j;
                while(num != 0){
                    if(num%10==3){
                        sb.append(" "+j);
                        break;
                    } else{
                        num = num/10;
                    }   
                }
            }           
  
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 26056
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) throws Exception {
	
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b){
			System.out.println("0");
			return;
		}
		System.out.println(a-b);
		
	}
}

Measured memory_bytes: 23124
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      bool gumoji(string s)
      {
        if (s.Length%2!=0)
        {
          return false;
        }
        else
        {
          if (s.Substring(0,s.Length/2)==s.Substring(s.Length/2,s.Length/2))
          {
            return true;
          }
          else
          {
            return false;
          }
        }
      }
      int ans = 0;
      for (int i=1;i<s.Length;i++)
      {
        if (gumoji(s.Substring(0,i)))
        {
          ans=i;
        }
      }
      Console.WriteLine(ans);
    }
}


Measured memory_bytes: 25928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int T = s.nextInt();
        int happinessPoints=(T/500)*1000;
        happinessPoints+=((T%500)/5)*5;
        System.out.println(happinessPoints);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 21332
#include<iostream>
using namespace std;
int main(){
	int E,Y;
	cin >> E >> Y;
	if (E == 0){
		if (1989 <= Y){
			cout << "H" << Y - 1988 << endl;
		}
		if (1926 <= Y && Y < 1989){
			cout << "S" << Y - 1925 << endl;
		}
		if (1912 <= Y && Y < 1926){
			cout << "T" << Y - 1911 << endl;
		}
		if (1868 <= Y && Y < 1912){
			cout << "M" << Y - 1867 << endl;
		}
	}
	if (E == 1){
		cout << Y + 1867 << endl;
	}
	if (E == 2){
		cout << Y + 1911 << endl;
	}
	if (E == 3){
		cout << Y + 1925 << endl;
	}
	if (E == 4){
		cout << Y + 1988 << endl;
	}


	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
 
int main(){
	int N,M,C,A,ans,count;
    cin >> N >> M >> C;
  	ans = 0; 
  	int B[M];
  	
  	for(int i = 0;i < M;i++){
    	cin >> B[i];
        }
  	for(int i = 0;i < N;i++){
      for(int j = 0;j < M;j++){
      	cin >> A;
        ans += A * B[j];
        
        }
         ans = ans + C;
        if (ans >= 1){
        	count++;
      } 
      ans = 0;
    }  
  cout << count;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun k ->
    let l = [ 1,  9; 1,  9;  1,  19;  2,  29;  3,  39;  4,  49;  5, 59;
              6, 69; 7, 79;  8,  89;  9,  99; 10,  99; 10, 109; 11, 99 ]
    in

    let proc ten s t acc =
        let rec loop i acc =
            if i > t then acc else
                loop (i + 1) ((i * ten + ten - 1) :: acc)
        in
        loop s acc
    in

    let rec loop ten acc = function
        | [] -> acc
        | (s, t) :: tl ->
                loop (ten * 10) (proc ten s t acc) tl
    in
    let r = Array.of_list (loop 1 [] l) in
    Array.sort compare r;
    for i = 0 to k - 1 do
        Printf.printf "%d\n" r.(i)
    done
)

Measured memory_bytes: 3936
L, R = map(int, input().split())
if R-L >= 2019:
    print(0)
else:
    saidai = float("inf")
    for i in range(L, R):
        for j in range(L+1, R+1):
            saidai = min(saidai, i*j%2019)
    print(saidai)

Measured memory_bytes: 40684
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int count=0;
		
		for(int a = 0;a<=A;a++) {
			for(int b = 0;b<=B;b++) {
				for(int c = 0;c<=C;c++) {
					int sum =(500 * a)+(100 * b)+ (50 * c);
					if(sum==X) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 21972
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    ans = 0
    
    for i in range(1,max(h)+1):
        t = [1 if h[k] >= i else 0 for k in range(N)]
        # print(t)
        # if(t[0] == 1 and t[1] == 0):
        #     ans += 1
        for j in range(1, len(t)):
            if(t[j-1] == 1 and t[j] == 0):
                ans += 1

        if(t[-1] == 1):
            ans += 1
            
    print(ans)


    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int N, M, Q, sum[510][510] = {{0}};

int main(){
    cin >> N >> M >> Q;
    rep(i, M){
        int L, R;
        cin >> L >> R;
        sum[L][R]++;
    }
    REP(i, 1, N+1){
        REP(j, 1, N+1){
            sum[i][j] += sum[i][j-1];
        }
    }
    REP(i, 1, Q+1){
        int p, q;
        cin >> p >> q;
        int ans = 0;
        REP(j, p, q+1){
            ans += (sum[j][q] - sum[j][p-1]);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int l[N];
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  sort(l, l+N);
  
  int x=0;
  for(int i=0;i<N-1;i++){
    x+=l[i];
  }
  
  if(x>l[N-1]){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
  return 0;
}

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

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

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second;} //End sort (Interval scheduling problem)

string S;
string T;
bool can;
int idx = 0;

void solve() {
	for(int i=S.size() - T.size(); i >= 0;i--) {
		int cnt = 0;
		for(int j=0;j<T.size();j++) {
			if(S[i + j] == T[j] || S[i + j] == '?') cnt++;
		}
		if(cnt == T.size()) {
			can = true;
			idx = i;
			break;
		}
	}

	return ;
}

int main(void){
	cin>>S>>T;

	solve();

	if(can) {
		for(int i=0;i<T.size();i++) S[idx++] = T[i];

		while(S.find("?") != -1) S[S.find("?")] = 'a';
		cout<< S <<endl;
	}
	else cout<< "UNRESTORABLE" <<endl;
		
	return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  if(a == b){
    cout << "EQUAL" << endl;
    return 0;
  }
  if(a.size() < b.size()){
    cout << "LESS" << endl;
    return 0;
  }
   if(a.size() > b.size()){
    cout << "GREATER" << endl;
    return 0;
  }
    for(int i = 0; i < a.size(); i++){
      if(a.at(i) > b.at(i)){
        cout << "GREATER" << endl;
        return 0;
      }
       if(a.at(i) < b.at(i)){
        cout << "LESS" << endl;
        return 0;
      }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, t, a, i, j;
    scanf("%d",&n);
    int h[n];
    double ans[n], min;
    int answer;

    scanf("%d %d",&t,&a);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
        ans[i] = ((a - (t - h[i] * 0.006)) >= 0) ? (a - (t - h[i] * 0.006)) : ((t - h[i] * 0.006) - a);
    }

    min = ans[0];

    for(i=0; i<n; i++){
      if(min > ans[i]){
        min = ans[i];
      }
    }

    for(i=0; i<n; i++){
      if(min == ans[i]){
        answer = i+1;
      }
    }

    printf("%d",answer);
    return 0;
}


Measured memory_bytes: 128
from bisect import bisect
n=int(input())
lst=[0,1]
for i in range(1,8):
    lst.append(6**i)
for i in range(1,7):
    lst.append(9**i)
lst.sort()
inf=float("inf")
dp=[[inf]*(n+1) for i in range(15)]
for i in range(15):
    dp[i][0]=0
for i in range(1,15):
    a=lst[i]
    if a>n:
        print(dp[i-1][n])
        break
    for j in range(1,a):
        dp[i][j]=dp[i-1][j]
    for j in range(a,n+1):
        dp[i][j]=min(dp[i-1][j],dp[i-1][j-a]+1,dp[i][j-a]+1)
else:
    print(dp[14][n])

Measured memory_bytes: 99180
n = int(input())
a = [0]*(n+1)
for i in range(1, 102):
    for j in range(1, 102):
        for k in range(1, 102):
            if (i*i + j*j + k*k + i*j + j*k + i*k) <= n:
                a[i*i + j*j + k*k + i*j + j*k + i*k] +=1
for x in a[1:]:
    print(x)

Measured memory_bytes: 9212