akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

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

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int val=7%n;
            for(int i=1;i<1e7;i++){
                if(val==0){
                    out.println(i);
                    return;
                }
                val=(val*10+7)%n;

            }
            out.println(-1);
        }
    }
}


Measured memory_bytes: 32992
def calc(left, right, time, vmax):
    if left <= time and time <= right:
        return vmax
    elif time < left:
        return vmax + left - time
    else:
        return vmax + time - right

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tlst = [[0, t[0]]]
for i in range(1, n):
    start = tlst[-1][1]
    stop = start + t[i]
    tlst.append([start, stop])

tmax = sum(t)
vnow = 0
ans = 0
for i in range(1, 2*tmax+1):
    time = 0.5 * i
    vmin = 10**9
    for j in range(n):
        left, right = tlst[j][0], tlst[j][1]
        vmax = v[j]
        vmin = min(vmin, calc(left, right, time, vmax))
    vmin = min(vmin, calc(0, 0, time, 0))
    vmin = min(vmin, calc(tmax, tmax, time, 0))
    ans += 0.25 * (vmin + vnow)
    vnow = vmin
print(ans)

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

int n;
char ope[10];

int main()
{
	int n;
	char ope[10];
	int tmp;
	cin >> n;
	while(n){
		int top=1,N=5,S=2,W=4,E=3,bottom=6;
		int ans = 1;
		for(int i=0;i<n;i++){
			cin >> ope;
			switch(ope[0]){
				case 'N':
					tmp=top; top = S; S=bottom;bottom=N;N=tmp;
					break;
				case 'E':
					tmp=top; top=W; W=bottom; bottom=E; E=tmp;
					break;
				case 'S':
					tmp=top; top=N; N=bottom; bottom=S; S=tmp;
					break;
				case 'W':
					tmp=top; top=E; E=bottom; bottom=W; W=tmp;
					break;
				case 'R':
					tmp=S; S=E; E=N; N=W; W=tmp; 
					break;
				case 'L':
					tmp=S; S=W; W=N; N=E; E=tmp;
					break;
			}
			ans += top;
		}
		cout << ans << endl;
		cin >> n;
	}
	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int MOD = 998244353;
    int N, K; cin>>N>>K;
    vec_int L(K), R(K);
    rep(i, K)cin>>L.at(i)>>R.at(i);

    vec_int DP(N+1,0);

    DP.at(1) = 1;

    vec_int DP_temp(K,0);
    for(int i=2;i<N+1;i++){
        for(int k=0;k<K;k++){
            // i- L[k] ~ i-R[k]までの区間のDPを足す
            if(i<=L.at(k)){
                //範囲外
                continue;
            }else if(i<=R.at(k) && i>L.at(k)){
                DP_temp.at(k) += DP.at(i-L.at(k));
            }else{
                DP_temp.at(k) += DP.at(i-L.at(k));
                DP_temp.at(k) -= DP.at(i-R.at(k)-1);
            }
//            DP.at(i) = DP_temp.at(k)%MOD;
            DP.at(i) = (DP.at(i)+DP_temp.at(k))%MOD;
        }
    }
    cout<<DP.at(N)%MOD<<endl;








    return 0;
}

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

int main() {
    int n,l;
    cin >> n >> l;
    string s[110];
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s,s+n);
    string str; // これで，空文字が生成される．
    for(int i = 0; i < n; ++i) {
        str += s[i];
    }
    cout << str << endl;

}

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

