akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
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;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long N = in.nextLong(), A = in.nextLong(), B = in.nextLong();
            if ((B - A) % 2 == 0) {
                out.printLine((B - A) / 2);
            } else {
                long ans1 = Math.min(B - 1, N - A);
                long ans2 = A + (B - A - 1) / 2;
                ans2 = Math.min(ans2, N - B + 1 + (N - (A + N - B + 1)) / 2);
                out.printLine(Math.min(ans1, ans2));
            }
        }

    }

    static class OutputWriter {
        PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}



Measured memory_bytes: 21460
package main

import (
        "fmt"
)

func solution(h, w int, c []string) []string {
        out := make([]string, 0, 2*h)

        for i := 0; i < h; i++ {
                out = append(out, c[i])
                out = append(out, c[i])
        }
        return out
}

func main() {
        var h, w int
        fmt.Scan(&h, &w)
        c := make([]string, h)
        for i := range c {
                fmt.Scan(&c[i])
        }
        for _, t := range solution(h, w, c) {
                fmt.Println(t)
        }
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

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

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

    vector<vector<int>> dp((1<<n), vector<int>(51, INF));
    dp[0][0] = 0;
    for(int bit=0; bit<(1<<n); bit++){

        for(int xi=0; xi<=50; xi++){
            if(dp[bit][xi] == INF) continue;

            int pos = __builtin_popcount(bit);
            for(int j=0; j<n; j++){
                if(bit >> j & 1) continue;

                int xj = a[j];
                if(abs(j - __builtin_popcount(bit)) % 2 == 1) xj = b[j];

                if(xj >= xi) dp[bit|(1<<j)][xj] = min(dp[bit|(1<<j)][xj], dp[bit][xi] + (pos - __builtin_popcount(bit)));
                pos += 1;
            }
        }
    }

    /*
    for(int bit=0; bit<(1<<n); bit++){
        for(int xi=0; xi<=5; xi++){
            cout << setw(11) << dp[bit][xi];
        }
        cout << endl;
    }
    */

    int ans = INF;
    for(int xi=0; xi<=50; xi++){
        ans = min(ans, dp[(1<<n)-1][xi]);
    }
    if(ans != INF) cout << ans << endl;
    if(ans == INF) cout << -1  << endl;
    return 0;
}

Measured memory_bytes: 66856
#include<bits/stdc++.h>
using namespace std;
vector<long long> attack(1000001,-1);
long long solve(long long h)
{
	if(h <= 0)
	{
		return 0;
	}
	else if(h == 1)
	{
		return 1;
	}
	else
	{
		if(h > 1000000)
			return 2 * solve(h/2) + 1;
			
		else
		{
			if(attack[h] == -1)
				return attack[h] = 2 * solve(h/2) + 1;
				
			return attack[h];
		}
	}	
}

