akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
const long long MOD = 1e9+7;
using namespace std;


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

	int A,B;
	cin >> A >> B;

	if (A==1 && B==2) {
		cout << 3 << endl;
	} else if (A==2 && B==3) {
		cout << 1 << endl;
	} else if (A==3 && B==1) {
		cout << 2 << endl;
	} else if (A==2 && B==1) {
		cout << 3 << endl;
	} else if (A==3 && B==2) {
		cout << 1 << endl;
	} else if (A==1 && B==3) {
		cout << 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 3576
import java.util.*;
public class Main {
    
    static int[] g = null;
    
    // Incredible problem. Truly humbled by those ace coders solution at AtCoder
  	// I give myself C for effort
    static void solve(){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();   
        int K = sc.nextInt();
        int NOC = N;
        int i = 0; 
        g = new int[N];
        while(NOC-->0) g[i++] = sc.nextInt();
        for(i=0; i<N-K; i++) System.out.println((g[i]<g[i+K])? "Yes" : "No");
        sc.close();
    }
    
    public static void main(String args[]) {
        solve();
    }
}


Measured memory_bytes: 60228
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    String n1 = n.substring(0,1);
    String n2 = n.substring(1,2);
    String n3 = n.substring(2,3);
    String a1 = "9";
    String a2 = "9";
    String a3 = "9";

    if (n1.equals("9")) {
      a1 = "1";
    }

    if (n2.equals("9")) {
      a2 = "1";
    }

    if (n3.equals("9")) {
      a3 = "1";
    }

    System.out.println(a1 + a2 + a3);

  }
}

Measured memory_bytes: 23508
N = int(input())

A = input()
B = input()
C = input()

count = 0

for i in range(N):
    if A[i] == B[i] != C[i]:
        count += 1
    elif B[i] == C[i] != A[i]:
        count += 1
    elif C[i] == A[i] != B[i]:
        count += 1
    elif A[i] != B[i] != C[i]:
        count += 2

print(count)

Measured memory_bytes: 3064
m,d=map(int,input().split())


ans=0
if d<22:
    print(0)
    exit()
    
else:
    d1=int(str(d)[0])
    d2=int(str(d)[1])
    for i in range(2,10):
        for j in range(2,10):
            if i*j<=m and 10*i+j<=d and j!=1:
                ans+=1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n,x,t;
    scanf("%lli %lli %lli", &n,&x,&t);
    if (n%x == 0) {
        printf("%lli",(n/x)*t);
    } else {
        printf("%lli",(n/x+1)*t);
    }
    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm> // C++11以前
#include <utility>   // C++11から

using namespace std;

#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i) )

void init_S(int S[]);
int judge(int a, int b, char s);
void push(int S[], int *top, int x);
int pop(int S[], int *top);


int main() {
    int top=0;
    int a, b;
    char moji[100];
    int S[1000];
    
    init_S(S);
    
    while( scanf("%s",moji)  != EOF){ // 最初、"%c"にしていたのが原因で、苦戦した 
        // 演算子の場合
        if(moji[0] == '+' || moji[0] == '-' || moji[0] == '*') {
            b = pop(S, &top);
            a = pop(S, &top);
            // 計算して結果をプッシュ
            int x = judge(a,b,moji[0]);
            push(S,&top, x);
        }
        // 数字の場合
        else {
            push(S, &top, atoi(moji) );
        }
    
    }
    printf( "%d\n", pop(S, &top) );

    return 0;
}

void init_S(int S[]) {
    //0番目には何も入らない
    S[0] = 0;
}

int judge(int a,int b,char s) {
    int calc;
    switch(s) {
        case '+':
            calc = a + b;
            break;
        case '-':
            calc = a - b;
            break;
        case '*':
            calc = a * b;
            break;
        defalut:
            calc = -10000;
    }
    return calc;
}

void push(int S[], int* top, int x) {
    (*top)++;
    S[*top] = x;
    // 二行をまとめて、S[++(*top)] = x; と一行にまとめることは可能
}

int pop(int S[], int* top) {
    return S[(*top)--];
}





