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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long  ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
             par[i] = i;
             siz[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        // merge technique（小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;
    UnionFind uf(n+m);
    rep(i,n){
        int k; cin >> k;
        rep(j,k){
            int L; cin >> L;
            uf.unite(i,n+L-1);
        }
    }
    rep(i,n-1){
        if(uf.same(i,i+1) == false){
            out("NO");
            return 0;
        }
    }
    out("YES");
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int cnt[26];

int main(){
	int h,w; cin >> h>> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char s; cin >> s;
			cnt[s-'a']++;
		}
	}
	int two=0;
	int one=0;
	for(int i=0;i<26;i++){
		if(cnt[i]%4!=0){
			two+=cnt[i]%4/2;
			one+=cnt[i]%2;
		}
	}
	if(one>0&&h*w%2==0){
		cout << "No" << endl;
		return 0;
	}
	if(one>1){
		cout << "No" << endl;
		return 0;
	}
	int ok=0;
	if(h%2==1){
		ok+=w/2;
	}
	if(w%2==1){
		ok+=h/2;
	}
	if(two>ok){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if(S == "Sunny")
    cout << "Cloudy" << endl;
  else if(S == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static Dir root;

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			root = new Dir("", null);
			for (int i = 0; i < N; ++i) {
				String[] path = sc.next().split("/");
				Dir cur = root;
				for (int j = 1; j < path.length - 1; ++j) {
					cur = cur.addChild(path[j]);
				}
				cur.file.add(new File(path[path.length - 1]));
			}
			for (int i = 0; i < M; ++i) {
				File f1 = get((sc.next() + "$").split("/"));
				File f2 = get((sc.next() + "$").split("/"));
				if (f1 == null || f2 == null) {
					System.out.println("not found");
				} else {
					System.out.println(f1 == f2 ? "yes" : "no");
				}
			}
		}
	}

	static File get(String[] path) {
		String last = path[path.length - 1];
		path[path.length - 1] = last.substring(0, last.length() - 1);
		boolean def = false;
		if (path[path.length - 1].equals("")) {
			def = true;
			path[path.length - 1] = "index.html";
		}
		Dir cur = root;
		for (int i = 1; i < path.length - 1; ++i) {
			cur = cur.get(path[i]);
			if (cur == null) return null;
		}
		last = path[path.length - 1];
		for (File f : cur.file) {
			if (f.name.equals(last)) return f;
		}
		if (!def) {
			cur = cur.get(last);
			if (cur != null) {
				for (File f : cur.file) {
					if (f.name.equals("index.html")) return f;
				}
			}
		}
		return null;
	}

	static class Dir {
		String name;
		Dir parent;
		ArrayList<Dir> child = new ArrayList<Dir>();
		HashSet<File> file = new HashSet<File>();

		Dir(String n, Dir p) {
			name = n;
			parent = p;
		}

		Dir addChild(String cn) {
			for (Dir c : child) {
				if (c.name.equals(cn)) return c;
			}
			Dir ret = new Dir(cn, this);
			child.add(ret);
			return ret;
		}

		Dir get(String segment) {
			if (segment.equals(".")) {
				return this;
			} else if (segment.equals("..")) {
				return parent;
			}
			for (Dir c : child) {
				if (c.name.equals(segment)) return c;
			}
			return null;
		}
	}

	static class File {
		String name;

		File(String n) {
			name = n;
		}

		public int hashCode() {
			return name.hashCode();
		}

		public boolean equals(Object obj) {
			File other = (File) obj;
			return name.equals(other.name);
		}
	}
}

Measured memory_bytes: 19896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

const static ll MOD = 1000000007;
int N, K;
vector<int> v;
ll dp[105][100005];

