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

int main( )
{
    int a, b, s;
    string op;
    cin >> a >> op >> b;
    if (op == "+") {
        cout << (a + b) << '\n';
    }
    else {
        cout << (a - b) << '\n';
    }
    return 0;
}



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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

double k = 0.006;

void solve() {
  int n;
  cin >> n;
  double t, a;
  cin >> t >> a;
  vector<double> h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  rep(i,n) {
    if (abs(a - (t - h[ans] * k)) > abs(a - (t - h[i] * k))) ans = i;
  }
  cout << ans + 1 << endl;
}

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

Measured memory_bytes: 3832
#include<stdio.h>

int data[999999];

int main(void)
{
	int a = 2;
	int b;
	int n;
	int pro;
	int i;
	int cnt;
	
	for (i = 1; i < 999999; i++) {
		data[i] = 1;
	}
	
	while (a * a <= 999999) {
		
		b = a;
		pro = 0;
		
		while (1) {
			
			pro = a * b;
			
			if (pro > 999999) {
				break;
			}
			
			data[pro - 1] = 0;
			
			b++;
		}
		
		a++;
		
	}
	
	
	while (scanf("%d", &n) != EOF) {
		
		
		cnt = 0;
		
		for (i = 1; i < n; i++) {
			
			if (data[i] == 1) {
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
		
	}
	return (0);
}

Measured memory_bytes: 4500
function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        input[k] = input[k].split(" ");
        var m = parseInt(input[k][0],10);
        var nmin = parseInt(input[k][1],10);
        var nmax = parseInt(input[k++][2],10);
        if(m == 0 && nmin == 0 && nmax == 0)
            break;

        var maxg = 0,maxn = 0;

        var p = [];
        for(var i = 0;i < m;i++)
            p[i] = parseInt(input[k++],10);

        for(var i = nmin - 1;i < nmax;i++){
            if(p[i] - p[i + 1] >= maxg){
                maxg = p[i] - p[i + 1];
                maxn = i;
            }
        }
        console.log(maxn + 1);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 18608
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int A, B, C, x, y;
  cin >> A >> B >> C >> x >> y;

  ll mincost = 1e12;


  REP2(c,0,200010){
    int a, b;
    ll cost = 0;
    a = 0; b = 0;
    a = max(0, x - c/2);
    b = max(0, y - c/2);

    cost = a*A + b*B + c*C;
    mincost = min(cost, mincost);
  }

  cout << mincost << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int P[maxn];
int pos[maxn];
int lt[maxn], rt[maxn];
#define ll long long
ll ans = 0;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> P[i];
        pos[P[i]] = i;
        lt[i] = i - 1;
        rt[i] = i + 1;
    }

    for (int i = 1; i <= n; ++i) {
        int lpos1 = lt[pos[i]];
        int lpos2 = lt[lpos1];

        int rpos1 = rt[pos[i]];
        int rpos2 = rt[rpos1];

        if (lpos1 != 0) {
            ans += 1LL * i * (lpos1 - lpos2) * (rpos1 - pos[i]);
        }
        if (rpos1 != n + 1) {
            ans += 1LL * i * (pos[i] - lpos1) * (rpos2 - rpos1);
        }

        lt[rpos1] = lpos1;
        rt[lpos1] = rpos1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int p[n];
    int q[n];
    int ans=n-1,tmp=n-1;
    for(int i=0; i<n;i++){
        cin >> p[i];
        q[p[i]-1] = i;
    }
    for(int i=0;i<n-1;i++){
        if(q[i] < q[i+1]){
            tmp--;
            ans = min(ans,tmp);
        }else{
            tmp = n-1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int A, B;
int gcd(int a, int b) {
    while (b) {
        int c = b;
        b = a % b;
        a = c;
    }
    return a;
}
int lcm(int a, int b) {
    if (!a || !b)
        return 0;
    return a * b / gcd(a, b);
}


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,a[100000],k,q;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>k>>q;
	for (int i=0,t;i<q;i++)
		cin>>t,
		a[--t]++;
	for (int i=0;i<n;i++){
		if (k-q+a[i]<=0)
			cout<<"No"<<"\n";
		else 
			cout<<"Yes"<<"\n";
	}
	return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll comb(ll a, ll b);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> x;
    int mem = 0;
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(All(a));

    rep(i, n - 1)
    {
        if (a[i] != a[i + 1])
        {

            x.push_back(i + 1 - mem);
            mem = i + 1;
        }
    }
    x.push_back(n - mem);
    sort(All(x));
    int maxi = (x.size() > k) ? x.size() - k : 0;

    mem = 0;
    rep(i, maxi)
    {
        mem += x[i];
    }
    c(mem);
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e5+10;
const int P=1e9+7;
inline int add(int a,int b)
{
	return (a + b) % P;
}
inline int mul(int a,int b)
{
	return 1ll * a * b  % P;
}
char s[MAXN];
int pre[MAXN],f[MAXN],nx[3];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s);
	int n;
	int flag=0;
	for(;s[n];++n)
		{
			pre[n+1]=pre[n]+(s[n]=='a'? 1:2 );
			pre[n+1]%=3;
		}
	for(rg int i=1;i<n;++i)
		if(s[i]==s[i-1])
			flag=1;
	if(flag==0)
		{
			putchar('1');
			return 0;
		}
	f[n]=1;
	for(rg int i=0;i<3;++i)
		nx[i]=i==pre[n]?n:n+1;
	for(rg int i=n-1;i;--i)
		{
			f[i]= pre[i]==pre[n];
			for(rg int c=1;c<=2;++c)
				f[i]=add(f[i],f[nx[(pre[i]+c)%3]]);
			nx[pre[i]]=i;
		}
	cout<<add(f[nx[1]],f[nx[2]]);
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 1152
/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int i,j,H,W;
		H=sc.nextInt();
		W=sc.nextInt();
		char [][]arr=new char[H][W];
		for (i=0;i<H;i++) {
			String str=sc.next();
			arr[i]=str.toCharArray();
		}
		int [][]dp=new int[H][W];
		boolean b=true;
		for(i=0;i<W;i++) {
			if(arr[0][i]=='#')
				b=false;
			if(b)
				dp[0][i]=1;
			else
				dp[0][i]=0;
		}
		b=true;
		for(i=0;i<H;i++) {
			if(arr[i][0]=='#')
				b=false;
			if(b)
				dp[i][0]=1;
			else
				dp[i][0]=0;
		}
		for (i=1;i<H;i++) {
			for (j=1;j<W;j++) {
				if(arr[i][j]=='#')
					dp[i][j]=0;
				else 
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
			}
		}
//		for (i=0;i<H;i++) {
//			for (j=0;j<W;j++) {
//				System.out.print(dp[i][j]+" ");
//			}
//			System.out.println();
//		}
		System.out.println(dp[H-1][W-1]);
		sc.close();
	}

}


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

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	for( int i = 0; i < n; ++i ) {
		double x[4], y[4];
		cin >> x[0] >> y[0];
		cin >> x[1] >> y[1];
		cin >> x[2] >> y[2];
		cin >> x[3] >> y[3];

		double vx0 = x[1] - x[0];
		double vy0 = y[1] - y[0];
		double vx1 = x[3] - x[2];
		double vy1 = y[3] - y[2];

		double result = vx0 * vy1 - vy0 * vx1;
		if( abs( result ) < 1e-10 ) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}



Measured memory_bytes: 3264
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  lst=sorted(map(int,input().split()))
  dis=200
  ans=100
  for i in range(102):
    temp=abs(x-i)
    if temp<dis and i not in lst:
      dis=temp
      ans=i
  print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main()
{  int a,b,m,i,j,k,m1=INT_MAX,m2=INT_MAX;
cin>>a>>b>>m;
int arr[a],brr[b];
for(i=0;i<a;i++)
{cin>>arr[i];
if(arr[i]<m1)m1=arr[i];}
for(i=0;i<b;i++)
{cin>>brr[i];
if(brr[i]<m2)m2=brr[i];}
int tot=m1+m2;
for(i=0;i<m;i++)
{  int x,y,c;
	cin>>x>>y>>c;
	x--;y--;
	if((arr[x]+brr[y]-c)<tot)
	tot=arr[x]+brr[y]-c;
	//cout<<arr[x]+brr[y]-c<<endl;
}
cout<<tot<<endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int result = 0;
		for(int i=1; i<=k; i++){
			for(int j=1; j<=k; j++){
				for(int m=1; m<=k; m++){
					int a = gcd(i,j);
					int b = gcd(a,m);
					result += b;
				}
			}
		}
		System.out.println(result);
	}
	public static int gcd(int m, int n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}


Measured memory_bytes: 27172
for i in range(int(input())):
    point = 0
    out = 0
    runner = [0, 0, 0]
    while True:
        event = input()
        if event == 'HIT':
            if runner[2] == 1:
                point += 1
                runner[2] = 0
            if runner[1] == 1:
                runner[2] = 1
                runner[1] = 0
            if runner[0] == 1:
                runner[1] = 1
                runner[0] = 0
            runner[0] = 1
        elif event == 'HOMERUN':
            point += (sum(runner)+1)
            runner = [0, 0, 0]
        elif event == 'OUT':
            out += 1
            if out == 3:
                print(point)
                break

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

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

using namespace std;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int INF = 1 << 29;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--;
    sx--;
    gy--;
    gx--;
    vector<string> B(h);
    rep(i, h) cin >> B[i];

    vector d(h, vector(w, INF));
    d[sy][sx] = 0;
    queue<pair<int, int>> Q;
    Q.emplace(sy, sx);
    while (!Q.empty()) {
        int y, x;
        tie(y, x) = Q.front();
        Q.pop();
        rep(dir, 4) {
            int y2 = y, x2 = x;
            rep(_, k) {
                y2 += dy[dir];
                x2 += dx[dir];
                if (y2 < 0 || h <= y2 || x2 < 0 || w <= x2 || B[y2][x2] == '@' || d[y2][x2] <= d[y][x]) break;
                if (d[y2][x2] > d[y][x] + 1) {
                    assert(d[y2][x2] == INF);
                    d[y2][x2] = d[y][x] + 1;
                    Q.emplace(y2, x2);
                }
            }
        }
    }

    printf("%d\n", d[gy][gx] < INF ? d[gy][gx] : -1);

    return 0;
} // test


