akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
int solve() {
 
	int n=Int;
	cout<<arr[n-1]<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
import sys; readline = sys.stdin.readline


N = int(readline())
sN = str(N)

a = {}

for i in range(1, N + 1):
    si = str(i)
    f = int(si[0])
    l = int(si[-1])

    t = (f, l)
    if not t in a:
        a[t] = 0
    
    a[t] += 1

count = 0


for k, v in a.items():
    f, l = k
    if f == l:
        count += v * v
    else:
        counter = a.get((l, f), 0)
        count += counter * v


print(count)




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

typedef long long ll;
typedef pair<int, int> pii;
#define f(i , n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, x, n) for (int i = x; i < (int)(n); ++i)
const int mod = 1000000007;
const int inf = 2012345678;
const double PI = acos(-1);
const ll infl = 9012345678901234567;
const double eps = 1e-8;
const int N = 1e5;
set<string> se;
int main(){
	string s;
	int k;
	cin>>s>>k;
	f(i,s.length()){
		string w = "";
		f1(j,i,i+5){
			if(j==s.length())break;
			w+=s[j];
			se.insert(w);
		}
	}
	set<string>::iterator it = se.begin();
	--k;
	while(k--)++it;
	cout<<(*it)<<endl;

}

Measured memory_bytes: 1664
#include <stdio.h>

int main() {
  int number_n, i, j, answer = 0, flag, count;
  char ch;
  scanf("%d", &number_n);
  char str[number_n+1];
  scanf("%s", str);
  for(i = 0; i < number_n-1; i++) {
    count = 0;
    for(ch = 'a'; ch <= 'z'; ch++) {
      flag = 0;
      for(j = 0; j <= i; j++) {
        if(str[j] == ch) flag = 1;
      }
      if(flag == 0) continue;
      for(j = i + 1; j < number_n; j++) {
        if(str[j] == ch) flag = 2;
      }
      if(flag == 2) count++;
    }
    answer = (count > answer)? count : answer;
  }
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 128
import io.StdIn._
object Main extends App {
  val Array(a, b, k) = readLine.split(" ").map(_.toLong)
  if ((a + b) < k) println("0 0 ")
  else if (a < k) println(s"0 ${b - (k - a)}")
  else println(s"${a - k} $b")
}


Measured memory_bytes: 27332
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;
#define Mid ((l+r)>>1)
#define lson rt<<1,l,Mid
#define rson rt<<1|1,Mid+1,r
const int maxn = 100000 + 5;
int arr[maxn << 2];

void build(int rt, int l, int r) {
    if (l == r)arr[rt] = 2147483647;
    else {
        build(lson);
        build(rson);
        arr[rt] = min(arr[rt << 1], arr[rt << 1 | 1]);
    }
}

void update(int rt, int l, int r, int pos, int num) {
    if (l == r && r == pos)
        arr[rt] = num;
    else {
        if (pos <= Mid)
            update(lson, pos, num);
        else
            update(rson, pos, num);
        arr[rt] = min(arr[rt << 1], arr[rt << 1 | 1]);
    }
}

int query(int rt, int l, int r, int L, int R) {
    if (L <= l && r <= R)
        return arr[rt];
    else {
        int tmp = 2147483647;
        if (L <= Mid)
            tmp = min(query(lson, L, R), tmp);
        if (R > Mid)
            tmp = min(query(rson, L, R), tmp);
        return tmp;
    }
}

int main() {
    int n, q, ch, x, y;
    queue<int> res;
    cin >> n >> q;
    build(1, 1, n);
    while (q--) {
        cin >> ch >> x >> y;
        if (ch)
            res.push(query(1, 1, n, x + 1, y + 1));
        else 
            update(1, 1, n, x + 1, y);
    }
    while (!res.empty())
    {
        cout << res.front() << endl;
        res.pop();
    }
    return 0;
}




Measured memory_bytes: 4296
#include<iostream>
#include<algorithm>
using namespace std;
long long n,i,l,m,poz1,poz2,j;
char A[100005],B[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    cin>>A;
    cin>>B;
    l=(1LL*n*m)/__gcd(n,m);
    poz1=0;
    poz2=0;
    i=0;
    j=0;
    while(poz1<=l && poz2<=l)
    {
        if(poz1==poz2)
        {
            if(A[i]!=B[j])
            {
                cout<<"-1\n";
                return 0;
            }
            i++;
            j++;
            poz1+=(l/n);
            poz2+=(l/m);
            continue;
        }
        if(poz1<poz2)
        {
            poz1+=(l/n);
            i++;
        }
        else
        {
            poz2+=(l/m);
            j++;
        }
    }
    cout<<l<<"\n";
    return 0;
}


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

namespace Algo
{
    class Program
    {
        static void Main()
        {
            var x = long.Parse(Console.ReadLine()!);
            var ans = 0L;
            ans += x / 11 * 2;
            if (x % 11 == 0) ans += 0;
            else if (x % 11 <= 6) ans += 1;
            else ans += 2;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27484
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	int t = T.size();
	vector<int> indexV;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '?' || S[i] == T[0])
		{
			string sub = S.substr(i, T.size());
			bool same = true;
			for (int j = 0; j < T.size(); j++)
			{
				if (sub[j] != '?' && sub[j] != T[j])
				{
					same = false;
					break;
				}
			}

			if (same) {
				indexV.push_back(i);
			}
		}
	}

	string A = S;
	int i = 0;
	if (indexV.size() == 0)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else {
		sort(indexV.begin(), indexV.end());
		int lastIndex = indexV.back();
		while (true)
		{
			if (i != lastIndex)
			{
				if (S[i] == '?')
				{
					A[i] = 'a';
				}
				else {
					A[i] = S[i];
				}

				i++;
			}
			else {
				A.replace(i, T.size(), T);
				i += T.size();
			}
			if (i >= S.size()) {
				break;
			}
		}
		cout << A << endl;
	}
}

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

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m;
    cin >> n >> m;
    int wa = 0, ac = 0;
    map<int, int> mp;
    while (m--)
    {
        int p;
        seika s;
        cin >> p >> s;
        if (mp[p] == -1)
        {
            continue;
        }
        if (s == "WA")
        {
            mp[p]++;
        }
        else
        {
            wa += mp[p];
            ac++;
            mp[p] = -1;
        }
    }
    cout << ac << ' ' << wa << endl;
}

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


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, a, x[50] = {}, dp[51][51][2501] = {};

int main() {
  cin >> n >> a;
  rep(i, 0, n) cin >> x[i];
  dp[0][0][0] = 1;

  rep(i, 0, n) rep(j, 0, i + 1) rep(k, 0, 2501){
    dp[i + 1][j][k] += dp[i][j][k];
    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
  }

  ll ans = 0;

  rep(i, 1, n + 1) {
    ans += dp[n][i][i * a];
  }

  cout << ans << endl;
}


Measured memory_bytes: 49152
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main()
{
    struct process
    {
        string name;
        int time;
    };
    int time, length, quantum;
    string name;
    cin >> length >> quantum;
    queue<process> processes;
    for (int i = 0; i < length; i++)
    {
        process tmp;
        cin >> tmp.name >> tmp.time;
        processes.push(tmp);
    }
    time = 0;
    while (!processes.empty())
    {
        if (quantum >= processes.front().time)
        {
            time += processes.front().time;
            cout << processes.front().name<< ' ' <<time<<endl;
            processes.pop();
        }
        else
        {
            time += quantum;
            processes.front().time -= quantum;
            processes.push(processes.front());
            processes.pop();
        }
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}

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

    int N; cin >> N;
    vector<int> a(N);
    int sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    int d_min = INT_MAX, i_min;
    rep(i, N) {
        if (chmin(d_min, abs(a[i]*N-sum))) {
            i_min = i;
        }
    }
    cout << i_min << endl;
}


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

public class Main extends Template{
	public void solve() throws IOException{
		int n = nextInt();
		int m = nextInt();
		int[][] power = new int[m][2];
		for(int i = 0; i < m; i++){
			power[i][0] = nextInt();
			power[i][1] = nextInt();
		}
		boolean[] guard = new boolean[n+1];
		int count = 0;
		for(int i = 1; i <= n; i++){
			if( !guard[i] ){
				count++;
				int max = 0;
				int index = -1;
				for(int j = 0; j < power.length; j++){
					if( power[j][0] <= i && power[j][1] >= i ){
						if( power[j][1] - i + 1 > max ){
							max = power[j][1] - i + 1;
							index = j;
						}
					}
				}
				if( index == -1 ){
					System.out.println("Impossible");
					return;
				} else {
					for(int j = power[index][0]; j <= power[index][1]; j++){
						guard[j] = true;
					}
				}
			}
		}
		System.out.println(count);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
}

abstract class Template implements Runnable{
	public abstract void solve() throws IOException;
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
		

Measured memory_bytes: 9444
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));

 		
int main() {

int N,M;
vec(X)
cin>>N>>M;
pb(X,0)
  map<ll,ll> S;
fx(N){
	int a;
	cin>>a;
	pb(X,(X.at(x)+a%M)%M)
	S[X.at(x+1)]++;
}

ll ans=S[0];
fyg(N+1,1){

  /*    if((M-X.at(y))%M==X.at(y)){
        ans+=S[X.at(y)]*(S[X.at(y)]-1)/2;
      }else{
        ans+=S[(M-X.at(y))%M]*S[X.at(y)];
      }
      S[X.at(y)]=0;
      S[(M-X.at(y))%M]=0;*/
  
  ans+=S[X.at(y)]*(S[X.at(y)]-1)/2;
	  S[X.at(y)]=0;

}
	ce(ans)
	
}





Measured memory_bytes: 4732
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll X, Y;
const int MAX_N = 100;
int dp[2 * MAX_N][2 * MAX_N][2];
int memo(int x, int y, bool turn)
{

    if (x <= 1 && y <= 1)
    {
        return !turn;
    }
    int &res = dp[x][y][turn];
    if (res >= 0)
    {
        return res;
    }
    res = !turn;
    int i = 1;

    while (2 * i <= x)
    {
        if (memo(x - 2 * i, y + i, !turn) == turn)
        {
            res = turn;
            return res;
        }
        i++;
    }
    i = 1;
    while (2 * i <= y)
    {
        if (memo(x + i, y - 2 * i, !turn) == turn)
        {
            res = turn;
            return res;
        }
        i++;
    }

    return res;
}
int main()
{
    cin >> X >> Y;
    if (abs(X - Y) <= 1)
    {
        cout << "Brown" << endl;
        return 0;
    }
    cout << "Alice" << endl;
    // memset(dp, -1, sizeof(dp));
    // for (int x = 0; x <= MAX_N; x++)
    // {
    //     for (int y = 0; y <= MAX_N; y++)
    //     {
    //         string res = (memo(x, y, 0) == 0 ? "Alice" : "Brown");
    //         if (res == "Brown")
    //         {
    //             cout << x << " " << y << " " << res << endl;
    //         }
    //     }
    // }

    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  a = a + b;
  if(a % 2)
  {
    cout << a / 2 + 1 << endl;
  }
  else
  {
    cout << a / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    sc = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    for i in range(1000):
        si = str(i)
        if len(si) == n:
            b = True
            for j in range(len(sc)):
                if si[sc[j][0]-1] != str(sc[j][1]):
                    b = False
                    break
            if b:
                print(i)
                exit()
    print(-1)


if __name__ == '__main__':
    solve()


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

int main() {
  // 入力
  int N;
  cin >> N ;
  
  vector<unsigned long int> X;
  unsigned long int X_tmp;
  for (int i=0; i<N; i++) {
    cin >> X_tmp;
    X.push_back(X_tmp);
  }

  sort(X.begin(), X.end());


  int P;
  unsigned long int sum = 1844674407370955161;
  unsigned long int sum_tmp = 0;
  for (unsigned long int i=X[0]; i<=X[N-1]; i++) {
    P = i;
    sum_tmp = 0;
    for (int j=0; j<N; j++) {
      sum_tmp += (X[j] - P)*(X[j] - P);
    }
    if (sum_tmp < sum) {
      sum = sum_tmp;
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<int> P(N),Q(N),R(N);
	
	for(int i=0;i<N;i++){
		cin>>P[i];
	}
	
	for(int i=0;i<N;i++){
		cin>>Q[i];
		R[i] = i+1;
	}
	
	int a,b;
	
	int now = 0;
	
	do{
		if(P==R)a = now;
		if(Q==R)b = now;
		now++;
	}
	while(next_permutation(R.begin(),R.end()));
	
	cout<<abs(a-b)<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll t,n,m,ans=0;
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(c<a){
        c+=24;
    }
    if(d<b){
        c--;
        d+=60;
    }
    ans+=(d-b);
    ans+=(c-a)*60;
    ans-=e;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int dp[n];
	memset(dp,0,sizeof(dp));
	//int sum=inf;
	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]<<endl;
	
	return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)
//ll MLG(ll n,ll b){ll a=0;while(n)a++,n/=b;return a-1;}

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int n,m;
    cin>>n>>m;
    int s=0;
    vector<int> a(n);
    rep(i,0,n)cin>>a[i],s+=a[i];
    sort(all(a),greater<int>());
    double xx=1.0*s/(4.0*m);
    int xd=ceil(xx);
    for(int i=0;i<n;i++){
        if(xd<=a[i])
            m--;
        else break;
    }
    if(m>=1)cout<<"No"<<nl;
    else cout<<"Yes"<<nl;
    return 0;
}


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

int main(){
    std::stack<int> rail;
    int buf;
    
    // repeat until "cin" fails.
    while (std::cin >> buf) {
        if (buf == 0) { // train goes out.
            std::cout << rail.top() << std::endl;
            rail.pop();
        }
        else{   // train comes in.
            rail.push(buf);
        }
    }
    
    return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int p[] = new int[n];
		for(int i = 0; i < n; i++){
			p[i] = sc.nextInt() - 1;
		}

		int count = 0;
		if(p[n - 1] == n - 1){
			int tmp = p[n - 2];
			p[n - 2] = p[n - 1];
			p[n - 1] = tmp;
			count++;

		}

		for(int i = 0; i < n - 1; i++){
			if(p[i] == i){
				int tmp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = tmp;
				count++;
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 52572
a, b, k = map(int, input().split())
for i in range(k):
    if (i % 2 == 0):
        if (a % 2 == 1):
            a -= 1
        a //= 2
        b += a
    else:
        if (b % 2 == 1):
            b -= 1
        b //= 2
        a += b
print(a, b)

Measured memory_bytes: 3316
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cassert>
#include<random>
#include<fstream>
#include<chrono>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define VR46         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);ifstream fin("ip.txt");ofstream fout("op.txt");
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;

const int N = 3e3 + 5;
int n, m, dp[N][N];
string s, t;

int REC(int p, int q)
{
    if( p>=n || q>=m )
        return 0;
    if( dp[p][q]!=-1 )
        return dp[p][q];
    int ans = 0;
    ans = max( ans, REC( p+1, q ) );
    ans = max( ans, REC( p, q+1 ) );
    ans = max( ans, REC( p+1, q+1 ) + ( s[p]==t[q] ) );
    dp[p][q] = ans;
    return ans;
}

string ans = "";
void retrace(int p, int q)
{
    if( p>=n || q>=m )
        return;
    if( dp[p][q] == dp[p+1][q] )
        retrace( p+1, q );
    else if( dp[p][q] == dp[p][q+1] )
        retrace( p, q+1 );
    else
    {
        if( s[p]==t[q] )
            ans += s[p];
        retrace( p+1, q+1 );
    }
}

signed main()
{
    VR46 // DONT USE DEQUE IF NOT NECESSARY
    // int t;cin>>t;rep(test,1,t)
    {
        cin >> s >> t;
        n = s.length();
        m = t.length();
        mem( dp, -1 );
        REC( 0, 0 );
        retrace( 0, 0 );
        cout << ans << endl;
    }
}

Measured memory_bytes: 71168
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N1 = sc.nextInt();
		int N2 = sc.nextInt();
      	int ans = 0;

      if(String.valueOf(N1).length()==1  && String.valueOf(N2).length()==1){
        ans = N1 * N2;
      
      }else{
      	ans= -1;
      }
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

ll n, m;
int main() {
  cin >> n >> m;
  ll x, y;
  ll sumx = 0;
  ll sumy = 0;
  rep(i, n) {
    cin >> x;
    sumx = (sumx + x*(2*i-n+1))%mod;
  }
  rep(i, m) {
    cin >> y;
    sumy = (sumy + y*(2*i-m+1))%mod;
  }
  cout << (sumx*sumy)%mod << endl;
}


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

int main(void)
{
  int n;
  int i, j;
  while(1){
    cin >> n;
    if(n == 0){
      break;
    }
    
    
    int array[11][11] = {};
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	cin >> array[i][j];
	array[i][n] = array[i][n] + array[i][j];
	array[n][j] = array[n][j] + array[i][j];
	array[n][n] = array[n][n] + array[i][j];
      }
    }

    for(i = 0; i <= n; i++){
      for(j = 0; j <= n; j++){
	std::cout << std::right << std::setw(5) << array[i][j];
      }
      cout << endl;
    } 

  }

    
    
  return 0;
}

Measured memory_bytes: 3072
n = int(input())
A = list(map(int,input().split()))
tmp = [int(x) for x in A if x%2 == 0]

cnt = 0
for i in tmp:
    if i % 3 == 0 or i % 5 == 0:
        cnt += 1

if cnt == len(tmp):
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
n,q=[int(i) for i in input().split(" ")]

list=[]
for i in range(n):
    x=input().split(" ")
    p=x[0]
    time=int(x[1])
    list.append([p,time])
 
time=0
while len(list)>0:
    if list[0][1]<=q:
        time+=list[0][1]
        print(list[0][0]+" "+str(time))
        list.pop(0)
    else:
        time+=q
        list[0][1]-=q
        list.append(list[0])
        list.pop(0)


Measured memory_bytes: 12880
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #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>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n, l;
    cin>>n>>l;

    int mn = MAX, ans = 0;
    for(int i=1;i<=n; i++){
        if(mn >= abs(l + i - 1)){
            mn = abs(l + i - 1);
            ans = i;
        }
    }

    int res = 0;
    for(int i=1;i<=n;i++){
        if(i != ans) res += l + i - 1;
    }

    cout<<res;
} 

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	else gcd(b,a%b);
}
int main(){
	long long int a,b,ans;
	while(cin>>a>>b){
		if(b>a){
			int tmp=a;
			a=b;
			b=tmp;
		}
		cout<<gcd(a,b)<<" "<<a/gcd(a,b)*b<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int n = read();
    int[] h = reads();

    auto dp = new int[n];
    dp[0] = 0; dp[1] = abs(h[1] - h[0]);
    foreach (i; 2..n)
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1]
                , abs(h[i] - h[i-2]) + dp[i-2]);
    writeln(dp[n-1]);
}


Measured memory_bytes: 3956
# -*- coding: utf-8 -*-

[n, m] = map(int, input().split(' '))
food_loved = []

for i in range(0, n):
    tmp = input().split(' ')
    food_loved.append(set(tmp[1:len(tmp)]))

result = food_loved[0]

for i in range(1, n):
    result = result & food_loved[i]

print(len(result))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
 
ll LIS(vector<ll>& sequence){
    multiset<ll> s;
    s.insert(sequence[0]);
    
    for(ll i = 1; i < sequence.size(); i++){
        ll now = sequence[i];
        //広義単調増加列の場合、以下を now >= *--s.end()にする
        if(now > *--s.end()) s.insert(now);
        else{
            auto itr = s.lower_bound(now);
            s.erase(itr);
            s.insert(now);
        }
    }
    return s.size();
}
 
int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    pr(LIS(A));
    return 0;
}