Measured memory_bytes: 3228
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int n;
	cin>>n;
	vector<string> a(n);
	map<string,int> p{};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sort(a[i].begin(),a[i].end());
		p[a[i]]+=1;
	}
	ll ans=0;
	for(const auto& [key,value]:p)
	{
		for(int j=1;j<value;j++)
		{
			ans+=j;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14012
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=int(1e9);
    rep(i,(1<<n)){
        int cnt=1;
        rep(j,n){
            if(i>>j&1)cnt*=2;
            else cnt+=k;
        }
        chmin(ans,cnt);
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3648
N=int(input())
tn,xn,yn=0,0,0
judge=[]
for i in range(N):
    t1,x1,y1=map(int,input().split())
    td=abs(t1-tn)
    xd=abs(x1-xn)
    yd=abs(y1-yn)
    if t1%2==(x1+y1)%2 and td>=xd+yd:
        judge.append(True)
    else:
        judge.append(False)

    tn,xn,yn=t1,x1,y1
print('Yes' if all(judge) else 'No')



Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
struct node {
	int x, y;
}p[10];
int a[10];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m, f = 0, h = 0;
	cin >> n >> m;
	a[1] = 1;
	for (int i = 0; i < m; i++) {
		cin >> p[i].x >> p[i].y;
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			if (p[i].x == p[j].x && p[i].y != p[j].y) f = 1;
		}
		if (p[i].x == 1) {
			if (n != 1 && p[i].y == 0) f = 1;
			if (n == 1) {
				a[0] = 0;
			}
		}
		a[p[i].x] = p[i].y;
	}
	if (n == 1 && m == 0) cout << 0 << endl;
	else if (f == 1) cout << -1 << endl;
	else if (f == 0) {
		for (int i = 1; i <= n; i++) {
			cout << a[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {

  int n,k[200] = {0};
  int i,j,l,o,t;
  char str[101];


  while(1) {
    scanf("%d",&n);

    if(n==0) break;

    for(i=0;i<n;i++) {

      scanf("%d",&k[i]);
    }

    scanf("%s",str);

    o = -1;
    for(i=0;i<strlen(str);i++) {
      //ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijKlmnopqrstuvwxyz
      o++;
      if(o == n) o = 0;
    
      t = k[o];
      while(1) {
	
	if(str[i] - t < 'A' && str[i] >= 'A' && str[i] <= 'Z') {
	  t = 'A' - (str[i] - t)-1;
	  str[i] = 'z';
	} else if(str[i] - t < 'a' && str[i] >= 'a' && str[i] <= 'z'){
	  t = 'a' - (str[i] - t)-1;
	  str[i] = 'Z';
	}else break;
      }
      // printf("t = %d\n",t);
      str[i] = str[i] - t;
      
    }

    printf("%s\n",str);

  }

  return 0;

}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned int uint;
typedef pair<int,int> pii;
//-------------------------------------------------------------------LYYY↓
namespace LYYY{
	int rd()
	{
		int s=0;char c=getchar();int f=1;
		while(c<48||c>57)
		{
			if(c==45) f=-1;
			c=getchar();
		}
		while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
		return s*f;
	}
	LL rdl()
	{
		LL s=0;char c=getchar();int f=1;
		while(c<48||c>57)
		{
			if(c==45) f=-1;
			c=getchar();
		}
		while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
		return s*f;
	}
	void wt(int x)
	{
		if(x>=10) wt(x/10);
		putchar(x%10+48);
	}
	void WT(int x)
	{
		if(x<0) x=-x,putchar(45);
		wt(x);
	}
	void wtl(LL x)
	{
		if(x>=10) wtl(x/10);
		putchar(x%10+48);
	}
	void WTL(LL x)
	{
		if(x<0) x=-x,putchar(45);
		wtl(x);
	}
}using namespace LYYY;
//-------------------------------------------------------------------bianliang↓
const int maxn=333333;
int id[maxn],tong[maxn],sum[maxn],f[maxn];
//-------------------------------------------------------------------hanshu↓
bool cmp(int x,int y)
{
	return tong[x]<tong[y];
}
//-------------------------------------------------------------------main()↓
int main()
{
	int N=rd();
	for(int i=1;i<=N;++i) ++tong[rd()];
	for(int i=1;i<=N;++i) id[i]=i;
	sort(id+1,id+1+N,cmp);
	for(int i=1;i<=N;++i) sum[i]=sum[i-1]+tong[id[i]];
	for(int i=N;i;--i) f[tong[id[i]]]=i;
	for(int i=N;i;--i)if(!f[i]) f[i]=f[i+1];
	for(int i=1;i<=N;++i)
	{
		int l=1,r=N/i,ans=0;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if((i-(N-f[mid]+1))*(LL)mid<=sum[f[mid]-1]) ans=mid,l=mid+1;
			else r=mid-1;
		}
		WT(ans),puts("");
	}
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;

void solve() {
    string s;
    while(cin >> s) {
        bool res = 0;
        if(s.size() >= 4) {
            s = s.substr(0, 4);
            if(s == "YAKI") res = 1;
        }
        puts(res ? "Yes" : "No");
    }
}

int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
const int INF = 1e9 + 7;

int main() {
	int n, m; cin >> n >> m;
	vector<pair<int, int>> std(n); rep(i, 0, n) cin >> std[i].first >> std[i].second;
	vector<pair<int, int>> c(m); rep(i, 0, m) cin >> c[i].first >> c[i].second;

	vector<int> ans(n);
	rep(i, 0, n) {
		int a = INF;
		rep(j, 0, m) {
			int l = abs(std[i].first - c[j].first) + abs(std[i].second - c[j].second);
			if (l < a) {
				a = l;
				ans[i] = j + 1;
			}
		}
	}

	rep(i, 0, n) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  string x, y;
  cin >>  x >> y;
  if (x>y) cout << ">" << endl;
  else if (x==y) cout << "=" << endl;
  else cout << "<" << endl;

}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

def pow(a, b)
  if b == 0
    1
  elsif b % 2 == 1
    a * pow(a, b - 1) % MOD
  else
    pow(a ** 2 % MOD, b / 2)
  end
end

def inv(n)
  pow(n, MOD - 2) % MOD
end

def comb(n, k)
  a = 1
  b = 1
  k.times do |i|
    b *= i + 1
    b %= MOD
  end
  k.times do |i|
    a *= n - i
    a %= MOD
  end
  a * inv(b) % MOD
end

N, a, B = gets.split.map(&:to_i)
ans = pow(2, N) - 1
ans += MOD - comb(N, a)
ans += MOD - comb(N, B)
puts ans % MOD

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long

const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int a[5];
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,a,b;
cin>>n>>a>>b;
if(n<=a)
{
	cout<<n+1;
	return 0;
}
else
{
	if(b-a>3)
	{
		ll ans=0;
		ans=b;
		n-=a;

		ans+=(n-1)/2*(b-a);
		if((n-1)%2)
		ans++;
		cout<<ans;
	}
	else
	{
		cout<<n+1;
	}
}
}

Measured memory_bytes: 256
// C - 4-adjacent
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), e(n, 0), f(n, 0);
  rep(i, 0, n)
  {
    cin >> d[i];
    if (d[i] % 4 == 0)
    {
      count++;
    }
    else if (d[i] % 2 == 0)
    {

      ans++;
    }
  }
  if (ans >= 2)
  {
    count += (ans / 2);
  }
  if (count >= n / 2)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 5520
#include <iostream>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#define llint long long
#define mod 998244353
#define eps 1e-8

using namespace std;

llint k;
llint n[100005], m[100005];

llint get(llint r, llint g, llint g2, llint x)
{
	if(x%2 == r%2) return g;
	else return g2;
}

llint grundy(llint a, llint b)
{
	if(a != 0 && b != 0) return 0;
	if(a != 1 && b != 1) return 1;
	if(a != 2 && b != 2) return 2;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k;
	for(int i = 1; i <= k; i++) cin >> n[i] >> m[i];
	
	llint ans = 0;
	for(int i = 1; i <= k; i++){
		llint r = m[i], g = 0, g2 = 1;
		//cout << r << " " << g << " " << g2 << endl;
		while(r > 0){
			if(r/2 < n[i]){
				ans ^= get(r, g, g2, n[i]);
				break;
			}
			llint ng = grundy(get(r, g, g2, r/2*2), get(r, g, g2, r/2+1));
			llint ng2 = grundy(get(r, g, g2, (r/2-1)*2), ng);
			r /= 2, g = ng, g2 = ng2;
			//cout << r << " " << g << " " << g2 << endl;
		}
		//cout << ans << endl;
	}
	
	if(ans == 0) cout << "tubuann" << endl;
	else cout << "mo3tthi" << endl;
	
	return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 2019
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    string S;
    cin >> S;
    int N = S.size();
    reverse(S.begin(),S.end());
    vector<int> F;
    F.push_back(0);
    int k=1;
    int num=0;
    REP(i,N){
        int d = (S[i]-'0');
        num+=(k*d)%MOD;
        num%=MOD;
        F.push_back(num);
        k=(k*10)%MOD;
    }
    
    //REP(i,F.size()){cout << F[i] << " ";}cout << endl;
    
    int L[2030]={};
    REP(i,F.size()){
        L[F[i]]++;
    }
    int Ans=0;
    REP(i,MOD){
        Ans+=L[i]*(L[i]-1)/2;
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 5488
N = int(input())
A = [list(map(int,input().split())) for i in range(2)]

a = sum(A[0])+A[1][-1]
ans = [a]

for i in range(1,N):
  a -= A[0][-i]
  a += A[1][-i-1]
  ans.append(a)

print(max(ans))

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
ll ans;
int n;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        ll t; cin>>t;
        if(i==1) ans = t;
        else{ans = lcm(ans,t);}
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]

def show():
    maplist=map(str, A)
    maplist=' '.join(maplist)
    print(maplist)
show()
for i in range(1,n):
    key=A[i]
    j=i-1
    while j>=0 and A[j]>key:
        A[j+1]=A[j]
        j-=1
    A[j+1]=key
    show()
    


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

using namespace std;
typedef long long ll;
ll n;
ll dp[100000+1][3];
ll a[100000+1],b[100000+1],c[100000+1];
ll mo(ll x){
  if(x>0) return x;
  else return -x;
}
ll cal(int i,int co){
  if(i<=0) return 0;
  if(dp[i][co-1]!=-1) return dp[i][co-1];
  ll res=0;
  if(co==1){
    dp[i][co-1]=a[i-1];
    res=max(cal(i-1,2),cal(i-1,3));
    dp[i][co-1]+=max(res,cal(i-2,1));
  }
  else if(co==2){
    dp[i][co-1]=b[i-1];
    res=max(cal(i-1,1),cal(i-1,3));
    dp[i][co-1]+=max(res,cal(i-2,2));
  }
  else if(co==3){
    dp[i][co-1]=c[i-1];
    res=max(cal(i-1,2),cal(i-1,1));
    dp[i][co-1]+=max(res,cal(i-2,3));
  }
  return dp[i][co-1];
}
int main() {
  memset(dp,-1,sizeof dp);
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  cal(n,1);cal(n,2);cal(n,3);
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,n,m) for(ll i=n;i<(m);i++)
#define ALL(a) a.begin(),a.end()
#define pb push_back
const ll INF=1000000000;
const ld EPS=1E-8;
using vec=vector<ld>;
using mat=vector<vec>;

// return A*B
mat mat_mul(const mat& A, const mat& B) {
	ll n = A.size(), m = A[0].size(), l = B[0].size();
	assert(B.size() == m);
	mat ret(n, vec(l, 0));
	REP(i, n) REP(j, l) {
		REP(k, m) ret[i][j] += A[i][k] * B[k][j];
	}
	return ret;
}

// return A^n
mat mat_pow(const mat& A, ll n) {
	ll m = A.size();
	assert(A[0].size() == m);
	mat ret(m, vec(m, 0));
	if(n == 0) {
		REP(i, m) ret[i][i] = 1;
		return ret;
	}
	if(n % 2) return mat_mul(A, mat_pow(mat_mul(A, A), n / 2));
	else return mat_pow(mat_mul(A, A), n / 2);
}

// solve Ax=b^t
vec gauss_jordan(const mat& A, const vec& b) {
	ll n = A.size();
	assert(A[0].size() == n);
	mat B(n, vec(n + 1));
	REP(i, n) REP(j, n) B[i][j] = A[i][j];
	REP(i, n) B[i][n] = b[i];
	
	REP(i, n) {
		ll pivot = i;
		FOR(j, i, n) if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
		swap(B[i], B[pivot]);
		
		if(abs(B[i][i]) < EPS) return vec();
		
		for(ll j = i + 1; j <= n; j++) B[i][j] /= B[i][i];
		REP(j, n) {
			if(i != j) {
				for(ll k = i + 1; k <= n; k++) B[j][k] -= B[j][i] * B[i][k];
				
			}
		}
	}
	vec x(n);
	REP(i, n) x[i] = B[i][n];
	return x;
}

ll s, n, k;
vector<ll> dp(101,0); // dp[i] := 和が i になるサイコロ目の通り数

void init_dp() {
	dp[0] = 1;
	REP(i, k) for(ll j = n * k; j >= 0; j--) {
		dp[j] = 0;
		for(ll l = 1; l <= n; l++) if(j - l >= 0) dp[j] += dp[j - l];
	}
}

ld solve() {
	if (s == 0) return 0;
	if(n == 1) {
		if(s % k == 0) return s / k;
		else return -1;
	}
	mat A(n * k, vec(n * k, 0));
	vec b(n * k, 1);
	
	for(ll i = 1; i <= n * k; i++) {
		A[i - 1][i - 1] = 1;
		for(ll j = k; j <= n * k; j++) {
			if(i != j) {
				A[i - 1][abs(i - j) - 1] -= dp[j] / pow(n, k);
			}
		}
	}
	
	vec e = gauss_jordan(A, b);
	if(s <= n * k) return e[s - 1];
	
	e.pb(1);
	mat C(n * k + 1, vec(n * k + 1, 0));
	REP(i, n * k + 1) {
		if(i == n * k - 1) {
			C[i][n * k] = 1;
			for(ll j = k; j <= n * k; j++) {
				C[i][n * k - j] = dp[j] / pow(n, k);
			}
		}
		else if(i == n * k) C[i][n * k] = 1;
		else C[i][i + 1] = 1;
	}
	C = mat_pow(C, s - n  * k);
	
	mat et(n * k + 1, vec(1));
	REP(i, n * k + 1) et[i][0] = e[i];
	
	mat ret = mat_mul(C, et);
	return ret[n * k - 1][0];
}

int main() {
	cin >> s >> n >> k;
	s = abs(s);
	init_dp();
	cout << fixed << setprecision(100) << solve() << endl;
	return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> maze(H, vector<int>(W, -1));
    int cnt = 0;
    for (int i = 0; i < H; ++i) {
        string S;
        cin >> S;
        for (int j = 0; j < W; ++j) {
            if (S[j] == '.') maze[i][j] = cnt++;
        }
    }
    vector<vector<int>> dist(cnt, vector<int>(cnt, INF));
    for (int i = 0; i < cnt; ++i) dist[i][i] = 0;
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = { 0, 1, 0, -1};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (maze[i][j] == -1) continue;
            for (int k = 0; k < 4; ++k) {
                int x = j + dx[k];
                int y = i + dy[k];
                if (x < 0 || y < 0 || x >= W || y >= H) continue;
                if (maze[y][x] >= 0) {
                    dist[maze[i][j]][maze[y][x]] = 1;
                    dist[maze[y][x]][maze[i][j]] = 1;
                }
            }
        }
    }
    for (int k = 0; k < cnt; ++k) {
        for (int i = 0; i < cnt; ++i) {
            for (int j = 0; j < cnt; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < cnt; ++i) {
        for (int j = 0; j < cnt; ++j) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long

using namespace std;

int main() {
    int flag = 0;
    string s;
    map<char, char> map;
    cin >> s;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (map.end() == map.find(s[i]))
        {
            map.insert(make_pair(s[i], s[i]));
        }
        else
        {
            flag = 1;
            break;
        }
    }
    if (flag == 1)
    {
        cout << "no" << endl;
    }
    else
    {
        cout << "yes" << endl;
    }
}

Measured memory_bytes: 256
using Yorukatsu034.Questions;
using Yorukatsu034.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu034.Questions
{
    /// <summary>
    /// ABC098 B
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var s = inputStream.ReadLine();
            yield return Enumerable.Range(1, s.Length - 1).Max(i =>
            {
                var x = s.Substring(0, i);
                var y = s.Substring(i);
                var xChars = new HashSet<char>(x);
                var yChars = new HashSet<char>(y);
                xChars.IntersectWith(yChars);
                return xChars.Count;
            });
        }
    }
}


namespace Yorukatsu034
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu034.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu034.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13408
#include<stdio.h>
int A[5000004];
int L[2500004];
int R[2500004];
int INFTY = 999999999;
int k;
int cnt;
void merge(int left, int mid, int right){
  int i,j;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i = 0;i <= n1-1;i++){
    L[i] = A[left + i];
  }
  for (i = 0;i <= n2-1;i++){
    R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  }
  i = 0;
  j = 0;

  for (k = left;k <= right-1;k++){
    cnt++;
    if (L[i] <= R[j]){
      A[k] = L[i++];
    }
    else 
      A[k] = R[j++];
  }
}

void mergeSort(int left, int right){
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main(){
  int i,a,b,n;

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

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


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 1;
    while(1) {
        if ( y * ans + z * ( ans + 1 ) > x ) break;
        ++ans;
    }
    cout << ans - 1 << endl;
    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int C=0;
  for (int i=0; i<3; i++) {
    if (S[i]==T[i]) {
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if(A+B > A-B)if(A*B > A+B)cout << A*B << endl;
  else cout << A+B << endl;
  else if(A*B > A-B)cout << A*B << endl;
  else cout << A-B << endl;
}

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

const long long MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        if(a[i] <= b[i]) cnt += (b[i]-a[i])/2;
        else cnt -= a[i] - b[i];
    }
    if(cnt >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define gc getchar_unlocked
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
// typedef pair<int, int>	pii;
// typedef pair<ll, ll>	pl;
// typedef vector<int>		vi;
// typedef vector<ll>		vl;
// typedef vector<pii>		vpii;
// typedef vector<pl>		vpl;
// typedef vector<vi>		vvi;
// typedef vector<vl>		vvl;

void solve() {
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << fixed << setprecision(10);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    // return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    std::string word = "aa";
    std::string w = "No";
    int64_t a,b,c,d,e,f;
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;

    std::vector< int64_t > list1( a );
    std::vector< int64_t > list2( b );
    //std::vector< int64_t > list3( c );

    int64_t min = INFINITY;
    int64_t min1 = INFINITY;
    int64_t min2 = INFINITY;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list1[i];
        min1 = std::min( min1, list1[i] );
    }

    for( int i = 0; i < b; i++ )
    {
        std::cin>> list2[i];
        min2 = std::min( min2, list2[i] );
    }

    for( int i = 0; i < c; i++ )
    {
        std::cin>> d;
        std::cin>> e;
        std::cin>> f;

        min = std::min( list1[d-1] + list2[e-1] - f, min );
    }

    min = std::min( min, min1 + min2 );

    std::cout<< min;
}


Measured memory_bytes: 1792
N=int(input())
V=input().split()
C=input().split()
i=0
j=0
s_l=[]
cnt=0
while i<N:
       s=int(V[i])-int(C[i])
       s_l.append(s)
       i+=1
while j<N:
       if s_l[j]>=0:
              cnt+=s_l[j]
       j+=1
print(cnt)


Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    long n = sc.nextLong();
    long m = sc.nextLong();
    long sum = 0;

    for(int i = 0; i < m; i++){
      long a = sc.nextLong();
      sum += a;
    }

    if(sum > n){
      System.out.println("-1");
    } else {
      System.out.println(n - sum);
    }
  }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	k %= 2;
	ll ans = a - b;
	if (k){
		ans = -ans;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    double r;cin>>r;
    double pi=M_PI;
    printf("%.10lf %.10lf\n",r*r*pi, 2.0*r*pi);
    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
int main(void)
{
    int a,b,i;
	while(1){
	scanf("%d",&a);
	if(a==-1) break;
	b=0;
	if(a<=10){
	b=1150;
	}
	else if(a<=20){
	b=1150;
	for(i=0;i<a-10;i++){
	b+=125;
	}
	}
	else if(a<=30){
	b=2400;
	for(i=0;i<a-20;i++){
	b+=140;
	}
	}
	else if(a>30){
	b=3800;
	for(i=0;i<a-30;i++){
	b+=160;
	}
	}
	printf("%d\n",4280-b);
	}
	return 0;
	}

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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef  long long int lli; 

int main(){
    
    lli i,x,j,k,n,y,m,t,a,b; 	
    AndIamIronMan;
//    cin>>t;
//    while(t--){
	cin>>n;
	if(n<=26){
		char tem=n+'a'-1;;
		cout<<tem;
		return 0;
	}
	string s="";
	while(n>=1){
		x=(lli)n%26;
		if(x==0){
			x=26;
		}
		s+='a'+x-1;
		n=n/26;
		if(x==26){
			n--;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
	
	
//	}
	return 0;
}


Measured memory_bytes: 3596
N,H = map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

B.sort(reverse=True)
amax=max(A)
ans=0
l=0
for b in B:
  if l>=H:
    print(ans);exit()
  if b>amax:
    ans+=1
    l+=b
  else:
    break
ans+=(H-l)//amax+min((H-l)%amax,1)
print(ans)
 

Measured memory_bytes: 61528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  
  ll N,D,D2,t,X,Y;
  cin >> N >> D;
  D2 = D*D;
  t = 0;
  
  for(ll i = 0; i < N; i++){
    cin >> X >> Y;
    if(X*X + Y*Y <= D2) t++;
  }
  
  cout << t << endl;
  
}


Measured memory_bytes: 3632
/**
*    created: 30.06.2020 17:51:55
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int sum = 0;
    rep(i,n) {
        cin >> m[i];
        sum += m[i];
    }
    x -= sum;
    sort(all(m));
    cout << n + x/m[0] << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  int count = 0;
  while(1){
  	B -= A;
    if(B < 0){
    	break;
    }else{
    	count++;
      	if(count == C){
        	break;
        }
    }
  }
  
  cout << count << endl;
}

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

n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
graph = [0] + [[] for _ in range(n)]
for i in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

ans = 0
for i in range(1, n+1):
    high = []
    if len(graph[i]) == 0:
        ans += 1
        continue
    for j in graph[i]:
        high.append(h[i] > h[j])
    if all(high):
        ans += 1
print(ans)


Measured memory_bytes: 94092
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];
llint dp[200005][3][2];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 2; k++){
				dp[i][j][k] = -inf;
			}
		}
	}
	dp[0][0][0] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 2; k++){
				if(k == 0) chmax(dp[i+1][j][1], dp[i][j][k] + a[i+1]);
				
				llint nj = j;
				if(k == 0) nj++;
				if(nj < 3) chmax(dp[i+1][nj][0], dp[i][j][k]);
			}
		}
	}
	
	llint ans;
	if(n % 2) ans = max(dp[n][1][0], dp[n][2][1]);
	else ans = max(dp[n][0][0], dp[n][1][1]);
	
	cout << ans << endl;
	
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

struct edge{int to; ll cost;};

vector<vector<edge>> graph;
vector<ll> dist;

void dfs(int v, int p){
    for(int i = 0; i < graph[v].size(); i++){
        edge e = graph[v][i];
        if(e.to != p){
            dist[e.to] = dist[v] + e.cost;
            dfs(e.to, v);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    graph.resize(n);
    dist.assign(n, LLONG_MAX);

    for(int i = 0; i < n-1; i++){
        int a, b; ll c; cin >> a >> b >> c;
        a--; b--;
        edge e = {b, c};
        graph[a].push_back(e);
        e = {a, c};
        graph[b].push_back(e);
    }

    int q, k; cin >> q >> k;
    k--;
    vector<int> x(q), y(q);
    for(int i = 0; i < q; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    dist[k] = 0;
    dfs(k, -1);

    for(int i = 0; i < q; i++) cout << dist[x[i]] + dist[y[i]] << endl;

    return 0;
}


Measured memory_bytes: 15104
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void scanArray(Scanner sc ,int[] array, int num){
        for(int i =0;i<num;i++){
            array[i] = sc.nextInt();
        }
    }
    //最小公倍数
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }

    public static void main(String[] args) {

        int N;
        Task[] TaskList;
        PriorityQueue<Task> queue = new PriorityQueue(1,new TaskComparator());

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            TaskList = new Task[N];

            for(int i =0;i<N;i++){
                int a = sc.nextInt();
                int b = sc.nextInt();
                TaskList[i] = new Task(a, b);
            }
        }
        for(Task t :TaskList){
            queue.add(t);
        }
        Task t = null;
        //現在時間
        int time = 0;
        //余裕時間
        int remain = 0;;
        while((t = queue.poll()) != null){

            if(time != t.b){
                //余裕時間を追加する
                remain += (t.b -time);
                //締め切りまで時間を進める
                time = t.b;
            }
            //現在の余裕時間でタスクができるなら減らす
            if(t.a <= remain){
                remain -= t.a;
            }else{
                //余裕時間を超えたタスクの場合
                System.out.println("No");
                return;
            }
            debug(remain+"");
        }
        System.out.println("Yes");
    }
    static class Task{
        int a;
        int b;

        public Task(int a,int b){
            this.a = a;
            this.b = b;
        }
    }

    static class TaskComparator  implements Comparator{
        @Override
        public int compare(Object o1, Object o2) {
            Task x = (Task)o1;
            Task y = (Task)o2;
            if (x.b > y.b) {
                return 1;
            } else if (x.b < y.b) {
                return -1;
            } else{
                return 0;
            }
        }
    }
}


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

int main(){
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  
  int a[100000]={0};
  rep(i,n){
    if(i<k || t[i]!=t[i-k] || !a[i-k]) a[i] = 1;
  }
  
  ll ans = 0;
  rep(i,n){
    if(a[i]){
      if(t[i] == 'r') ans += p;
      if(t[i] == 's') ans += r;
      if(t[i] == 'p') ans += s;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
int w,h;
void dfs(int x,int y,vector<vector<char>> &vc){
  if(vc[x][y] == '.') return;
  char c = vc[x][y];
  vc[x][y] = '.';
  rep(i,4){
    int cx = x+dx[i];
    int cy = y+dy[i];
    if(value(cx,cy,w,h)){
      if(vc[cx][cy] == c){
        dfs(cx,cy,vc);
      }
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin>>h>>w&&h){
    vector<vector<char>> vc(w,vector<char>(h,'.'));
    rep(i,h){
      rep(j,w){
        cin>>vc[j][i];
      }
    }
    int ans = 0;
    rep(i,h){
      rep(j,w){
        if(vc[j][i] != '.'){
          dfs(j,i,vc);
          ++ans;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    ll n,ans,t,i;cin>>n;
    vector<ll> x(n),l(n);
    for(i=0;i<n;i++){
        cin>>x[i]>>l[i];
    }

    vector<pair<ll,ll>> P(n);
    for(i=0;i<n;i++){
        P[i].first=x[i]+l[i];//終端
        P[i].second=x[i]-l[i];//始点
    }

    sort(P.begin(),P.end());//終端でsort

    t=P[0].first;
    ans=1;
    for(i=1;i<n;i++){
        if(t<=P[i].second){//前の終端が一つ後ろの始点とかぶっていない時
            ans++;
            t=P[i].first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pa pair<int,int>
#define N 20

pa f[1<<N];
int n,ans;

pa operator + (const pa& a,const pa& b) {
	int c[4];
	c[0]=a.first; c[1]=a.second; c[2]=b.first; c[3]=b.second;
	sort(c,c+4);
	return make_pair(c[3],c[2]);
}

int main()
{
	scanf("%d",&n);
	for (int i=0;i<(1<<n);i++) scanf("%d",&f[i].first);
	for (int i=0;i<n;i++)
		for (int j=0;j<(1<<n);j++) if (j>>i&1)
			f[j]=f[j]+f[j^1<<i];
	for (int i=1;i<(1<<n);i++) {
		ans=max(ans,f[i].first+f[i].second);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7168