int main(){
  cin >> N >> K;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  dp[0][K] = 1;
  rep(i,v.size()){
    int a = v[i];
    vector<ll> imos(100005, 0);
    for(int j=K; j>=0; j--){
      imos[j] += dp[i][j];
      if(j-a-1>=0) imos[j-a-1] -= dp[i][j];
    }
    ll base = 0;
    for(int j=K; j>=0; j--){
      base += imos[j];
      dp[i+1][j] = base;
      dp[i+1][j] %= MOD;
    }
  }

  cout << dp[N][0] << endl;
  
  return 0;
}


Measured memory_bytes: 80112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

int main() {
    int n, a[3], c;
    cin >> n >> a[0] >> a[1] >> c;

    init(n * 2);

    int a01 = a[0] + a[1];

    for (int j = 0; j < 2; j++) {
        a[j] = (ll)a[j] * inv(a01) % P;
    }
    //a[2] = inv((a[0] + a[1]) % P);
    c = (ll)c * inv(100) % P;
    ll d = (1 - c) % P; if (d < 0) d += P; d = inv(d);

    vector<int> p[2];
    for (int j = 0; j < 2; j++) {
        p[j] = vector<int>(n + 1);
        p[j][0] = 1;
        for (int i = 1; i <= n; i++) {
            p[j][i] = (ll)p[j][i - 1] * a[j] % P;
        }
    }

    ll r = 0;
    for (int j = 0; j < 2; j++) {
        for (int i = 0; i < n; i++) {
            //n対iで勝つ確率 n-1対iからAが勝つ確率
            ll t = (ll)p[j][n - 1] * p[j ^ 1][i] % P;
            t = t * comb(n - 1 + i, i) % P;
            t = t * a[j] % P;
            t = t * (n + i) % P;//回数の期待値

            //n+i回現れるまでにCが
            t = t * d % P;

            r += t;
        }
    }

    cout << r % P << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
 //  void generate() {
//     memset(div, 0, sizeof div);
//     for (int i = 1; i <= N; i++) {
//         for (int j = i; j <= N; j += i) {
//             divisors[j] += 1;
//         }
//     }
// }

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }
 
int solve() {fastio
       int l;
       cin>>l;
       double x = double(l)/3;
       x = x*x*x;
       cout<<fixed<<setprecision(12)<<x;

    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long

int main() {

	lint N; cin >> N;
	vector<pair<lint,lint>> T(5);
	for (lint i = 0; i < 5; i++)
	{
		lint a; cin >> a;
		T[i] = make_pair(a, i);
	}
	sort(T.begin(), T.end());
	lint m = T[0].first;
	if (N %m == 0) {
		cout << 4 + (N / m) << endl;
	}
	else {
		cout << 5 + (N / m) << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }


struct UnionFind {
  struct Node {
    ll parent;
    ll size;
  };
  vector<Node> tree;

  UnionFind(ll size) : tree(size) {
    for (ll i = 0; i < size; i++) {
      tree[i].parent = i;
      tree[i].size = 1;
    }
  }

  ll find(ll x) {
    if (tree[x].parent == x) {
      return x;
    } else {
      return tree[x].parent = find(tree[x].parent);
    }
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (tree[x].size < tree[y].size)
      swap(x, y);

    tree[y].parent = x;
    tree[x].size += tree[y].size;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};

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

  ll n, m;
  cin >> n >> m;
  vl a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  reverse(all(a));
  reverse(all(b));

  UnionFind uf(n);
  ll ans = n*(n-1)/2;
  vl vec;
  rep(i, m) {
    vec.push_back(ans);
    if (!uf.same(a[i], b[i])) {
      ll x = uf.find(a[i]);
      ll y = uf.find(b[i]);
      ans -= uf.tree[x].size * uf.tree[y].size;
    }
    uf.unite(a[i], b[i]);
  }

  reverse(all(vec));
  for (auto&& i : vec) {
    cout << i << endl;
  }
}


Measured memory_bytes: 5364
import java.util.*;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		long Q=sc.nextLong();	//0.25l
		long H=sc.nextLong();	//0.50l
		long S=sc.nextLong();	//1.0l
		long D=sc.nextLong();	//2.0l
		long N=sc.nextLong();	//Nlかう
		long ans=0;	//必要な金額

		H=Math.min(H,2*Q);
		S=Math.min(S,2*H);

		if(2*S<=D) ans=N*S;
		else{
			//2L:D円の方がお買い得の場合
			long num_s=0;
			if(N%2==1) num_s++;	//1L購入本数
			long num_d=N/2;
			ans=num_s*S+num_d*D;
		}

		System.out.println(ans);

	}
}

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

