akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <math.h>
#include <map>

using namespace std;

typedef long long LL;
#define INF 0x3f3f3f3f
int n;

int d[3],d1[3];
char str[3][30]={"lunch","dinner","midnight"};


void solve() {
	int a,b,c,t;
	bool vaild = false;
	memset(d,0,sizeof(d));
	memset(d1,0,sizeof(d1));
	for (int i = 0; i < n; i++) {
		scanf("%d:%d %d",&a,&b,&c);
		if (a < 2) {
			a = a + 24;
		}
	//	b += 15;
		vaild = 0;

		if (a >= 11 && a < 15) {
			d1[0]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[0]++;
			//cout<<t<<endl;
		}
		if (a >= 18 && a < 21) {
			d1[1]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[1]++;

		}
		if (a >= 21 && a < 26) {
			d1[2]++;
			if (c > b)
				t = c - b;
			else t = c + 60 - b;
			if (t <= 8)
				d[2]++;
		}


	}
	for (int i = 0; i < 3; i++) {
		if (!d1[i])
		printf("%s no guest\n",str[i]);
		else printf("%s %d\n",str[i],d[i]*100/d1[i]);
	}
}

int main() {
	while (scanf("%d",&n),n) {
		solve();
	}
	return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;

vector <ii> ans;
int n,m;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  if (n % 2 == 0)
    m = n + 1;
  else
    m = n;
  for (int i = 1 ; i <= n ; i++) {
    for (int j = i + 1 ; j <= n ; j++) {
      if (i + j == m)
        continue;
      ans.push_back({i,j});
    }
  }
  cout << ans.size() << "\n";
  for (auto i : ans)
    cout << i.first << " " << i.second << "\n";
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    cin >> t[i];
    t[i]--;
  }
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  int m;
  cin >> m;
  rep(i,m)
  {
    int tod,q;
    cin >> tod >> q;
    tod--;
    q--;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    t[tod] = q;
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    int kans = sums;
    rep(j,26) kans -= rowans[j];
    cout << kans << "\n";
  }
  // kans:ans(-1)
}


Measured memory_bytes: 3676
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(2e5) + 999;
#define int long long int

int ans;
int h,w;
int a[81][81],b[81][81];
bool dp[100][100][15000];

void solve(int x,int y,int sum){

	if(x>h or y>w)
		return;
	if(dp[x][y][sum])
		return;

	solve(x+1,y,abs(sum+a[x][y]-b[x][y]));
	solve(x,y+1,abs(sum+a[x][y]-b[x][y]));
	solve(x+1,y,abs(sum-a[x][y]+b[x][y]));
	solve(x,y+1,abs(sum-a[x][y]+b[x][y]));

	dp[x][y][sum] = true;
	if(x==h and y==w){
		ans = min(ans,abs(sum+a[x][y]-b[x][y]));
		ans = min(ans,abs(sum-a[x][y]+b[x][y]));
	}
}


int32_t main(){
    IOS;
    cin>>h>>w;
    memset(a,0,sizeof a);
    memset(b,0,sizeof b);
    for(int i=1;i<=h;i++)
    	for(int j=1;j<=w;j++)
    		cin>>a[i][j];

    for(int i=1;i<=h;i++)
    	for(int j=1;j<=w;j++)
    		cin>>b[i][j];

    ans = 1e17;
    solve(1,1,0);
    cout<<ans<<endl;
    
   




    return 0;
}

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

const int mod=1e9+7;
int a[30][30];
long dp[30][1<<21];

int main()
{
    int n; cin>>n;
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
            cin>>a[i][j];
    dp[0][0]=1;
    for(int j=0; j<(1<<n); ++j) {
        int i=__builtin_popcount(j);
        for(int k=0; k<n; ++k) if (a[i][k] && !((j>>k)&1))
            (dp[i+1][j|(1<<k)]+=dp[i][j])%=mod;
    }
    cout<<dp[n][(1<<n)-1]<<endl;
}


Measured memory_bytes: 311552
while True:
    list_calc = input().split()
    if "?" in list_calc:
        exit()
    elif "-" in list_calc:
        print(int(list_calc[0]) - int(list_calc[-1]))
    elif "*" in list_calc:
        print(int(list_calc[0]) * int(list_calc[-1]))
    elif "/" in list_calc:
        print(int(int(list_calc[0]) / int(list_calc[-1])))
    elif "+" in list_calc:
        print(int(list_calc[0]) + int(list_calc[-1]))



