akhauriyash/Code-Regression huggingface dataset:
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	ll a, b;
	cin >> a >> b;
	cout << (a*(a - 1)) / 2 + (b*(b - 1)) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  for (int i = 0; i < N; i++) {
    if (A[i] < B[N - 1]) {
      cout << B[N - 1] << "\n";
    } else {
      cout << B[N - 2] << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    while(getline(cin,s)){
        stringstream ss(s);
        vector<int> V;
        int x;
        while(ss>>x){
            V.push_back(x);
        }
        if(V[0] == 0)break;
        int ans = 0;
        int num = 0;
        for(int i = 0;i < V.size();i++){
            if(V[i] == 1)ans += 1,num++;
            else if(V[i] > 9)ans += 10;
            else ans += V[i];
        }
        if(num>0 && ans<=11)ans += 10;
        if(ans > 21)ans = 0;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1240
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int my_time(vector<int>& v) {
    int t = 0;
    for(int i=0; i<5; i++) {
        t += v[i];
        if(t % 10 != 0 && i != 4) {
            t += 10 - (t % 10);
        }
    }
    return t;
}

int main() {
    int a,b,c,d,e, mint = INT_MAX;
    vector<int> me(5);
    for(size_t i = 0; i < 5; i++)
    {
        cin >> me[i];
    }
    

    vector<int> v(5);
    for(int i=0; i<5; i++) {
        for(int j=0; j<5; j++) {
            for(size_t k = 0; k < 5; k++)
            {
                for(size_t l = 0;  l < 5; l++)
                {
                    for(size_t m = 0;  m < 5; m++)
                    {
                        if(j != i && k != i && k != j && l != i && l != j && l != k && m != i && m != j && m != k && m != l){
                            v[0] = me[i];
                            v[1] = me[j];
                            v[2] = me[k];
                            v[3] = me[l];
                            v[4] = me[m];
                            mint = min(my_time(v), mint);
                        }
                    }
                    
                }
                
            }
            
        }
    }

    cout << mint << endl;
}


Measured memory_bytes: 256
// Created by Sharat Sachin
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)

using namespace std;
using ll = long long;

set<char> v;

bool check(int n){
  string s = std::to_string(n);
  for(char x: s){
    if(v.find(x)!=v.end()) return true;
  } 
  return false;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, xx;
    cin>>xx>>n;
    rep(i,n) {
      char s;
      cin>>s;
      v.insert(s);
    }
    while(check(xx)) xx++;
    cout<<xx;
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long cnt=0;
		for(int b=1; b<=N; b++) {
			int p = N/b;
			int q = N%b;
			cnt += p * Math.max(0,b-K) + Math.max(0, q-K+1);
		}
		if(K==0) cnt -= N;
		System.out.println(cnt);
		sc.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n<r)return 0;
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}

ll nHr(ll n,ll r){
  if(n<0 || r<0)return 0;
  return nCr( n+r-1 , n );
}

int main(){
  ll n,k;
  cin>>n>>k;
  cout<<nHr(n-k,k)<<endl;
  return 0;
}



Measured memory_bytes: 8652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        int b;
        cin >> b;
        ++a[b-1];
    }
    sort(a.begin(), a.end(), greater<int>());
    
    int ans = 0;
    int cnt = 0;
    for (int i=0; i<N; ++i){
        ++cnt;
        if (cnt > K) ans+=a[i];
    }
    
    cout << ans << endl;

    return 0;
}

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

