akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int a,b,cnt = 0;
	cin>>a>>b;
	int j = 1;
	for(int i=1;i<a;i++)
		cnt++;
	if(a<=b)
		cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
const int N=1e7+5;
typedef long long ll;
const ll mod=998244353;
ll qpow(ll x,ll y) {
    ll res=1;
    for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
    return res;
}
ll p[N],inv[N];
ll C(int n,int m) {
    if(n<m) return 0;
    return p[n]*inv[m]%mod*inv[n-m]%mod;
}
int main() {
    int n;
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*i%mod;
    inv[N-1]=qpow(p[N-1],mod-2);
    for(int i=N-2;~i;i--) inv[i]=inv[i+1]*(i+1)%mod;
    scanf("%d",&n);
    ll ans=qpow(3,n);
    for(int i=n/2+1;i<=n;i++) {
        ll c=qpow(2,n-i+1);
        ans=(ans-c*C(n,i)%mod+mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main()
{
    int n;
    int l[100];
    int count = 0;

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> l[i];

    for (int i = 0; i < n; i++)
    {
        int a, b, c;
        a = l[i];

        for (int j = i + 1; j < n; j++)
        {
            b = l[j];

            for (int k = j + 1; k < n; k++)
            {
                c = l[k];

                if ((a != b) && (b != c) && (c != a) && (a + b > c) && (b + c > a) && (c + a > b))
                {
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3572
N, K = map(int,input().split())

if K == 0:
  print(N*N)
  exit()

result = 0
for i in range(K+1, N+1):
  loop = int(N/i)
  result += (i-K)*loop
  result += max(N-K-(loop*i)+1,0)

print(result)


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

int main(){
    int D[3];
    cin >> D[0] >> D[1] >> D[2];
    
    sort(D,D+3);
    
    int ans = 0;
    ans = D[0] + D[1];
    cout << ans << "\n";
    return 0;
} 


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll X;
	scan(X);
	ll ans=0;
	ans+=X/500*1000;
	X%=500;
	ans+=X/5*5;
	prin(ans);
	return 0;
}


Measured memory_bytes: 3616
k = input()
a,b = input().split()
k=int(k)
a=int(a)
b=int(b)

def sample(a, b, k):
  for i in range(a,b+1):
    if i % k == 0:
      return "OK"
  return "NG"

print(sample(a,b,k))


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int sz=2*n-1;
	if(x==1 || x == sz){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;

        int start = x - (n-1);
        if(start <= 0) start += 2*n-1;
        REP(i,sz){
            cout << 1+(start+i-1)%sz <<endl;;
        }
	}

	return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    vector< pair< pair<string, int>, int > > list(N);

    rep(i,N) {
        cin >> list[i].first.first >> list[i].first.second;
        list[i].first.second *= -1;
        list[i].second = i + 1;
    }

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

    rep(i,N) cout << list[i].second << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	
	if(N*A < B)
	{
		printf("%d\n", N*A);
	}
	else
	{
		printf("%d\n", B);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args) throws IOException{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		//Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out, true);
		int n=Integer.parseInt(in.readLine());
		StringBuilder sb=new StringBuilder();
		HashSet<String> set=new HashSet<>();
		ArrayList<String> res=new ArrayList<>();
		for(int i=0;i<n;i++){
			String str[]=in.readLine().split(" ");
			if(str[0].equals("insert"))
				set.add(str[1]);
			else{
				if(set.contains(str[1]))
					res.add("yes");
				else
					res.add("no");
			}

		}
		for(int i=0;i<res.size();i++){
			if(i==n-1)
				out.print(res.get(i));
			else
				out.printf(res.get(i)+"\n");
		}
	}

}



Measured memory_bytes: 204572
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    int m;
    cin >> m;
    cout << 24 - m + 24 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S  = sc.nextLine().split(" ");
    long A = Integer.parseInt(S[0]);
    long B = Integer.parseInt(S[1]);
    long C = Integer.parseInt(S[2]);
    long sum = A * B * C;
    
    long ansA = (sum - (B * C * (A / 2))) - (B * C * (A / 2));
    long ansB = (sum - (C * A * (B / 2))) - (C * A * (B / 2));
    long ansC = (sum - (A * B * (C / 2))) - (A * B * (C / 2));
    
    long ans = (Math.min(ansA, Math.min(ansB, ansC)));
    System.out.println(ans);
  }
}

Measured memory_bytes: 25300
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define int long long

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;



int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }
    reverse(all(b));
    int c = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) {
            c = a[i];
            break;
        }
    }
    int l = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == c && b[i] == c) {
            l = i;
            break;
        }
    }
    int r = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] != c && b[i] != c && l <= r) {
            swap(b[i], b[l]);
            ++l;
        }
    }

    if (l <= r) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
        //assert(b[i] != a[i]);
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 6340
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        for(var i = 0; i < Math.Ceiling((double)str.Length / 2); i++)
        {
            Write(str.Substring(2 * i, 1));
        }
        WriteLine();
    }
}