int main() {
  int a=100100,z=-1;
  string s;
  cin >> s;
  rep(i,s.size()){
    if (s[i]=='A') a=min(a,i);
    if (s[i]=='Z') z=max(z,i);
  }
  cout << z-a+1 << endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n, c;
int d[100][100], a[510][510]; 
vector<int> z(100, 0), o(100, 0), t(100, 0); 

ll solve(ll c1, ll c2, ll c3){
	ll ans = 0;
	rep(i, c){
		ans += d[i][c1] * z[i];
		ans += d[i][c2] * o[i];
		ans += d[i][c3] * t[i];
	}
	return ans;
}

int main() {
	cin >> n >> c;
	rep(i, c)rep(j, c)cin >> d[i][j];	
	rep(i, n)rep(j, n){
		cin >> a[i][j];
		if((i+j+2) % 3 == 0)z[a[i][j]-1]++;
		if((i+j+2) % 3 == 1)o[a[i][j]-1]++;
		if((i+j+2) % 3 == 2)t[a[i][j]-1]++;
	}
	ll ans = inf;
	for(int i = 0; i < c; i++){
		for(int j = 0; j < c; j++){
			if(i == j)continue;
			for(int k = 0; k < c; k++){
				if(k == i || k == j)continue;
				ans = min(ans, solve(i, j, k));
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int N;
  cin >> N;
  if (N % 10 == 3) cout << "bon" << endl;
  else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3652
//
// Created by Myabu on 2020/01/04.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    string S;
    cin>>S;
    
    int count_0 = 0;
    int count_1 = 0;

    for (char i : S) {
        if(i == '0'){
            count_0 ++;
        }else{
            count_1 ++;
        }
    }

    cout<<min(count_0, count_1) * 2<<endl;


    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

class Dice {
public:
    vector<int> eyes;
    Dice(vector<int> v) {
        eyes = v;
    }
    void rotate(char dist, bool rev);
    bool match(Dice dice);
};

void Dice::rotate(char dist, bool rev = false) {
    if (rev) {
        string s = "ENRLSW";
        dist = s[5 - s.find(dist)];
    }
    switch (dist) {
    case 'E':
        swap(eyes[0], eyes[3]);
        swap(eyes[3], eyes[5]);
        swap(eyes[5], eyes[2]);
        break;
    case 'W':
        swap(eyes[0], eyes[2]);
        swap(eyes[2], eyes[5]);
        swap(eyes[5], eyes[3]);
        break;
    case 'N':
        swap(eyes[0], eyes[1]);
        swap(eyes[1], eyes[5]);
        swap(eyes[5], eyes[4]);
        break;
    case 'S':
        swap(eyes[0], eyes[4]);
        swap(eyes[4], eyes[5]);
        swap(eyes[5], eyes[1]);
        break;
    case 'L':
        swap(eyes[1], eyes[2]);
        swap(eyes[2], eyes[4]);
        swap(eyes[4], eyes[3]);
        break;
    case 'R':
        swap(eyes[1], eyes[3]);
        swap(eyes[3], eyes[4]);
        swap(eyes[4], eyes[2]);
        break;
    }
}

bool Dice::match(Dice dice) {
    string rot = "RRRRERRRWRRRWRRRERRRERRR";
    for (int i = 0; i < rot.size(); i++) {
        dice.rotate(rot[i]);
        if (this->eyes == dice.eyes) return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<Dice> dices;
    for (int i = 0; i < n; i++) {
        vector<int> d(6); for (int j = 0; j < 6; j++) cin >> d[j];
        dices.push_back(Dice(d));
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dices[i].match(dices[j])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3252
#include<stdio.h>
int main(void)
{
	int n,w,a,k,e;
	scanf("%d",&n);
	e=n;
	while(1){
		a=n%10;
		w+=a;
		n=n/10;
		if(n==0){
			break;
		}
	}
	k=e%w;
	if(k==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int n,a,b,c,k;
	
	cin >> n ;
	cin >> a ;
	cin >> b ;
	if(a<b){
		k=a;  a=b;  b=k;
	}
	
	while(b!=0){
		a=a%b;
		k=a;  a=b;  b=k;
	}
	
	if(n==3){
		cin >> c ;
		if(a>c){
			k=a;  a=c;  c=k;
		}
		while(c!=0){
		a=a%c;
		k=a;  a=c;  c=k;
		}
	}
	
	for(int i=1;i<=a;i++){
		if(a%i==0){
			cout << i <<"\n";
		}
	}
	
return 0;
}

Measured memory_bytes: 1160
#include "stdio.h"
#include<iostream>

using namespace std;

int getParentNumber(int i){
  return int(i/2);
}

int getChildLeft(int i){
  return 2*i;
}

int getChildRight(int i){
  return 2*i+1;
}


int main(void){
  
  int N;
  scanf("%d", &N);
  
  int* data = new int [N+1];
  
  for(int i=1;i<N+1;i++){
    cin >> data[i];
  }
  
  for(int i=1;i<N+1;i++){
    printf("node %d: ", i);
    printf("key = %d, ", data[i]);
    
    if(1 <= getParentNumber(i)){
      printf("parent key = %d, ", data[getParentNumber(i)]);  
    }  

    if(getChildLeft(i) <= N){
      printf("left key = %d, ", data[getChildLeft(i)]);
    }

    if(getChildRight(i) <= N){
      printf("right key = %d, ", data[getChildRight(i)]); 
     }

    printf("\n");
  
  };

  delete [] data;

  return 0;
}



Measured memory_bytes: 3208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var Bs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var Cs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var ret = 0;
            for (int i = 0; i < As.Count(); i++)
            {
                ret += Bs[As[i] - 1];
                if (i != 0 && As[i] - As[i - 1] == 1)
                    ret += Cs[As[i] - 2];
            }
            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 13396
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int ketawa(int n) {
	int ret = 0;
	while (n >= 10) {
		ret += (n%10);
		n /= 10;
	}
	ret += n;
	return ret;
}

int main() {
	cin >> n;
	int ans = INF;
	for (int i = 1; i < n; i++) {
		ans = min(ans, ketawa(i) + ketawa(n - i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
S_str=str(input())
S=int(S_str[-1])
N=len(S_str)

mod=[0]*2019
mod[0]=1
now=S%2019
mod[now]+=1

for i in range(N-1)[::-1]:
    #print(i+1,S,S%2019)
    next=pow(10,N-1-i,2019)
    next=(next*int(S_str[i]))%2019
    now=(now+next)%2019
    mod[now]+=1

    

def culc(x):
    return x*(x-1)//2


ans=0
for j in range(len(mod)):
    ans+=culc(mod[j])

print(ans)




Measured memory_bytes: 9376
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int i;
  string s,t;
  int c[26],m[26];
  cin >> s >> t;
  for(i=0;i<s.size();i++){
    cout << s[i];
    if(i<t.size())
      cout << t[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
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
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS
 

  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i<n;i++) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  int ans = a[0];
  if(n%2 == 0){
    for(int i = 1;i<=(n-2)/2;i++){
      ans += a[i]*2;
    }
  }
  else{
    for(int i = 1;i<=(n-2)/2;i++){
      ans += a[i]*2;
    }
    ans += (a[(n-2)/2 + 1]);
  }
  cout<<ans<<endl;
  
  
  


  
}

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

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



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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll, P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    for(int i=0;i<n-1;i++){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let mut s = s;
    s.dedup();
    println!("{}", s.len() - 1);
}


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

int main()
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a,a+3);
  
  ll ans = 0;
  if(a[0] % 2 == a[1] % 2 && a[0] % 2== a[2] % 2)
  {
    ans = (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2;
  }else if(a[0] % 2 == a[1] % 2 && a[0] % 2 != a[2] % 2)
  {
    a[0]++; a[1]++;
    ans++;
    ans += (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2;
  }else if(a[0] % 2 != a[1] % 2 && a[0] % 2 == a[2] % 2)
  {
    a[0]++; a[2]++;
    ans++;
    ans += (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2;
  }else
  {
    a[1]++; a[2]++;
    ans++;
    ans += (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n=int(input())
    ar=inpt()
    mx=ar[0]
    mn=10000000
    amt=1000
    s=0
    for i in ar:
        if(i<mx):
            s=amt//mn
            amt=amt%mn
            amt+=(s*mx)
            mn=i
            mx=i
        mx=max(mx,i)
        mn=min(mn,i)
    s = amt // mn
    amt = amt % mn
    amt += (s * mx)
    print(amt)


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 67724
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    readln;
    auto N = nk[0];
    auto K = nk[1];
    int c;
    while (N > 1) {
        ++c;
        N -= K-1;
    }
    writeln(c);
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    print(s == "ABC" ? "ARC" : "ABC");
    return 0;
}

Measured memory_bytes: 3600
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N; cin >> N;
	vector<string> v(3);
	rep(i, 3) cin >> v[i];

	int ans = 0;
	rep(k, N){
		vector<int> alpha_cnt(30);
		int cnt_tmp = 0;
		rep(i, 3){
			int d = v[i][k] - 'a';
			// print(d);
			alpha_cnt[d]++;
			chmax(cnt_tmp, alpha_cnt[d]);
		}
		ans += 3 - cnt_tmp;
	}
	cout << ans << endl;

	return 0;
}


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

namespace C_ABC176
{
    class MainClass
    {

        static int[] n;
        static long[] s;

        public static void Main(string[] args)
        {
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);

            long tmp = 0;
            long ans = 0;
            for (int i = 0; i < n[0]; i++)
            {
                if (tmp > s[i])
                {
                    ans += tmp - s[i];
                    s[i] += tmp - s[i];

                }
                tmp = s[i];
            }
            WriteLine(ans);



        }

        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	bool good = true;
	if (s[n-1] == '1') good = false;
	if (s[0] == '0') good = false;
	for (int q = 0; q < n-1; q++) if (s[q] != s[n-2-q]) good = false;
	if (!good)
	{
		cout << "-1\n";
		return 0;
	}
	vector<pair<int,int>> edges(n-1);
	int ptr = 0, verticesused = 2, lastused = 2;
	edges[ptr++] = {1,2};
	for (int q = 1; q < n/2; q++)
	{
		if (s[q] == '0')
		{
			verticesused++;
			edges[ptr++] = {verticesused, lastused};
		}
		else
		{
			verticesused++;
			edges[ptr++] = {verticesused, lastused};
			lastused = verticesused;
		}
	}
	while (ptr < n-1)
	{
		verticesused++;
		edges[ptr++] = {verticesused, lastused};	
	}
	for (auto e : edges) cout << e.first << " " << e.second << "\n";
	return 0;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//BELOW
void solve(void)
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<bool> visited(n, false);
  // > vec (n,0);
  vector<int> path;
  function<void(int)> go = [&](int x) {
    visited[x] = true;
    path.push_back(x);
    for (int xx : graph[x])
    {
      if (visited[xx] == false)
      {
        go(xx);
        break;
      }
    }
  };

  go(0);
  reverse(ALL(path));
  visited[0] = false;
  path.pop_back();
  go(0);
  cout << path.size() << endl;
  for (int i = 0; i < path.size(); i++)
  {
    if (i != 0)
      cout << char(32);
    cout << path[i] + 1;
  }
  cout << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 13768
#!/usr/bin/env python3

import itertools
import sys


def construct(h, w, k, stage):
    table = [[None for _ in range(w)] for _ in range(h)]
    berries = []
    for r, c in itertools.product(range(h), range(w)):
        if stage[r][c] == "#":
            berries.append((r, c))
    for idx, (r0, c0) in enumerate(berries, start=1):
        table[r0][c0] = idx
        # up
        for r in range(0, r0)[::-1]:
            if table[r][c0] is not None or stage[r][c0] == "#":
                break
            else:
                table[r][c0] = idx
        # down
        for r in range(r0 + 1, h):
            if table[r][c0] is not None or stage[r][c0] == "#":
                break
            else:
                table[r][c0] = idx
    # empty-left-to-right
    for c0 in range(w - 1):
        if all(table[r][c0] is None for r in range(h)):
            for r in range(h):
                for c in range(c0 + 1, w):
                    if table[r][c] is not None:
                        table[r][c0] = table[r][c]
                        break
    # empty-right-to-left
    for c0 in range(1, w)[::-1]:
        if all(table[r][c0] is None for r in range(h)):
            for r in range(h):
                for c in range(c0)[::-1]:
                    if table[r][c] is not None:
                        table[r][c0] = table[r][c]
                        break
    return table


def main():
    h, w, k = (int(z) for z in input().split())
    stage = [input() for _ in range(h)]
    res = construct(h, w, k, stage)
    for line in res:
        print(*line)
    return
    # debug
    print("------", file=sys.stderr)
    print(h, w, k, file=sys.stderr)
    for line in stage:
        print(*line, file=sys.stderr, sep="")
    print("------", file=sys.stderr)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_RegularTriangle solver = new A_RegularTriangle();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_RegularTriangle {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(a == b && b == c ? "Yes" : "No");
        }

    }

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

        public FastScanner(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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 19796
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, k;
    cin >> n >> k;
    ll ans = k;
    for (int i = 1; i < n; i++) {
        ans *= k - 1;
    }
    cout << ans << endl;
}



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


int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M),R(M);
  for(int i=0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
  }
  int m_R = *min_element(R.begin(),R.end());
  int M_L = *max_element(L.begin(),L.end());
  int ans = m_R - M_L + 1;
  if(ans<0)ans = 0;

  cout << ans << endl;
}

Measured memory_bytes: 1024
# C - Synthetic Kadomatsu
'''
100, 90, 80
98, 80, 40, 30, 21
L[0]〜L[N-1]がそれぞれ、A,B,C,使わないのいずれかかを考える。
4**8=65536
'''
import itertools
INF = 10**18
N, A, B, C = map(int, input().split())
L = [0] * N
for i in range(N):
    L[i] = int(input())
    
c = (0, 1, 2, 3) # 3は使わない
ans = INF

for comb in itertools.product(c,repeat=N):
    tmp = [0]*4 
    ansArr = [0]*3
    #print(comb)
    for i, j in enumerate(comb):
        if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
    if tmp[0]==0 or tmp[1]==0 or tmp[2]==0:
        continue
    ansArr[0] += abs(A-tmp[0])
    ansArr[1] += abs(B-tmp[1])        
    ansArr[2] += abs(C-tmp[2])
    #print(tmp)
    #print(ansArr)
    ans = min(ans, sum(ansArr))
    #print(ans)

print(ans)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_M = (int)(2e5 + 5);

int m;

ll d[MAX_M];
ll c[MAX_M];

int main(void) {
  // Here your code !
  scanf("%d", &m);

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

  ll whole = 0LL;
  for (int i = 0; i < m; ++i) {
    whole += d[i] * c[i];
  }

  ll digit = 0LL;
  for (int i = 0; i < m; ++i) {
    digit += c[i];
  }

  // cout << whole << endl;

  ll ans = (digit - 1LL) + (whole / 9LL);

  if (whole % 9LL == 0LL) {
    ans -= 1LL;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, temp;
    cin >> a >> b >> c;
    temp = a;
    a = b;
    b = temp;

    temp = a;
    a = c;
    c = temp;
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> choco(H);
  REP(i,H){
    cin >> choco[i];
  }
  
  ll ans = H+W-2;
  REP(h,1<<H-1){
      ll cur = 0;
      bool isOKi = true;
      // 縦の分割
      map<ll,ll> cut;
      REP(i,H){
          if (h>>i&1){
            cur++;
            cut[i+1] = 0;
          }
      }
      cut[H] = 0; 
      // 横を貪欲
      ll left = -1;
      ll right = 0;
      while(right<W){
        ll top = 0;
        bool isOK = true;
        for (auto itr=cut.begin(); itr!=cut.end(); ++itr){
            ll bottom = itr->first;
            REP3(i, top, bottom){
                itr->second += (choco[i][right] == '1') ? 1 : 0;
            }
            //cout << h << " " << right << " " << up << "-" << bottom << ":" << itr->second << "\n";
            if (itr->second > K){
                if (right-left==1){
                    isOKi = false;
                    break;
                } else {
                  isOK = false;
                }
            }
            top = bottom;
        }
        if (!isOKi) {
          break;
        }
        if (!isOK) {
            left = right-1;
            cur++;
            for (auto itr=cut.begin(); itr!=cut.end(); ++itr){
                cut[itr->first] = 0;
            }           
        } else {
          right++;
        }
      }
      //cout << h << " " << cur << "\n";
      if (isOKi){
          ans = min(ans, cur);
      }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
<?php
/*
function RoundRobinScheduling ($N, $TMAX, $A) {
  $arr = array();
  $total = 0;
  $br = '';
  while($A) {
    $v = array_shift($A);
    $t = $v[1];
    if ($t <= $TMAX) {
      $total += $t;
      echo($br);
      if (!$br) {
        $br = "\n";
      }
      echo($v[0].' '.$total);
    } else {
      $total += $TMAX;
      $v[1] = $t - $TMAX;
      $A[] = $v;
    }
  }
}
*/
/*
function RoundRobinScheduling (&$N, $TMAX, $A) {
  $arr = array();
  $total = 0;
  $br = '';
  $index = $N;
  $skip = true;
  while($index < $N || $skip) {
    if ($index >= $N) {
      $skip = false;
      $index = 0;
    }
    $v = &$A[$index];
    if (!$v) {
      $index++;
      continue;
    }
    $t = $v[1];
    if ($t <= $TMAX) {
      $total += $t;
      echo($br);
      if (!$br) {
        $br = "\n";
      }
      echo($v[0].' '.$total);
      $A[$index] = NULL;
    } else {
      $total += $TMAX;
      $v[1] = $t - $TMAX;
      $skip = true;
    }
    $index++;
  }
}
*/

function RoundRobinScheduling ($N, $TMAX, $A) {
  $arr = array();
  $total = 0;
  $br = '';
  while($A->count()) {
    $v = $A->shift();
    $t = $v[1];
    if ($t <= $TMAX) {
      $total += $t;
      echo($br);
      if (!$br) {
        $br = "\n";
      }
      echo($v[0].' '.$total);
    } else {
      $total += $TMAX;
      $v[1] = $t - $TMAX;
      $A->push($v);
    }
  }
}

list($N, $T) = array_map('intval', explode(' ', trim(fgets(STDIN))));
$A = new SplQueue();
for($i=0;$i<$N;$i++) {
  $A->push(explode(' ', trim(fgets(STDIN))));
}
RoundRobinScheduling($N, $T, $A);

?>



Measured memory_bytes: 39232
#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 MAX = 510000;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * (ll)i % mod;
    inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  COMinit();
  if(n < k) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  rep(i,k) {
    if(i % 2 == 0) (ans += Pow(k-i,n) * COM(k,k-i)) %= mod;
    else (ans -= Pow(k-i,n) * COM(k,k-i)) %= mod;
  }
  if(ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 15040
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = ""
    for i in range(2):
        tmp = ""
        if i:
            tmp += "D"
            tmp += "R"*(x+1)
            tmp += "U"*(y+1)
            tmp += "L"

        else:
            tmp += "R"*x
            tmp += "U"*y
        s += tmp + tmp.translate(str.maketrans({"U": "D",
                                                "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9088
// 簡易競プロテンプレ
#include <bits/stdc++.h>
using namespace std;

int main(void){
 long long a,b,c; cin >> a >> b >> c;
 if ((a%2==0) || (b%2==0) || (c%2==0)) cout << 0 << endl;
 else{
  cout << min(min(a*b, b*c), c*a) << endl;
 }
 
 return 0;
}

Measured memory_bytes: 256
const gcd = (a, b) => {
    if (b === 0) return a;
    else if (a === 0) return b;
    return gcd(b, a%b);
}

const initGCD = (n, a) => {
    let L = [...new Array(n)].fill(0)// aをiで分けたときの左部分GCD
    let R = [...new Array(n)].fill(0)// aをiで分けたときの右部分GCD
    L[0] = R[n-1] = 0
    for(let i=1; i<n; i++) {
        L[i] = gcd(L[i-1], a[i-1])
        R[n-i-1] = gcd(R[n-i], a[n-i])
    }
    return [L,R]
}

const main = (arg) => {
    const n = Number(arg.split("\n")[0])
    const a = arg.split("\n")[1].split(" ").map(Number)

    const [L,R] = initGCD(n, a)

    const m = [...new Array(n)].fill(0)// gcd when ai is excluded
    for(let i=0; i<n; i++) {
        m[i] = gcd(L[i],R[i])
    }
    console.log(Math.max(...m))
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 45656
#include <bits/stdc++.h>
#define ll long long int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  ll l, r;
  cin >> l >> r;

  if (r - l + 1 >= 2019)
  {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 2200;
  FOR(i, l, r)
  {
    FOR(j, i + 1, r + 1)
    {
      ans = min(ans, (i * j) % 2019);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    N = int(input())
    if N==0:
        break
    a = 0
    for i in range(1,N):
        s = 0
        for j in range(i,N+1):
            s += j
            if s == N:
                a += 1
                
            elif s > N:
                break
            
    print(a)
        


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

int main() {
  int X, cnt=2000;
  cin >> X;
  for(int i=1; i<33; i++) {
    for(int j=2; j<10; j++) {
      if(cnt>X-pow(i, j)&&X>=pow(i, j)) {
        cnt=X-pow(i, j);
      }
    }
  }
  cout << X-cnt << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int gcd(int x, int y)
{
  int d, tmp;

  d = x % y;

  if(x > y){            //数字の入れ替え
    tmp = x;
    x = y;
    y = tmp;
  }

  while(d != 0){      //ユークリッドの互除法を使用
    x = y;
    y = d;
    d = x % y;
  }
  return y;
}

int main(void)
{
  int x, y;

  scanf("%d %d", &x, &y);

  printf("%d\n", gcd(x, y));

  return 0;
}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(1<<n);
    for(int i=0;i<1<<n;i++) cin >> a[i];
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<1<<i;j++){
            if(a[2*j] != a[2*j+1]){
                a[j] = abs(a[2*j]-a[2*j+1]);
            }else{
                a[j] = a[2*j];
            }
        }
    }
    cout << a[0];
    return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> cnt('z' - 'a' + 1, INT_MAX);
  for (int j = 0; j < n; ++j) {
    string e;
    cin >> e;
    for (size_t i = 0; i < cnt.size(); ++i) {
      cnt[i] = min(cnt[i], (int)count(e.begin(), e.end(), 'a' + i));
    }
  }
  string ans;
  for (size_t i = 0; i < cnt.size(); ++i) {
    for (int j = 0; j < cnt[i]; ++j) {
      ans.push_back('a' + i);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int count = 0;

    for (int i = 0; i <= N/R; i++) {
        for (int j = 0; j <= N/G; j++) {
            if (N - (i*R + j*G) >= 0 && (N - (i*R + j*G)) % B == 0){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3612
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		boolean[][] map = new boolean[5001][5001];
		int[] xs = new int[3001];
		int[] ys = new int[3001];
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i <= 5000; i++)
				for (int j = 0; j <= 5000; j++)
					map[i][j] = false;
			
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt(), y = sc.nextInt();
				map[x][y] = true;
				xs[i] = x;
				ys[i] = y;
			}
			int res = 0;
			for (int i = 0; i < n-1; i++) {
				for (int j = i+1; j < n; j++) {
					int dx = Math.abs(ys[i] -ys[j]), dy = Math.abs(xs[i] -xs[j]);
					if ((xs[i] >= xs[j]) == (ys[i] >= ys[j])) {
						int X1 = xs[i]-dx, X2 = xs[j]-dx, Y1 = ys[i]+dy, Y2 =ys[j]+dy;
						if (0 <= X1 && X1 <= 5000 && 0 <= X2 && X2 <= 5000 &&
								0 <= Y1 && Y1 <= 5000 && 0 <= Y2 && Y2 <= 5000 &&
								map[X1][Y1] && map[X2][Y2]) {
							res = Math.max(res, dx*dx+dy*dy);
						} else {
							X1 = xs[i]+dx; X2 = xs[j]+dx; Y1 = ys[i]-dy; Y2 =ys[j]-dy;
							if (0 <= X1 && X1 <= 5000 && 0 <= X2 && X2 <= 5000 &&
									0 <= Y1 && Y1 <= 5000 && 0 <= Y2 && Y2 <= 5000 &&
									map[X1][Y1] && map[X2][Y2]) {
								res = Math.max(res, dx*dx+dy*dy);
							}
						}
					} else {
						int X1 = xs[i]+dx, X2 = xs[j]+dx, Y1 = ys[i]+dy, Y2 =ys[j]+dy;
						if (0 <= X1 && X1 <= 5000 && 0 <= X2 && X2 <= 5000 &&
								0 <= Y1 && Y1 <= 5000 && 0 <= Y2 && Y2 <= 5000 &&
								map[X1][Y1] && map[X2][Y2]) {
							res = Math.max(res, dx*dx+dy*dy);
						} else {
							X1 = xs[i]-dx; X2 = xs[j]-dx; Y1 = ys[i]-dy; Y2 =ys[j]-dy;
							if (0 <= X1 && X1 <= 5000 && 0 <= X2 && X2 <= 5000 &&
									0 <= Y1 && Y1 <= 5000 && 0 <= Y2 && Y2 <= 5000 &&
									map[X1][Y1] && map[X2][Y2]) {
								res = Math.max(res, dx*dx+dy*dy);
							}
						}
					}
				}
			}
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 87084
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;//不用开数组
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>x>>y;//输入每组数据
        if(!(x+y<=t&&(t-x-y)%2==0)){//判断是否符合
            cout<<"No"<<endl;//不符合
            return 0;}}//避免重复输出
    cout<<"Yes"<<endl;//全部符合
    return 0;
}

Measured memory_bytes: 256