int main() {
    bool flag;
    string s;
    cin >> s;
    
    flag = false;
    for (int i=0; i<3; i++) {
        if (s[i]=='7') {
            flag = true;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(all(A));
  ll ans = 0; ll tmp = A[0]; ll cnt = 0; ll k = 0;
  while(true) {
    REP(i, N) {
      if(i == k) continue;
      A[i] = A[i] % tmp;
      if(A[i] == 0) cnt++;
    }
    sort(all(A));
    REP(i, N) {
      if(A[i] == 0) continue;
      tmp = A[i];
      k = i;
      break;
    }
    if(cnt == N - 1) {
      ans = tmp;
      break;
    }
    cnt = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3940
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        sc.nextLine();
        Cell[][] a = new Cell[h + 2][w + 2];
        Queue<Cell> queue = new ArrayDeque<>();
        for (int i = 0; i < w + 2; i++) {
            a[0][i] = new Cell(0, i, '#');
        }
        for (int i = 1; i < h + 1; i++) {
            String line = sc.nextLine().replace("\n", "");
            a[i][0] = new Cell(i, 0, '#');
            for (int j = 1; j < w + 1; j++) {
                a[i][j] = new Cell(i, j, line.charAt(j - 1));
                if (a[i][j].color == '#') {
                    queue.add(a[i][j]);
                }
            }
            a[i][w + 1] = new Cell(i, w + 1, '#');
        }
        for (int i = 0; i < w + 2; i++) {
            a[h + 1][i] = new Cell(h + 1, i, '#');
        }
        sc.close();

        Cell dark = null;
        int countMax = 0;
        while ((dark = queue.poll()) != null) {
            int operate = 0;
            int x = dark.x;
            int y = dark.y;
            if (a[x - 1][y].color == '.') {
                a[x - 1][y].color = '#';
                a[x - 1][y].count = a[x][y].count + 1;
                countMax = a[x - 1][y].count;
                queue.add(a[x - 1][y]);
            }
            if (a[x + 1][y].color == '.') {
                a[x + 1][y].color = '#';
                a[x + 1][y].count = a[x][y].count + 1;
                countMax = a[x + 1][y].count;
                queue.add(a[x + 1][y]);
            }
            if (a[x][y - 1].color == '.') {
                a[x][y - 1].color = '#';
                a[x][y - 1].count = a[x][y].count + 1;
                countMax = a[x][y - 1].count;
                queue.add(a[x][y - 1]);
            }
            if (a[x][y + 1].color == '.') {
                a[x][y + 1].color = '#';
                a[x][y + 1].count = a[x][y].count + 1;
                countMax = a[x][y + 1].count;
                queue.add(a[x][y + 1]);
            }
        }
        System.out.println(countMax);
    }

    static class Cell {
        public int x;
        public int y;
        public char color;
        public int count;
        
        public Cell(int x, int y, char color) {
            this.x = x;
            this.y = y;
            this.color = color;
            this.count = 0;
        }
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 1000000005
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    int t;
    cin>>t;

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


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << double(W) * double(H) / 2 << " " << (2 * x == W && 2 * y == H)
       << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
A=list(map(int,input().split()))
B=[]
if n%2:
    for i in range(n-1,-1,-2):
        B.append(A[i])
    for i in range(1,n-1,2):
        B.append(A[i])
else:
    for i in range(n-1,0,-2):
        B.append(A[i])
    for i in range(0,n-1,2):
        B.append(A[i])
print(*B,sep=' ')

Measured memory_bytes: 26192
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main()
{


    ll a;

    cin>>a;

    cout<<a*a+a+a*a*a;




    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

// AGC を含まない
// A?GC を含まない
// GAC を含まない
// ACG を含まない
// AG?C を含まない

// ラスト3文字のDP...？

int main(void) {
  long N;
  cin >> N;
  unordered_map<string, long> mp;
  vector<string> ATCG = { "A", "T", "C", "G" };
  for (auto x: ATCG) for (auto y: ATCG) for (auto z: ATCG) {
    string tmp = x + y + z;
    if (tmp == "AGC" or tmp == "GAC" or tmp == "ACG") continue;
    mp[tmp] ++;
  }
  for (long i = 3; i < N; i++) {
    unordered_map<string, long> next_mp;
    for (auto x: ATCG) for (auto y: ATCG) for (auto z: ATCG) {
      string tmp = x + y + z;
      if (tmp == "AGC" or tmp == "GAC" or tmp == "ACG") continue;
      long count = 0;
      for (auto it: mp) {
        if (it.first[0] == 'A' and it.first[2] == 'G' and tmp[2] == 'C') continue;
        if (it.first[0] == 'A' and it.first[1] == 'G' and tmp[2] == 'C') continue;
        if (it.first[1] == tmp[0] and it.first[2] == tmp[1]) count = (count + it.second) % MOD;
      }
      next_mp[tmp] = count;
    }
    mp = next_mp;
  }
  long ret = 0;
  for (auto it: mp) ret = (ret + it.second) % MOD;
  cout << ret << endl;
  return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
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};

signed main()
{   
    gearup;
    string s;cin>>s;
    int a = s[0]-'0';
    int b = s[1]-'0';
    int c = s[2]-'0';
    int d = s[3]-'0';
    if(a -b -c - d ==7) printf("%d-%d-%d-%d=7\n" ,a ,b ,c ,d);
    else if (a -b - c + d ==7) printf("%d-%d-%d+%d=7\n" ,a ,b ,c ,d);
    else if (a - b +c - d ==7) printf("%d-%d+%d-%d=7\n" ,a ,b ,c ,d);
    else if (a - b + c + d ==7) printf("%d-%d+%d+%d=7\n" ,a ,b ,c ,d);
    else if ( a +b -c - d ==7) printf("%d+%d-%d-%d=7\n" ,a ,b ,c ,d);
    else if ( a +b - c + d ==7) printf("%d+%d-%d+%d=7\n" ,a ,b ,c ,d);
    else if ( a + b +c - d ==7) printf("%d+%d+%d-%d=7\n" ,a ,b ,c ,d);
    else if ( a + b + c + d ==7) printf("%d+%d+%d+%d=7\n" ,a ,b ,c ,d);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    --a;
    --b;
    --c;
    --d;
    bool check1 = true;

    int now = a;
    for (int i = a+1; i < c+1; ++i) {
        if (s[i] == '.' && now >= i-2) now = i;
        if (now < i-2) {
            check1 = false;
            break;
        }
    }
    now = b;
    for (int i = b+1; i < d+1; ++i) {
        if (s[i] == '.' && now >= i-2) now = i;
        if (now < i-2) {
            check1 = false;
            break;
        }
    }
    bool check2 = false;
    if (d > c) check2 = true;
    else {
        for (int i = b-1; i < d; ++i) {
            if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') check2 = true;
        }
    }
    yns(check1 && check2);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int l = reader.nextInt();
			int r = reader.nextInt();
			ans += Math.abs(l-r) + 1;
		}


		System.out.println(ans);
		reader.close();

	}
}





Measured memory_bytes: 24660
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn rep<T, F: FnMut() -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|_| f()).collect()
}

fn main() {
    use std::collections::HashMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let a: Vec<usize> = rep(n, || scan(tokens));
    let mut c = vec![0; n + 1];
    for i in 0..n {
        c[i + 1] = (c[i] + a[i]) % k;
    }
    let mut ans = 0;
    let mut map: HashMap<usize, Vec<usize>> = HashMap::new();
    for i in 0..n + 1 {
        let e = (c[i] + (k - i % k)) % k;
        let v = map.entry(e).or_insert_with(Vec::new);
        ans += v.len();
        if i >= k {
            ans -= binsearch(&v, i - k);
        }
        v.push(i);
    }
    println!("{}", ans);
}

fn binsearch(v: &[usize], q: usize) -> usize {
    if v.is_empty() || v[0] > q {
        return 0;
    }
    let mut a = 0;
    let mut b = v.len();
    while a + 1 < b {
        let c = (a + b) / 2;
        if v[c] <= q {
            a = c;
        } else {
            b = c;
        }
    }
    b
}


Measured memory_bytes: 30292
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, sum = 0;
  cin >> N;
  int dammy;
  dammy = N;
  while(dammy != 0){
    sum += dammy % 10;
    dammy /= 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
	int N;
	cin >> N;

	int h[N];
	for (int i = 0; i < N; i++) cin >> h[i];

	long long c[N];
	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for (int i = 1; i + 1 < N; i++) {
		c[i + 1] = min(c[i - 1] + abs(h[i + 1] - h[i - 1]), c[i] + abs(h[i + 1] - h[i]));
	}

	cout << c[N - 1] << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

using i32 = int;
using i64 = long long;

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

i64 A[1000], B[1000], C[1000];
i64 ABC[3000];
signed main() {
  i32 X, Y, Z, K;
  scanf("%d%d%d%d", &X, &Y, &Z, &K);
  REP(i, X) scanf("%lld", A + i);
  REP(i, Y) scanf("%lld", B + i);
  REP(i, Z) scanf("%lld", C + i);
  sort(A, A + X, greater<i64>());
  sort(B, B + Y, greater<i64>());
  sort(C, C + Z, greater<i64>());
  i64 A0 = A[0],
      B0 = B[0],
      C0 = C[0];
  REP(i, X) A[i] = A0 - A[i];
  REP(i, Y) B[i] = B0 - B[i];
  REP(i, Z) C[i] = C0 - C[i];
  i64 l = 0,
      r = A0 + B0 + C0;
  while (l < r) {
    i64 m = (l + r) / 2;
    i32 cnt = 0;
    REP(i, X) {
      if (A[i] > m) break;
      REP(j, Y) {
        if (A[i] + B[j] > m) break;
        REP(k, Z) {
          if (A[i] + B[j] + C[k] > m) break;
          ++cnt;
          if (cnt >= K) {
            r = m;
            goto NEXT;
          }
        }
      }
    }
    l = m + 1;
    NEXT:;
  }
  i32 c = 0;
  REP(i, X) {
    if (A[i] >= l) break;
    REP(j, Y) {
      if (A[i] + B[j] >= l) break;
      REP(k, Z) {
        if (A[i] + B[j] + C[k] >= l) break;
        ABC[c++] = A[i] + B[j] + C[k];
      }
    }
  }
  sort(ABC, ABC + c);
  REP(i, c) {
    printf("%lld\n", A0 + B0 + C0 - ABC[i]);
  }
  REP(_, K - c) {
    printf("%lld\n", A0 + B0 + C0 - l);
  }
}

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

using namespace std;

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

    s1[0] = toupper(s1[0]);
    s2[0] = toupper(s2[0]);
    s3[0] = toupper(s3[0]);
    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.io.*;
import java.util.*;
class Main{
  static Node root = null;
  static StringBuilder bl = new StringBuilder();
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String [] s = new String[2];
    for(int i = 0; i<n; i++){

      s = br.readLine().split("\\s+");

      if(s[0].charAt(0) == 'i'){
        Insert( Integer.parseInt(s[1]));
      }
      else if(s[0].charAt(0) == 'p'){
        inorder(root);
        bl.append("\n");
        preorder(root);
        bl.append("\n");
      }
    }
    System.out.print(bl);
  }
  static void Insert (int k){
    Node y = null;
    Node x = root;
    Node z = new Node();
    z.key = k;
    z.left = null;
    z.right = null;

    while(x != null){
      y = x;
      if(z.key < x.key){
        x = x.left;
      }else{
        x = x.right;
      }
    }
    z.parent = y;

    if( y == null){
      root = z;
    }else if( z.key < y.key){
      y.left = z;
    }else{
      y.right = z;
    }
  }

  static void preorder(Node u){
    if( u == null) return;
    bl.append(" ").append(u.key);
    preorder(u.left);
    preorder(u.right);
  }

  static void inorder(Node u){
    if(u == null) return;
    inorder(u.left);
    bl.append(" ").append(u.key);
    inorder(u.right);
  }

}

class Node{
  int key;
  Node parent;
  Node right;
  Node left;
  Node(){};
}


Measured memory_bytes: 188240
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int N;
    std::cin >> N;
    std::cout << N/3 << std::endl;
}


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