Measured memory_bytes: 8308
#Union Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#UF木
#自分のとこと同じグループだったらプラス一

N,M = map(int,input().split())
p=[0] + list(map(int,input().split()))

#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N+1)

for i in range(M):
    x,y=map(int,input().split())
    unite(x,y)

ans = 0
for i in range(1,N+1,1):
    if same(p[i],i):
        ans+=1
print(ans)




Measured memory_bytes: 85692
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

S = input()
N = len(S)
modlist = [0] * 13
splitmod = []

if S[0] == "?":
    for i in range(10):
        modlist[i % 13] += 1
else:
    modlist[int(S[0])] += 1
S = S[1:]

# 前から処理していく
# 10と13は互いに素なので
# a == b (mod z)なら
# 10a == 10b (mod z)
# 例
# 18 == 5 (mod 13)
# 180 == 50 (mod 13)
# 13 * 13 + 11 == 13 * 3 + 11 (mod 13)
for st in S:
    modalta = [0] * 13
    if st == "?":
        # 例えば 7?4の時
        # 7 * 10 + 1, 2, 3...
        for i in range(10):
            # modlist
            for j in range(13):
                opt = (j * 10 + i) % 13
                modalta[opt] += modlist[j]
    else:
        for j in range(13):
            opt = (j * 10 + int(st)) % 13
            modalta[opt] += modlist[j]
    # mod調整
    for i in range(13):
        modalta[i] %= mod
    modlist = copy.deepcopy(modalta)