using namespace std;

int main()
{
	long long int X;
	long long int sum = 100;
	int years = 0;
	cin >> X;
	while (X > sum)
	{
		sum += sum / 100;
		years++;
	}

	cout << years;

	return 0; 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    ll n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes"<<"\n";
    else 
    cout<<"No"<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}





// bool prime[100000];

// // int gcdExtended(int a, int b, int *x, int *y) ;
// ll modInverse(int a, int m) 
// { 
//     int x, y; 
//     int g = gcdExtended(a, m, &x, &y); 
//     // if (g != 1) 
//     //     cout << "Inverse doesn't exist"; 
//     // else
//     // { 
//         // m is added to handle negative x 
//         int res = (x%m + m) % m; 
//         return res; 
//     // } 
// } 
  
// // // C function for extended Euclidean Algorithm 
// int gcdExtended(int a, int b, int *x, int *y) 
// { 
//     // Base Case 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
  
//     int x1, y1; // To store results of recursive call 
//     int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
//     // Update x and y using results of recursive 
//     // call 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
  
//     return gcd; 
// } 
// ll modu(ll x)
// {
//     if(x<0)
//     {
//         x+=mod;
//     }
//     else 
//     {
//         x=x%mod;
//     }
//     return x;
// }

// void SieveOfEratosthenes(int n) 
// { 
//     // Create a boolean aay "prime[0..n]" and initialize 
//     // all entries it as true. A value in prime[i] will 
//     // finally be false if i is Not a prime, else true. 
     
//     memset(prime, true, sizeof(prime)); 
  
//     for (int p=2; p*p<=n; p++) 
//     { 
//         // If prime[p] is not changed, then it is a prime 
//         if (prime[p] == true) 
//         { 
//             // Update all multiples of p greater than or  
//             // equal to the square of it 
//             // numbers which are multiple of p and are 
//             // less than p^2 are already been marked.  
//             for (int i=p*p; i<=n; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     prime[1]=false;
  
//     // Print all prime numbers 
//     // for (int p=2; p<=n; p++) 
//     //    if (prime[p]) 
//     //       cout << p << " "; 
// } 
// ll power(ll x, unsigned ll y, ll p) 
// { 
//     ll res = 1;      // Initialize result 
  
//     x = x % p;  // Update x if it is more than or  
//                 // equal to p 
  
//     while (y > 0) 
//     { 
//         // If y is odd, multiply x with result 
//         if (y & 1) 
//             res = (res*x) % p; 
  
//         // y must be even now 
//         y = y>>1; // y = y/2 
//         x = (x*x) % p;   
//     } 
//     return res; 
// } 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b, max;
    scanf("%d %d",&a, &b);

    max = a*b;

    if(max < a-b){
        max = a-b;
    }

    if(max < a + b){
        max = a + b;
    }

    printf("%d", max);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> vec(M);
    for(int i=0;i<M;i++){
        cin >>vec[i];
    }
    vector<ll> str(N+1);
    for(int i=0;i<N+1;i++){
        str[i]=-1;
    }
    for(int i=0;i<M;i++){
        str[vec[i]]=0;
    }
    str[0]=1;
    if(str[1]==-1){
        str[1]=1;
    }
    if(str[2]==-1){
        str[2]=str[1]+str[0];
    }
    for(int i=3;i<N+1;i++){
        if(str[i]==-1){
            str[i]=(str[i-1]+str[i-2]+MOD)%MOD;
        }
    }
    cout << str[N]%MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(n+2);  // 1-indexed
  rep(i,n) cin >> arr[i+1];

  vi cost(n+1);
  rep(i,n+1) cost[i] = abs(arr[i+1] - arr[i]);
  int original = accumulate(all(cost), 0);

  vi plan(n);
  rep(i,n) plan[i] = original - cost[i] - cost[i+1] + abs(arr[i] - arr[i+2]);
  rep(i,n) cout << plan[i] << endl;
  return 0;
}


