akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

const int INF = 1e9;

template<class T>
struct segment_tree {
  int size;
  T inf;
  vector<T> tree; 

  segment_tree() {}

  segment_tree(int n, T inf) {
    this->inf = inf;
    init_rmq(n);
  }

  //initialization for range minimum query
  void init_rmq(int n) {
    size = 1;
    while (size < n) size *= 2;
    tree.resize(size*2-1);
    REP(i,size*2-1) tree[i] = inf;
  }

  //change the valued of k-th(0-based index) into x
  void update(int k, T x) {
    k += size - 1;
    tree[k] = x;
    while (k > 0) {
      k = (k-1)/2;
      tree[k] = min(tree[k*2+1], tree[k*2+2]);
    }
  }

  //get minimum on [s, e) calling rmq(s,e)
  T rmq(int s, int e) {
    return rmq(s, e, 0, 0, size);
  }

  //how to use：rmq(s, e, 0, 0, [size])
  T rmq(int s, int e, int k, int l, int r) {
    if (r<=s || e<=l)
      return inf;
    else if (s<=l && r<=e) 
      return tree[k];
    else {
      T vl = rmq(s, e, k*2+1, l, (l+r)/2);
      T vr = rmq(s, e, k*2+2, (l+r)/2, r);
      return min(vl, vr);
    }
  }

  //initialization for range sum query
  void init_sum(int n) {
    size = 1;
    while (size < n) size *= 2;
    tree.resize(size*2-1);
    REP(i,size*2-1) tree[i] = 0;
  }

  void update_sum(int k, int x) {
    k += size-1;
    tree[k] = x;
    while (k>0) {
      k = (k-1)/2;
      tree[k] = tree[k*2+1] + tree[k*2+2];
    }
  }

  //Range Sum Query calling rsq(s,e)
  T rsq(int s, int e) {
    return rsq(s, e, 0, 0, size);
  }

  T rsq(int s, int e, int k, int l, int r) {
    if (r<=s || e<=l)
      return 0;
    else if (s<=l && r<=e)
      return tree[k];
    else {
      T vl = rsq(s, e, k*2+1, l, (l+r)/2);
      T vr = rsq(s, e, k*2+2, (l+r)/2, r);
      return vl + vr;
    }
  }
};

