akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  long long a,b;
  cin>>n>>a>>b;
  long long x[n];
  REP(i,n){
    cin>>x[i];
  }
  long long ans=0;
  REP(i,n-1){
    ans += min(a*(x[i+1]-x[i]),b);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int l = s.Length;
        int count = 0;
        int stack = 0;
        for(int i = 0;i < l;i++){
            if(s[i] == 'T'){
                if(stack == 0){
                    count++;
                }
                else{
                    stack--;
                }
            }
            else{
                stack++;
            }
        }
        Console.WriteLine(2*count);
    }
    void getinput(){
        s = Console.ReadLine();
    }    
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
// -2: back, -1: cw, 0: on, 1: ccw, 2: front
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L s, P p) { return ccw(s.s, s.t, p); }

P proj(P p, L l) {
  P e = l.vec() / l.abs();
  return l.s + dot(p - l.s, e) * e;
}
P refl(P p, L l) { return (R)2 * proj(p, l) - p; }
R distPP(P p, P q) { return abs(q - p); }
R distPL(P p, L l) { return distPP(p, proj(p, l)); }
R distPS(P p, L s) {
  P q = proj(p, s);
  if (!ccw(s, q)) return distPP(p, q);
  return min(distPP(p, s.s), distPP(p, s.t));
}
R distLL(L l, L m) {
  if (sgn(crs(l.vec(), m.vec()))) return 0;
  return distPL(l.s, m);
}
R distLS(L l, L s) {
  if (ccw(l, s.s) * ccw(l, s.t) != 1) return 0;
  return min(distPL(s.s, l), distPL(s.t, l));
}
R distSS(L s, L t) {
  if (ccw(s, t.s) * ccw(s, t.t) <= 0 and ccw(t, s.s) * ccw(t, s.t) <= 0) return 0;
  return min({distPS(s.s, t), distPS(s.t, t), distPS(t.s, s), distPS(t.t, s)});
}
P intxn(L l, L m) {
  assert(sgn(crs(l.vec(), m.vec())));
  return l.s + crs(m.s - l.s, m.vec()) / crs(l.vec(), m.vec()) * l.vec();
}

struct C { P o; R r; };
V<P> intxnCL(C c, L l) {
  int s = sgn(distPL(c.o, l), c.r);
  if (s > 0) return {};
  P p = proj(c.o, l);
  if (!s) return {p};
  P q = sqrt(c.r * c.r - norm(p - c.o)) * l.vec() / l.abs();
  return {p - q, p + q};
}
V<P> intxnCC(C c, C d) {
  R a = distPP(c.o, d.o);
  if (!sgn(a)) {
    assert(sgn(c.r, d.r));
    return {};
  }
  P p = polar(c.r / a, acos((a * a + c.r * c.r - d.r * d.r) / (2 * a * c.r)));
  return {c.o + conj(p) * (d.o - c.o), c.o + p * (d.o - c.o)};
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    C a; cin >> a.o >> a.r;
    C b; cin >> b.o >> b.r;
    R d = distPP(a.o, b.o);
    if (sgn(d, a.r + b.r) > 0) cout << 0 << '\n';
    else if (sgn(d + b.r, a.r) < 0) cout << 2 << '\n';
    else if (sgn(d + a.r, b.r) < 0) cout << -2 << '\n';
    else cout << 1 << '\n';
  }
}


Measured memory_bytes: 3260
#include <stdio.h>