Measured memory_bytes: 2432
#include <cstdio>
#include <algorithm>

int a, b, n, map[17][17];

int search(int x, int y)
{
	if (x == 1 && y == 1)
	{
		map[1][1] = 1;
		return 1;
	}

	int left = 0, down = 0;
	if (map[y][x - 1] != -1)
	{
		left = search(x - 1, y);
	}
	if (map[y - 1][x] != -1)
	{
		down = search(x, y - 1);
	}
	map[y][x] = left + down;

	return map[y][x];
}

int main()
{
	while (true)
	{
		for (int i = 0; i <= b; ++i)
		{
			std::fill(map[i], map[i] + a + 1, 0);
		}

		scanf("%d %d", &a, &b);
		if (a == 0 || b == 0)
		{
			break;
		}
		scanf("%d", &n);
		for (int i = 0; i < n; ++i)
		{
			int x, y;
			scanf("%d %d", &x, &y);
			map[y][x] = -1;
		}

		std::fill(map[0], map[0] + a + 1, -1);
		for (int i = 0; i <= b; ++i)
		{
			map[i][0] = -1;
		}

		printf("%d\n", search(a, b));
	}
}


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

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

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

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());

  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += l[i];
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
n =int(input())
ans=[0]*n
for x in range(1,int(n**0.5)+1):
    for y in range(1,int((n-x**2)**0.5)+1):
        for z in range(1,int((n-x**2-y**2)**0.5)+1):
            p = x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=p and p<=n:
                ans[p-1]+=1
for i in range(n):
    print(ans[i])
            

Measured memory_bytes: 69824
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, d;
  cin >> n >> d;
  int ans;
  if (n % (1 + 2 * d) == 0) ans = n / (1 + 2 * d);
  else ans = n / (1 + 2 * d) + 1;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3604
use proconio::input;

fn main()
{
    input! {
    s:String,
    }

    let (a, b) = (s[..=1].parse::<i32>().unwrap(), s[2..].parse::<i32>().unwrap());

    let ans = match (a, b) {
        (1..=12, 1..=12) => "AMBIGUOUS",
        (1..=12, _) => "MMYY",
        (_, 1..=12) => "YYMM",
        _ => "NA",
    };

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

Measured memory_bytes: 2112
from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C,D)
#def count(n):
 # c = (B-A)//n
  #if A%n > B%n or A%n == 0:
   # c += 1
  #return c

#c = B-A+1-count(C)-count(D)+count(lcm)
def count2(A):
  c = A - A//C - A//D + A//lcm
  return c

c = count2(B)-count2(A-1)
print(int(c))

Measured memory_bytes: 5048
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;							\
											 c>0?i<b:							\
											 i>b;								\
											 i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
     
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
     
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

class Mycin {
	bool flag = true;
public:
	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
	operator bool() {return flag;}
} mycin;

class Mycout {
public:
	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
	Mycout& operator << (const char c) {printf("%c", c); return *this;}
	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
} mycout;

#define cin mycin
#define cout mycout
#define endl '\n'

int n;
int Ma, Mb;
int a[40];
int b[40];
int c[40];
int dp[405][405];

void solve() {
	cin >> n >> Ma >> Mb;
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	cerr << endl;
	rep(i, n) cerr << a[i] << " " << b[i] << " " << c[i] << endl;

	rep(i, 405) rep(j, 405) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i, n) {
		rrep(j,395) rrep(k, 395) {
			chmin(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
		}
	}

	int res = INF;
	rep2(i, 1, 1000) {
		int d = i * Ma;
		int e = i * Mb;
		if (d > 403) break;
		if (e > 403) break;
		chmin(res, dp[d][e]);
	}
	if (res == INF) cout << (int)-1 << endl;
	else cout << res << endl;
}