print(modlist[5] % mod)

Measured memory_bytes: 75988
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        if(n==7||n==5||n==3){
            out.println("YES");
        }else{
            out.println("NO");
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
}


Measured memory_bytes: 21844
#include <cassert>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
  UnionFind(int n) : v_(n, -1) {}

  int size(int x) { return -v_[find(x)]; }

  int find(int x) {
    assert(x < v_.size());
    if (v_[x] < 0) return x;
    return v_[x] = find(v_[x]);
  }

  bool is_same(int x, int y) { return find(x) == find(y); }

  void merge(int x, int y) {
    assert(x < v_.size());
    assert(y < v_.size());

    x = find(x);
    y = find(y);
    if (x == y) return;
    if (-v_[x] <= -v_[y]) swap(x, y);
    v_[x] += v_[y];
    v_[y] = x;
  }

 private:
  vector<int> v_;
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  UnionFind uf(n);
  vector<int64_t> ans(m);
  ans[m - 1] = (int64_t)n * (n - 1) / 2;
  for (int i = m - 1; i > 0; i--) {
    if (uf.is_same(a[i], b[i])) {
      ans[i - 1] = ans[i];
      continue;
    }
    int64_t conv = (int64_t)uf.size(a[i]) * uf.size(b[i]);
    ans[i - 1] = ans[i] - conv;
    uf.merge(a[i], b[i]);
  }
  for (auto e : ans) cout << e << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int v[100001];