int main() {
  int h, w;
  fscanf(stdin, "%d%d ", &h, &w);
  segment_tree<int> hd(w+10, INF);
  map<int, int> hdmap;
  REP(i,w) {
    hdmap[i] = i;
    hd.update(i,0);
  }
  REP(i,h) {
    int l, r;
    fscanf(stdin, "%d%d ", &l, &r);
    --l; 
    auto it = hdmap.lower_bound(l);
    int re = -1;
    while (it != hdmap.end() && it->first < r) {
      re = max(re, it->second);
      hd.update(it->first, INF);
      hdmap.erase(it++);
    }
    if (re != -1 && r < w) {
      if (!hdmap.count(r))
        hdmap[r] = re;
      else {
        int x = hdmap[r];
        hdmap[r] = max(x, re);
      }
      hd.update(r, r-hdmap[r]);
    }
    int res = hd.rmq(0,w,0,0,hd.size);
    fprintf(stdout, "%d\n", res == INF ? -1 : res+i+1);
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  ll result = 0;
  while (true) {
    ll maxi = 0;
    int maxIdx = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] >= maxi) {
        maxi = a[i];
        maxIdx = i;
      }
    }
    if (maxi < n) break;
    ll quot = a[maxIdx] / n;
    result += quot;
    a[maxIdx] %= n;
    for (int i = 0; i < n; i++) {
      if (i == maxIdx) continue;
      a[i] += quot;
    }
  }
  printf("%lld\n", result);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[500010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
ll start;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld%lld",&n,&m,&start);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		g.e[i].s=x;
		g.e[i].g=y;
		g.e[i].c=c;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

//ベルマンフォード
//グラフと始点を引いて単一始点最短経路を返す
//辺のソートは不要
//O(EV)、負辺ありでもOK
//*
ll d[1010];
void berumanfoodo(ll s){
	rep(i,0,g.vcnt)d[i]=i==s?0:INF;
	rep(nnnn,0,g.vcnt-1)rep(i,0,g.ecnt)if(d[g.e[i].s]!=INF)d[g.e[i].g]=min(d[g.e[i].g],d[g.e[i].s]+g.e[i].c);
	rep(nnnn,0,g.vcnt)rep(i,0,g.ecnt)if(d[g.e[i].s]!=INF){
		if(d[g.e[i].g]>d[g.e[i].s]+g.e[i].c)d[g.e[i].g]=-INF;
	}
}
//*/

int main(){
	readgraph();
	berumanfoodo(start);
	int flag=1;
	rep(i,0,g.vcnt)flag&=d[i]!=-INF;
	if(flag)rep(i,0,g.vcnt)printf(d[i]==INF?"INF\n":"%lld\n",d[i]);
	else puts("NEGATIVE CYCLE");
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
ll const mod = 1e9+7;

int main(void){
    // Your code here!
    string S;
    cin >> S;
    int ans = 0;
    if(S=="SAT") cout << 1 << endl;
    else if(S=="FRI") cout << 2 << endl;
    else if(S=="THU") cout << 3 << endl;
    else if(S=="WED") cout << 4 << endl;
    else if(S=="TUE") cout << 5 << endl;
    else if(S=="MON") cout << 6 << endl;
    else cout << 7 << endl;
}


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

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

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

int main(void){

    string str;
    cin >> str;

    ll ans = 0;

    for(int i = 0; i < 1<<(str.size()-1);i++){
        ll num = str[0]-'0';

        for(int j = 0;j < str.size()-1;j++){
            if(i & (1<<j)){
                ans += num;
                num = 0;
            }
            num = num*10 + str[j+1]-'0';
        }
        ans += num;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            // if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/testdata.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/testData.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
            // fin.close();
            // fout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver
    {

        public void solve (InputReader cin, PrintWriter cout)
        {
            try {
                int n;
                n = cin.nextInt();
                int sum = 0;
                while (n > 0) {
                    sum += n % 10;
                    n = n / 10;
                }
                if (sum == 1) {
                    sum = 10;
                }
                cout.println(sum);
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

        public double nextDouble () {
            return Double.parseDouble(next());
        }

    }

}

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

int main() {
int N;
  
 
  cin>>N;
  
  vector<int> B(N);
  
int i=0;
    for(i=0;i<N;i++)
  {cin>>B.at(i);}
  
  int c=B.at(0);
  
for(i=1;i<N;i++)
{c=c+min(B.at(i-1),B.at(i));
  }

  cout<<c+B.at(N-2)<<endl;

}

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

using namespace std;

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

void solve() {
  ll n, a, b;
  cin >> n >> a >> b;
  if(n == 1) {
    if(a == b) cout << 1 << endl;
    else cout << 0 << endl;
    return;
  }
  if(a > b) {
    cout << 0 << endl;
    return;
  }
  ll lhs = a*(n-1) + b;
  ll rhs = b*(n-1) + a;
  cout << rhs-lhs+1 << endl;
}

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


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()


const int INF = 1001001001;

int main(){
	int n, t; cin >> n >> t;
	vector<pi> ab(n); rep(i,n) cin >> ab[i].first >> ab[i].second;
	sort(all(ab));
	vector<vi> dp(n+1, vi(t+1, 0));
	dp[0][0] = 0;
	rep(i, n){
		rep(j, t){
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			dp[i+1][min(t, j+ab[i].first)] = max(dp[i][min(t,j+ab[i].first)], dp[i][j]+ab[i].second);
		}
	}
	int ans = 0;
	// rep(i,n+1){
	// 	rep(j, t+1){
	// 		cout << dp[i][j] <<" ";
	// 	}
	// 	cout << endl;
	// }
	rep(i,n+1){
		ans = max(ans, dp[i][t]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b){
  if (b == 0){
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b){
  return a * b / gcd(a, b);
}
int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 1; i < (1 << N); i++){
    long long c = 1;
    for (int j = 0; j < N; j++){
      if (i >> j & 1){
        c = lcm(c, p[j]);
      }
    }
    bool ok = true;
    for (int j = 0; j < N; j++){
      if (!(i >> j & 1)){
        if (c % p[j] == 0){
          ok = false;
        }
      }
    }
    if (ok){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3088
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
    
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

# v: node, p: parent node, add: parent value
def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])
 
dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))


Measured memory_bytes: 301432
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  string s, t;
  ll ans = -1;
  cin >> s >> t;
  for (int i = 0; i < t.size(); i++) {
    if (s.find(t[i], 0) == string::npos) {
      cout << ans << endl;
      return 0;
    }
  }
  ll loop = 0;
  int tmp = -1;
  for (int i = 0; i < t.size(); i++) {
    if (s.find(t[i], tmp + 1) == string::npos) {
      loop++;
      tmp = s.find(t[i], 0);
    } else {
      tmp = s.find(t[i], tmp + 1);
    }
  }
  cout << loop * s.size() + tmp+1;

  return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

// const ll mod = 1000000007;
// const ll mod = 998244353;
const ll mod = 1000003;

const int MAX_N = 1000010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    create_table(mod-1);
    int q;
    cin >> q;
    for (int i = 0;i < q;++i) {
        ll x,d,n;
        cin >> x >> d >> n;
        if (d) {
            ll a = x*pow_mod(d,-1)%mod,ans;
            if (a+n > mod) ans = 0;
            else ans = fact[a+n-1]*fact_inv[a-1]%mod*pow_mod(d,n)%mod;
            cout << ans << "\n";
        } else cout << pow_mod(x,n) << "\n";
    }
    return 0;
}

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

#define endl '\n'
#define STDIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define deb(x) cout << #x << " " << x << endl;

using namespace std;

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

	int n, k, q, x;
	cin >> n >> k >> q;
	vector<int> players(n, k - q);

	while(q--)
	{
		cin >> x;
		players[x - 1]++;
	}

	for (int i : players)
	{
		if (i > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 1024
def main():
    S = int(input())
    x1, y1 = 0, 0
    x2, y2 = 1, 10**9

    x3, y3 = divmod(S, -y2)
    x3, y3 = -x3, -y3

    print(x1, y1, x2, y2, x3, y3)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    vector<char>S;
    for(int i=0;i<n;i++)
    {
        if(str[i]!=str[i+1])
        {
          S.push_back(str[i]);
        }
    }
    cout<<S.size()<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    int num = stoi(str), div = 0;
    for(auto&& i : str){
        div += i - '0';
    }
    if(num % div){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for(int i = 0; i < N; i++){
    if(A[i] == A[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n, x;

int gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {
	cin >> n;
	vector<int> a;
	for (int i=0;i<n;i++) {cin >> x; a.push_back(x);}
	x=gcd(a[0], a[1]); for (int i=0;i<n;i++) x=gcd(a[i], x);
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] && s[0] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

std::vector<int> a, b, c, d;
int n, m;
std::vector<int> stack;
int res = 0;
void dfs() {
	if ((int) stack.size() == n) {
		int cur = 0;
		for (int i = 0; i < (int) a.size(); i++)
			if (stack[b[i]] - stack[a[i]] == c[i]) cur += d[i];
		res = std::max(res, cur);
		return;
	}
	for (int i = stack.size() ? stack.back() : 1; i <= m; i++) {
		stack.push_back(i);
		dfs();
		stack.pop_back();
	}
}

int main() {
	n = ri();
	m = ri();
	int q = ri();
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for (int i = 0; i < q; i++) a[i] = ri() - 1, b[i] = ri() - 1, c[i] = ri(), d[i] = ri();
	dfs();
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,m,i,j,k,l,vis[20][20],a[100005],f[100005][20],x,y,z,ans,top[100005],b[100005][20];
int maxx(int u,int v){
	return u>v?u:v;
}
int main(){
	//freopen("camp.in","r",stdin);
	//freopen("camp.out","w",stdout);
	n=read();m=read();
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			vis[i][j]=-1000000000;
	for(i=1;i<=m;i++){
		x=read()-1;y=read()-1;z=read();
		vis[x][y]=z;
		vis[y][x]=z;
		ans+=z;
	}
	for(i=0;i<(1<<n);i++)
		for(j=0;j<n;j++)
			if((1<<j)&i){
				a[i]=a[i^(1<<j)];
				for(k=j;k<n;k++){
					if(((1<<k)&i)&&vis[j][k]>0)
						a[i]+=vis[j][k];
					if((1<<k)&i){
						top[i]++;
						b[i][top[i]]=k;
					}
				}
				break;
			}
	for(i=0;i<(1<<n);i++)
		for(j=0;j<n;j++)
			f[i][j]=-1000000000;
	for(i=1;i<(1<<n);i+=2)
		f[i][0]=a[i];
	for(i=1;i<(1<<n);i+=2)
		for(j=1;j<n;j++)
			if((i&(1<<j))&&(i==(1<<n)-1||(i&(1<<n-1))==0))
				for(k=(i-1)&i;k>=1;k=(k-1)&i)
					if((k&(1<<j))==0)
						for(l=1;l<=top[k];l++)
							f[i][j]=maxx(f[i][j],f[k][b[k][l]]+a[i^k]+vis[j][b[k][l]]);
	pus(ans-f[(1<<n)-1][n-1],2);
	return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){

  ll l,r;
  cin >> l >> r;

  ll min=2019;
  for(ll i=l;i<r;i++){
    if(i%2019==0){
      min=0;
      break;
    }

    for(ll j=i+1;j<=r;j++){
      if(j%2019==0){
        min=0;
        break;
      }

      ll remainder=(i*j)%2019;
      if(min>remainder){
        min=remainder;
      }
    }

    if(min==0){
      break;
    }
  }
cout << min << endl;

  }

Measured memory_bytes: 3540
use std::io::*;
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
    fn bsearch(&self, x: &T) -> Option<usize>;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn bsearch(&self, x: &T) -> Option<usize> {
        let lower_idx = self.lower_bound(x);
        if lower_idx < self.len() && self[lower_idx] == *x {
            return Some(lower_idx);
        }
        return None;
    }
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let ci: Vec<char> = s.chars().collect();

    let mut r_idxs: Vec<usize> = Vec::new();
    let mut g_idxs: Vec<usize> = Vec::new();
    let mut b_idxs: Vec<usize> = Vec::new();

    for i in 0..n {
        if ci[i] == 'R' {
            r_idxs.push(i);
        } else if ci[i] == 'G' {
            g_idxs.push(i);
        } else {
            b_idxs.push(i);
        }
    }

    // println!("{:?}", r_idxs);
    // println!("{:?}", g_idxs);
    // println!("{:?}", b_idxs);

    let mut ans = 0;
    for i in 0..r_idxs.len() {
        let r = r_idxs[i];
        for j in 0..g_idxs.len() {
            let g = g_idxs[j];
            ans += b_idxs.len();

            let mut v: Vec<usize> = vec![r, g];
            v.sort();

            let mut nums: Vec<usize> = Vec::new();
            if v[1] * 2 >= v[0] {
                nums.push(v[1] * 2 - v[0]);
            }
            if v[0] * 2 >= v[1] {
                nums.push(v[0] * 2 - v[1]);
            }
            if (v[0] + v[1]) % 2 == 0 {
                nums.push((v[0] + v[1]) / 2);
            }
            for num in nums {
                if b_idxs.bsearch(&num).is_some() {
                    ans -= 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[100009],b[64];
ll gmatrix[100009][64];//in case of multiple queries use 2-D array
ll basis[100009];//for multiple queries use array
void add(ll x,ll index)
{
    /*basis[index]=basis[index-1];
    for(ll i=63;i>=0;i--)
    {
        gmatrix[index][i]=gmatrix[index-1][i];
    }*/
    for(ll i=63;i>=0;i--)
    {
    	if(b[i])
    		continue;
        if(x&((ll)1<<i))
        {
            if(gmatrix[index][i])
                x^=gmatrix[index][i];
            else
            {
                gmatrix[index][i]=x;
                basis[index]++;
                return;
            }
        }
    }
}
ll maximum(ll x,ll index)//for finding maximum xor
{
    for(ll i=63;i>=0;i--)
    {
    	if(b[i])
    		continue;
        if(!(x&((ll)1<<i)))
        {
            x^=gmatrix[index][i];
        }
    }
    return x;
}
void solve()
{
	ll n;
	cin>>n;
	ll x;
	ll z=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		x=a[i];
		for(ll j=0;j<62;j++)
		{
			ll p=x%2;
			b[j]^=p;
			x/=2;
		}
	}
	for(ll i=0;i<n;i++)
	{
		x=a[i];
		z^=x;
		add(x,0);
	}
	ll p=maximum(0,0);
	z^=p;
	cout<<p+z;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}


Measured memory_bytes: 4448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    char s[100200];
    scanf("%s",s);
    for (int i=1; i<strlen(s); i++){
        if (s[i]==s[i-1]){
            printf("%d %d\n",i,i+1);
            return 0;
        }
    }
    for (int i=2; i<strlen(s); i++){
        if (s[i]==s[i-2]){
            printf("%d %d\n",i-1,i+1);
            return 0;
        }
    }
    printf("-1 -1\n");
	return 0 ;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int curLen = 0;
    int prev = (int) 1e9 + 5;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x <= prev)
        {
            curLen++;
        }
        else
        {
            curLen = 1;
        }
        prev = x;
        ans = max(ans, curLen);
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main(void)
{
    ll n,x;
    cin >> n >> x;
    vector<ll> xi(n);
    ll ans=0;
    for (int i = 0; i < n; i++) {
        cin >> xi[i];
        xi[i] = abs(xi[i]-x);
        if(i==0)ans = xi[i];
        else ans = gcd(ans, xi[i]);
    }
    pr(ans);
}

Measured memory_bytes: 1024
D, N = map(int, input().split())
ith_ans = 0
candi = 1
while True:
    if candi % pow(100, D) == 0 and candi % pow(100, D+1) != 0:
        ith_ans += 1
    if ith_ans == N:
        print(candi)
        break
    candi += 1


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int r;
	cin>>r;
	if(r<1200) cout<<"ABC";
	else if(1200<=r&&r<2800) cout<<"ARC";
	else if(r>=2800) cout<<"AGC";
	return 0;
}

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


int main() {
  int n, m;
  cin >> n >> m;
  map<ll,int> mp;
  rep(i,n) {
    int b;
    cin >> b;
    mp[-1*b]++;
  }
  rep(i,m) {
    int x, y;
    cin >> x >> y;
    mp[-1*y]+=x;
  }
  ll ans=0;
  int num=n;
  for(auto p : mp) {
    ans += -1*p.first*min(p.second,num);
    num -= p.second;
    if(num<=0) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 16100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    int n;
    cin>>n>>k;
    vector<int>a(k);
    for(int i=0;i<k;i++){
        cin>>a[i];
    }
    int z=n-(a[k-1]-a[0]);
    for(int i=0;i<k-1;i++){
        z=max(z,a[i+1]-a[i]);
    }
    int result=n-z;
    cout<<result<<endl;

    return 0;
}

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

int main(){
    int a,b;
    
    cin>>a>>b;
    
    if(a > b){
        cout<<"a > b"<<endl;
        
    }else if(a < b){
        cout<<"a < b"<<endl;
        
    }else{
        cout<<"a == b"<<endl;
        
    }
}


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

using namespace std;

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

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

    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        auto lb = lower_bound(a.begin(), a.end(), k) - a.begin();
        auto ub = upper_bound(a.begin(), a.end(), k) - a.begin();
        cout << lb << " " << ub << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k,i=0,j,c=0,p,h[1000010];
    cin >> n >> k;
    if(n%k==0)
    {
        cout << '0' << endl;
        return 0;
    }
    if(n<k)
    {
    if(n<abs(n-k))
    {
        cout << abs(n) << endl;
        return 0;
    }
    else
    {
        cout << abs(n-k) << endl;
        return 0;
    }
    }
    if(abs(n%k)<abs(n%k-k))
    {
        cout << n%k << endl;
    }
    else
    {
        cout << abs(n%k-k) << endl;
    }
    return 0;

}


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

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

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

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

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

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

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

    bitset<200000> sieve;
    sieve.flip();
    sieve[1] = 0;
    for (ll i = 2; i < 200000; i++) for (ll j = i * i; j < 200000; j += i)
        sieve[j] = 0;

    while (true) {
        int n, p; cin >> n >> p;
        int u = p * 2 + 5;
        if (n == -1) break;
        vi v, v2;
        for (int i = n + 1; v.size() < u; i++) if (sieve[i]) v.push_back(i);
        // cout << "? "; for (int h : v) cout << h << " "; cout << endl;
        rep(i, 0, u) rep(j, i, u) v2.push_back(v[i] + v[j]);
        sort(all(v2));
        // for (int h : v2) cout << h << " "; cout << endl;
        cout << v2[p - 1] << endl;
    }
}


Measured memory_bytes: 3340
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    int sum = 700;
    rep(i, s.size()) {
      if (s[i] == 'o') {
        sum += 100;
      }
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;
    cin >> n;
    vector<int>a(n-1);
    rep(i,n-1){
        cin >> a[i];
    }
    map<int,int>mp;
    rep(i,n-1){
        int now = a[i];
        mp[now]++;
    }
    rep(i,n){
        cout<<mp[i+1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 13520
from collections import defaultdict,deque

N,M=map(int,input().split())
Out=defaultdict(list)
In=defaultdict(int)

for i in range(M):
    x,y=map(int,input().split())
    Out[x].append(y)
    In[y]+=1

q=deque(v for v in range(1,N+1) if In[v]==0)

dp=[0]*(N+1)

while q:
    From = q.popleft()
    for to in Out[From]:
        dp[to]=max(dp[From]+1,dp[to])
        In[to]-=1
        if In[to]==0:
            q.append(to)
print(max(dp))


Measured memory_bytes: 84536
import numpy as np
from collections import Counter
import math

n, m = map(int, input().split())
A = np.array(list(map(int, input().split())))


def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

acc_sum = [0]
tmp = 0
for i in range(n):
    tmp += A[i]
    acc_sum.append(tmp % m)
acc_sum = Counter(acc_sum)
ans = 0
for k in acc_sum:
    if acc_sum[k] >= 2:
        ans += combinations(acc_sum[k], 2)
print(ans)


Measured memory_bytes: 23604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define repA(i,n) for(ll i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

void solve() {
  string s;
  cin>>s;
  rep(i,3)  cout<<s[i];
  
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  ll t = 1;
  //cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;

using namespace std;

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

	cin>>c;
	printf("%c",c + 1);

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int cost[] = { 0,2,5,5,4,5,6,3,7,6};
int use[10];
int ansUse[10];
int n, m;
int a[9];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}



int main() {
	double rate = 380000.0;
	double ans = 0;
	int n;
	scanf("%d", &n);

	REP(i, n) {
		double x;
		char u[4];
		scanf("%lf%s", &x, u);
		if (strcmp(u, "JPY") == 0) {
			ans += x;
		}
		else {
			ans += x*rate;
		}
	}
	printf("%lf\n", ans);
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))


def solve(N,A):
    ans = 0
    lis = [0]*(2*10**5)
    for i,a in enumerate(A):
        if -a-i >= -2*10**5:
            lis[-a-i]+=1
    for i,a in enumerate(A):
        if a-i < 0:
            ans += lis[a-i]
    return ans
print(solve(N,A))

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

using namespace std;
string s1,s;
int n,i;
bool pal(string a)
{
    string b=a;
    reverse(b.begin(), b.end());
    return (a==b);
}
int main()
{
    cin>>s;
    n=s.size();

    for(i=0;i<(n-1)/2;i++)
        s1.push_back(s[i]);

    if(pal(s) && pal(s1))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[5005],c[5005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		p[i]--;
	}
	for(int i=0;i<n;i++)
	cin>>c[i];
	long long ans=-1e18;
	for(int i=0;i<n;i++)
	{
		int now=i;
		long long cs=0;
		long long cc=0;
		while(true){
			cc++;
			cs+=c[now];
			now=p[now];
			if(now==i)
			break;
		}
		long long path=0;
		int cnt=0;
		while(true){
			cnt++;
			path+=c[now];
			if(cnt>k)
			break;
			int num=(k-cnt)/cc;
			long long score=path+max(0LL,cs)*num;
			ans=max(ans,score);
			now=p[now];
			if(now==i)
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll n,m,i,j,cc=100000000000000LL;
   cin>>n;
   for(i=1;i*i<=n;i++){
      if(n%i==0){
        ll x=i-1;
        ll y=n/i-1;
        //cout<<x+y<<endl;
        if(cc>x+y)cc=x+y;
      }
   }
   cout<<cc<<endl;
}


Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {
	
	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

int main(void) {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

/*
2 1  1
3 3  2
4 6  3
5 10 4

*/


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(long[]);
    const H = tmp[0], W = tmp[1];
    tmp = readln.split.to!(long[]);
    const h = tmp[0], w = tmp[1];

    writeln(H * W - (h * W + w * H - h * w));
}



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

int main (){
  string x;
  int sum = 0;
  while(1){
    cin >> x;
    if(x == "0" ) break;
    for(int i = 0, l = x.size(); i<l ; i++){
      sum += x[i] - '0'; 
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}



Measured memory_bytes: 3200
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string s, t;
	std::cin >> s >> t;
	std::cout << t << s << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main(){
	int n,x; cin>>n>>x;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	sort(all(v));
	rep(i,n){
		if(x-v[i]>=0) {x-=v[i]; v[i]=0;}
	}
	if(x>0) v[n-1]-=x;
	int cnt=0;
	rep(i,n){
		if(v[i]==0) cnt++;
	}
	cout<<cnt<<endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(x[i] >= abs(k-x[i])){
            ans += abs(k-x[i]);
        }else{
            ans += x[i];
        }
    }
    cout << 2*ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		int target = cin.nextInt();
		String list[] = new String[target];
		int tmp=100;
		int listNo =0;
		for(int i=0;i<target;i++){
			list[i] = cin.next();
			if(list[i].length()<tmp){
				tmp = list[i].length();
				listNo = i;
			}
		}
		// shortest word
		HashMap<Character,Integer> result = new HashMap<Character,Integer>();
		for(int j=0;j<list[listNo].length();j++){
			if(result.containsKey(list[listNo].charAt(j))){
				result.put(list[listNo].charAt(j), result.get(list[listNo].charAt(j))+1);
			}else{
				result.put(list[listNo].charAt(j), 1);
			}
		}
		HashMap<Character,Integer>tmp_map = new HashMap<Character,Integer>();
		for(int k=0;k<target;k++){
			if(k!=listNo){
				tmp_map.clear();
				for(int l=0;l<list[k].length();l++){
					if(tmp_map.containsKey(list[k].charAt(l))){
						tmp_map.put(list[k].charAt(l), tmp_map.get(list[k].charAt(l))+1);
					}else{
						tmp_map.put(list[k].charAt(l), 1);
					}
				}
				if(result.size()>0){
					Object key[] = result.keySet().toArray();
					for(int p=0;p<key.length;p++){
						if(tmp_map.containsKey((char)key[p])){
							if(result.get((char)key[p])>tmp_map.get((char)key[p])){
								result.put((char)key[p], tmp_map.get((char)key[p]));
							}
						}else{
							result.remove((char)key[p]);
						}
					}
				}
			}
		}

		if(result.size()==0){
			System.out.println("");
		}else{
			Object output[] = result.keySet().toArray();
			Arrays.sort(output);
			for(int n=0;n<result.size();n++){
				for(int m=0;m<result.get((char)output[n]);m++){
					System.out.print(output[n]);
				}
			}
			System.out.println("");
		}

	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
    using namespace std;
    long long n,m,x,y,a[100005],ans,dp[100005];
    vector<long long>v[100005];
    long long dfs(long long i)
    {
        if(dp[i]!=-1)
        return dp[i];
        for(int j=0;j<v[i].size();j++)
            dp[i]=max(dp[i],dfs(v[i][j])+1);
        return dp[i];
    }
    int main()
    {
        cin>>n>>m;
        for(int i=0;i<=n;i++)
        dp[i]=-1;
        for(int i=0;i<m;i++)
        {
            cin>>x>>y;
            x--;
            y--;
            v[x].push_back(y);
            a[y]=1;
        }
        for(int i=0;i<n;i++)
        {
            if(a[i]==0)
            ans=max(ans,dfs(i)+1);
        }
        cout<<ans;
        return 0;
    }

Measured memory_bytes: 11904
S=input()
import collections
array=[]
for i in range(len(S)):
    array.append(S[i])
c=collections.Counter(array)
e=[chr(i) for i in range(97, 97+26)]
for j in range(len(e)):
    if not c[e[j]]%2==0:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 1000000 + 10;

int N, M;
char S[MAXN], T[MAXN];
char TreeS[MAXN * 4], TreeT[MAXN * 4];
int Trans[128][128];

void BuildTree(char* S, char* Tree, int Node, int L, int R)
{
	if (L == R)
	{
		Tree[Node] = S[L];
		return;
	}
	int Mid = (L + R) / 2;
	BuildTree(S, Tree, Node * 2, L, Mid);
	BuildTree(S, Tree, Node * 2 + 1, Mid + 1, R);
	Tree[Node] = Trans[Tree[Node * 2]][Tree[Node * 2 + 1]];
}

char Query(char* Tree, int Node, int L, int R, int l, int r)
{
	if (L == l && r == R)
		return Tree[Node];
	int Mid = (L + R) / 2;
	if (r <= Mid)
		return Query(Tree, Node * 2, L, Mid, l, r);
	else if (l > Mid)
		return Query(Tree, Node * 2 + 1, Mid + 1, R, l, r);
	else
		return Trans[Query(Tree, Node * 2, L, Mid, l, Mid)][Query(Tree, Node * 2 + 1, Mid + 1, R, Mid + 1, r)];
}

void Work()
{
	Trans['A']['A'] = 'B';
	Trans['A']['B'] = ' ';
	Trans['A'][' '] = 'A';
	Trans['B']['A'] = ' ';
	Trans['B']['B'] = 'A';
	Trans['B'][' '] = 'B';
	Trans[' ']['A'] = 'A';
	Trans[' ']['B'] = 'B';
	Trans[' '][' '] = ' ';

	scanf("%s%s", S, T);
	N = strlen(S);
	M = strlen(T);
	BuildTree(S, TreeS, 1, 0, N - 1);
	BuildTree(T, TreeT, 1, 0, M - 1);

	int q;
	scanf("%d", &q);
	while (q --)
	{
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf((Query(TreeS, 1, 0, N - 1, a - 1, b - 1) == Query(TreeT, 1, 0, M - 1, c - 1, d - 1)) ? "YES\n" : "NO\n");
	}
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 7040