Measured memory_bytes: 1536
using System;
using System.IO;
using System.Linq;

namespace Programming
{
    class Class1
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(
                Console.OpenStandardOutput())
            {
                AutoFlush = false
            });
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                //line.Split(' ').Select(int.Parse).ToArray();
                Console.WriteLine(line.Replace(',', ' '));
            }

            Console.Out.Flush();

        }

    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 998244353
#define PI 3.141592653
#define INF 1000000000000000

ll kaijyo[210000];
ll gaijyo[210000];

ll powe(ll a, ll b){ //aのb乗のmod
	ll ret = 1;
	while(0 < b){
		if((b%2) == 0){
			a = (a*a)%MOD;
			b >>= 1;
		}
		else{
			ret = (ret*a)%MOD;
			b--;
		}
	}
	return ret;
}

void runfirst(){ //必ず回す!!
	kaijyo[0] = 1;
	gaijyo[0] = 1;
	FOR(i,1,209999) {
		kaijyo[i] = (kaijyo[i-1]*i)%MOD;
		gaijyo[i] = powe(kaijyo[i],MOD-2);
	}
}


ll C(ll m, ll n){
	return (kaijyo[m]*((powe(kaijyo[m-n],MOD-2) * powe(kaijyo[n],MOD-2))%MOD)%MOD);
}

//runfirst()を忘れずに。


int main(){
	runfirst();
	ll n, m, k; cin >> n >> m >> k;
	ll ans = 0;
	FOR(i,0,k) {
		ans = (ans+(((C(n-1,i)*m)%MOD)*powe(m-1,n-i-1))%MOD)%MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  
  
}

Measured memory_bytes: 3600
// {{{ by unolight
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}
// }}}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) cin >> a[i];
    set<int> s;
    deque<int> q;
    int ans=1;
    bool seen = false;
    for ( int i=0; i<k; i++ ) { 
        while ( q.size() && a[q.back()]>a[i] ) q.pop_back();
        q.push_back(i);
        s.insert(a[i]);
        if ( q.size()==k  ) seen=true;
    }

    for ( int i=k; i<n; i++ ) {
        while ( q.size() && q.front()<=i-k ) q.pop_front();
        while ( q.size() && a[q.back()]>a[i] ) q.pop_back();
        q.push_back(i);

        bool ok=false;
        if ( s.find(a[i-k])==s.begin() ) { ok=true; }
        s.erase(s.find(a[i-k]));
        s.insert(a[i]);
        if ( !(ok && *s.rbegin()==a[i]) && !(seen && q.size()==k) ) ans++;
        if ( q.size()==k ) seen = true;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll s;
    cin >> s;
    ll ma = 1000000000;
    if (s <= ma)
    {
        cout << "0 0 1 0 0 " << s << endl;
        return 0;
    }
    ll v = (s - 1) / ma + 1;
    ll tmp = ma * v - s;
    assert(tmp <= ma);
    cout << "0 0 1000000000 1 " << tmp << " " << v << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
const int MAXN = 100000 + 4;
const int NIL = -1;
int n, k, degree;

struct node
{
    int parent, left_child, right_brother;
};

node T[MAXN];
int D[MAXN];

void depth( int u, int p )
{
    D[u] = p;
    if ( T[u].right_brother != NIL ) depth( T[u].right_brother , p );
    if ( T[u].left_child != NIL ) depth( T[u].left_child, p + 1 );

}

void print( int u )
{
    int i, c;
    printf( "node %d: parent = %d, depth = %d, ", u, T[u].parent, D[u] );
    if ( T[u].parent == NIL ) printf( "root, " );
    else if ( T[u].left_child == NIL ) printf( "leaf, " );
    else printf( "internal node, " );

    printf("[");
    for ( i = 0, c = T[u].left_child; c != NIL; i++, c = T[c].right_brother ){
        if (i) printf( ", " );
        printf( "%d", c );
    }
    printf("]\n");
}

int main()
{
    int l, r, c;
    scanf( "%d", &n );
    for ( int i = 0; i < n; i++ ) { T[i].parent = NIL; T[i].left_child = NIL; T[i].right_brother = NIL; }
    for ( int i = 0; i < n; i++ ) {
        cin>>k>>degree;
        for ( int j = 0; j < degree; j++ ) {
            cin>>c;
            if ( !j ) T[k].left_child = c;
            else T[l].right_brother = c;
            l = c;
            T[c].parent = k;
        }
    }
    for ( int i = 0; i < n; i++ ){
        if ( T[i].parent == -1 ) r = i;
    }

    depth(r, 0);

    for ( int i = 0; i < n; i++ ) print(i);

    return 0;
}



Measured memory_bytes: 7864
#include<stdio.h>

int main(){
	
	int N,i,j;
	scanf("%d",&N);
	
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(i*j==N){
				printf("Yes");
				return 0;
			}
		}
	}
	
	printf("No");
	
	return 0;
}



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