int main(){
   int n;
   cin >> n;
   rep(i,n){
      int tmp;
      cin >> tmp;
      v[tmp]++;
   }
   int ans = 0;
   for (int i = 0;i < 100000;i++){
      ans = max(ans,v[i]+v[i+1]+v[i+2]);
   }
   cout << ans << endl;
   
   return 0;
   
}



Measured memory_bytes: 640
n, m = map(int, input().split())
MOD = 1000000007
def nPk(n, k):
    r = 1
    while k > 0:
        r *= n
        r %= MOD
        n -= 1
        k -= 1
    return r
if abs(n - m) > 1:
    print(0)
elif n == m:
    print(nPk(n, n) * nPk(m, m) * 2 % MOD)
else:
    print(nPk(n, n) * nPk(m, m) % MOD)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n;
    cin >> n;
    set<int> s;
    int pool = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a <= 399) s.insert(1); 
        else if (a <= 799) s.insert(2);
        else if (a <= 1199) s.insert(3);
        else if (a <= 1599) s.insert(4);
        else if (a <= 1999) s.insert(5);
        else if (a <= 2399) s.insert(6);
        else if (a <= 2799) s.insert(7);
        else if (a <= 3199) s.insert(8);
        else pool++;
    }
    cout << max((int)s.size(), 1) << " " << (int)s.size() + pool << endl;    
}