Measured memory_bytes: 5600
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


ll hoge(int x)
{
	return (ll)x*(x-1)/2;
}

int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n);
		map<int,int> m;

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			m[a[i]]++;
		}

		ll sum=0;
		for(auto mm:m)
		{
			sum+=hoge(mm.second);
//			printf("[%d,%d]\n", mm.first, mm.second);
		}
		for(int i=0;i<n;i++)
		{
			ll ans=sum-hoge(m[a[i]])+hoge(m[a[i]]-1);
			printf("%lld\n", ans);
		}
	}
	return 0;
}


Measured memory_bytes: 8320
#include<iostream>

using namespace std;

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

	int c2=0,c4=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin >> a;
		if(a%2==0)c2++;
		if(a%4==0)c4++;
	}

	cout << ((c4+1==n-c2 && c2==c4)||(c4>=n-c2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100001

int Partition(int*,int,int);

int main(void){
  int i,n,p,q;
  int A[MAX];

  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &A[i]);

  p=Partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i==p) printf("[%d] ", A[i]);
    else if(i==n-1) printf("%d\n", A[i]);
    else printf("%d ", A[i]);
  }

  return 0;
}

int Partition(int *A,int p, int r){
  int i,j,tmp,x;

  x=A[r];

  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }

  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;

  return i+1;

}

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

signed main(void)
{
	set<char> st;
	string s;
	cin >> s;
	st.insert(s[0]);
	st.insert(s[1]);
	st.insert(s[2]);
	if (st.size() == 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int a,b,c,d;
int main(){
a=read();
b=read();
c=read();
d=read();
if(a!=c)puts("1");
else puts("0");
}

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;


int main() {_
	string s;
	cin >> s;

	ll q;
	cin >> q;
	int reverse = 0;
	
	while(q--) {
		ll t,f;
		string c;
		cin >> t;

		if(t==1) {
			reverse = 1 -reverse;
		}
		else {
			cin >> f >> c;
			int len = s.length();
			if(reverse==0) {
				if(f==1) {
					s.insert(0,c);
				}
				if(f==2) {
					s.insert(len,c);
				}
			}
			else if(reverse) {
				if(f==1) 	s.insert(len,c);
				if(f==2)  	s.insert(0,c);
			}
		}
	}
	//cout << reverse << "\n";
	if(reverse==0)
		cout << s << "\n";
	else {
		for(ll i = s.length() -1; i >= 0; --i)
			cout << s[i];
		cout << "\n";
	}
	
	
}


Measured memory_bytes: 1040
n,m,R = map(int,input().split())
r = list(map(int,input().split()))

from itertools import permutations
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
cost = np.ones((n,n))*float('inf')
for i in range(m):
    a,b,c = map(int,input().split())
    cost[a-1][b-1]=cost[b-1][a-1]=c
d = floyd_warshall(cost)
def main():
    m = float('inf')

    for j in permutations(r):
        l = 0
        for i in range(len(j)-1):
            s,t = j[i],j[i+1]
            l += d[s-1][t-1]
        if l<m:
            m = l
    print(int(m))


if __name__ == "__main__":
    main()

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

const ll mod = 1e9 + 7;

map<pair<ll,ll>,ll> dp;

ll f(ll x, ll y) {
  if (x<0 || y<0) return 0;
  if (dp.count({x,y})) return dp[{x,y}];
  if (x==0 && y==0) return 1;

  ll res = 0;
  if (x>=2 && y>=2) res += f((x-2)/2, (y-2)/2);
  if (x>=1 && y>=1) res += f((x-1)/2, (y-1)/2);
  res += f(x/2, y/2);
  res %= mod;
  res += mod;
  res %= mod;

  return dp[{x,y}] = res;
}

ll n;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n;
  ll res = f(n,n);
  res %= mod;
  res += mod;
  res %= mod;
  cout<<res<<endl;
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
# print('input >>')
N = input()
last = int(N[-1])

# print('-----output-----')
if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
    print('hon')
elif last == 0 or last == 1 or last == 6 or last == 8:
    print('pon')
elif last == 3:
    print('bon')

Measured memory_bytes: 9176
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    ll e = 0, o = 0;
    ll ans = 1;
    for(auto &x : a){
        cin >> x;
        ans *= 3LL;
        if(x & 1) o++;
        else e++;
    }
    if(e > 0){
        ans -= powl(2LL, e);
    }else{
        ans -= 1;
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
  string x;cin >>x;
  ll ans=0;
  char key='S';
  vector<ll>cnt;
  ll now=0;
    for (int i = 0; i < x.size(); ++i) {
        if(key==x[i]){
            now++;
        }
        else {
            cnt.push_back(now);
            if(key=='S')key='T';
            else key='S';
            now=1;
        }
    }
    cnt.push_back(now);
    if(cnt.size()%2==1)cnt.push_back(0);
    ll s=0,t=0;
//    for (int i = 0; i < cnt.size(); ++i) {
//        cout <<cnt[i]<<" ";
//    }
//    cout <<endl;
    for (int i = 0; i < cnt.size(); i+=2){
        s+=cnt[i];
        t=cnt[i+1];
        ll mint=min(s,t);
        s-=mint;
        t-=mint;
//        cout <<s <<" "<<t<<endl;
        ans+=t;
//        cout <<ans <<endl;
        t=0;
    }
    ans+=s;
    cout <<ans <<endl;
   return 0;
}



Measured memory_bytes: 1532
import java.util.Scanner;

/**
 * @author : gaurav.ss
 * @since : 16/02/20
 **/
 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int[] a=new int[n];
        boolean flag=true;
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            if(x%2==0){
                if(x%3!=0 && x%5!=0){
                    flag=false;

                }
            }
        }
        if(flag)
            System.out.println("APPROVED");
        else
            System.out.println("DENIED");
    }
}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		int max = 0;
		for (int i = 0; i <= s.length - t.length; i++) {
			int cnt = 0;
			for (int j = 0; j < t.length; j++) {
				if (s[i + j] == t[j]) {
					cnt++;
				}
			}
			max = Math.max(max, cnt);
		}
		System.out.println(t.length - max);
	}
}


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