Measured memory_bytes: 11092
// ABC 049 D
// Union Find
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int N, K, L, x, y;
int find(int x, int *parent){
    return parent[x]==x ? x : parent[x]=find(parent[x], parent);
}
void unite(int x, int y, int *parent){
    parent[find(x,parent)] = find(y,parent);
}

int main() {
    cin >> N >> K >> L;
    int douro[N] = {}, senro[N] = {};
    REP(i,N){
        douro[i] = i;
        senro[i] = i;
    }
    REP(i,K){
        cin >> x >> y;
        x--; y--;
        unite(x,y,douro);
    }
    REP(i,L){
        cin >> x >> y;
        x--; y--;
        unite(x,y,senro);
    }
    map<pair<int,int>,int> mp;
    vector<pair<int,int>> v(N);
    REP(i,N){
        pair<int,int> p = make_pair(find(i,douro),find(i,senro));
        mp[p]++;
        v[i] = p;
    }
    REP(i,N-1){
        cout << mp[v[i]] << " ";
    }
    cout << mp[v[N-1]] << endl;
    return 0;
}


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

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

  string s;
  cin >> s;

  int len = s.size();

  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());

  int uniqLen = s.size();

  cout << (len == uniqLen ? "yes" : "no") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long fact[510000];
long long inv[510000];
long long factinv[510000];
int M=505000;
long long C(int a,int b){
	return fact[a]*factinv[b]%mod*factinv[a-b]%mod;
}
int main(){
	inv[1]=fact[0]=factinv[0]=1;
	for(int i=2;i<M;i++)inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	for(int i=1;i<M;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=1;i<M;i++)factinv[i]=factinv[i-1]*inv[i]%mod;
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	for(int i=0;i<a-c;i++){
		ret=(ret+C(i+d-1,i)*C(a-i-1+b-d-1,a-i-1))%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 12032
#include <stdio.h>
const int N=1e3+10;
int main(){
    int n,a[N],q,l,r,ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    scanf("%d",&q);
    while(q--){
        scanf("%d%d%d",&l,&r,&n);
        ans=0;
        for(int i=l;i<r;i++)if(a[i]==n)ans++;
        printf("%d\n",ans);
    }
}


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


int main()
{
	int A,B;
	cin>>A>>B;
	int ans=-1;
	Rep(i,1,1001)
	{
		if((int)(i*0.08)==A&&(int)(i*0.1)==B)
		{
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;

  cout << s1[0] << s2[1] << s3[2] << endl;
  return 0;
} 

Measured memory_bytes: 3604
a = int(input())
b = []

for i in range(a+1):
    if i % 3 == 0 and i % 5 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
print(sum(b))



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second



int main(int argc, char const *argv[]) {
  int n, m; cin >> n >> m;
  vector<P> ans;
  /* mの最大値が偶数か奇数化を判定する */ 
  int max_m = (n - 1) / 2;
  /* cout << max_m << endl; */
  if (max_m % 2) {
    int c = n / 2;
    /* cout << "now start 前半" << endl; */
    REP(i,max_m/2) {
      /* cout << c/2 - i << " " << c/2 + i + 2 << endl; */
      ans.emplace_back(c/2 - i,c/2 + i + 2);
    }
    if ((n - c) % 2) c = ((c + 1) + n) / 2;
    else c = ((c + 1) + n) / 2 + 1;
    /* cout << "c " << c << "now start 後半" << endl; */
    REP(i,max_m - max_m / 2) {
      /* cout << c + i << " " << n - i << endl; */ 
      ans.emplace_back(c - i - 1,c + i);
    }
  } else {
    int c = (n + 1) / 2;
    /* cout << "now start 前半" << endl; */
    REP(i,max_m/2) {
      /* cout << c/2 - i << " " << c/2 + i + 2 << endl; */
      ans.emplace_back(c/2 - i,c/2 + i + 2);
    }
    if ((n - c) % 2) c = ((c + 1) + n) / 2;
    else c = ((c + 1) + n) / 2 + 1;
    /* cout << "c " << c << "now start 後半" << endl; */
    REP(i,max_m - max_m / 2) {
      /* cout << c + i << " " << n - i << endl; */ 
      ans.emplace_back(c - i - 1,c + i);
    }
 
  }
  REP(i,m) cout << ans[i].F << " " << ans[i].S << endl;
  return 0;
}


Measured memory_bytes: 4316
#include <iostream>
#include <iomanip>
#include <string>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int l = s.length();
  
  for(int i=0;i<l;i++){
    cout << "x";
  }
  
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
g=[[0 for i in range(n)]for j in range(n)] 
for i in range(n):
    s=input()
    l=s.split()
    for i in range(len(l)):
        l[i]=int(l[i])
    for i in l[2:]:
        g[l[0]-1][i-1]+=1
for i in range(n):
    for j in range(n):
        print(g[i][j],end="")
        if j!=len(g[i])-1:
            print(" ",end="")
    print()



Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
using V = vector<int>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }


int main() {
  int n, q; cin >> n >> q;
  V c(n); cin >> c;
  rep(i, n) --c[i];
  int B = sqrt(q); // number of buckets

  // input and sort queries
  using Query = array<int, 3>;
  vector<Query> query(q);
  rep(i, q) {
    int l, r; cin >> l >> r;
    --l;
    query[i] = {l, r, i};
  }
  sort(all(query), [&] (const Query &a, const Query &b) {
    if (a[0] / B != b[0] / B) return a[0] < b[0];
    else if (a[0] / B % 2 == 0) return a[1] < b[1];
    else return a[1] > b[1];
  });

  // edit here
  int sum = 0;
  int l = 0, r = 0;
  V cnt(n), ans(q);

  auto add = [&] (int i) {
    if (cnt[c[i]] == 0) ++sum;
    ++cnt[c[i]];
  };
  auto del = [&] (int i) {
    --cnt[c[i]];
    if (cnt[c[i]] == 0) --sum;
  };
  // 

  // O(n \sqrt{q})
  for(const auto [li, ri, i] : query) {
    while (li < l) add(--l);
    while (ri < r) del(--r);
    while (r < ri) add(r++);
    while (l < li) del(l++);
    ans[i] = sum;
  }

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


Measured memory_bytes: 15480
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main(N, Vn, Cn):
    XYmax = 0
    for i in range(N):
        xyi = Vn[i] - Cn[i]
        if xyi > 0:
            XYmax += xyi
    print(XYmax)

N = i2n()
Vn = i2nn()
Cn = i2nn()
main(N, Vn, Cn)


Measured memory_bytes: 3064
//============================================================================
// Name        : Test.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int m,r,f;

	while(1){
		cin >> m >> r >> f;
		if(m == -1 && r == -1 && f == -1) break;

		if(m == -1 || r == -1) cout << "F" << endl;
		else if(m + r >= 80) cout << "A" << endl;
		else if(m + r >= 65 && m + r < 80) cout << "B" << endl;
		else if(m + r >= 50 && m + r < 65) cout << "C" << endl;
		else if(m + r >= 30 && m + r < 50){
			if(f >= 50) cout << "C" << endl;
			else cout << "D" << endl;
		}else if(m + r  <= 30) cout << "F" << endl;

	}
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

#define mkf(n,mod)  int *fact=(int *)malloc((n+1)*sizeof(int)); mfac((n),fact,(mod)) //enables to let x!=fact[x]
#define mkfiv(n,mod)  int *finv=(int *)malloc((n+1)*sizeof(int)); mfiv((n),finv,fact[n],(mod)) // 1/x! = finv[x]

int mmul(int p,int q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;}

int mpow(int x,int n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}}return ans;}

int mdiv(int p,int q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);}

void mfac(int x,int *f,int m){//O(n)
    *f=1; for(int i=1;i<=x;++i)f[i]=mmul(f[i-1],i,m);}

void mfiv(int x,int *f,int fx,int m){//O(n)
    f[x] = mdiv(1,fx,m); 
    for(int i=x;i>0;--i)f[i-1]=mmul(f[i],i,m);}

int mncr(int n,int r,int m,int* fac,int* fiv){//O(1)
    return mmul(fac[n],mmul(fiv[r],fiv[n-r],m),m);}


int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,k;
    cin >>n>>k;

    mkf(n+1,MOD);
    mkfiv(n+1,MOD);

    int st=n-1;

    for (int i = st; i >= max(0,n-1-k); --i){
        int a = mncr(n-1,i,MOD,fact,finv);
        int b = mncr(n,i+1,MOD,fact,finv);
        ans = (ans+mmul(a,b,MOD))%MOD;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 500020
#define P 9191891
#define MO 1000000007
#define LL long long
LL hash[MAXN],Pow[MAXN];
char s[MAXN];
int n;
bool vis[MAXN];
bool check(int x)
{
	LL cmp;
	for(int i=2*x;i<=n;i+=x)
		if((hash[i-x]*Pow[x]+hash[x])%MO==hash[i])
			vis[i]=1;
		else
		{
			cmp=(hash[n]-hash[n-x]*Pow[x]%MO+MO)%MO;
			for(int j=n-x*2;j>0;j-=x)
				if((hash[j]*Pow[x]+cmp)%MO==hash[j+x])
					vis[j]=1;
				else break;
			return 0;
		}
	return n%x==0;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	Pow[0]=1;
	for(int i=1;i<=n;i++)
		Pow[i]=P*Pow[i-1]%MO;
	int mn=n+1;
	for(int i=1;i<=n;i++)
		hash[i]=(hash[i-1]*P+s[i]-'a')%MO;
	for(int i=1;i<=n/2;i++)
		if(check(i))
		{
			mn=i;
			break;
		}
	if(mn==n+1)
		printf("1\n1\n");
	else if(mn==1) printf("%d\n1\n",n);
	else
	{
		int ans;
		if(n/mn==2) ans=n-1;
		else ans=n-n/mn;
		for(int i=2;i<mn;i++) if(vis[i]) ans--;
		for(int i=n-1;i>n-mn;i--) if(vis[i]) ans--;
		printf("2\n%d\n",ans);
	}
	return 0;
}

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

int main(){
long double a, b, c;
cin >> a >> b >> c;
long double A = sqrt(a*b);

if(a + b + 2*A < c) cout << "Yes" << endl;
else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  cout << max({(N-1)/A, (N-1)/B, (N-1)/C, (N-1)/D, (N-1)/E})+5 << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
First_List = list(map(int,input().split()))
Second_List = list(map(int,input().split()))
Num_List = sorted(First_List)
F_Flg = 0
S_Flg = 0
Loop_Num = 1
for Sorted_Pair in itertools.permutations(Num_List, N):
    Search_Pair = list(Sorted_Pair)
    if (Search_Pair == First_List) & (F_Flg == 0):
        F_Flg = Loop_Num
    if (Search_Pair == Second_List) & (S_Flg == 0):
        S_Flg = Loop_Num
        
    
    Loop_Num += 1

print(abs(F_Flg-S_Flg))

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

int main(){
    char ans[10];
    int num[5], c=0;
    cin >> ans;
    for(int i=0; i<4; i++){
        num[i]=ans[i]-'0';
    }
    for(int i=0; i<4; i++){
        ans[i*2]=num[i]+'0';
    }
    for(int i=0; i<8; i++){
        c = num[0];
        for(int j=0; j<3; j++){
            if((i>>j&1)==1){
                c += num[j+1];
                ans[j*2+1]='+';
            }
            else {
                c -= num[j+1];
                ans[j*2+1]='-';
            }
        }
        if(c==7){
            break;
        }
    }

    for(int i=0; i<7; i++){
        cout << ans[i];
    }
    cout << "=7" << endl;
}

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

int main(){
	while(1){
		vector<int> a, v;
		int n, m, t1;
		scanf("%d%d", &n, &m);
		if(n+m == 0)break;
		a.push_back(0);
		for(int i = 0;i < n;i++){
			scanf("%d", &t1);
			a.push_back(t1);
		}
		n++;
		for(int i = 0;i < n;i++){
			for(int j = i;j < n;j++){
				v.push_back(a[i]+a[j]);
			}
		}
		int s = v.size(), ans = 0;
		sort(v.begin(), v.end());
		//for(int i = 0;i < s;i++)printf("%d ", v[i]);
		for(int i = s-1;i >= 0;i--){
			int t = upper_bound(v.begin(), v.end(), m-v[i])-v.begin();
			if(t == 0){
				if(v[i] <= m)ans = max(ans, v[i]);
			}else{
				if(v[i]+v[t-1] <= m)ans = max(ans, v[i]+v[t-1]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
struct unionfind{
  vector<int> p;
  unionfind(int n){
    p = vector<int>(n, -1);
  }
  int root(int x){
    if (p[x] == -1){
      return x;
    } else {
      p[x] = root(p[x]);
      return p[x];
    }
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
  void unite(int x, int y){
    x = root(x);
    y = root(y);
    p[x] = y;
  }
};
int main(){
  cout << fixed << setprecision(3);
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<double> x(n), y(n), z(n), r(n);
    for (int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    vector<tuple<double, int, int>> E;
    for (int i = 0; i < n; i++){
      for (int j = i + 1; j < n; j++){
        double d = sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2) + pow(z[j] - z[i], 2));
        if (d <= r[i] + r[j]){
          E.push_back(make_tuple(0, i, j));
        } else {
          E.push_back(make_tuple(d - r[i] - r[j], i, j));
        }
      }
    }
    sort(E.begin(), E.end());
    int m = E.size();
    double ans = 0;
    unionfind UF(n);
    int cnt = 0;
    for (int i = 0; i < m; i++){
      double d = get<0>(E[i]);
      int v = get<1>(E[i]);
      int w = get<2>(E[i]);
      if (!UF.same(v, w)){
        UF.unite(v, w);
        ans += d;
        cnt++;
        if (cnt == n - 1){
          break; 
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3340
""" B
    https://atcoder.jp/contests/abc175/tasks/abc175_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(N, L):
    count = 0

    for i in range(0, N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                lines = [L[i], L[j], L[k]]
                if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                    continue
                max_line = max(lines)
                sum_line = sum(lines) 
                if max_line < sum_line - max_line:
                    count += 1

    return count

if __name__ == "__main__":
    _N = readInteger()
    _L = readIntegerSet(_N)

    print(main(_N, _L))


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

int main()
{
	string a,b,c;
	cin>>a>>b;
	int a_s,b_s;
	cin>>a_s>>b_s;
	cin>>c;
	if(a==c)
		a_s--;
	else
		b_s--;
	cout<<a_s<<' '<<b_s;
	return 0;
} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  bool h = false;
  bool fin = false;
  scanf("%d", &n);
  REP(i, 10){
    REP(j, 10){
      if (n == i * j){
        h = true;
        fin = true;
        break;
      }  
    if (fin) break;  
    }
  }

  if (h) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        int ans = 0;
        int count = 0;  //水やり完了済
        boolean watered = false;

        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
            if (h[i] == 0) {
                count++;
            }
        }

        while (count < h.length) {
            for (int i = 0; i < N; i++) {
                // 0でなければ減らす
                if (h[i] > 0) {
                    h[i]--;
                    if (h[i] == 0) {
                        count++;
                    }
                    watered = true;
                    continue;
                }

                // 0になってたら別の水やり操作が必要
                if (watered) {
                    ans++;
                    watered = false;
                }
            }

            if (watered) {
                ans++;
                watered = false;
            }
        }

        out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
      #define ll long long  int
      #define N 400000
      #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
      #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
      #define po pop_back
      #define pb push_back
      #define pp pair<ll,ll>
      #define lb lower_bound
      #define fi first
      #define se second
      #define debug(x) cout << #x << " = " << x << endl
      #define ub upper_bound
      #define ibs ios_base::sync_with_stdio(false)
      #define cti cin.tie(0)
      #define all(x) x.begin(),x.end()
      #define PI 3.14159265
      #define cot cout.tie(0)
      using namespace std;
       /**
        * @author :: Sawlani
        *
        */

        int main()
        {
            ll n;
             cin >> n;
             ll ans=100000000000000;
             f(i,1,sqrt(n))
             {
                 ll k=n/i;
                 if(n%i==0&&n%k==0)
                 {
                     ans=min(ans,i+k-2);
                 }

             }
             cout <<  ans <<  endl;

        }




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
#define ll long long
int main(){
	ll N,ans=0,i=1;
	
	cin >> N;
	for (int i = 1; i < N+1; i++){
		int x = log10(i);
		if (((x+1) % 2) == 1){
			ans++;
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	string s;
	cin >> s;
	int len = s.size();
	if(s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}
	int ccnt = 0;
	int cind;
	for(int i = 2;i <= len-2;i++){
		if(s[i] == 'C'){
			ccnt++;
			cind = i;
		}
	}
	if(ccnt != 1){
		cout << "WA" << endl;
		return 0;
	}
	for(int i = 1;i < len;i++){
		if(i == cind) continue;
		if(isupper(s[i])){
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


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

signed main(){
  unsigned long long int N,K,U;
  cin >> N >> K;
  U=N;
  long long ans1=0;
  long long ans2=0;
  ans1=U%K;
  ans2=K-U%K;
  cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 3644
while true do
    n,t,l,b=gets.chomp.split(" ").map(&:to_i)
    exit if n == 0
    l_array = []
    b_array = []
    l.times do
        l_array.push(n - gets.to_i)
    end
    b.times do
        b_array.push(n - gets.to_i)
    end
    board = Array.new(n+1, 0)
    rest_board = Array.new(n+1, 0)
    board[n] = 1
    t.times do
        next_board = Array.new(n+1, 0)
        next_rest_board = Array.new(n+1, 0)

        board.each_with_index do |num, i|
            if i == 0
                next_board[0] = num * 6
            else
                (1..6).each do |j|
                    next_board[(i-j).abs] += num
                end
            end
        end
        l_array.each do |i|
            next_rest_board[i] = next_board[i]
            next_board[i] = 0
        end
        b_array.each do |i|
            next_board[n] += next_board[i]
            next_board[i] = 0
        end
        rest_board.each_with_index do |num, i|
            next_board[i] += num * 6
        end

        board = next_board
        rest_board = next_rest_board
    end
    sum = board.inject(:+) + rest_board.inject(:+)
    goal = board[0]

    result = (goal.to_f / sum.to_f).round(6)
    puts format("%.6f", result)
end


Measured memory_bytes: 7488
import java.util.*;

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

        int N_500 = 0;
        int N_5 = 0;

        int happy =0;

        N_500  = X / 500;
        N_5 = (X % 500) / 5;

        happy = 1000 * N_500 + 5 * N_5;

        System.out.print(happy);
        




        


    }

}

Measured memory_bytes: 23124
n=int(raw_input())

while n:
    n-=1
    x1,y1,x2,y2,x3,y3,x4,y4=map(float,raw_input().split())
    print 'YES' if abs((y3-y4)*(x1-x2)-(y1-y2)*(x3-x4))< 1e-10 else 'NO'

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

int main() {
	string w, e("-");	
	int c, i, s;
	while (cin >> w) {
		if (w == e) break;
		cin >> c;
		i = 0;
		while (c--) {
			cin >> s;
			i += s;
		}
		i %= w.length();
		cout << w.substr(i) << w.substr(0, i) << endl;
	}
	return 0;
}

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

import sys
import os
import itertools

T = int(input())
for t in range(T):
    input()

    map = []
    for i in range(8):
        s = input().strip()
        map.append(list(s))

    X = int(input())
    Y = int(input())
    X -= 1
    Y -= 1

    def exist_bomb(x, y):
        if 0 <= x < 8 and 0 <= y < 8 and map[y][x] == '1':
            return True
        else:
            return False

    Q = []
    Q.append((X, Y))
    map[Y][X] = '0'

    while Q:
        x, y = Q.pop(0)

        for i in range(1, 4):
            if exist_bomb(x + i, y):
                Q.append((x + i, y))
                map[y][x+i] = '0'

            if exist_bomb(x - i, y):
                Q.append((x - i, y))
                map[y][x-i] = '0'

            if exist_bomb(x, y + i):
                Q.append((x, y + i))
                map[y+i][x] = '0'

            if exist_bomb(x, y - i):
                Q.append((x, y - i))
                map[y-i][x] = '0'

    # result
    print("Data {}:".format(t+1))
    for i, row in enumerate(map):
        print(''.join(row))

Measured memory_bytes: 7692
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
#define MOD 1'000'000'007
using namespace std;
typedef long long ll;
typedef long double ld;

ll N,A,B;
ll X[100000];

int main(){
    cin>>N>>A>>B;
    rep(i,N) cin>>X[i];

    ll ans=0;
    rep(i,N-1){
        ll walk=A*(X[i+1]-X[i]);
        ans+=min(walk,B);
    }

    cout<<ans<<endl;
}

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

int A,B,C,D;

int main()
{
    cin>>A>>B>>C>>D;

    int t = 0;
    int s = max(A,C);
    int e = min(B,D);

    t = max(t,e-s);

    cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int max(vector<int> s){
    int a=0;
    for(int i=0; i<s.size() ; i++){
        a = max(a, s.at(i));
    }
    return a;
}
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char> > ch(h,vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0 ; j < w; j++){
            cin>>ch.at(i).at(j);
        }
    }
    bitset<10> ho;
    int mini=h*w;
    for(int i =0; i<(1<<(h-1)); i++){
        bool ok=true;
        ho = i;
        vector<int> sen;
        for(int j =0; j<10; j++){
            if(ho.test(j)) sen.push_back(j+1);
        }
      
        sen.push_back(h);
        int tate=0;
        int si=sen.size();
        vector<int> white(si,0);
        for(int j =0; j<w; j++){
            vector<int> tmpwhite(si,0);
            int l =0;//たての位置
            for(int m=0; m<sen.size() ; m++){
                int count =0;
                while(l<sen.at(m)){
                    if(ch.at(l).at(j)=='1') count++;
                    l++;
                }
                tmpwhite.at(m)=count;
            }
            for(int m=0; m<sen.size(); m++){
                white.at(m) += tmpwhite.at(m);
            }
            if(max(tmpwhite)>k){
                ok =false;
                break;
            }
            if(max(white)>k){
                tate++;
                white = tmpwhite;
            }
        }
        if(ok) mini = min(mini,(tate +si-1) );
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
 
abmax = max(x,y)+1
 
price = 0
 
for i in range(abmax):
  nab = i*2
  na = x - i
  nb = y - i
  if(na<0):
    na = 0
  if(nb<0):
    nb = 0
  p = c * nab + a * na + b * nb
  if(p<price or price == 0):
    price = p
print(price)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <set>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	int n, m;
  	cin >> n >> m;
  	for(int i = m / n; i > 0; --i){
    	if(m % i == 0){
        	cout << i << endl;
          	break;
        }
    }
}


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

int main(){
	long n,a,b;
  	cin >> n >> a >> b;
	if( a>b || n==1 && a!=b) {
    	cout << 0 << endl;
      	return 0; 
    }
	cout << (n-2)*(b-a)+1 <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, m; cin >> n >> m;
    vector<int> s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];

    vector<vector<ll>> dp(n+5, vector<ll>(m+5, 0)), a(n+5, vector<ll>(m+5, 0));
    rep(i, n) rep(j, m) {
        if (s[i] == t[j]) {
            a[i+1][j+1] = dp[i][j] + 1;
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j] + a[i+1][j+1];
            chmod(dp[i+1][j+1]);
        } else {
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j] + a[i+1][j+1];
            chmod(dp[i+1][j+1]);
        }
    }
    cout << dp[n][m]+1 << endl;

    return 0;
}




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

import heapq
N, Q = (int(i) for i in input().split())
L = [0] * (2 * N + Q)
for i in range(N):
    S, T, X = (int(i) for i in input().split())
    L[2 * i] = (S-X, 1, X)
    L[2 * i + 1] = (T-X, -1, X)
for i in range(Q):
    D = int(input())
    L[2 * N + i] = (D, 2, 0)
L.sort()

Xs = set([])
XH = []
heapq.heapify(XH)
for t, f, X in L:
    if f == 1:
        Xs.add(X)
        heapq.heappush(XH, X)
    elif  f == -1:
        Xs.remove(X)
    else:
        if Xs:
            while XH[0] not in Xs:
                X = heapq.heappop(XH)
            print(XH[0])
        else:
            print("-1")

Measured memory_bytes: 89680
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    ll power = 1;
    for(int i = 1; i <= N; ++i){
        power *= i;
        power %= mod;
    }
    cout << power << endl;

    return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}

const int N = 300300;
ll f[N], rf[N];

ll getC(int n, int k) {
	if (k < 0 || k > n) return 0;
	return mult(f[n], mult(rf[k], rf[n - k]));
}

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

	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = mult(f[i - 1], i);
	rf[N - 1] = rev(f[N - 1]);
	for (int i = N - 1; i > 0; i--)
		rf[i - 1] = mult(rf[i], i);

	int n;
	ll a, b, k;
	cin >> n >> a >> b >> k;
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		ll z = k - a * i;
		if (z < 0 || z % b != 0) continue;
		z /= b;
		if (z > n) continue;
		ans = add(ans, mult(getC(n, i), getC(n, z)));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll a,b,x=0,y,d=0,n,h,w,k,m,min=1000,ans=0,ptr=0,sum=0;
    string s,s1,s2;
    bool f=true;
    cin >> a >> b;
    if(b==1) {
        cout << 0 <<endl;
        return 0;
    }

    while(f){
        if(sum+a>=b){
            ans++;
            f = false;
        }
        else if(b > sum){
            sum += a-1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256