Measured memory_bytes: 256
a,b=gets.chomp.split(" ").map(&:to_i);
x = a + b;
y = a - b;
z = a * b;

ret = 0;

if(x >= y && x >= z)
	ret = x;
elsif(y >= x && y >= z)
	ret = y;
else
	ret = z;
end
puts ret  

Measured memory_bytes: 1788
n, *s = open(0).read().split()
n = int(n)

c0 = s.count('AC')
c1 = s.count('WA')
c2 = s.count('TLE')
c3 = n - (c0 + c1 + c2)

print('AC x ' + str(c0), 'WA x ' + str(c1), sep='\n')
print('TLE x ' + str(c2), 'RE x ' + str(c3), sep='\n')


Measured memory_bytes: 17176
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A;
    cin >> N >> A;

    string ans = "No";
    while(A >= 0){
        if((N - A) % 500 == 0) ans = "Yes";
        A--;
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (a+b)%2 == 1 {
		fmt.Println("IMPOSSIBLE")
		return
	}
	if b > a {
		fmt.Println(b - (b-a)/2)
		return
	}
	fmt.Println(a - (a-b)/2)
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long N = in.nextLong();

            List<Long> l753 = new ArrayList<>(Arrays.asList(3L, 5L, 7L));
            gen(l753, 1);
            l753 = l753.stream()
                    .distinct()
                    .map(String::valueOf)
                    .filter(s -> s.indexOf('3') >= 0)
                    .filter(s -> s.indexOf('5') >= 0)
                    .filter(s -> s.indexOf('7') >= 0)
                    .map(Long::valueOf)
                    .filter(l -> l <= N)
                    .collect(Collectors.toList());
            out.println(l753.size());
        }

        private void gen(List<Long> l753, int l) {
            if (l >= 10) return;

            int len = l753.size();
            for (int i = 0; i < len; i++) {
                for (int j = 0; j < 3; j++) {
                    l753.add(l753.get(i) * 10 + 3 + j * 2);
                }
            }
            gen(l753, l + 1);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 68484
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
int a,b,c,d,e;
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
printf("%d\n",(max(40,a)+max(40,b)+max(40,c)+max(40,d)+max(40,e))/5);
}