const int N = 200010;

char s[N];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	int now = 0, ans = 0;
	for (int i = 0; i < n; ++ i){
		if (s[i] == 'S'){
			++ now;
		}
		else{
			if (now){
				-- now;
			}
			else{
				++ ans;
			}
		}
	}
	ans += now;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
/**
 *   
 *   Date: 30 March 2020
 *   Time: 13:15:00
**/
#pragma GCC optimize("O3")
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;
ll dp[102][100010];
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,w,mx=0;
	cin>>n>>w;
	matrix v1(n+2,vector<ll>(3));
	for(ll i=1;i<=n;i++)
	{
		cin>>v1[i][0]>>v1[i][1];
	}
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<=w;j++)
		{
			
			dp[i][j]=dp[i-1][j];
			if(j-v1[i][0] >= 0)
			dp[i][j]=max(dp[i][j],dp[i-1][j-v1[i][0]]+v1[i][1]);
			//mx=max(mx,dp[i][j+v1[i][0]]);
		}
	}
	cout<<dp[n][w]<<endl;

return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n), b(n), c(n - 1);
    
    for (int &t : a) {
        cin >> t;
        --t;
    }
    
    for (int &t : b)
        cin >> t;
        
    for (int &t : c)
        cin >> t;
        
    int ans = 0;
        
    for (int i = 0; i < n; ++i) {
        if (i < n - 1 && a[i] + 1 == a[i + 1]) {
            ans += c[a[i]];
        }
        
        ans += b[a[i]];
    }
    
    
    cout << ans;
}

Measured memory_bytes: 256
// time-limit: 2000
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif

int sign(li x) { return x < 0 ? -1 : x > 0; }

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b) return a / b + 1;
  else return a / b;
}

void _main(int tc) {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return;
    }
    int aux = ceil(b - a, a - 1);
    if ((a - 1) * aux < b) aux++;
    cout << aux << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21724
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

using QWORD = unsigned long long;
using SQWORD = long long;
using DWORD = unsigned int;
using SDWORD = int;
using WORD = unsigned short;
using SWORD = short;
using DOUBLE = double;
using FLOAT = float;

#define MIN_SDWORD (-2147483648)
#define MAX_SDWORD (2147483647)
#define ArrayLength(a)  (sizeof(a) / sizeof(a[0]))

static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; }
static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; }
static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; }
static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; }
static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; }
static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; }

#define BYTE_BITS   (8)
#define WORD_BITS   (16)
#define DWORD_BITS  (32)
#define QWORD_BITS  (64)

using M_BOOL = bool;
#define M_TRUE (true)
#define M_FALSE (false)