int main()
{
	attack[0] = 0ll;
	attack[1] = 1LL;
	long long h;
	cin>>h;
	long long ans = (long long)(pow(2LL, long(floor(log2(h))) + 1L )) - 1LL;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8320
let make_list f t step =
  let rec make_list_inner c t lst =
    if c >= t then lst else make_list_inner (c+step) t (c::lst)
  in
  List.rev (make_list_inner f t [])

let sum list = List.fold_left (+) 0 list

let solve d =
  sum (List.map (fun x -> (x * d) * (x * d) * d) (make_list 1 (600/d) 1))
           
    
    
let () =
  let rec read () =
    try let ans = (Scanf.scanf "%d\n" solve) in
        Printf.printf "%d\n" ans;
        read ()
    with End_of_file ->
         ()
  in
  read ()
;;

Measured memory_bytes: 2496
#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 IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

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

class RMQ_segment_tree
{
    using data_type = int;

public:

    vector<data_type> dat;
    int N;
    data_type inf;

    RMQ_segment_tree(int n, data_type inf): inf(inf) {
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, inf);
    }

    //k番目の値をaに更新
    void update(int k, data_type a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    //[a, b)の最小値
    data_type minval(int a, int b){
        return query(a, b, 0, 0, N);
    }

    data_type query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return dat[k];
        else{
            data_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            data_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

signed main(){

    int N, x; cin >> N >> x;
    vec a(N); readvec(a);

    RMQ_segment_tree sgt(2 * N, INF);
    REP(i, N) sgt.update(i, a[i]);
    REP(i, N) sgt.update(i + N, a[i]);
    
    int ans = INF;
    REP(m, N){
        int tmp = x * m;
        REP(i, N) tmp += sgt.minval(i + N - m, i + N + 1);
        ans = min(ans, tmp);
    }

    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: 384
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	char S[3];
	repeat(i, i < 3)
		cin >> S[i];
	//DEBUG();
	int a = 0;
	int max=0;
	
	repeat(i, i < 3) {
		//cout << S[i]<<"  "<<a;
		if (S[i] == 'R') {
			a++;
		}
		else {
			if (max < a)
				max = a;
			a = 0;
		}
	}
	if (max < a)
		max = a;
	cout << max;

	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, k = map(int, input().split()) # 入力が複数
n = n % k
d = set([n])
while True:
    diff = abs(n - k)
    pre = n
    n = min(diff, n)
    if n in d:
        break
    else:
        d.add(n)
print(min(d))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli a=0,b=0;
    string s;
    lli i,j;
    vector<lli> vec,ans;
    cin>>s;
    rep(i,1,s.size()){
        if((s[i]=='L')&&(s[i-1]=='R')){
            vec.push_back(1);
            vec.push_back(2);
            i++;
        }
        else{
            vec.push_back(0);
        }
    }
    if(vec.size()!=s.size()){
        vec.push_back(0);
    }
    rep(i,0,s.size()){
        if((s[i]=='R')&&(vec[i]==0)){
            a++;
            ans.push_back(0);
        }
        else{
            if(vec[i]==1){
                ans.push_back(a/2);
                ans.push_back(ceil((double)a/2));
                i++;
                a=0;
            }
            else{
                ans.push_back(0);
            }
        }
    }
//    rep(i,0,vec.size()){
//        cout<<vec[i];
//    }
//    cout<<endl;
//    rep(i,0,ans.size()){
//        cout<<ans[i];
//    }
//    cout<<endl;
    rrep(i,s.size()-1,0){
        if((s[i]=='L')&&(vec[i]==0)){
            a++;
        }
        else{
            if(vec[i]==2){
//                cout<<a/2<<" "<<ceil((double)a/2)<<endl;
                ans[i]+=((a/2)+1);
                ans[i-1]+=((ceil((double)a/2))+1);
                i--;
                a=0;
            }
        }
    }
    rep(i,0,ans.size()){
        cout<<ans[i];
        if(i!=ans.size()-1){
            cout<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
int count=0,pre=0;
string S;
cin>>S;
rep(i,S.size()){
    if(pre==0){
        if(S[i]=='B'){
            pre=1;
        }
        else{
            pre=-1;
        }
        count++;
    }
    else if(pre==1){
        if(S[i]=='W'){
            pre=-1;
            count++;
        }
    }
    else if(pre==-1){
        if(S[i]=='B'){
            pre=1;
            count++;
        }
    }
}
cout<<count-1<<endl;

return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
#define endl "\n"
using namespace std;

void solve(){
	
}
vector<ll> adj[100001];
bool vis[100001];
ll t[100001];

ll dfs(ll node){
    if(vis[node]){
        return t[node];
    }
    vis[node] = true;
    ll maxi = 0;
    for(auto x : adj[node]){
            maxi = max(maxi,1+dfs(x));
    }
    return t[node] = maxi;
}

int main(){
	fastio;
	ll n,m,a,b;
    cin>>n>>m;
    for(ll i=1;i<=m;i++){
        cin>>a>>b,  adj[a].pb(b);
    }
    memset(vis,false,sizeof(vis));
    memset(t,0,sizeof(t));
    ll maxi = 0;
    for(ll i=1;i<=n;i++){
        if(vis[i] == 0){
            maxi = max(maxi,dfs(i));
        }
    }
    cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 11992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 305 ;
using namespace std ;

int n, m, a[N][N], d[N] ;
bool vis[N] ;

int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) rep(j, 1, m) scanf("%d", &a[i][j]) ;
	rep(i, 1, m) vis[i] = true ;
	int ans = n ;
	rep(k, 1, m) {
		rep(i, 1, m) d[i] = 0 ;
		rep(i, 1, n) {
			rep(j, 1, m) if (vis[a[i][j]]) {
				++ d[a[i][j]] ;
				break ;
			}
		}
		int mx = 0 ;
		rep(i, 1, m) mx = max(mx, d[i]) ;
		ans = min(ans, mx) ;
		rep(i, 1, m) if (d[i] == mx) {
			vis[i] = false ;
			break ;
		}
	}
	printf("%d\n", ans) ;
	return 0 ; 
}

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

int main()
{
    int n;
    cin >> n;
    int p;
    priority_queue<int> pq;
    F(n){
        cin >> p;
        pq.push(p);
    }
    int sum=pq.top()/2;
    if(!pq.empty()) pq.pop();
    F(n-1){
        sum += pq.top();
        if(!pq.empty()) pq.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    H, W, K = list(map(int, input().split()))
    dp = [[0 for _ in range(W)] for __ in range(H+1)]
    dp[0][0] = 1
    mod = 10**9+7
    for h in range(H):
        for w in range(W):
            downleft = 0
            down = 0
            downright = 0
            for bits in range(1<<W-1):
                invalid = False
                for odr in range(W-2):
                    if (bits & (1<<odr)) and (bits & (1<<(odr+1))):
                        invalid = True
                if invalid:
                    continue
                if w > 0 and (bits & (1<<(w-1))):
                    downleft += 1
                elif w < W-1 and (bits & (1<<w)):
                    downright += 1
                else:
                    down += 1
            if w > 0 and downleft > 0:
                dp[h+1][w-1] += downleft*dp[h][w]
                dp[h+1][w-1] %= mod 
            if w < W-1 and downright > 0:
                dp[h+1][w+1] += downright*dp[h][w]
                dp[h+1][w+1] %= mod
            if down > 0:
                dp[h+1][w] += down*dp[h][w]
                dp[h+1][w] %= mod
    print(dp[H][K-1])


if '__main__' == __name__:
    resolve()

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

int main() {
	double w;
	while(scanf("%lf", &w) != EOF){
		if(w <= 48.0)
			cout << "light fly" << endl;
		else if (48.0 < w && w <= 51.0)
			cout << "fly" << endl;
		else if(51.0 < w && w <= 54.0)
			cout << "bantam" << endl;
		else if(54.0 < w && w <= 57.0)
			cout << "feather" << endl;
		else if(57.0 < w && w <= 60.0)
			cout << "light" << endl;
		else if(60.0 < w && w <= 64.0)
			cout << "light welter" << endl;
		else if(64.00 < w && w <= 69.0)
			cout << "welter" << endl;
		else if(69.0 < w && w <= 75.0)
			cout << "light middle" << endl;
		else if(75.0 < w && w <= 81.0)
			cout << "middle" << endl;
		else if(81.0 < w && w <= 91.0)
			cout << "light heavy" << endl;
		else if(91.0 < w)
			cout << "heavy" << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

double xs,ys,xt,yt;
int n;
double x[1010], y[1010], r[1010];
double d[1010];

signed main(){
	cin>>x[0]>>y[0]>>x[1]>>y[1]; r[0]=r[1]=0; cin>>n;
	rep(i,n){
		cin>>x[i+2]>>y[i+2]>>r[i+2];
	}
	n+=2;
	reps(i,n-1) d[i]=1e15;

	priority_queue<PDD> p; p.push({0,0});
	while(!p.empty()){
		double cost=-p.top().first;
		int cur=p.top().second;
		p.pop();
		if(cost!=d[cur]) continue;
		rep(i,n) if(i!=cur){
			double dist=max(pow(pow(x[i]-x[cur],2)+pow(y[i]-y[cur],2),0.5)-r[i]-r[cur],0.0);
			if(d[i]>d[cur]+dist){
				d[i]=d[cur]+dist; p.push({-d[i],i});
			}
		}
	}
	cout<<d[1]<<endl;
	return 0;
}


Measured memory_bytes: 6384
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c ,n, sum, A[500010], B[500000],rui[500000],  dp[5000];
str S,T,U;bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> n >> a;
b = n % a;
c = abs(b -a);
cout << min({n,b,c}) << endl;





	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
string bz="CODEFESTIVAL2016";//CODEFESTIVAL2016
string a;
//C0DEFESTIVAL2016
int ans;
int main()
{
cin>>a;
for(int i=0;i<16;i++)
{
	if (a[i]!=bz[i]) ans++;
}
cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int long long n, k;
	cin>>n>>k;
	cout<<min(n%k, abs(n%k-k))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
  int i,h,m,s;
  cin >> i;
  h = i/ 3600;
  m = i / 60 - h * 60;
  s = i/1 -h*3600-m*60 ;
  cout << h << ":" << m << ":" << s << endl;
  
  return 0;
}


Measured memory_bytes: 3132
my $s = <>;
chomp $s;
my @PDB;
my @MDB;
my $state  =0;
my $mstate =0;
my $pmmax  =0;
my $pmmin  =0;
my $sum=0;
for(my $i=0;$i<$s;$i++){
    my $line = <>;chomp $line;
    my @dat = split(//,$line);
    #print "@dat\n";
    my $min=0;
    my $max=0;
    my $total=0;
    for(my $j=0;$j<=$#dat;$j++){
        #print "$dat[$j]\n";
      if($dat[$j] eq '(' ){
         #print "plus \n";
        $total++;
      }else{
        $total--;
      }
      if($min >$total ){ $min =$total;}
      if($max <$total ){ $max =$total;}
    }
    $max = $max - $total;
    #print "$total $min\n";
    $sum = $sum + $total;
    if($total ==0){
      if($pmmin > $min){$pmmin = $min;}
    }elsif($total >0){
      if( $min >=0 ){#-にならないならここで足してしまう
        $state = $state + $total;
        next;
      }
      my @row = ($total,$min);
      push (@PDB,\@row);
    }else{
      $min = $min - $total;#左からみた最小
      if( $min >=0){
        $mstate = $mstate + $total;
        #print"$min $mstate\n";
        next;
      }
      my @row = ($total,$min);
      push (@MDB,\@row);
    }
    #print "$sum $total \n";
}
#print "$state $mstate \n";

@PDB = sort{ $b->[1] <=> $a->[1]} @PDB;
#my @amari;
for(my $i=0;$i<=$#PDB;$i++){
  if(($state+$PDB[$i][1]) >= 0){#採用
    $state = $state + $PDB[$i][0];
    #print "@{$PDB[$i]} state $state \n ";
  }else{
    print "No";exit;
  }
}
#print "$state $pmmin \n";
if( ($state+$pmmin) < 0){ print "No";exit;}
#print "MDB $#MDB\n";

@MDB = sort{ $b->[1] <=> $a->[1]} @MDB;
for(my $i=0;$i<=$#MDB;$i++){
  if((-$mstate+$MDB[$i][1]) >= 0){#採用
    $mstate = $mstate + $MDB[$i][0];
    #print "@{$MDB[$i]} mstate $mstate \n ";
  }else{
    print "No";exit;
  }
}
$state = $state + $mstate;

if( $state == 0){
    print "Yes";
}else{
    print "No";
}


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

const int MOD = (int)1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> L(2*N);
  for(int i=0;i<2*N;i++)  cin >> L.at(i);

  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0;i<2*N;i+=2){
    ans+=L.at(i);
  }
  cout << ans << endl;

  return 0;
}


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

int store[400007];
map<int, int> cnt;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &store[i]), cnt[store[i]]++;
    sort(store+1, store+n+1, greater<int>());

    ll ans = 0;
    bool flg = false;

    for (int i = 1; i <= n; i++) {
        if (cnt[store[i]] >= 2) {
            cnt[store[i]] -= 2;
            if (!ans) ans = store[i];
            else {
                ans *= ll(store[i]);
                flg = true;
                break;
            }
        }
    }

    if (!flg) cout << 0 << endl;
    else cout << ans << endl;
}


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

int main() {
  int n, k;

  cin >> n;
  cin >> k;

  int a[n];
  for (int i=0; i<n; i++){
    cin >> a[i];
    if(i >= k){
      int pre = a[i-k];
      int now = a[i];
      if(pre < now) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
  return 0;
  
}

Measured memory_bytes: 3908
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    for(int c=1;c<=3;c++){
        if(c*a*b%2!=0){
            cout<<"Yes";
            return 0;
        }
        else{
            cout<<"No";
            return 0;
        }
    }
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, z, w;
  cin >> n >> z >> w;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  if(n == 1) cout << abs(a.at(0) - w) << '\n';
  else cout << max(abs(a.at(n - 1) - a.at(n - 2)), abs(a.at(n - 1) - w)) << '\n';
}

Measured memory_bytes: 256
/*
***************************************************************************
 name  : ITP1_02_A.cpp
 title : Small,Large, or Equal
 make  : 2018/08/01 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object

main(void){
  int a,b; // integers

  std::cin >> a >> b; // input "a b"

  if(a-b > 0){
    std::cout << "a > b" << std::endl; // output "a > b"
  }
  else
  if(a-b < 0){
    std::cout << "a < b" << std::endl; // output "a < b"
  }
  else{
    std::cout << "a == b" << std::endl; // output "a == b"
  }

}



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

int main(){
int n, x, i, max = -1000000, min =1000000;
long sum = 0;

cin >> n;

for( i = 0; i < n; i++ ){
 cin >> x;
 sum = sum + x;
 if ( x > max ) max = x;
 if ( x < min ) min = x; 
}
cout << min << " " << max << " " << sum << endl;
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

const int A = 1000005;

 ll gcd(ll a,ll b){
     if(a<b) swap(a,b);
     bool have_mod =true;
     while(have_mod){
         ll mod = a % b;
         if(mod == 0 ) have_mod = false;
         a = b;
         b = mod;
     }
     return a;
 }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
 
  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
 
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
 
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
 
  cout << "not coprime" << endl;
  return 0;
}

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

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
#define INF (1 << 29)
const lld MAXN = 201;

int d[MAXN][MAXN] = {INF};

void w_f(int nn)
{
	for(int k = 0; k < nn; k++)
	{
		for(int i = 0; i < nn; i++)
		{
			for(int j = 0; j < nn; j++)
			{
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
}

void init()
{
	for(int i = 0; i < MAXN; i++)
	{
		for(int j = 0; j < MAXN; j++)
		{
			if (i == j)
			{
				d[i][j] = 0;
			}else
			{
				d[i][j] = INF;
			}
		}
	}
}

int main()
{
	int N,M,R;
	vector<int> r;

	cin >> N >> M >> R;
	for(int i = 0; i < R; i++)
	{
		int x;
		cin >> x;
		r.push_back(x-1);
	}

	init();

	for(int i = 0; i < M; i++)
	{
		int a,b,c;
		cin >> a >> b >> c;

		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}

	w_f(N);

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

	int sol = INF;

	do{
		int now = 0;
		for(int i = 0; i < R-1; i++)
		{
			now += d[r[i]][r[i+1]];
		}
		sol = min(sol,now);
	}while(next_permutation(r.begin(),r.end()));

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;

int n, k, a[200001], ans;



int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("A.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    cout << ((n-1)/1000+1)*1000-n;
}


Measured memory_bytes: 3560
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

std::map<intmax_t, int> factor(intmax_t n) {
  std::map<intmax_t, int> res;
  for (intmax_t i=2; i*i<=n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n > 1)
    ++res[n];
  return res;
}

int main() {
  intmax_t N, P;
  scanf("%jd %jd", &N, &P);

  std::map<intmax_t, int> divs = factor(P);
  intmax_t res = 1;
  for (const auto& p: divs) {
    intmax_t k = p.second/N;
    for (int i=0; i<k; ++i)
      res *= p.first;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1000000000
using namespace std;
int n;
int num[100]={0};
long long memo[100][21];
long long solve(int now,int sum){
  if(sum<0 || sum>20){
    return 0;
  }
  if(memo[now][sum]!=INF){
    return memo[now][sum];
  }
  if(now==n-1){
    return sum==num[n-1];
  }
  return memo[now][sum]=solve(now+1,sum+num[now])+solve(now+1,sum-num[now]);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<21;j++){
      memo[i][j]=INF;
    }
  }
  cout<<solve(1,num[0])<<endl;
}
  

Measured memory_bytes: 1172
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 300001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;

int n;
intt h[SIZE] , dp[SIZE];

int main()
{
    FAST_READ;
    cin>>n;
    for (int i = 1;i<=n;i++) cin>>h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3;i<=n;i++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i - 2]));
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<int> a1(N) , a2(N);
    REP(i,N) cin >> a1[i];
    REP(i,N) cin >> a2[i];
    int cnt = accumulate(ALL(a2),0) + a1[0];
    int ans = cnt;
    FOR(i,1,N) {
        cnt += a1[i] - a2[i-1];
        ans = max(ans,cnt);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    A, B, C, D = MAP()

    X = B // C - (A - 1) // C
    Y = B // D - (A - 1) // D
    g = (C * D) // gcd(C, D)
    Z = B // g - (A - 1) // g

    print(B - A + 1 - X - Y + Z)


if __name__ == '__main__':
    main()

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

int main(){
	int a, b;
	char op;

	while(1){
		scanf("%d %c %d", &a, &op, &b);

		if(op == '?'){
			break;
		}
		else{
			switch(op){
				case '+':
				printf("%d\n", a + b);
				break;

				case '-':
				printf("%d\n", a - b);
				break;

				case '*':
				printf("%d\n", a * b);
				break;

				case '/':
				printf("%d\n", a / b);
				break;
			}
		}
	}
	return 0;

}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

int f[1111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	init(1111111);
	for(int i=1;i<=n-1;i++)
	{
		f[i] = choose(i-1,n-i-1);
		//if(i>=n/2) cerr<<i<<' '<<f[i]<<'\n';
	}
	int ans = 0; int pre = 0;
	for(int i=1;i<=n-1;i++)
	{
		int res = 0;
		res = add(mult(f[i], mult(fact[i], fact[n-1-i])), MOD - pre);
		//cerr<<res<<' '<<pre<<'\n';
		pre = add(pre, res);
		ans=add(ans,mult(res,i));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 21760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        long total = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N-1; i++){
            for(int j = i+1; j < i+2; j++){
                if(A[i] == A[j] || A[i] < A[j]){
                    continue;
                }
                if(A[i] > A[j]){
                    total += A[i] - A[j];
                    A[j] = A[i];
                }
            }
        }
        System.out.println(total);
    }
}


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

void fnInput(vector<int>& rvnCard)
{
  int nCardSiz;
  cin >> nCardSiz;

  for (int i = 0; i < nCardSiz; i++)
    cin >> rvnCard[i];

  sort(begin(rvnCard), end(rvnCard));
}

int fnDigitsSum(int nNum)
{
  int nDigitsSum = 0;
  while ( nNum )
  {
    nDigitsSum += nNum % 10;
    nNum /= 10;
  }
  return nDigitsSum;
}

int fnGameExec(const vector<int>& cnrvnCard)
{
  int nAlcePnt = 0, nBobPnt = 0;

  for (int i = 0; i < cnrvnCard.size(); i++)
  {
    if (i % 2 == 0)
      nBobPnt  += cnrvnCard[i];
    else
      nAlcePnt += cnrvnCard[i];
  }

  int nDiffPnt = nAlcePnt - nBobPnt;
  return nDiffPnt;
}

int main()
{
  vector<int> vnCard(100);
  fnInput(vnCard);
  cout << fnGameExec(vnCard) << endl;

  return 0;
}


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

using namespace std;

void f(long long &a, long long b) {
    a = min(a, b);
}

const long long INF = 1e18L + 5;

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

    int n, w;
    cin >> n >> w;
    vector<int> weight(n), value(n);
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }
    int sum_value = 0;
    for (int x : value) sum_value += x;
    vector<long long> dp(sum_value+1, INF);
    dp[0] = 0;


    for (int i = 0; i < n; i++) {
        for (int j = sum_value-value[i]; j >= 0; j--) {
            f(dp[j+value[i]], dp[j] + weight[i]); 
        }
    }

    long long ans = 0;
    for (int i = 0; i <= sum_value; i++) {
        if (dp[i] <= w) {
            ans = max(ans, (long long) i);
        }
    }
    printf("%lld", ans) ;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    vector<vector<int>> t(n, vector<int>(2));
    rep(i, n){
        cin >> t[i][0] >> t[i][1];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));

    rep(i, n){
        int m = t[i][0], //mass
            v = t[i][1]; //value
        for(int j=0; j <= w; j++){
            if(j-m < 0){
                dp[i+1][j] = dp[i][j];
                continue;
            }
            dp[i+1][j] = max(dp[i][j], dp[i][j-m] + v);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	long long int min=10000000;
	int num;
	int count=0;
	for(int i=0;i<n;i++)
	{
	    cin>>num;
	    if(num<=min)
	    {
	        min=num;
	        count++;
	    }
	}
	cout<<count;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 2e5 + 10;

int main(){
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  vector<int> a(n+1);
  a[0] = 0;
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] >= a[i-1]) continue;
    cnt += a[i-1] - a[i];
    a[i] = a[i-1];
  }
  cout << cnt;
return 0;
}


Measured memory_bytes: 3968
import Data.List as List
import Data.Set as Set
import Control.Applicative
import Control.Monad

f :: [Int] -> [Int] -> (Int, Int)
f xs ys = (hit, blow - hit)
  where
  hit = length $ List.filter id $ zipWith (==) xs ys
  blow = size $ intersection (fromList xs) (fromList ys)

chunksOf n [] = []
chunksOf n xs = (List.take n xs):chunksOf n (List.drop n xs)

main = do
  ss <- fmap (fmap read) <$> fmap words <$> lines <$> getContents :: IO [[Int]]
  mapM_ (\(x, y) -> putStrLn $ show x ++ " " ++ show y) $ fmap (\xs -> f (xs!!0) (xs!!1)) $ chunksOf 2 ss


Measured memory_bytes: 4088
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;

int water(vector<int>& h) {

    if (h.empty()) return 0;
    if (h.size()==1) return h[0];


    int r=0;
    vector<int> t;
    for (int i=0; i < h.size(); i++ ){
        if (h[i]==0) {
            if ( !t.empty()) {
                r += water(t) + 1;
                t.clear();
            }
        }
        else {
            t.push_back(h[i]-1);
        }
    }
    r += water(t);
    if (!t.empty()) r++;

    return r;
}

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    cout << water(h) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.buffer.readline

n, x, mod = map(int, input().split())
ans = 0
temp = x
num = 1
# while temp < mod:
#     temp *= x
#     num += 1


A = [0] * (mod + 1)

kouho = {}
if n < mod:
    A[1] = x % mod
    ans += A[1]
    for i in range(2, n + 1):
        A[i] = A[i - 1] * A[i - 1] % mod
        ans += A[i]
        # print(ans)
else:
    A[1] = x
    ans += A[1]
    kouho[A[1]] = 1
    temp = A[1]
    i = 1
    migi = 1
    for i in range(2, mod + 1):
        A[i] = temp * temp % mod
        if A[i] in kouho:
            migi = i
            break
        kouho[A[i]] = i
        temp = A[i]
    saisho = 0
    hidari = kouho[A[i]]
    saisho = sum(A[1:hidari])
    # for i in range(1, hidari):
    #     saisho += A[i]
    cycle_val = sum(A[hidari:migi])
    # cycle_val = 0
    # for i in range(hidari, migi):
    #     cycle_val += A[i]
    cycle = migi - hidari
    if cycle >= 2:

        kaisu = n // cycle
        amari = n % cycle - (hidari - 1)
        amari %= cycle
        kaisu = (n - (amari + hidari - 1)) // cycle
        amari_val = sum(A[hidari : hidari + amari])
        # amari_val = 0
        # for i in range(hidari, hidari + amari):
        #     amari_val += A[i]
        ans = saisho + cycle_val * kaisu + amari_val
    else:
        ans = 0
        if cycle == 0:
            for j in range(1, i + 1):
                ans += A[j]
        else:
            for j in range(1, i + 1):
                ans += A[j]
            ans += (n - i) * A[j]
print(ans)



Measured memory_bytes: 76240
require "prime"
n,m=gets.split.map(&:to_i)
# 参考：https://qiita.com/norioc/items/5c270ad6ff5d22d1efd0#comment-da13f6b749dba662ec63
def d(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end
d(m).reverse.each do |i|
  if i<=m/n
    puts i
    exit
  end
end


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

int main(){
  string S;
  cin >> S;
  if(S=="hi"|S=="hihi"|S=="hihihi"|S=="hihihihi"|S=="hihihihihi"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

typedef unsigned long long ull;

map<ull,int> memo;

int dfs2(ull, int, int);

int dfs1(ull s){
	if(s < 10){ return 0; }
	if(memo.count(s)){
		return memo[s];
	}
	int k;
	for(k = 8; !(s >> ((k - 1) * 8)); --k);
	if(k == 1){
		return s / 10;
	}

	int a = dfs2(s - (1ull << ((k - 1) * 8)), 10 - k, k);
	int b = dfs1(s & ((1ull << ((k - 1) * 8)) - 1));
	int res = max(a, b);

	memo[s] = res;
	return res;
}

int dfs2(ull s, int t, int u){
	if(s >> ((t - 1) * 8) & 0xff){
		return dfs1(s - (1ull << ((t - 1) * 8))) + 1;
	}
	if(t == 1){
		return 0;
	}
	if(t == 2){
		if((s & 0xff) >= 2){
			return dfs1(s - 2) + 1;
		}
		return 0;
	}
	if(t == 3){
		if(s & 0xff && s & 0xff00){
			return dfs1(s - 0x101) + 1;
		}
		if((s & 0xff) >= 3){
			return dfs1(s - 3) + 1;
		}
		return 0;
	}
	
	int res = 0;
	for(u = min(t, u); u >= 1; --u){
		if(s >> ((u - 1) * 8) & 0xff){
			int a = dfs2(s - (1ull << ((u - 1) * 8)), t - u, u);
			res = max(res, a);
		}
	}
	return res;
}

int main(){
	int n, x;
	while(scanf("%d", &n), n){
		int cnt[10] = {};
		for(int i = 0; i < n; ++i){
			scanf("%d", &x);
			++cnt[x];
		}
		
		int ans = 0;
		for(int i = 1; i <= 4; ++i){
			x = min(cnt[i], cnt[10 - i]);
			ans += x;
			cnt[i] -= x;
			cnt[10 - i] -= x;
		}
		
		ans += cnt[5] / 2;
		cnt[5] &= 1;
		
		ull s = 0;
		for(int i = 1; i <= 8; ++i){
			s |= (ull)cnt[i] << ((i - 1) * 8);
		}
		
		memo.clear();
		ans += dfs1(s);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1672
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,yen;
  cin>>n>>yen;
  int ans10=-1,ans5=-1,ans1=-1;
  rep(i,yen/10000+1){
    rep(j,n-i+1){
      if(9*i+4*j==yen/1000-n){
        ans10=i; ans5=j; ans1=n-i-j;
      }
    }
  }
  cout<<ans10<<" "<<ans5<<" "<<ans1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b=0;
  cin>>a>>b;
  int yen=0;
  bool broken=false;
  
  for(int i=0;i<1000;i++){
    yen=i+1;
    if(floor(yen*0.08)==a&&floor(yen*0.1)==b){
      cout<<yen;
      broken=true;
      break;
    }
  }
  if(!broken){
    cout<<-1;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N-1)]
process = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N+1)]
value = [0] * (N + 1)

for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

for que in process:
    value[que[0]] += que[1]

def dfs(s, parent, add):
    value[s] += add
    for x in graph[s]:
        if x == parent:
            continue
        dfs(x, s, value[s])

dfs(1, 0, 0)

ans =  ' '.join(map(str, value[1:]))

print(ans)

Measured memory_bytes: 301424
def gcd(x, y):
    while True:
        r = x % y
        x, y = y, r
        if r == 0:
            return x


def lcm(a, b):
    return a * b // gcd(a, b)


N = int(input())
T = [int(input()) for _ in range(N)]

ans = T[0]

for i in range(1, N):
    ans = lcm(ans, T[i])

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000
#define MAX_ABIT 42

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

llong N, X;

llong C(llong n) { return pow(2, n + 2) + EPS - 3; }
llong P(llong n) { return pow(2, n + 1) + EPS - 1; }

llong solve(llong n, llong pos, llong res) {
    //cout << n << " " << pos << " " << res << endl;
    if(n == 0) {
        if(X > pos)
            return res + 1;
        else if(X < pos - 1)
            return res - 2;
        else if(X == pos - 1)
            return res - 1;
        else
            return res;
    }

    if(X > pos) {
        return solve(n - 1, pos + C(n - 1) + 2, res + P(n - 1) + 1);
    } else if(X < pos) {
        return solve(n - 1, pos - C(n - 1) - 2, res - P(n - 1) - 1);
    } else return res;
}

int main(int argc, char **argv) {
    cin >> N >> X;

    cout << solve(N - 1, C(N - 1) + 2, P(N - 1) + 1) << endl;
}

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

typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)2e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );


int main( int argc, char const *argv[] ) {
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    if( abs( a-c ) <= d ) return cout << "Yes" << endl,0;
    if( abs(a-b) <= d && abs(b-c) <= d ) return cout << "Yes" << endl,0;
    cout << "No" << endl;
    return 0;
}








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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll a[5];
    ll ans = 0;
    
    ll m = 10;
    ll d = 0;
    for(ll i=0; i<5; i++)
    {
        cin >> a[i];

        if(a[i]%10!=0)
        {
            if(a[i]%10 < m)
            {
                m = a[i]%10;
                d = i;
            }
        }
    }

    if(m!=10)
    {
        for(ll i=0; i<5; i++)
        {
            if(i!=d && a[i]%10!=0)
            {
                ans+=(a[i]+10-a[i]%10);
            }

            else if(i!=d)
            {
                ans+=a[i];
            }
        }

        cout << ans+a[d] << endl;
    }

    else
    {
        for(ll i=0; i<5; i++)
        {
            if(a[i]%10!=0)
            {
                ans+=(a[i]+10-a[i]%10);
            }

            else
            {
                ans+=a[i];
            }
        }

        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256