Measured memory_bytes: 1028
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(" ").map(Number)
    var n = data[0]
    var a = data[1]
    var b = data[2]
    var densha = n * a
    var taxi = b
    if (densha < taxi) {
        console.log(densha)
    } else {
        console.log(taxi)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let n:i32 = r.reads();
    let a:i32 = r.reads();
    let b:i32 = r.readl();

    let mut res = 0;
    
    for i in 1..(n + 1) {
        let mut sum = 0;
        for c in i.to_string().chars() {
            sum += (c as i32) - 48;
        }
        if(a <= sum && sum <= b) {
            res += i;
        }
    }

    println!("{}",res);

}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const int inf=1<<30;
const int N=2e5+10;
using namespace std;
char s[1010][1010];
int gcd(int a,int  b){return b==0?a:gcd(b,a%b);}
int main()
{
	int w,h,n;
	cin>>w>>h>>n;
	int cnt1=0,cnt2=w,cnt3=0,cnt4=h;
	for(int i=0;i<n;i++)
	{
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1)
		cnt1=max(x,cnt1);
		if(a==2)
		cnt2=min(x,cnt2);
		if(a==3)
		cnt3=max(y,cnt3);
		if(a==4)
		cnt4=min(y,cnt4);	
	}	
	int q=cnt4-cnt3,p=cnt2-cnt1;
	if(q<0||p<0)
	p=0;
	cout<<p*q<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int y,m,d;
	while(scanf("%d%d%d",&y,&m,&d)>0)
	{
		if(y<1868 ||
			(y==1868&&m<9) ||
			(y==1868&&m==9&&d<=7) )
			printf("pre-meiji\n");
		else if(y<1912 ||
			y==1912&&m<7 ||
			y==1912&&m==7&&d<=29)
			printf("meiji %d %d %d\n",y-1868+1,m,d);
		else if(y<1926 ||
			y==1926&&m<12 ||
			y==1926&&m==12&&d<=24)
			printf("taisho %d %d %d\n",y-1912+1,m,d);
		else if(y<1989 ||
			y==1989&&m==1&&d<=7)
			printf("showa %d %d %d\n",y-1926+1,m,d);
		else
			printf("heisei %d %d %d\n",y-1989+1,m,d);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int x = n / 2;
  int y = n / 2 + 1;
  if (n % 2 == 0) {
    cout << x * x;
  }
  else {
    cout << x * y;
  }
}


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