static void printMatrix(DWORD **p, DWORD dwSize)
{
    printf("---\n");
    for (DWORD i = 0; i < dwSize; i++) {
        for(DWORD j = 0; j < dwSize; j++) {
            printf("%5d", p[i*dwSize + j]);
        }
        cout << endl;
    }
    printf("---\n");
}

int main()
{
    DWORD dwInput_N, dwInput_M, dwInput_Q;
    char str[100];

    cin.getline(str, sizeof(str));
    dwInput_N = atoi(strtok(str, " "));
    dwInput_M = atoi(strtok(NULL, " "));
    dwInput_Q = atoi(strtok(NULL, " "));

    /* input train */
    static DWORD aadwTrainMap[501][501];
    for (DWORD dwIdx = 0; dwIdx < dwInput_M; dwIdx++) {
        cin.getline(str, sizeof(str));
        WORD wCity_L, wCity_R;

        wCity_L = std::stoi(strtok(str, " "));
        wCity_R = std::stoi(strtok(NULL, " "));
        aadwTrainMap[wCity_L][wCity_R]++;
    }

    /* calc camsum(Row) */
    for (DWORD dwRow = 0; dwRow <= dwInput_N; dwRow++) {
        DWORD dwSum = 0;
        for (DWORD dwCol = dwRow; dwCol <= dwInput_N; dwCol++) {
            dwSum += aadwTrainMap[dwRow][dwCol];
            aadwTrainMap[dwRow][dwCol] = dwSum;
        }
    }

    /* calc camsum(col) */
    for (DWORD dwCol = 0; dwCol <= dwInput_N; dwCol++) {
        DWORD dwSum = 0;
        for (DWORD dwRow = 0; dwRow <= dwInput_N; dwRow++) {
            dwSum += aadwTrainMap[dwRow][dwCol];
            aadwTrainMap[dwRow][dwCol] = dwSum;
        }
    }

    /* input question */
    for (DWORD dwIdx = 0; dwIdx < dwInput_Q; dwIdx++) {
        DWORD dwAnswer;
        cin.getline(str, sizeof(str));
        WORD wBegin = std::stoi(strtok(str, " "));
        WORD wEnd   = std::stoi(strtok(NULL, " "));

        dwAnswer= (aadwTrainMap[wEnd][wEnd]
                    - aadwTrainMap[wBegin-1][wEnd]
                    - aadwTrainMap[wEnd][wBegin-1]
                    + aadwTrainMap[wBegin-1][wBegin-1]);
        printf("%d\n", dwAnswer);
    }

    return 0;

}


Measured memory_bytes: 1920
n, a, b = [int(i) for i in input().split()]
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif a > b:
    print(0)