int main(){
  	int N;
  	cin >> N;
	double x,ans(0);
  	string u;
  	for(int i = 0 ; i < N ; i ++){
      	cin >> x >> u;
      	if(u == "JPY") ans += x; else ans += x * 380000.0;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
from string import ascii_lowercase as al


def dfs(p, i):
    if len(p) == N:
        print("".join(p))
        return
    for j in range(i+1):
        if j == i:
            dfs(p + list(al[j]), i+1)
        else:
            dfs(p + list(al[j]), i)


N = int(input())
dfs([], 0)


Measured memory_bytes: 5028
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read(){
	int f=1,x=0; char c=getchar();
	while (c>'9' || c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0'; c=getchar();}
	return f*x;
}
int head[210],num_edge,n,a[110],b[110],c[110],d[110];
int ans,match[210];
bool book[210];
struct Edge{
	int u;
	int v;
	int next;
}edge[110*110];
void add_edge(int u,int v){
	edge[++num_edge].next=head[u];
	edge[num_edge].u=u;
	edge[num_edge].v=v;
	head[u]=num_edge;
}
bool dfs(int u){
	for(int i=head[u];i;i=edge[i].next){
		if(book[edge[i].v]==0){
			book[edge[i].v]=1;
			int tem=edge[i].v;
			if(match[tem]==0||dfs(match[tem])){//让人家的媳妇儿去找外遇，要是找到了，这个男人就归你了。 
				match[tem]=u;
				match[u]=tem;
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		a[i]=read();
		b[i]=read();
	}
	for(int i=1;i<=n;i++){
		c[i]=read();
		d[i]=read();
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if((a[i]<c[j])&&(b[i]<d[j])) {
				add_edge(i,n+j);
				add_edge(n+j,i);
//				cout<<i<<" "<<n+j<<endl;
			}
		}
	}
	for(int i=1;i<=n;i++){
		memset(book,0,sizeof(book));//千万记住这里要清零。 
		book[i]=1;
		if(dfs(i))ans++;
	}
//	for(int i=1;i<=n;i++)if(match[i]!=0)ans++;
	cout<<ans;
//	for(int i=1;i<=n;i++) cout<<i<<"->"<<match[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct Edge { int to, cost; };

template<class T, class Edge> V<T> dijkstra(const VV<Edge>& g, int s = 0) {
  V<T> dist(g.size(), numeric_limits<T>::max());
  using P = pair<T, int>;
  priority_queue< P, V<P>, greater<P> > pque;
  pque.emplace(dist[s] = 0, s);
  while (!pque.empty()) {
    T d; int v;
    tie(d, v) = pque.top(); pque.pop();
    if (d > dist[v]) continue;
    for (const auto& e : g[v]) if (dist[v] + e.cost < dist[e.to]) {
      pque.emplace(dist[e.to] = dist[v] + e.cost, e.to);
    } 
  }
  return dist;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, k; cin >> n >> m >> k;
  V<> p(n); for (auto&& e : p) cin >> e;
  V<> c(n); for (auto&& e : c) cin >> e, --e;
  V<> q(n); for (auto&& e : q) cin >> e;
  VV<Edge> g(2 * n);
  while (m--) {
    int u, v, c; cin >> u >> v >> c, --u, --v;
    g[u].push_back(Edge{v, c});
    g[v].push_back(Edge{u, c});
    g[n + u].push_back(Edge{n + v, c});
    g[n + v].push_back(Edge{n + u, c});
  }
  constexpr int o = 1e9;
  for (int v = 0; v < n; ++v) {
    g[v].push_back(Edge{n + v, o - p[v]});
  }
  auto d = dijkstra<lint>(g);
  V<lint> res(k, -9e18);
  for (int v = 0; v < n; ++v) {
    res[c[v]] = max(res[c[v]], o + q[v] - d[n + v] - d[v]);
  }
  for (lint e : res) cout << e << '\n';
}


Measured memory_bytes: 25404
N, A, B, C = map(int, input().split())
lLst = [0] * N
for i in range(N):
    lLst[i] = int(input())
maxM = 10000

def dfs(nCnt, atake, btake, ctake):
    if nCnt == N:
        if min(atake, btake, ctake) > 0:
            return abs(A - atake) + abs(B - btake) + abs(C - ctake) - 30
        else:
            return maxM

    ret0 = dfs(nCnt + 1, atake, btake, ctake)
    ret1 = dfs(nCnt + 1, atake + lLst[nCnt], btake, ctake) + 10
    ret2 = dfs(nCnt + 1, atake, btake + lLst[nCnt], ctake) + 10
    ret3 = dfs(nCnt + 1, atake, btake, ctake + lLst[nCnt]) + 10
    return min(maxM, ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

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

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a, b;
  for(int i=0; i<n; i++){
    int ea, eb;
    std::cin >> ea >> eb;
    a.push_back(ea);
    b.push_back(eb);
  }
  long ans = 0;
  for(int i=0; i<31; i++){
    if(i != 30 && (k & (1<<i)) == 0) continue;
    int mask = (k | ~(~0<<i)) & ~(1<<i);
    if(i == 30) mask = k;
    long score = 0;
    for(int j=0; j<n; j++)
      if((a[j] | mask) == mask) score += b[j];
    if(score > ans) ans = score;
  }
  std::cout << ans << std::endl;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);

  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  a.push_back(-1e17);
  b.push_back(-1e17);
  c.push_back(-1e17);
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  sort(c.rbegin(), c.rend());

  priority_queue<pair<ll, tuple<int, int, int>>> pq;
  pq.push({a[0] + b[0] + c[0], make_tuple(0, 0, 0)});

  vector<ll> ans;
  set<tuple<int, int, int>> used;
  used.insert({0, 0, 0});

  while ((int)ans.size() < k) {
    auto u = pq.top();
    pq.pop();

    ans.push_back(u.first);
    auto v = u.second;

    for (int i = 0; i < 3; ++i) {
      int na = get<0>(v) + (i == 0);
      int nb = get<1>(v) + (i == 1);
      int nc = get<2>(v) + (i == 2);
      if (used.find(make_tuple(na, nb, nc)) == used.end()) {
        used.insert(make_tuple(na, nb, nc));
        pq.push({a[na] + b[nb] + c[nc], make_tuple(na, nb, nc)});
      }
    }
  }

  rep(i, k) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 4188
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	string s;
	cin>>s;
	string t="";
	for(int i=0;i<s.length();i++)
    {
        if(s[i]=='0')
            t+=s[i];
        else if(s[i]=='1')
            t+=s[i];
        else
        {
            if(t.length()>0)
                t.erase(t.length()-1,1);
        }
       // cout<<t<<"\n";
    }
   cout<<t<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int k,n;
  vector<int>point;
  cin>>k>>n;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    point.push_back(p);
  }

  int maxim=0;
  for(int i=0;i<n-1;i++){
    maxim=max(maxim,point[i+1]-point[i]);
  }
  maxim=max(maxim,k-point[n-1]+point[0]);
  
  cout<<k-maxim<<endl;
  return(0);
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, T, A;
  cin >> N;
  cin >> T >> A;
  vector<float> data(N,0);
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    data.at(i) = T - n * 0.006;
  }
  int ans;
  float  num, keep =2000;
  for (int i = 0; i < N; i++) {
    num = A - data.at(i);
    if (keep > fabs(num)) {
      keep = fabs(num);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
using namespace std;

int main() {
	string s;
	cin>>s;
	for (int i = 0; i< s.size(); i++) {
		cout << s[i];
		if (i == 3) {
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

result = 0
for A in combinations_with_replacement(range(1, M + 1), N):
    t = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            t += d
    result = max(result, t)
print(result)


Measured memory_bytes: 9132
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
ll power(int n, int m){
  int res = 1;
  int i = 0;
  while(i < m){
    res *= n;
    i++;
  }
  return res;
}
int main(){
  int D, G;
  cin >> D >> G;
  int p[D], c[D];
  for(int i=0;i<D;i++){
    cin >> p[i] >> c[i];
  }

  int search = power(2,D);
  int ans = 10000;

  for(int x=0;x<search;x++){
    int point=0;
    int num=0;
    for(int i=0;i<D;i++){
      if(x&(1<<i)){
        point += 100*(i+1)*p[i] + c[i];
        num += p[i];
      }
    }
    if(point<G){
      int j = D;
      while(point<G && j>=0){
        j--;
        if(!(x&(1<<j))&& j>=0){
          point += 100*(j+1)*p[j];
          num += p[j];
        }
      }
      if(j>=0){
        while(point >= G){
          point -= 100*(j+1);
          num--;
        }
        num++;
        ans = min(ans, num);
      }
    }else{
      ans = min(ans, num);
    }       
  }

  cout << ans <<endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vvi vec(n,vi(3));
    vi ans(n);
    REP(i,n-1){
        REP(j,3){
            cin>>vec[i][j];
        }
    }
    REP(i,n-1){
        int now=0;
        FOR(j,i,n-1){
            int a=vec[j][0];
            int b=vec[j][1];
            int c=vec[j][2];
            if(i==j){
                now=a+b;
                continue;
            }
            int t=max(0,(now-b+c-1)/c);
            now=a+b+c*t;
        }
        ans[i]=now;
    }
    //reverse(all(ans));
    REP(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <cassert>

using namespace std;

#define TT1T2 template<class T1, class T2>
TT1T2 void debug_print_array(const T1 &a, T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cerr << a[i] << (i + 1 != sz ? "," : ""); cout << endl; }
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DA(a,n) cerr<<#a<<"=["; debug_print_array(a,n); cerr<<"]\n"
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T, const int N> using Graph = vector <T> [N];

const int MAXN = 100;
int cnt[MAXN];

void No() {
    cout << "No";
    exit(0);
}

void Yes() {
    cout << "Yes";
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(20);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif



    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            cnt[c - 'a']++;
        }
    }
    int all = 0;
    int pp = 0;
    for (int i = 0; i < 26; i++) {
        all += (cnt[i] / 4) * 4;
        cnt[i] %= 4;
        pp += cnt[i] % 2 == 1;
    }
    int other = 0;
    if (n % 2 == 1 && m % 2 == 0) {
        other = m;
    } else if (n % 2 == 0 && m % 2 == 1) {
        other = n;
    } else if (n % 2 == 1 && m % 2 == 1) {
        other = n + m - 1;
    }

    if (all + other < n * m) {
        No();
    }
    if (pp > 1 || (pp && other == 0)) {
        No();
    } else {
        Yes();
    }




    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int P[] = new int[M];
    int Y[] = new int[M];
    List<List> A = new ArrayList<List>(N);
    for(int i=0; i<N; i++){
      List<Integer> B = new ArrayList<Integer>();
      A.add(B);
    }      
    for(int i=0; i<M; i++){
      P[i] = Integer.parseInt(sc.next());
      Y[i] = Integer.parseInt(sc.next());
      A.get(P[i]-1).add(Y[i]);
    }
    for(int i=0; i<N; i++){
      Collections.sort(A.get(i));
    }
    for(int i=0; i<M; i++){
      int x = Collections.binarySearch(A.get(P[i]-1), Y[i]) + 1;
      out.printf("%06d%06d\n",P[i],x);
    }
    
  }

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

Measured memory_bytes: 118024
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N;
    Ssum[0]=0;
    for (i=0;i<N;i++){
        cin >> S[i];
        Ssum[i+1]=Ssum[i]+S[i];
    }
    for (i=1;i<N;i++){
        
        tmp=abs(Ssum[i]-(Ssum[N]-Ssum[i]));
        if (ans>tmp){
            ans=tmp;
        }
        
    }
    

    
    cout << ans<<endl;

    return 0;
    
}


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

std::string x;

int main() {
	std::cin >> x;
	if(x[1] == x[2] && (x[0] == x[1] || x[3] == x[2])) {
		puts("Yes");
		return 0;
	} 
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

LLI sum(LLI s, LLI t){
  return t*(t+1)/2 - (s-1)*s/2;
}

using P = pair<LLI,LLI>;

int main(){
  LLI N,X,D;
  while(cin >> N >> X >> D){

    LLI ans = 0;

    if(D == 0){
      if(X == 0){
        ans = 1;
      }else{
        ans = N + 1;
      }
    }else{
      if(D < 0){
        X = -X;
        D = -D;
      }

      map<LLI, vector<P>> s;

      FORE(k,0,N){
        LLI y = k * X / D;
        s[(k * X) % D].emplace_back(sum(0, k-1) + y, sum(N-k, N-1) + y);
      }


      for(auto &kv : s){
        auto &v = kv.snd;
        sort(ALL(v));

        //dump(v);

        vector<P> temp;

        for(auto &p : v){
          if(temp.empty()){
            temp.push_back(p);
          }else{
            if(temp.back().snd < p.fst){
              temp.push_back(p);
            }else{
              chmax(temp.back().snd, p.snd);
            }
          }
        }

        for(auto &p : temp){
          ans += p.snd - p.fst + 1;
        }
      }
      
    }



    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 22144
def build_combinations_counter(N=10**5, p=10**9+7):
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # mod p におけるnの逆元 n^(-1)
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
    def cmb(n, r, p, fact, factinv):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n-r] % p
    
    import functools
    return functools.partial(cmb, p=p, fact=fact, factinv=factinv)

def resolve():
    n, k = list(map(int, input().split()))
    MOD = 10**9+7
    counter = build_combinations_counter(2*10**5, 10**9+7)
    ans = 0
    for i in range(min(n, k+1)):
        ans += counter(n, i) * counter(n-1, n-i-1)
        ans %= MOD
    print(ans)
    
    
if __name__ == "__main__":
    resolve()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum+=a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    rep(i, m){
        if(a[i] < sum * (1 / (4 * (double)m))){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n,k;
    while(cin >> n >> k, n&k){
        int num[n],total=0;
        for(int i=0;i<n;i++) cin>>num[i];
        for(int i=0;i<k;i++) total+=num[i];
        int ans=total;
        for(int i=0;i<n-k;i++){
            total+=num[i+k]-num[i];
            ans=max(ans,total);
        }
            cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3448
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

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

	int temp = n % 500;
	if (temp > a) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    string S; cin>>S;
    int flag = 1;

    if(S.at(2)!=S.at(3) || S.at(4)!=S.at(5)){
        flag=0;
    }

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

Measured memory_bytes: 256
use proconio::input;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
        a: i32,
        v: i32,
        b: i32,
        w: i32,
        t: i32,
    }

    let ans = if v > w {
        let dist = (a - b).abs();
        let speed = v - w;
        let time = (dist + speed - 1) / speed;
        if time <= t {
            "YES"
        } else{
            "NO"
        }
    } else {
        "NO"
    };

    println!("{}", ans);

}


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

void dfs(int v,int t,vector<vector<int>> &edge,vector<int> &used,vector<int> &ans){
    ans.push_back(v);
    for(int i=0;i<edge[v].size();i++){
        if(!used[edge[v][i]]){
            used[edge[v][i]]=true;
            dfs(edge[v][i],t,edge,used,ans);
            return;
        }
    }
    return;
}


int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> edge(n);
    int v,t;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        if(i==0){
            v=a;
            t=b;
        }
    }
    vector<int> used(n,0);
    used[v]=1;
    used[t]=1;
    vector<int> ans;
    dfs(v,t,edge,used,ans);
    reverse(ans.begin(),ans.end());
    dfs(t,v,edge,used,ans);
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]+1;
        if(i!=ans.size()-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 12280
c = input()

# 英小文字 c が与えられるので、cが母音であるか判定してください。
# c が母音であるとき、vowel と、そうでないとき consonant と出力せよ。

if c in ("a", "e", "i", "o", "u"):
    print("vowel")
else:
    print("consonant")

Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (a = 0; a < b; a++)
  

int main(){
  
  int K, X;
  cin >> K >> X;
  
  if (K * 500 >= X){
    
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
}

Measured memory_bytes: 256