int main(){
	int data[100][100], N, M, target[100], a, b, c, d = 0, e, score[100];
	scanf("%d\n", &N);
	scanf("%d\n", &M);
	for(a = 0; a < M; a++){
		scanf("%d", &target[a]);
	}
	for(b = 0; b < M; b++){
		for(c = 0; c < N; c++){
			scanf("%d", &data[b][c]);
		}
	}
	for(a = 0; a < 100; a++){
		score[a] = 0;
	}
	for(b = 0; b < M; b++){
		for(c = 0; c < N; c++){
			if(data[b][c] == target[d]){
				score[c] = score[c] + 1;
			}else{
				e = target[d] - 1;
				score[e] = score[e] + 1;
			}
		}
	d = d + 1;
	}
	for(a = 0; a < N; a++){
		printf("%d\n", score[a]);
	}
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, a, b; cin >> n >> a >> b;
    cout << min(a, b) << " ";
    cout << max(a + b - n, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    vector<vector<int>> bingo(3,vector<int>(3));
    vector<vector<bool>> atari(3,vector<bool>(3,false));
    int n;

    REP(i,3){
        REP(j,3)
            cin >> bingo[i][j];
    }
    cin >> n;
    REP(i,n){
        int val;
        cin >> val;
        
        REP(j,3){
            REP(k,3){
                if(bingo[j][k] == val){
                    atari[j][k] = true;
                }
            }
        }
    }
    int yokocnt = 0;
    int tatecnt = 0;
    int naname = 0;
    int renaname = 0;
    REP(i,3){
        REP(j,3){
            if(atari[i][j]){
                yokocnt++;
            }
            if(yokocnt == 3){
                Yes();
                return 0;
            }
            if(atari[j][i]){
                tatecnt++;
            }
            if(tatecnt == 3){
                Yes();
                return 0;
            }
            if(i == j && atari[i][j]){
                naname++;
            }
            if(naname == 3){
                Yes();
                return 0;
            }
            if(i == 0 && j == 2 && atari[i][j]){
                renaname++;
            }
            if(i == 1 && j == 1 && atari[i][j]){
                renaname++;
            }
            if(i == 2 && j == 0 && atari[i][j]){
                renaname++;
            }
            if(renaname == 3){
                Yes();
                return 0;
            }
        }
            yokocnt = 0;
            tatecnt = 0;
    }
    No();
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<u64>();
    let l = v[0];
    let r = v[1];

    let mut min:u64 = 2000000000;

    for i in l..r {
        if i % 2019 == 0 {
            min = 0;
            break;
        }
        for j in i+1..r+1 {
            if j % 2019 == 0 {
                min = 0;
                break;
            }
            //println!("{} {} {}", i, j, i*j%2019);
            min = std::cmp::min(min, i * j % 2019);
        }

        if min == 0 {
            break;
        }
    }
    println!("{}", min);
}


Measured memory_bytes: 4352
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc =new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt();
		    int b=sc.nextInt();
			int c=sc.nextInt();
		    int x=sc.nextInt();
		    int n=0;
		    for(int i=0;i<=a;i++){
		    	 for(int j=0;j<=b;j++){
		    	 for(int k=0;k<=c;k++){
		    	 	 	if((i*500+j*100+k*50)==x){
		    	 	 		n++;
		    	 	 	}
		    	 	 }
		    	 	
		    	 }
		    }
		    System.out.println(n);
		    
			
			
			
			
		}
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    int param = 0;

    cin >> n;
    if ((n>=700&&n<800))
    {
        param = 1;
    }
    n-=(n/100)*100;
    
    if ((n>=70&&n<80))
    {
        param = 1;
    }

    n-=(n/10)*10;
    if (n==7)
    {
        param = 1;
    }
    

    if (param==1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll s = -1;
    for (ll i = 0; i < n - 1; i++)
    {
        if (a[i] + a[i + 1] >= l)
        {
            s = i + 1;
            break;
        }
    }
    if (s == -1)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        cout << "Possible" << endl;
        for (ll i = 1; i <= s - 1; i++)
        {
            cout << i << endl;
        }
        for (ll i = n - 1; i >= s + 1; i--)
        {
            cout << i << endl;
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

string S;
string ORI;
int main(){
	cin >> S;
	ORI = S;

	reverse(S.begin(), S.end());
	for(int i = 0; i < S.size(); i++){
		if(S[i] == 'b'){
			S[i] = 'd';
		}else if(S[i] == 'd'){
			S[i] = 'b';
		}else if(S[i] == 'p'){
			S[i] = 'q';
		}else if(S[i] == 'q'){
			S[i] = 'p';
		}
	}
	if(S == ORI){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
ll geti(){
    ll ret=0;char ch=getchar(),k=1;
    while((ch<'0' || ch>'9') && ch!='-')ch=getchar();
    if(ch=='-')k=0,ch=getchar();
    while(ch>='0' && ch<='9')ret=ret*10+ch-'0',ch=getchar();
    return k?ret:-ret;
}
struct node {
    ll per,cost,percost;
} p[5];
bool cmp (const node &x,const node &y) {
    return x.percost<y.percost;
}
int main(){
    p[1].per=1; p[1].cost=geti(); p[1].percost=p[1].cost*8;
    p[2].per=2; p[2].cost=geti(); p[2].percost=p[2].cost*4;
    p[3].per=4; p[3].cost=geti(); p[3].percost=p[3].cost*2;
    p[4].per=8; p[4].cost=geti(); p[4].percost=p[4].cost;
    sort(p+1,p+5,cmp);
    ll n = geti()*4, ans = 0;
    for(int i=1;i<=4;i+=1) {
        ans += (n/p[i].per)*p[i].cost;
        n = n%p[i].per;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string make(string s, string a, string b)
{
	string x;
	for (int i = 0; i < s.size(); i++)
	{

		bool flag = true;

			for (int j = 0; j < a.size(); j++)
			{
				if (i + j >= s.size() || s[i + j] != a[j])
				{
					flag = false;
					break;
				}
			}
		
		if (flag)
		{
			i += a.size() - 1;
			x += b;
		}
		else
		{
			x += s[i];
		}
	}
	return x;
}

int dfs(string s, string ans, int t, int n, vector<string> a, vector<string> b)
{
	if (s.size() > ans.size() || t > 10)
		return 11;
	string w;
	int l = 11;
	for (int i = 0; i < n; i++)
	{
		w = make(s, a[i], b[i]);
		if (w == ans)
		{
			return t + 1;
		}
		if (s != w)
		{
			l = min(l, dfs(w, ans, t + 1, n, a, b));
		}
	}

	return l;
}

int main(void)
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0)
			break;
		vector<string> a(n), b(n);
		for (int i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i];
		}
		string s, ans;
		cin >> s >> ans;
		int k = dfs(s, ans, 0, n, a, b);
		if (k == 11)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << k << endl;
		}
	}

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string result = "";
    switch(n%10)
    {
        case 0:
        case 1:
        case 6:
        case 8:
            result = "pon";
            break;
        case 3:
            result = "bon";
            break;
        default:
            result = "hon";
            break;
    }
    cout << result << endl; 
}

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc086/tasks/abc086_a

#include<bits/stdc++.h>

using namespace std;

int main(){
	int a;
	int b;
	cin >> a >> b;
	int n = a*b;
	if(n%2==0){
		cout << "Even" << endl;
		return 0;
	}
	cout << "Odd" << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class BIncrementDecrement {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    int x   = 0;
    rep(i, N) {
      if (S[i] == 'I')
        x++;
      else if (S[i] == 'D')
        x--;
      ans = max(ans, x);
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  BIncrementDecrement solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int rs = 0;
	int cnt;
	for(int i = 1; i <= n; i++){
		cnt = 0;
		for(int j = 1; j <= i; j++)
			if(i % j == 0)
				cnt++;
		if(i % 2 == 1 && cnt == 8)
			rs++;
	}
	cout << rs;
	return 0;
}

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

int main() {
	// your code goes here
	int n,i;
	cin>>n;
	int ar[n+1],c[n+1]={0};
	ar[0]=0;
	for(i=1;i<=n;i++) cin>>ar[i];
	c[2]=abs(ar[2]-ar[1]);
	for(i=3;i<=n;++i)
	{
		c[i]=min( c[i-1] + abs(ar[i]-ar[i-1]) , c[i-2] + abs( ar[i]-ar[i-2] )  );
		
		
	}
	cout<<c[n];
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main() {
	int n,m;
	cin >> n >> m;
	cout << n*(n-1)/2+m*(m-1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) {
    ll ans=0,i,j,n;
    cin>>n;
    ll arr[n+1];
    for(i=0;i<n;i++)
        cin>>arr[i];
    ll dp[n+1];
    dp[0]=arr[0];
    for(i=1;i<n;i++)
        dp[i]=(dp[i-1]+arr[i])%hell;
    for(i=1;i<n;i++)
        ans=(ans+(arr[i]*dp[i-1])%hell)%hell;
    cout<<ans;
}
}


Measured memory_bytes: 6776
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int MAXN = 1e5 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e10 ;
struct node{
    int a,b;
    int index ;
} ;

string convert(int n){
    string str="";
    while(n > 0){
        str+=(char)(n%10 + '0');
        n/=10;
    }
    reverse(str.begin(),str.end());
    return str ;
}

ll powr(ll a,ll b,int m){
    if(b==0)
        return 1 ;
    ll x = powr(a,b/2,m)%m;
    x = (x*x)%m ;
    if(b%2)
        return ((x%m)*(a%m))%m ;
    return x ;
}
int main(){
    /* if(compare("99","9988"))
     cout<<"Yes\n"; */
    int x;cin>>x ;
    int mx=0;
    for(int i=1;i<=1000;i++)
        for(int j=2;j<=10;j++)
        {
            int v =pow(i,j);
            if(v > x)
                break ;
            else mx = max(mx,v);
        }
    cout<<mx<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  int n; cin >> n;
  int d,x; cin >> d >> x;
  vector<int> a(n) ;
  for(int i = 0;i < n; i++) cin >> a[i];
 
  // compute 
  vector<int> c(n) ;
  int sum = 0;
  int ans = 0;
  for(int i = 0; i < n; i++){
    c[i]= ((d - 1) / a[i]) + 1;
    sum += c[i];
  }

  ans = sum + x;
  
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var sb = new StringBuilder();
            char prevChar = ' ';
            foreach (var c in S)
            {
                if (c != prevChar)
                {
                    sb.Append(c);
                }

                prevChar = c;
            }

            Console.WriteLine(sb.Length);
        }
    }
}


Measured memory_bytes: 13120
X=int(input())
import sys

for a in range(10**6):
    A=a**5
    if A-X>=0:
        l,r=max(a-119,0),a
        for b in range(10):
            m=(l+r)//2
            B=m**5
            if A-B-X>0:
                l=m
            elif A-B-X<0:
                r=m
            else:
                print(a,m)
                sys.exit()
    else:
        l,r=0,64
        for b in range(10):
            m=(l+r)//2
            B=m**5
            if A+B-X>0:
                r=m
            elif A+B-X<0:
                l=m
            else:
                print(a,-m)
                sys.exit()
            

Measured memory_bytes: 9256
#include<bits/stdc++.h>// important code 5 :  
#define MAXN 100010
#define mod  1000000007
using namespace std;
int a[MAXN];
int  n,m;
int main()
{

    while(~scanf("%d %d",&n,&m))
    {
        a[1]=1;a[0]=1;
        while(m--)
        {
            int  t;
            scanf("%d",&t);
            if(t==1)
            {
                a[t]=0;
            }
            else
            {
                a[t]=-1;
            }
        }
        for(int i=2; i<=n; ++i)
        {
            if(a[i]==-1)
            {
                a[i]=0;
                continue;
            }
            else
            {
                a[i]=a[i-1]%mod+a[i-2]%mod;
                a[i]%=mod;
            }
        }
        printf("%d\n",a[n]);
    }
    return 0;

}


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

int main() {
    long long n;
    cin >> n;
    long long mod=1e9+7;
    long long a[1001];
    for(int i=0;i<=1000;i++) a[i]=0;
    long long ans=1;
    for(int i=2;i<=n;i++){
        for(int j=i+i;j<=n;j+=i) a[j]=1;
    }
    long long com;
    for(int i=2;i<=n;i++){
        if(a[i]==0){
            com=0;
            for(int j=i;j<=n;j*=i){
                com+=n/j;
            }
            ans=ans*(com+1)%mod;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll v, c9=0;
  string n;
  cin >> n;
  forll(i, 0, n.size()){
	if (n[n.size() - 1 - i] == '9')
	  c9 += 1;
	else
	  break;
  }
  ll r = n.size() - c9;
  if (r > 1)
	cout << 9 * (r - 1) + (ll)(n[0] - '0') - 1 + 9 * c9 << endl;
  else if (r == 1)
    cout << n[0] - '0' + 9 * c9 << endl;
  else
	cout << 9 * c9 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long


int main(){

	ll X, Y, r=0;
	cin >> X>> Y;

	while (X <= Y){
		X *= 2;
		r++;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50

def create_new_arr(DICT, SEQ):
    new_seq = ''
    next_id = 0
    for s in SEQ:
        if s not in DICT:
            DICT[s] = str(next_id)
            next_id += 1
        new_seq += DICT[s]
    return new_seq

def run():
    S, T = input(), input()
    s_dic = {}
    t_dic = {}

    new_S = create_new_arr(s_dic, S)
    new_T = create_new_arr(t_dic, T)

    if new_S == new_T:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    run()

Measured memory_bytes: 9924
using System;
using System.Linq;
class AS
{
static void Main()
{
while(true)
{
string gh=Console.ReadLine();
if(gh==null){break;}int[] df=gh.Split().Select(int.Parse).ToArray();
int a=df[0],b=df[1];
while(true)
{
if(a==0){Console.WriteLine(b);break;}else if(b==0){Console.WriteLine(a);break;}
if(a>b){a=a-b;}else{b=b-a;}
}
}

}
}

Measured memory_bytes: 9460
N = gets.to_i
S = gets.chomp.split(//)

animals = [
  ['S', 'S'],
  ['S', 'W'],
  ['W', 'S'],
  ['W', 'W']
]

paths = []
animals.each do |animal|
  path = animal.dup
  S.each_with_index do |c, i|
    next if i == 0 || i == S.length-1
    if path[i] == 'S'
      if c == 'o'
        path << (path[i-1] == 'S' ? 'S' : 'W')
      else
        path << (path[i-1] == 'S' ? 'W' : 'S')
      end
    else
      if c == 'o'
        path << (path[i-1] == 'S' ? 'W' : 'S')
      else
        path << (path[i-1] == 'S' ? 'S' : 'W')
      end
    end
  end
  paths << path
end

paths.each do |path|
  result = true
  S.each_with_index do |s, i|
    if path[i] == 'S'
      if s == 'o'
        if path[i-1] != (path[i+1] || path[0])
          result = false
          break
        end
      else
        if path[i-1] == (path[i+1] || path[0])
          result = false
          break
        end
      end
    else
      if s == 'x'
        if path[i-1] != (path[i+1] || path[0])
          result = false
          break
        end
      else
        if path[i-1] == (path[i+1] || path[0])
          result = false
          break
        end
      end
    end
  end
  if result
    puts(path.join)
    exit
  end
end
puts('-1')

Measured memory_bytes: 45876
l,r=map(int,input().split())

mod=2019
if r-l>=2019:
    print(0)
    quit()

ans=2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        tmp=i*j
        ans=min(ans,tmp%mod)
print(ans)

Measured memory_bytes: 41564
import fractions
 
import math
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
n = int(input())
a = list(map(int,input().split()))

c=0

z=lcm_list(a)

for i in range(0,n):
  c+=(z//a[i])
#print(z)
print(c%((10**9)+7))

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define INF 1LL<<59
struct edge{ll to,cost;};
typedef pair<ll,ll> P;
ll d[202020];
ll V=202020;
vector<edge> G[202020];

edge makeedge(ll t,ll c){
    edge e;
    e.to=t;
    e.cost=c;
    return e;
}

void addedge(ll s,ll t,ll c){
    G[s].push_back(makeedge(t,c));
    //G[t].push_back(makeedge(s,c)); //双方向
}

void dijkstra(ll s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s)); 

    while(!que.empty()){
        P p=que.top(); que.pop();
        ll v=p.second;
        if(d[v]<p.first) continue;
        for(ll i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i,j;
    ll n,m,s;
    cin>>n>>m>>s;
    s=min(s,(ll)2600);
    for(i=0;i<m;i++){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;
        v--;
        for(j=a;j<3000;j++) addedge(u*3000+j,v*3000+j-a,b);
        for(j=a;j<3000;j++) addedge(v*3000+j,u*3000+j-a,b);
    }
    for(i=0;i<n;i++){
        ll c,e;
        cin>>c>>e;
        c=min(c,(ll)2600);
        for(j=0;j+c<=2800;j++){
            addedge(i*3000+j,i*3000+j+c,e);
        }
    }
    dijkstra(s);
    for(i=1;i<n;i++){
        ll ans=INF;
        for(j=0;j<3000;j++) ans=min(ans,d[i*3000+j]);
        cout<<ans<<endl;
    }
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;


map<ll,ll> cc; 
int main(){
	fastio;
	ll n,p,ans = 0,ac = 0,pot = 1;
	string s;
	cin >> n >> p >> s;
	vi pos;
	if(p == 2) pos = {0,2,4,6,8};
	else if(p == 5) pos = {0,5};
	if(p == 2 || p == 5){
		f(i,0,n){
			bool go = false;
			f(j,0,pos.size()){
				if(s[i]-'0' == pos[j]) go = true;
			} 
			if(go) ans+= i+1;
		}
		cout << ans << endl;
		return 0;
	}
	
	cc[0] = 1;
	af(i,n-1,0){
	
		(ac += pot*(s[i]-'0') ) %=p;
		ans += cc[ac];
		cc[ac]++;
		(pot *= 10)%=p;
	}
	cout << ans << endl;

	
}

Measured memory_bytes: 4184
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n,m;
  cin>>n>>m;
  vl k(n),l(m);
  vvl a(n,vl(m));

  rep(i,n){
    cin>>k[i];
    rep(j,k[i]){
      cin>>a[i][j];
      l[a[i][j]-1]++;
    }
  }

  rep(i,m)if(l[i]==n)p++;
  print(p);

}

Measured memory_bytes: 3488
N = int(input())
ans = []
if N == 0:
    print(0)
    exit()
for i in range(10**10):
    if N == 0:
        break
    if N%2 == 1:
        ans.append("1")
        N -= (-1)**(i)
    else:
        ans.append('0')
    N = N // 2

print(''.join(ans[::-1]))

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author I.E
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

#pragma GCC optimize("Ofast")
static auto speedup = [](){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

class BJudgeStatusSummary {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        int ac = 0, wa = 0, tle = 0, re = 0;
        for (int i = 0; i < n; i++) {
            string s;
            in >> s;
            if (s == "AC") {
                ac += 1;
            } else if (s == "WA") {
                wa += 1;
            } else if (s == "TLE") {
                tle += 1;
            } else {
                re += 1;
            }
        }
        out << "AC x " << ac << endl;
        out << "WA x " << wa << endl;
        out << "TLE x " << tle << endl;
        out << "RE x " << re << endl;
	}
};


int main() {
	BJudgeStatusSummary solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3236
import java.util.Scanner;

public class Main{

	/**リング状の文字列の任意の位置から時計回りに連続した
	 * 文字をいくつか選んで特定の文字列が作れるかどうか。
	 * 
	 * @param args
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		String word_in_s = scan.next();
		String word_search_s = scan.next();
		
//		String word_in_s = args[0];
//		String word_search_s = args[1];

		String word_chain = word_in_s + word_in_s;			//検索文字列を２つつなげた
		int checker =0;

		checker = word_chain.indexOf(word_search_s);
		if(checker != -1){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}
}



Measured memory_bytes: 26272
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;


inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int mod = 1e9+7;
const int maxn=2e5+10;
ll num[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
			cin>>num[i];
		
		ll pre=0,sum=0;
		
		for(int i=0;i<n;i++)
			pre+=num[i];
		
		for(int i=0;i<n;i++)
		{
			pre-=num[i];
			sum+=(pre%mod*num[i]%mod)%mod;
			sum%=mod;	
		}
		
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5204
import java.util.*;

public class Main {
    public static List<String> permutation(String list) {
        List<String> ans = new ArrayList<>();
        if (list.length() == 1) {
            return Collections.singletonList(list);
        }
        for (int i = 0; i < list.length(); i++) {
            char pick = list.charAt(i);
            String rest = list.substring(0, i) + list.substring(i + 1);
            for (String rest_permutation : permutation(rest)) {
                ans.add(pick + rest_permutation);
            }
        }
        return ans;
    }
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        String[][] line = new String[2][1];
        for(int i = 0; i < 2; i++) {
            Arrays.fill(line[i], "");
            for(int j = 0; j < N; j++) {
                line[i][0] += scanner.next();
            }
        }
        String number = "";
        for(int i = 1; i <= N; i++) {
            number += i;
        }

        List<String> p = permutation(number);
        Integer R = 0;

        for (int j = 0; j < 2; j++) {
            for (int i = 0; i < p.size(); i++) {
                if(p.get(i).equals(line[j][0])) {
                    if(R==0)R+=i;
                    else R-=i;
                };
            }

        }
        System.out.println(Math.abs(R));
    }
}


Measured memory_bytes: 59816
import java.util.*;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if ((b-a)%2==0){
            System.out.println((b+a)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }

    }
}


Measured memory_bytes: 21844
N, M = gets.split.map &:to_i
A = $<.map {|l| l.split.map{|x| x.to_i }}

d = [-1e100] * N
d[0] = 0

M.times do
  A.each do |a,b,c|
    x = d[a-1] + c
    d[b-1] = x if d[b-1] < x
  end
end

e = d[N-1]

M.times do
  A.each do |a,b,c|
    x = d[a-1] + c
    d[b-1] = x if d[b-1] < x
  end
end

puts d[N-1] == e ? d[N-1] : 'inf'


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

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

  int out;

  if(s=="SUN") out = 7;
  if(s=="MON") out = 6;
  if(s=="TUE") out = 5;
  if(s=="WED") out = 4;
  if(s=="THU") out = 3;
  if(s=="FRI") out = 2;
  if(s=="SAT") out = 1;

  cout << out << endl;

  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
minv = gets.chomp.to_i
maxv = - 2 * 10 ** 9
for j in 1..(n - 1)
  maxv = [maxv, (input = gets.chomp.to_i) - minv].max
  minv = [minv, input].min
end

p maxv



Measured memory_bytes: 8860
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define mod 998244353
#define inf MOD 
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
void solve() {

}
int main() {
	ll n; cin >> n;
	ll a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	ll mini = inf;
	mini = min({ a,b,c,d,e });
	cout << (n - 1) / mini + 1 + 4 << endl;
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	//店舗の情報をソートする⇒クエリ毎にその点がどの店舗間にあるか調べる⇒両側のお店から近い距離を答えに追加する
	while (1) {
		ll d, n, m;//全長、本店含む店舗の個数、注文の個数
		ll adr[100000+10];//店舗の座標
		adr[0] = 0;
		cin >> d;
		if (d == 0) break;
		cin >> n >> m;
		repi(i, 1, n) {
			rd(adr[i]);
		}
		sort(adr, adr + n);
		ll ans = 0;
		repi(i, 0, m) {
			ll ki;
			ll *pos, idx;
			rd(ki);
			pos = lower_bound(adr, adr + n, ki);
			idx = distance(adr, pos);
			if (idx == 0) continue;
			else if (idx == n) ans += min(d - ki, ki - adr[n - 1]);
			else ans += min(adr[idx] - ki, ki - adr[idx - 1]);
		}
		wrln(ans);
	}
	return 0;
}


Measured memory_bytes: 3844
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        String s = sc.next();
        int ans=s.length();
        for (char i = 'a'; i <= 'z'; i++) {
            String t=s;
            int count = 0;
            if (!t.contains(Character.toString(i))) continue;
            while (!d(t)) {
                String temp = "";
                count++;
                for (int j = 0; j < t.length() - 1; j++) {
                    if (t.charAt(j + 1) == i) {
                        temp+=i;
                    }else {
                        temp+=t.charAt(j);
                    }
                }
                t=temp;
            }
            ans = min(ans, count);
        }
        out.println(ans);
    }
    static boolean d(String s){
        int c=0;
        for (int i = 0; i < s.length()-1; i++) {
            if(s.charAt(i)!=s.charAt(i+1)){
                c++;
                break;
            }
        }
        return c==0;
    }
}

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

using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e5 + 10;
const double eps = 1e-9;

int main() {
    int t = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        t += (s[i] == '+' ? 1 : -1);
    }
    cout << t << endl;
}

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

int main() {
	int k, x; cin >> k >> x;
	vector<int> ans;

	int count = 1;
	for (int i = x; i >= -1000000; i--)
	{
		if(count > k) break;

		ans.push_back(i);

		count++;
	}
	
	count = 2;
	for (int i = x+1; i <= 1000000; i++)
	{
		if(count > k) break;

		ans.push_back(i);

		count++;
	}
	
	sort(ans.begin(), ans.end());

	rep(i, ans.size()){
		cout << ans.at(i) << endl;
	}
}

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

const ll INF=1e18;

int main(){
  int N; cin>>N;
  pair<ll,ll> X[N];
  ll mi=INF,ma=-INF;
  rep(i,N){
    ll x,y; cin>>x>>y;
    if(x>y) swap(x,y);
    mi=min(mi,x);
    ma=max(ma,y);
    X[i]={x,y};
  }
  ll Rmi=mi,Rma=-INF,Bmi=INF,Bma=ma;
  rep(i,N){
    ll x=X[i].first, y=X[i].second;
    Rma=max(Rma,x);
    Bmi=min(Bmi,y);
  }
  ll ans=(Rma-Rmi)*(Bma-Bmi);
  Rmi=mi,Rma=ma,Bma=-INF,Bmi=INF;
  sort(X,X+N);
  ll Ymi=INF;
  Bma=X[N-1].first;
  for(int i=1;i<N;i++){
    Ymi=min(Ymi,X[i-1].second);
    Bma=max(Bma,X[i-1].second),Bmi=min(X[i].first,Ymi);
    ans=min(ans,(Rma-Rmi)*(Bma-Bmi));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a , b;
  string s, t, u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u){
    a--;
    cout << a << " " << b <<"\n";
    return 0;
  }
  if(t == u){
    b--;
    cout << a  << " " << b <<"\n";
    return 0;
  }
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int answer = 0;
	for(int i = 0; i * r <= n; ++i){
		for(int j = 0; j * g + i * r <= n; ++j){
			if((n - i * r - j * g) % b == 0){ ++answer; }
		}
	}
	cout << answer << endl;
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    float a[n],sum=0;
    string s[n];
    for(int i=0;i<n;i++){
        cin >> a[i] >> s[i];
    }
    for(int i=0;i<n;i++){
        if(s[i].compare("JPY") == 0){
            sum += a[i];
        }else{
            sum += (a[i] * 380000);
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 1000010
char s[MAXN],t[MAXN];
int n,p[MAXN],l,ans,x[MAXN],y[MAXN],sl,sr,k;
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	char ls=t[n];
	int np=n,flag=1;
	for(int i=1;i<=n;i++)
		if(s[i]!=t[i])
		{
			flag=0;
			break;
		}
	if(flag==1)
	{
		printf("0\n");
		return 0;
	}
	flag=1;
	for(int i=n-1;i>=0;i--)
		if(t[i]!=ls)
		{
			np=min(np,i+1);
			for(;np;np--)
				if(s[np]==ls)
				{
					p[i+1]=np;
					break;
				}
			if(np==0)
			{
				flag=0;
				break;
			}
			ls=t[i];
		}
	if(flag==0)
	{
		printf("-1\n");
		return 0;
	}
	ans=1;
	sl=0,sr=0;
	for(int i=1;i<=n;i++)
	{
		if(p[i]==0) continue;
		if(l>=p[i])
		{
			k++;
			ans=max(ans,y[sl]+k);
			l++;
		}
		else if(l<p[i]&&p[i]<i)
		{
			if(ans==1)
			{
				ans=2,l=i;
				x[sr]=i-k,y[sr++]=2-k;
			}
			else if(ans==2)
			{
				sl=sr;
				x[sr]=i-k,y[sr++]=2-k;
				l=i;
			}
			else
			{
				l=p[i];
				k++;
				for(int j=sl;j<sr;j++)
					if(x[sl]+k-1<p[i]) sl++;
					else
					{
						ans=max(ans,y[j]+k);
						break;
					}
				x[sr]=i-k,y[sr++]=2-k;
			}
		}
		else if(l<p[i]&&p[i]==i)
		{
			k=0;
			sl=sr;
			l=i;
		}
	}
	printf("%d\n",ans);
}
/*
5
abcde
aabcc

*/

Measured memory_bytes: 13824
n0 = int(input()) 
t0 = [input() for i in range(n0)] 
n1 = int(input()) 
t1 = [input() for i in range(n1)] 
s = set(t0) | set(t1)
l = max([sum([1 for x0 in t0 if x0 == i]) - sum([1 for x1 in t1 if x1 == i]) for i in s])
print(max(l,0))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

int main(){
	/*int x;
	cin >> x;
	cout << x / 100.0 << endl;
	cout << log10(x / 100.0) << endl;
	cout << log10(1.01) << endl;
	cout << (log10(x / 100.0)) / (log10(1.01));*/
	long long int x;
	long long int total = 100;
	int num = 0;
	cin >> x;
	while(total < x){
		total = total * 1.01;
		total = floor(total);
	//	cout << total << endl;
		num++;
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll fun(ll i,ll j)
{
    return ((i-j)*(i-j));
}
int main()
{
    long long int t,a[1010],d,j,ans=1e9+9,i,s;
   scanf("%lld",&t);
    for(i=0;i<t;i++)
       scanf("%lld",&a[i]);
    sort(a,a+t);
    s=0;
    for(i=a[0];i<=a[t-1];i++){
        for(j=0;j<t;j++){
           s+=fun(i,a[j]);
        }
        ans=min(ans,s);
        s=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3660