else:
    top = a + b + (n-2)*b
    bottom = a + b + (n-2)*a
    print(top-bottom+1)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
	long long l;
	cin >> l;
	long long end = 0;
	end += (l / 500) * 1000;
	l %= 500;
	end += (l / 5)*5;
	cout << end << endl;

}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a.at(i);
    }
    int now = 1;
    int i = 1;
    while (1) {
        now = a.at(now);
        if (now == 2) {
            cout << i << endl;
            break;
        }
        i++;
        if (i > n) {
            cout << -1 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3780
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 500010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int n, m;

int c[MAXN], num[MAXN], tree[MAXN], asdgafdga[MAXN], asdasdasd[MAXN], ww;
struct node {
	int l, r, pos;
}ask[MAXN];

int lowbit(int x) {
	return x & (-x);
}

void change(int x, int k) {
	while (x <= n) {
		c[x] += k;
		x += lowbit(x); 
	}
}

int query(int x) {
	int ans = 0;
	while (x) {
		ans += c[x];
		x -= lowbit(x);
	}
	return ans;
}
bool cmp (node a, node b) {
	return a.r < b.r;
}

signed main() {
	n = read();
	m = read();
	for (int i = 1; i <= n; i++) num[i] = read();
	for (int i = 1; i <= m; i++){
		ask[i].l = read();
		ask[i].r = read();
		ask[i].pos = i;
	}
	sort(ask + 1, ask + 1 + m, cmp);
	int next = 1;
	for (int i = 1; i <= m; i++) {
		for (int j = next; j <= ask[i].r; j++){
			if (asdgafdga[num[j]]) change(asdgafdga[num[j]], -1);
			change(j, 1), asdgafdga[num[j]] = j;
		}
		next = ask[i].r + 1;
		asdasdasd[ask[i].pos] = query(ask[i].r)- query(ask[i].l - 1);
	}
	for (int i = 1; i <= m; i++) printf("%d\n", asdasdasd[i]);
	return 0;
}

Measured memory_bytes: 31160
import bisect

N,M = map(int,input().split())
P = []

Indexs = {}
Syuturyoku = []
vp = []
vy = []

for j in range(N):
	P.append([0])


for i in range(M):
	p,y = map(int,input().split())
	vp.append(p)
	vy.append(y)

	P[p-1].append(y)
	Indexs[y] = i
	Syuturyoku.append(0)

for i in range(len(P)):
	P[i].sort()

for si in range(M):
	x = bisect.bisect_left(P[vp[si] - 1], vy[si])
	print('{:06}{:06}'.format(vp[si], x)) 


Measured memory_bytes: 38136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long amt = sc.nextLong();

		long a = amt / 500;

		long b = (amt - 500 * a) / 5;

		System.out.println(1000 * a + 5 * b);


	}
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(A == B){
			Console.WriteLine("Draw");
			return;
		}
		
		if(A == 1){
			Console.WriteLine("Alice");
			return;
		
		}
		if(1 == B){
			Console.WriteLine("Bob");
			return;
		}
		
		Console.WriteLine(A>B ? "Alice" : "Bob" );
		
	}
	int A,B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
/* You got a dream , you gotta protect it . */
/* You got a dream , you gotta protect it . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const long long MOD = 1e9 + 7;
int main(){
    FAST
    string s;
    cin >> s;
    sort(s.begin() , s.end());
    if(s[0] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0 ;
    }
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3+7;
int mat[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int h,w,sI,sJ,eI,eJ; cin >> h >> w >> sI >> sJ >> eI >> eJ;
    sI--; sJ--; eI--; eJ--;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j]=='#') mat[i][j]=1;
            else mat[i][j]=0;
        }
    }
    deque<pair<int,int>> q;
    vector<vector<int>> d(h, vector<int>(w, 1e9+7));
    q.push_front({sI,sJ});
    d[sI][sJ]=0;
    int dir[] = { 1,0,-1,0,1 };
    while (!q.empty()) {
        int cI,cJ;
        tie(cI,cJ) = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            int nI=cI+dir[i];
            int nJ = cJ+dir[i+1];
            if (nI >= h || nI < 0 || nJ >= w || nJ < 0) continue;
            if (mat[nI][nJ]) continue;
            if (d[nI][nJ] > d[cI][cJ]) {
                d[nI][nJ] = d[cI][cJ];
                q.push_front({nI,nJ});
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nI=cI+i;
                int nJ = cJ+j;
                if (nI >= h || nI < 0 || nJ >= w || nJ < 0) continue;
                if (mat[nI][nJ]) continue;
                if (d[nI][nJ] > d[cI][cJ]+1) {
                    d[nI][nJ] = d[cI][cJ]+1;
                    q.push_back({nI,nJ});
                }
            }
        }
    }
    if (d[eI][eJ]==1e9+7) cout << -1 << endl;
    else cout << d[eI][eJ] << endl;
    
    return 0;
}

Measured memory_bytes: 11632
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

typedef long long ll;
const int MOD = (int)1e9 + 7;

using namespace std;

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

int main() {
  ll n, k; cin >> n >> k;
  ll res = 0;
  for(int i=k; i<=n+1; ++i) {
    ll ans = i * n - pow(i, 2) + i + 1;
    res =  (res + ans) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3644