class UnionFindTree:
    def __init__(self, n: int):
        self.n = n
        self.root = [-1] * n
        self.rank = [0] * n
    def findRoot(self, x: int) -> int:
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.findRoot(self.root[x])
            return self.root[x]
    def unite(self, x: int, y: int):
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    def same(self, x: int, y: int) -> bool:
        if self.findRoot(x) == self.findRoot(y):
            return True
        else:
            return False
    def count(self, x: int) -> int:
        return -self.root[self.findRoot(x)]
    def treeCount(self) -> int:
        cou = 0
        for i in self.root:
            if i < 0:
                cou += 1
        return cou


def main():
    N, M = map(int, input().split())
    UFT = UnionFindTree(N)
    ans = [0] * M
    bridges = []
    for _ in range(M):
        A, B = map(int, input().split())
        bridges.append((A-1, B-1))
    ans[M-1] = N * (N-1) // 2
    for i in range(M-1, 0, -1):
        A = bridges[i][0]
        B = bridges[i][1]
        if UFT.same(A, B):
            ans[i-1] = ans[i]
        else:
            ans[i-1] = ans[i] - UFT.count(A) * UFT.count(B)
            UFT.unite(A, B)
    for i in ans:
        print(i)


if __name__ == '__main__': main()

Measured memory_bytes: 23288