Measured memory_bytes: 12140
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin, (X).rend()
#define DRI(X) int (X); cin >> X
#define DRII(X, Y) int X, Y; cin >> X >> Y
#define DRIII(X, Y, Z) int X, Y, Z; cin >> X >> Y >> Z
// #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define readV(X) for(int &ele : (X)) cin >> ele
#define readVI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MP make_pair
#define PB push_back
#define F first
#define S second
 
using namespace std;
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) {
//     cerr << *it << " = " << a << endl;
//     err(++it, args...);
// }
// template<typename... Args>
// void read(Args&... args)
// {
//     ((cin >> args), ...);
// }
 
// template<typename... Args>
// void write(Args... args)
// {
//     ((cout << args), ...);
// }
typedef long long LL;
const int INF = 1<<29;
 
 
int main(){
    FAST_IO
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    int N, q, t, time, sum; cin >> N;
    vector<int> nums(N + 1); readVI(nums);
    sum = accumulate(ALL(nums), 0);
    cin >> q;
    REP(rep, 0, q){
        cin >> t >> time;
        cout << sum - nums[t] + time << "\n";
    }

}    

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (U == S) {
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

class UnionFind {
public:
	vector<int> par;

	UnionFind(int n) {
		par.resize(n);
		for (int i = 0; i < n; i++) par[i] = i;
	}

	UnionFind() {};

	int root(int x) {
		if (par[x] == x)return x;
		else return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		par[x] = y;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n, m, s, t, q;
	cin >> n >> m;
	UnionFind uf(n);
	while (m--) cin >> s >> t, uf.unite(s, t);
	cin >> q;
	while (q--)cin >> s >> t, cout << (uf.same(s, t) ? "yes" : "no") << endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans(n);
    for(int i = 0; i < q; i++){
        int num;
        cin >> num;
        ans[num-1]++;
    }
    for(int i = 0; i < n; i++){
        if(ans[i] > (q - k)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);

		String[] S = sc.nextLine().split("");

		int ans = 0;

		int i = 0;
		for (int j = 1; j < S.length; j++) {
			if (!S[i].equals(S[j])) {
				ans++;
			}
			i++;
		}

		System.out.print(ans);
	}

}

Measured memory_bytes: 20176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    if(n<=599) cout << 8 << endl;
    else if(n>=600 && n<=799) cout << 7 << endl;
    else if(n>=800 && n<=999) cout << 6 << endl;
    else if(n>=1000 && n<=1199) cout << 5 << endl;
    else if(n>=1200 && n<=1399) cout << 4 << endl;
    else if(n>=1400 && n<=1599) cout << 3 << endl;
    else if(n>=1600 && n<=1799) cout << 2 << endl;
    else if(n>=1800) cout << 1 << endl;

    return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int H, N;
	cin >> H >> N;

	vector<pair<ll, ll>> magic(N, make_pair(0,0));
	#define atk first
	#define mp second
	int max_atk = 0;
	rep(i,N){
		cin >> magic[i].atk >> magic[i].mp;
		chmax(max_atk, magic[i].atk);
	}

	// DP[i] : モンスター体力を i 減らすための最小 MP
	vi dp((H+1) + max_atk, 1e9);
	dp[0] = 0;
	FOR(i, 1, H + max_atk){
		rep(j, N){
			if(magic[j].atk > i){
				continue;
			}
			else{
				chmin(dp[i], dp[i - magic[j].atk] + magic[j].mp);
			}
		}
	}

	int ans = 1e9;
	FOR(i, H, H + max_atk){
		chmin(ans, dp[i]);
	}
	cout << ans << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

int main() {
  string s;
  int alp[27];
  for (int i = 0; i < 26; i++) {
    alp[i] = 0;
  }
  alp[26] = 1;

  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    puts("-1");
  } else {
    string ans = "";
    for (int i = 0; i < (int)s.size(); i++) {
      alp[s[i] - 'a']++;
    }

    if (s.size() < 26) {
      for (int i = 0; i < 26; i++) {
        if (alp[i] == 0) {
          ans = s + (char)('a' + i);
          break;
        }
      }
    } else {
      string s_next = s;
      next_permutation(s_next.begin(), s_next.end());
      for (int i = 0; i < (int)s.size(); i++) {
        ans += s_next[i];
        if (s[i] != s_next[i]) break;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> count(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        count[a]++;
        count[b]++;
    }
    for (int i = 0; i < n; i++) {
        if (count[i] & 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
INF=10**9+7
D = [INF]*(10**6+1)
L = [True]*(10**6+1)
L[0] = False
L[1] = False
D[1] = 1
for i in range(2, 10**6+1):
    if L[i]:
        D[i] = i
        for j in range(i*2, 10**6+1, i):
            L[j] = False
            D[j] = min(i, D[j])
# print(D[:101])


def egcd(a, b):
    if a == 0:
        return b
    else:
        g = egcd(b % a, a)
        return g


def factorization(n):
    ans = set()
    if n == 1:
        ans.add(1)
        return ans
    while n>1:
        ans.add(D[n])
        n//=D[n]
    return ans


N = int(input())
A = list(map(int, input().split()))

s = set(factorization(A[0])-{1})
for i in range(1, N):
    tmp = factorization(A[i])-{1}
    if tmp & s != set():
        break
    s |= tmp
else:
    print('pairwise coprime')
    exit()

L1 = A
while len(L1) > 1:
    l = len(L1)//2
    k = [0]*l
    for i in range(l):
        k[i] = egcd(L1[2*i], L1[2*i+1])
    if len(L1) % 2 == 1:
        k.append(L1[-1])
    L1 = k

if L1[0] == 1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 192840
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

// BinaryTreeNode for alds1_7_B
type BinaryTreeNode struct {
	left   int
	right  int
	parent int
}

func sibling(nodes []BinaryTreeNode, iNode int) int {
	parentID := nodes[iNode].parent
	if parentID == -1 {
		return -1
	}

	parentNode := nodes[parentID]
	if parentNode.left == iNode {
		return parentNode.right
	}
	return parentNode.left
}

func degree(node BinaryTreeNode) int {
	degree := 0
	if node.left != -1 {
		degree++
	}
	if node.right != -1 {
		degree++
	}
	return degree
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func height(nodes []BinaryTreeNode, iNode int) int {
	if iNode == -1 {
		return -1
	}

	leftID := nodes[iNode].left
	leftHeight := height(nodes, leftID)

	rightID := nodes[iNode].right
	rightHeight := height(nodes, rightID)

	return max(leftHeight, rightHeight) + 1
}

func depth(nodes []BinaryTreeNode, iNode int) int {
	parentID := nodes[iNode].parent

	if parentID == -1 {
		return 0
	}
	return depth(nodes, parentID) + 1
}

func nodeType(nodes []BinaryTreeNode, iNode int) string {
	// fmt.Println(nodes[iNode])
	if nodes[iNode].parent == -1 {
		return "root"
	} else if nodes[iNode].left != -1 || nodes[iNode].right != -1 {
		return "internal node"
	}
	return "leaf"
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	nodes := make([]BinaryTreeNode, nNodes)
	for iNode := 0; iNode < nNodes; iNode++ {
		nodes[iNode] = BinaryTreeNode{
			left:   -1,
			right:  -1,
			parent: -1,
		}
	}

	for iNode := 0; iNode < nNodes; iNode++ {
		key := nextInt()
		leftID := nextInt()
		rightID := nextInt()

		nodes[key].left = leftID
		nodes[key].right = rightID
		if leftID != -1 {
			nodes[leftID].parent = key
		}
		if rightID != -1 {
			nodes[rightID].parent = key
		}
	}
	for iNode := 0; iNode < nNodes; iNode++ {
		node := nodes[iNode]
		fmt.Printf(
			"node %v: parent = %v, sibling = %v, degree = %v, depth = %v, height = %v, %v\n",
			iNode,
			node.parent,
			sibling(nodes, iNode),
			degree(node),
			depth(nodes, iNode),
			height(nodes, iNode),
			nodeType(nodes, iNode),
		)
	}
}



Measured memory_bytes: 1160
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

C = [[0, 0] for i in range(N)]

C_all = 0
for i in range(N - 1):
    C[i][0] = abs(A[i + 1] - A[i])
    C[i][1] = abs(A[i + 2] - A[i])
    C_all += C[i][0]

C[N - 1][0] = abs(A[N] - A[N - 1])
C[N - 1][1] = abs(A[0] - A[N - 1])
C_all += abs(A[N] - A[N - 1]) + abs(A[N])

for i in range(1, N):
    print(C_all - (C[i - 1][0] + C[i][0]) + C[i - 1][1])

print(C_all - (C[N - 1][0] + abs(A[N])) + C[N - 1][1])

Measured memory_bytes: 24360
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;

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

  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        flag = true;
      }
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//http://vivi.dyndns.org/tech/cpp/list.html#insert
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

/*auto count_a(auto b, auto e, auto k, auto a)
{
    auto count_a = count(a.begin() + b, a.begin() + e, k); //size_t
    return count_a;
}*/

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        ll b, e, k;
        cin >> b >> e >> k;
        cout << count(a.begin() + b, a.begin() + e, k) << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
# https://atcoder.jp/contests/abc083/tasks/abc083_b
import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())

    ans = 0
    for i in range(1, N+1):
        ans += i if A <= sum(map(int, list(str(i)))) <= B else 0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ld a, b, c;
    cin >> a >> b >> c;
    cout << (a+b+2*sqrt(a*b) < c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	K, Q = getlist()
	D = getlist()
	for _ in range(Q):
		N, X, M = getlist()
		X %= M
		d = [0] * K
		zeroCount = 0
		for i in range(K):
			var = D[i] % M
			d[i] = var
			if var == 0:
				zeroCount += 1
		Dsum = sum(d)
		p = int((N - 1) // K)
		q = (N - 1) % K
		An = X + Dsum * p
		# print(p, q)
		# print(An)
		# print(d)
		zero = 0
		for i in range(q):
			An += d[i]
			if d[i] == 0:
				zero += 1

		# print(X, An)
		# print(zeroCount * p + zero)
		# print(int(An // M) - int((X + M - 1) // M))
		ans = N - 1 - (zeroCount * p + zero) - (int(An // M) - int(X  // M))
		print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 48988
N, M = map(int, input().split())
g = []
for i in range(1,M+1):
  if M%i==0:
    j = M//i
    if i<=M//N:
      g += [i]
    if j<=M//N:
      g += [j]
  if i>M**0.5:
    break
print(max(g))

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

using namespace std;
int main()
{
    int N;
    while ( !cin.eof() )
    {
        cin >> N;
        vector<int> ans;
        
        for (int a = 9; a > -1; a = a-1)
        {   
            if (N >= (1 << a))
            {
                N = N - (1 << a);
                ans.push_back(1 << a);
            }
            
        }
        reverse(ans.begin(), ans.end());
        
        for (int i = 0; i < ans.size(); i++)
        {
            cout << ans[i] ;
            if (i == ans.size()-1)
                cout << endl;
            else
                cout << " ";
        }
    }
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;


#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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


int A, B;
int a[10010][10010], b[1000];
int dp[10010][3];
 
int main()
{
    int N, M; cin >> N >> M;
    int A;
    rep(i,M){
        cin >> A;
        N -= A;
    }

    cout << max(N,-1) << endl;

    return 0;
}


Measured memory_bytes: 3624
N=gets.chomp.to_i
A=gets.chomp.split.map(&:to_i)
B=gets.chomp.split.map(&:to_i)
C=gets.chomp.split.map(&:to_i)
satisfaction=0
lastdish=nil

A.each {|dish_id|
    satisfaction+=B[dish_id-1]
    if lastdish==dish_id-1
        satisfaction+=C[lastdish-1]
    end
    lastdish=dish_id
}

puts satisfaction

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int X, N; cin >> X >> N;
  vector<int> a(102,0);
  int p; 
  rep(i,N) {
    cin >> p;
    a[p]=1000;
  }

  for (int i=0;i<=101;i++){
    if (a[i]<101) a[i] = abs(i-X);
  }
  int retval = min_element(all(a))-a.begin();
  cout << retval << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3600
import java.util.Scanner;

class Main{
    private static int nS;
    private static int nT;
    private static int[] S;
    private static int[] T;
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	nS = sc.nextInt();	
	S = new int[nS];
	for(int i=0;i<nS;i++){
	    S[i] = sc.nextInt();
	}
	nT = sc.nextInt();
	T = new int[nT];
	for(int i=0;i<nT;i++){
	    T[i] = sc.nextInt();
	}
	
	int cnt = 0;
	for(int i=0;i<nT;i++){
	    for(int j=0;j<nS;j++){
		if(T[i] == S[j]){
		    cnt++;
		    break;
		}
	    }
	}
	System.out.println(cnt);
	
    }

    
}



Measured memory_bytes: 40196
import fractions
RangeMin, RangeMax, valA, valB = map(int, input().split())

RangeMin -= 1
valC = int(valA * valB / fractions.gcd(valA, valB))
ansList = []



for Range in [RangeMin, RangeMax] :
  ans1 = 0
  ans1 += Range // valA
  ans1 += Range // valB
  ans1 -= Range // valC
  ansList.append(ans1)

ans = ansList[1] - ansList[0]
ans = RangeMax - RangeMin - ans

print(ans)

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

using namespace std;

pair<int, int> dfs(int u, const vector<vector<int>> &g, vector<int> &vis) {
    vis[u] = 1;
    int best = u, dist = 0;
    for (int v : g[u]) {
        if (!vis[v]) {
            //auto [x, d] = dfs(v, g, vis);
            auto p = dfs(v, g, vis);
            int x = p.first, d = p.second;
            if (d + 1 > dist) {
                dist = d + 1;
                best = x;
            }
        }
    }
    return {best, dist};
}
int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    vector<int> vis(N, 0);
    //auto [x, d] = dfs(0, g, vis);
    auto p = dfs(0, g, vis);
    int x = p.first;
    vis.assign(N, 0);
    //auto [y, diam] = dfs(x, g, vis);
    p = dfs(x, g, vis);
    int diam = p.second;

    cout << (diam % 3 == 1 ? "Second\n" : "First\n") << endl;

    return 0;
}

Measured memory_bytes: 24448
#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;
  }

  return 0;
}



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

int main(){
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A),q(B),r(C);
  for(int i=0;i<A;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<B;i++){
    cin >> q.at(i);
  }
  for(int i=0;i<C;i++){
    cin >> r.at(i);
  }
  sort(p.begin(),p.end(),greater<int>());
  sort(q.begin(), q.end(),greater<int>());
  p.erase(p.begin()+X,p.end());
  q.erase(q.begin()+Y,q.end());
  r.insert(r.end(),p.begin(),p.end());
  r.insert(r.end(),q.begin(),q.end());
  sort(r.begin(),r.end(),greater<int>());
  int64_t ans=0;
  for(int i=0;i<X+Y;i++){
    ans+=r.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){

   int A,B,C; cin >> A >> B >> C;
   int maxv = max({A,B,C});
   if(maxv %2 != (A+B+C)%2) maxv++;
   
   int sum = (maxv - A) + (maxv - B) + (maxv - C);
   cout << sum / 2 << endl;
}

Measured memory_bytes: 3640
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)2e5;

pii dat[N+5];

int main(){
    int n; scanf("%d", &n);
    REP(i,1,n) scanf("%d %d", &dat[i].se, &dat[i].fi);
    sort(dat+1, dat+1+n);
    //
    int timee = 0, res = 1;
    REP(i,1,n) if((timee += dat[i].se) > dat[i].fi){
        res = 0;
        break;
    }
    // print
    puts(res ? "Yes" : "No");
    return 0;
}


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

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

vector<vector<int>> G;
vector<int> color;

bool dfs(int v, int c) {
    color[v] = c;
    for(int u : G[v]) {
        if(color[u] == c) return false;
        if(color[u] == 0 && !dfs(u, -c)) return false;
    }
    return true;
}

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

    ll n, m;
    cin >> n >> m;
    G.resize(n);
    color.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(dfs(0, 1)) {
        ll a = 0, b = 0;
        rep(i, n)(color[i] == 1 ? a : b)++;
        cout << a * b - m << endl;
    } else
        cout << n * (n - 1) / 2 - m << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
typedef struct node {
  int parent;
  int left;
  int right;
}Node;

int Depth(int);
Node trees[100000];
int depth[100000];
int main(){
  int c,n,i,j,k,id,l=0,r;

    scanf("%d",&n);
    
    for(i=0;i<n;i++){
    trees[i].parent=-1;
    trees[i].left=-1;
    trees[i].right=-1;
  }
    
  for(i=0;i<n;i++) {
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++) {
      scanf("%d",&c);
      if(j==0) trees[id].left=c;
      else trees[l].right=c;
      l=c;
      trees[c].parent=id;
    }
  }
  
    for(i=0;i<n;i++){
    depth[i] = Depth(i);
  }

    for(i=0;i<n;i++) {
      printf("node %d: ",i);
      printf("parent = %d, ",trees[i].parent);
      printf("depth = %d, ",depth[i]);
      if(trees[i].parent == -1)printf("root, ");
      else if(trees[i].left == -1)printf("leaf, ");
      else printf("internal node, ");
      printf("[");
      for(j = 0,c=trees[i].left;c!=-1;j++,c=trees[c].right){
	if(j!=0)printf(", ");
	printf("%d",c);
	
      }
      printf("]\n");
    }
    return 0;
}

int Depth(int u){
   int d = 0;
   
  while(1){
     
    u = trees[u].parent;
    if ( u == -1 ) break;
    d++;
     
  }
  return d;
   
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 100005, P = 1e9 + 7;

int n, K, f[N];

int inline power(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = (LL)res * a % P;
		a = (LL)a * a % P;
		b >>= 1;
	}
	return res;
}

int main() {
	scanf("%d%d", &n, &K);
	for (int i = K; i; i--) {
		int t = K / i;
		f[i] = power(t, n);
		for (int j = i * 2; j <= K; j += i) f[i] = ((LL)f[i] - f[j] + P) % P;
	}
	LL ans = 0;
	for (int i = 1; i <= K; i++) {
		int t = K / i;
		ans = (ans + (LL)i * f[i]) % P;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k; 
  if (e-a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int K,X;
void input(){
    cin>>K>>X;
    return;
}

void solve(){
    for(int i=max(X-K+1,-1000000); i<=min(X+K-1,1000000);++i)
        cout<<i<<" ";
    cout<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = (b + c) - a;
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#import math
#=input()
#=int(input())
h1,m1,h2,m2,k=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

t1 = 60 * h1 + m1
t2 = 60 * h2 + m2

ans = (t2 - t1) - k
print(ans)

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  long long a,b,x;

  cin >> a >> b >> x;

  if (a == 0)
    cout << b/x + 1 << endl;
  else
    cout << b/x - (a-1)/x << endl;  

  return 0;
}

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

int main() {
  int N;
  ll D, A;
  cin >> N >> D >> A;
  vector<ll> cum(N + 1, 0);

  using Mon = pair<ll, ll>;
  vector<Mon> M(N);
  for (int i = 0; i < (int)N; ++i) cin >> M[i].first >> M[i].second;

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

  ll ans = 0;
  for (int i = 0; i < (int)N; ++i) {
    if (i > 0) cum[i] += cum[i - 1];

    if (M[i].second + cum[i] <= 0) continue;
    ll k = (M[i].second + cum[i] + A - 1) / A;

    ans += k;
    cum[i] -= A * k;
    int j =
        distance(M.begin(),
                 upper_bound((M).begin(), (M).end(), make_pair(M[i].first + 2 * D, (ll)1e18)));
    cum[j] += A * k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++)
  {
      if(s[i]==',')
      cout<<" ";
      else
      {
          cout<<s[i];
      }
      
  }
  return 0;
}

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

using namespace std;

int main() {
    string now, then;
    set<string> s;
    int n;
    scanf("%d", &n);
    char cnow, cthen;
    bool rule = true;
 	cin >> now;
 	cnow = now[now.length()-1];
 	s.insert(now);
 	for(int i = 0; i < n-1; i++) {
 		cin >> then;
 		if(then[0] != cnow) {
 			rule = false;
 			break;
 		} else {
 			if(s.find(then)!=s.end()) {
 				rule = false;
 				break;
 			}
 		}
        s.insert(then);
        now = then;
        cnow = then[then.length()-1];
 	}

    if(rule) printf("Yes\n");
    else printf("No\n");


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001];
vector<char> ans;
int main(void){
    string s,t,ans;
    cin>>s>>t;
    int p=s.size(),q=t.size();
    for(int i=1;i<=p;i++){
        for(int j=1;j<=q;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    while(dp[p][q]!=0){
        if(s[p-1]==t[q-1]){
            ans.push_back(s[p-1]);
            p--;
            q--;
        }
        else if(dp[p][q-1]>dp[p-1][q])q--;
        else p--;
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)101*1000)
#define INF ((ll)2e9)
#define MOD ((ll)1e9+7)

ll n,a[N],b[N],ans=1;

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=n-1;i>=0;i--)
	{
		if(i==n-1 || b[i+1]!=b[i])
		{
			if(i==0 || a[i]!=a[i-1])
			{
				if(b[i]!=a[i])return cout<<0,0;
			}
			else
			{
				if(b[i]>a[i])return cout<<0,0;
			}
		}
		else
		{
			if(i==0 || a[i]!=a[i-1])
			{
				if(b[i]<a[i])return cout<<0,0;
			}
			else
			{
				ans*=min(a[i],b[i]);ans%=MOD;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m, l;
vector<lli> r;
lli a[201][201];

lli rec(lli s, lli c) {
  if (s == (1ll<<l)-1) return 0;
  lli y = 1e18;
  for (lli i=0; i<l; ++i) {
    lli b = 1ll<<i;
    if (!(s & b)) y = min(y, a[r[c]][r[i]] + rec(s | b, i));
  }
  return y;
}

int main() {
  cin >> n >> m >> l; read_n(r, l);
  fill(&a[0][0], &a[200][200]+1, 1e18);
  for (lli i=0; i<=n; ++i) a[i][i] = 0;
  for (lli i=0; i<m; ++i) {
    lli x, y, c; cin >> x >> y >> c;
    a[x][y] = a[y][x] = c;
  }
  for (lli k=1; k<=n; ++k) {
    for (lli j=1; j<=n; ++j) {
      for (lli i=1; i<=n; ++i) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }

  lli ans = 1e18;
  for (lli i=0; i<l; ++i) ans = min(ans, rec(1ll<<i, i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Eleven Lover
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			if (line.equals("0")) break;

			int N = line.length();
			int[][] dp = new int[N + 1][11];

			for (int i = 0; i < N; i++) {
				int d = line.charAt(i) - '0';
				dp[i + 1][d] = (d > 0 ? 1 : 0);
				for (int j = 0; j < 11; j++) {
					if (dp[i][j] != 0) {
						dp[i + 1][(10 * j + d) % 11] += dp[i][j];
					}
				}
			}

			int ans = 0;

			for (int i = 0; i < N; i++) {
				ans += dp[i + 1][0];
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 62760