long long N, K;
const long long mod = 1000000007;
struct Matrix{
  vector<vector <long long> > M;
  int x, y;
  Matrix(long long n, long long m){
    x = n;
    y = m;
    M.resize(x, vector<long long>(y)); 
  }
  void Wypisz(){
    for (int i = 0; i<y; i++){
      for (int j = 0; j<x; j++){
        cout << M[j][i] << " ";
      }
      cout << "\n";
    }
  }

  void Wczytaj(){
    for (int i = 0; i<y; i++){
      for (int j = 0; j<x; j++){
        cin >> M[j][i];
      }
    }
  }

};

Matrix Mnozenie( Matrix a, Matrix b){
    Matrix wynik(b.x, a.y);
    for (int i = 0; i<b.x; i++){
      for (int j = 0; j<a.y; j++){
        for (int k = 0; k<a.x; k++){
            wynik.M[i][j]+=a.M[k][j]*b.M[i][k]; // a.x = b.y
            wynik.M[i][j]%=mod;
        }
      }
    }
    return wynik;
}

Matrix Szypkie(Matrix macierz, long long potega){
        if (potega == 1){
            return macierz;
        }
        if (potega%2 == 0){
          return Szypkie(Mnozenie(macierz, macierz), potega/2);
        }
        else{
          return Mnozenie(macierz, Szypkie(macierz, potega-1));
        }
}

long long funkcja(Matrix A){
    A = Szypkie(A, K);
    long long wynik = 0;
    for (int i = 0; i<A.x; i++){
      for (int j = 0; j<A.y; j++){
          wynik+=A.M[i][j];
          wynik%=mod;
      }
    }
    return (wynik+mod)%mod;
}



int main(){
    ios_base::sync_with_stdio(0);
    cin >> N >> K;
    Matrix graf(N, N);
    graf.Wczytaj();
    cout << funkcja(graf);





}


Measured memory_bytes: 5376
# include <iostream>
# include <algorithm>
# include <cmath>
# include <tuple>
# include <vector>
# include <queue>
# include <string>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool flag = true;
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (i%2==0) {
            if (c!='R' && c!='U' && c!='D') {
                flag = false;
            }
        } else {
            if (c!='L' && c!='U' && c!='D') {
                flag = false;
            }
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int, input().split()))
if sum(l)%n==0:
  ct=0
  a=sum(l)//n
  for i in l:
      ct+=(i-a)**2
  print(ct)
else:
  ct1,ct2=0,0
  a=sum(l)//n
  b=sum(l)//n +1
  for i in l:
      ct1+=(i-a)**2
      ct2+=(i-b)**2
  print(min(ct1,ct2))

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

int main() {
  int n;
  int k;
  int q;

  cin >> n >> k >> q;

  std::vector<int> data(n, k-q);

  int ans[q];

  for(int i=0;i<q;i++){
    cin >> ans[i];
  }

  for(int i=0;i<q;i++){
    data[ans[i]-1]++;
  }
  
  for(int i=0;i<n;i++){
    if(data[i]>0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1536
from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit as setreclim
from sys import maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits

prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x,y)%mod, l)

class Dijkstra:
    """Dijkstra's algorithm : find the shortest path from a vertex
       used in GRL1A(AOJ)
    """

    def __init__(self, V, E, start, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list
            start: start vertex
            INF: Infinity distance
        """
        self.V = V
        self.E = E
        self.dijkstra(start, INF)

    def dijkstra(self, start, INF):
        que = list()
        self.distance = [INF] * self.V # distance from start
        self.prev = [-1] * self.V # prev vertex of shortest path
        self.distance[start] = 0
        heappush(que, (0, start))

        while len(que) > 0:
            dist, v = heappop(que)
            if self.distance[v] < dist: continue
            for to, cost in self.E[v]:
                if self.distance[v] + cost < self.distance[to]:
                    self.distance[to] = self.distance[v] + cost
                    heappush(que, (self.distance[to], to))
                    self.prev[to] = v

    def getPath(self, end):
        path = [end]
        while self.prev[end] != -1:
            end = self.prev[end]
        return path[::-1]

V, E, r = map(int, input().split())
INF = 10**10
edge = [[] for _ in range(V)]
for i in range(E):
    s, t, cost = map(int, input().split())
    edge[s].append((t, cost))
sp = Dijkstra(V, edge, r, INF)
for d in sp.distance:
    print(d if d != INF else 'INF')

Measured memory_bytes: 101628
#include <stdio.h>

int toPosition(char, int);
void printCard(int);

int main(void) {
  int numberOfCards, i;
  int cards[52] = {};
  scanf(" %d", &numberOfCards);
  for (i = 0; i < numberOfCards; i++) {
    char suit;
    int number;
    scanf(" %c %d", &suit, &number);
    cards[toPosition(suit, number)] = 1;
  }
  for (i = 0; i < 52; i++) {
    if (!cards[i])
      printCard(i);
  }
  return 0;
}

int toPosition(char suit, int number) {
  switch (suit) {
  case 'S':
    return number - 1;
  case 'H':
    return 13 + number - 1;
  case 'C':
    return 26 + number - 1;
  case 'D':
    return 39 + number - 1;
  }
  return -1;
}

void printCard(int position) {
  int suitNum = position / 13;
  switch (suitNum) {
  case 0:
    printf("S %d\n", position % 13 + 1);
    break;
  case 1:
    printf("H %d\n", position % 13 + 1);
    break;
  case 2:
    printf("C %d\n", position % 13 + 1);
    break;
  case 3:
    printf("D %d\n", position % 13 + 1);
    break;
  }
}



Measured memory_bytes: 2036
object Main extends App {
  val sc = new java.util.Scanner(System.in)

  @scala.annotation.tailrec
  def loop(chars: Seq[Char], acc: List[(Int, Int)]): Seq[(Int, Int)] = {
    if (chars.isEmpty) {
      acc.reverse
    } else {
      val (l, xs) = chars.span(_ == '<')
      val (r, xs2) = xs.span(_ == '>')
      loop(xs2, (l.length, r.length) :: acc)
    }
  }

  val steps = (1 to 500000).scanLeft(0L)(_ + _).toArray
  val chars@x :: _ = sc.next().toCharArray.toList
  println {
    loop(if (x == '>') '>' :: chars else chars, List.empty).map {
      case (l, r) if 0 < l && l < r => steps(l - 1) + steps(r)
      case (l, r) => steps(l) + steps(0.max(r - 1))
    }.sum
  }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  bool flag = true;
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }
  vector<int> dis(N,0);
  if(D[0] != 0) flag = false;
  for(int i = 0; i < N; i++){
    dis[D[i]]++;
  }
  if(dis[0] != 1) flag = false;
  bool con = true;
  for(int i = 0; i < N; i++){
    if(con == false && dis[i] != 0) flag = false;
    if(dis[i] == 0) con = false;
  }
  ll res = 1;
  for(int i = 1; i < N; i++){
    for(int j = 0; j < dis[i]; j++){
      res *= dis[i-1];
      res = res % MAX;
    }
  }
  if(flag)  cout << res << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */

int main(){
  int n,k; cin >> n >> k;
  int ans = INF;
  vi in (n);
  rep(i,n)  cin >> in[i];
  sort(ALL(in));
  rep(i,n-k+1){
    ans = min(ans, in[i+k-1] - in[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {

	int count[26], h;
	char str;

	for (int h = 0; h < 26; h++) {
		count[h] = 0;
	}

	while (cin >> str) {
			for (char c = 'a'; c <= 'z'; c++) {
				if (str == c || str == c + 'A' - 'a')count[c-'a']++;
				
			}
	}


	for (int h = 0; h < 26; h++) {
		cout << (char)('a' + h) << " : " << count[h] << "\n";
	}
	

	return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;

int main(){
	 string s; cin >>s;
	 if(s.size()<4){
	 	cout << "No" << endl;
	 	return 0;
	 }
	 if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
	 	cout << "Yes" << endl;
	 }
	 else{
	 	cout << "No" << endl;
	 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n; 
	cin>>n;
	vector<int> arr(n), dp(n);
	for(int i=0; i<n; ++i) cin>>arr[i];
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]); 
	for(int i=2; i<n; ++i){
		dp[i] = min( dp[i-2] + abs(arr[i]- arr[i-2])   , dp[i-1] + abs(arr[i]- arr[i-1]) ); 
	}
	cout<<dp[n-1]<<'\n';
	
	return 0;
}


Measured memory_bytes: 4000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

ll a[200009];
ll ab[200009];
ll af[200009];
signed main(){
    ll n,k;
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        af[i] = -1;
    }
    ll tp = 0;
    ll cir = 0;
    ll cir_bs = 0;
    ll cir_tw =0;
    af[0] = 0;
    rep(i,n){
        tp = a[tp] -1;
        ab[i] = tp;
        if(af[tp] >= 0){
            cir_bs = af[tp];
            cir = (i+1)-af[tp];
            cir_tw = tp;
            break;
        }
        af[tp] = i+1;
        // cout<<ab[i]<<" "<<af[i]<<endl;
    }
    ll ans;
    if(k <= cir_bs) ans = ab[k-1];
    else{
        k -= cir_bs;
        ans = ab[cir_bs -1 + k%cir];
    }
    cout<<ans+1 <<endl;
}


Measured memory_bytes: 8260
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[100];
    rep(i, H) cin >>S[i];
    rep(x, H) {
        rep(y, W) {
            bool ok = false;
            if (S[x][y] == '.') continue;
            rep(i, 4) {
                int xx = x + dx[i];
                int yy = y + dy[i];
                if (xx < 0 || xx >= H) continue;
                if (yy < 0 || yy >= W) continue;
                if (S[xx][yy] == '#') ok = true;
            }
            if (!ok) {
                cout << "No" << endl;
                return 0;
            } 
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int d;
  cin >> d;
  if (d == 25){
    cout << "Christmas" << endl;
  }
  else if (d == 24){
    cout << "Christmas Eve" << endl;
  }
  else if (d == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  else{
    cout << "Christmas Eve Eve Eve" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
# print(ks)
for i in range(2**n):
    bulb = [0]*m
    bin_str = format(i, '010b')
    for j in range(m):
        cnt = 0
        for k in ks[j][1:]:
            # print(k)
            if bin_str[-k] == "1":
               cnt += 1 
        if cnt % 2 == p[j]:
            # print(cnt)
            bulb[j] = 1
    # print(bin_str)
    # print(bulb)
    if bulb == [1]*m:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<string> s;
  string str;
  for(int i = 0; i < n; i++){
    cin >> str;
    s.push_back(str);
  }

  sort(s.begin(), s.end()); // sort

  s.erase(unique(s.begin(), s.end()), s.end());  // uniq
  
  //for(auto i:s) cout << i <<endl;   // 表示
  cout << s.size();
}

Measured memory_bytes: 11668
// https://atcoder.jp/contests/abc133/tasks/abc133_c
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <vector>
#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define MOD 1000000007
using namespace std;

int solve(int l, int r) {
    int ans = INF;
    if (r - l > 2018) {
        r = l + 2018;
    }

    rep(i, l, r) {
        rep(j, l + 1, r + 1) {
            int rem = (i * j) % 2019;
            if (rem == 0) {
                return 0;
            }
            if (rem < ans) {
                ans = rem;
            }
        }
    }

    return ans;
}

int main() {
    int l, r;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> l >> r;

    int ans = solve(l, r);
    cout << ans << endl;
}


Measured memory_bytes: 3596
N = gets.to_i
plus = Hash.new(0)

N.times do 
  plus[gets.chomp] += 1
end

M = gets.to_i
minus = Hash.new(0)

M.times do
  minus[gets.chomp] += 1
end

puts [0, plus.keys.map { |word| plus[word] - minus[word] }.max].max


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

namespace Task {

#define long long long

std::map<int, int> map;

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n, cnt = 2;
    register long ans = 1;
    std::cin >> n;
    for (register int i = 0, t; i < n; i++) std::cin >> t, map[t]++;
    for (auto it = map.rbegin(); it != map.rend(); it++) {
        if (it->second > 1) {
            ans *= it->first, cnt--;
            if (it->second > 3 && cnt == 1) ans *= it->first, cnt--;
        }
        if (cnt == 0) break;
    }
    if (cnt == 0)
        std::cout << ans;
    else
        std::cout << '0';
}

#undef long
}

int main() {
    Task::solve();
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

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

   ll ans = 1;
   bool zero = false, minus = false;

   rep(i, 0, N) {
     ll A; cin >> A;
     if (A == 0) {
       ans = 0;
       zero = true;
     }
     else if (ans != 0 && A > 1000000000000000000 / ans) {
       ans = -1;
       minus = true;
     }
     else ans *= A;
   }

   if (zero) cout << 0 << endl;
   else if (minus) cout << -1 << endl;
   else cout << ans << endl;
 }


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin >> n;
    ll ans =1;
    f(1, n){ans = (ans * 10) %MOD;}
    ll nin = 1;
    f(1, n){nin = (nin*9) % MOD; }
    nin = (2*nin)%MOD;
    ans -= nin;
    if(ans <0) ans += MOD;
    ll eig = 1;
    f(1, n) { eig = (eig*8)%MOD;}
    ans = (ans + eig) % MOD;
    cout << ans << "\n";
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstdlib>
#include<stdexcept>
#include<numeric>
#include<cmath>
#include<fstream>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define S second
#define ppins(a,b,c,d) PP(P(a,b),P(c,d))
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<bool,bool> BI;


bool judge(string s1,string s2)
{
 
  rep(i,8)
    {
      if(s1[i] == '?')continue;
      if(s1[i] != s2[i])
	return false;
    }
 
  for(int i=8;i<16;i++)  
    {
      if(s1[i] == '?')continue;
      if(s1[i] != s2[i])
	return false;
    }
 
  return true;
}

vector<char> rules;
vector<string> sourceAnDdestination;
int main()
{
  while(true)
    {
      int n,m;
      cin >> n >> m;
      if(n+m == 0)
	break;
      char Message[1024][52];
      rules.clear(),sourceAnDdestination.clear();
      cin.ignore();
     
      
      rep(i,n)
	{
	  string line;
	  string so,de,soandde;
	  cin >> line >> so >> de;
	  soandde = so+de;
	  rules.pb(line[0]),sourceAnDdestination.pb(soandde);
	}

      BI legal[m];
      rep(i,m)
	legal[i] = BI(false,false);
  
     
      rep(i,m)
	{
	  string a,b,c;
	  cin >> a >> b >> c;
	  string aandb = a+b;
	  sourceAnDdestination.pb(aandb);
	  strcpy(Message[i],c.c_str());
	 
	}
    

      int cnt = 0;
   
      for(int i=n-1;i>=0;i--)
	{
	 
	  if(rules[i] == 'p')
	    {
	      
	      rep(j,m)
		{
	
		  if(legal[j].S)
		    continue;
		  if(judge(sourceAnDdestination[i],sourceAnDdestination[n+j]))
		    {		      
		      legal[j] = BI(true,true);
		      cnt++;
		    }
	
		 
		}
	     
	    }
	  else 
	    {
	      rep(j,m)
		{
		  if(legal[j].S)
		    continue;
		  if(judge(sourceAnDdestination[i],sourceAnDdestination[n+j]))
		    {
		      legal[j] = BI(false,true);
		    }
		}
	    }
	}

      cout << cnt << endl;
      rep(i,m)
	{
	  if(legal[i].F)
	    {
	      cout << sourceAnDdestination[i+n].substr(0,8) << " " << sourceAnDdestination[i+n].substr(8,8) << " " << Message[i] << endl; 
	    }
	}

    }
  return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        long x = in.nl();
        long a = 0, b = 0;
        OUT:for (long i = -200; i < 200; i++) {
            a = i*i*i*i*i;
            for (long j = -200; j < 200; j++) {
                b = j*j*j*j*j;
                if(a-b==x){
                    out.printf("%d %d\n",i,j);
                    break OUT;
                }
            }
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 34296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int X = sc.nextInt();
    	int Y = sc.nextInt();
    	int Z = sc.nextInt();
    	sc.close();
    	int[] ary = new int[Z];
    	int min = X <= Y ? X : Y;
    	for(int i = min; i > 0; i--){
    		if(X % i == 0 && Y % i == 0){
    			ary[Z-1] = i;
    			Z--;
    		}
    		if(Z <= 0) break;
    	}
    	System.out.println(ary[0]);
    }
}

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

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];

    int ans = 0;
    while (!(a[0] == a[1] && a[0] == a[2] && a[1] == a[2])) {
        int maxv = *max_element(a, a + 3);
        int maxCount = count(a, a + 3, maxv);
        if (maxCount == 1) {
            rep(i, 3) if (a[i] != maxv) a[i]++;
        } else if (maxCount == 2) {
            rep(i, 3) if (a[i] != maxv) a[i] += 2;
        }
        ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,count=0;
double sum = 0;
cin>>n>>m;
vector<int> v;
for(int i=0;i<n;i++)
{
	int a; cin>>a;
	v.push_back(a);

}
for(int j=0;j<n;j++)
{
	sum=sum+(double)v[j];
}
double check = ((double)sum/(double)(4*m));
for(int z=0;z<n;z++)
{
	if(check<=v[z])
	{
		count++;}
}
if(count>=m)
{
	cout<<"Yes";

}
else
{
	cout<<"No";
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1 ; i <= n ; i++)
	{
		if (__gcd(i,15) == 1)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

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

lst = [list(map(int,input().split())) for i in range(n)]
p = [0 for i in range(n)]
for i in range(3):
  dic = [[] for _ in range(101)]
  for j in range(n):
    dic[lst[j][i]].append(j)
  for x in range(101):
    l = dic[x]
    if lst:
      if len(l) == 1:
        p[l[0]] += x
for i in p:
  print(i)


Measured memory_bytes: 5624
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 305;
int dp[N][N][N] = {}, k;
char s[N];

int main()
{
    scanf("%s%d", s+1, &k);
    int n = strlen(s+1);
    for(int i = 1;i<=n;i++) for(int j = 0;j<=k;j++) dp[i][i][j] = 1, dp[i][i-1][j] = 0;
    for(int j = 1;j<n;j++){
        for(int i = 1;i+j<=n;i++){
            for(int r = 0;r<=k;r++){
                dp[i][i+j][r] = max(dp[i+1][i+j][r], dp[i][i+j-1][r]);
                if(s[i] == s[i+j]) dp[i][i+j][r] = max(dp[i][i+j][r], dp[i+1][i+j-1][r]+2);
                if(r) dp[i][i+j][r] = max(dp[i][i+j][r], dp[i+1][i+j-1][r-1]+2);
            }
        }
    }
    int ans = dp[1][n][k];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 110464
#[allow(unused)]
use std::io::*;
#[allow(unused)]
use std::str::*;
#[allow(unused)]
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if s.is_empty() {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
    s.parse::<T>().unwrap_or_else(|_| panic!("faild to parse {}", s))
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub const MOD: u64 = 1000000007;

fn main() {
    loop {
        let n: u64 = read();
        let m: u64 = read();

        let check = |d: u64| m / d >= n;

        let mut ans = 1;
        for i in 1..m + 1 {
            if i * i > m {
                break;
            }
            if m % i == 0 {
                let j = m / i;
                if check(i) && ans < i {
                    ans = i;
                }
                if check(j) && ans < j {
                    ans = j;
                }
            }
        }

        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
    int a, b;
    int n = 0;
    char str[3][5] = {" == ", " < ", " > "};
    scanf("%d %d", &a, &b);
    if(a < b){
        n = 1;
    }else if(a > b){
        n = 2;
    }
    printf("a%sb\n", str[n]);
    return 0;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
class Queue{
private:
pair<string,int> m[60000];
int head,tail;
public:
    Queue(){
        head=0;
        tail=0;
    }
    bool isEmpty(){
        return head==tail;
    }
    void enqueue(pair<string,int> x){
        m[tail]=x;
        if(tail +1 ==60000)tail=0;
        else tail++;
    }
    pair<string,int> deque(){
        pair<string,int> x=m[head];
        if(head+1==60000)head=0;
        else head++;
        return x;
    } 
};

int main(){
ll n;
while(1){
ll min=0;
cin>>n;
if(n==0)break;
ll A[n];
REP(i,n)cin>>A[i];
min=abs(A[1]-A[0]);
REP(i,n-1)FOR(j,i+1,n)min= min<abs(A[j]-A[i])? min:abs(A[j]-A[i]);
cout<<min<<endl;
}
}


Measured memory_bytes: 3096
import java.util.Arrays;
import java.util.Scanner;

//Bara-Bara Manju
public class Main{
	
	int res, num, ID;
	int[][] div;
	int[] c, u;
//	long S;
	
	void f(int k, int rest){
		if(rest==0){
			for(int i=1;i<10;i++)div[ID][i] = u[i];
			ID++;
			return;
		}
		if(k<=0)return;
		for(int use=0;use*k<=rest;use++){
			u[k] = use;
			f(k-1, rest-use*k);
			u[k] = 0;
		}
	}
	
	void dfs(int k, int num, int sum){
//		if(res<num)System.out.println(num+" Time:"+(System.currentTimeMillis()-S));
		res = Math.max(res, num);
		if(k==ID || num+sum/10 <= res)return;
		int t = 1000;
		for(int i=1;i<10;i++)if(div[k][i]>0)t = Math.min(t, c[i]/div[k][i]);
		for(int use=0;use<=t;use++){
			for(int i=1;i<10;i++)c[i]-=use*div[k][i];
//			System.out.println("K:"+k+" Use:"+use);
			dfs(k+1, num+use, sum-use*10);
			for(int i=1;i<10;i++)c[i]+=use*div[k][i];
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		div = new int[50][11];
		u = new int[11];
		f(9, 10);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
//			S = System.currentTimeMillis();
			c = new int[11];
			int sum = 0;
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				c[x]++;
				sum+=x;
			}
			int g = c[5]/2;
			sum-=g*10;
			c[5]%=2;
			for(int i=6;i<10;i++){
				int t = Math.min(c[i], c[10-i]);
				sum-=10*t;
				g+=t;
				c[i]-=t;
				c[10-i]-=t;
			}
			res = 0;
			dfs(0, g, sum);
			System.out.println(res);
//			System.out.println(System.currentTimeMillis()-S);
		}
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;	//(b, a)
int n;
P pa[200000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) {
		cin >> pa[i].second >> pa[i].first;
	}
	sort(pa, pa + n);
	
	int asum = 0;
	rep(i, n) {
		asum += pa[i].second;
		if (asum > pa[i].first) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	cin>>a>>b>>c>>d>>e;
	if(!a)printf("1\n");
	else if(!b)printf("2\n");
	else if(!c)printf("3\n");
	else if(!d)printf("4\n");
	else if(!e)printf("5\n");
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    ll f[N+1];
    for(int i = 0; i <= N; i++) f[i] = 1;
    for(int i = 2; i <= N; i++){
        for(int j = i; j <= N; j+=i){
            f[j]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= N; i++) ans += i * f[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81684
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
          String str = scan.next();
          
          Map<String, String> map = new HashMap<>();
          map.put("Sunny","Cloudy");
          map.put("Cloudy","Rainy");
          map.put("Rainy","Sunny");
          
          System.out.println(map.get(str));
        }
    }
}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int weight = sc.nextInt();
		int[] w = new int[n];
		int[] v = new int[n];
		
		for(int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		
		long[][] dp = new long[n+1][weight+1];
		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < weight + 1; j++) {
				dp[i][j] = 0;
			}
		}
		//ーーーーーここまでで入力と初期化完了ーーーーーーーーーー
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < weight; j++) {
				dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j]);
				if(j+w[i] <= weight)dp[i+1][j+w[i]] = Math.max(dp[i+1][j+w[i]], dp[i][j] + v[i]); 
			}
		}
		long ans = 0;
		for(int i = 1; i < weight + 1; i++) {
			ans = Math.max(ans, dp[n][i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 131464