akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int N; cin>>N;
    vec h(N); REP(i,N) cin>>h[i];
    vec DP(100001,INF);
    DP[0]=0;

    FOR(i,1,N){
        DP[i]= min(DP[i],DP[i-1]+abs(h[i]-h[i-1]));
        if(i>1) DP[i]=min(DP[i],DP[i-2]+abs(h[i]-h[i-2]));
    }
    Out(DP[N-1]);
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>


int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}

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

const int MAX=405;

char S[MAX][MAX];
pair<int,int> par[MAX][MAX];
pair<int,int> root(int a,int b){
    if(par[a][b]==make_pair(a,b)) return par[a][b];
    else return par[a][b]=root(par[a][b].first,par[a][b].second);
}
void unite(int a,int b,int c,int d){
    if(root(a,b)!=root(c,d)) par[root(c,d).first][root(c,d).second]=root(a,b);
}
bool same(int a,int b,int c,int d){
    if(root(a,b)==root(c,d)) return 1;
    else return 0;
}

int main(){
    
    int H,W;cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>S[i][j];
            par[i][j]=make_pair(i,j);
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i==0){
                if(j!=0){
                    if(S[i][j]!=S[i][j-1]) unite(i,j,i,j-1);
                }
            }
            else{
                if(S[i][j]!=S[i-1][j]) unite(i,j,i-1,j);
                if(j!=0){
                    if(S[i][j]!=S[i][j-1]) unite(i,j,i,j-1);
                }
            }
        }
    }
    long long int cnt=0;
    pair<long long int,long long int> T[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#') T[root(i,j).first][root(i,j).second].first++;
            if(S[i][j]=='.') T[root(i,j).first][root(i,j).second].second++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cnt+=T[i][j].first*T[i][j].second;
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;

    ll p = x / d;

    ll rem = max(k - p,ll(0));

    if(k > p){
      ans = abs(x - d * p);
    }
    else{
      ans = abs(x - d * k);
    }


    if(rem % 2 == 0){
      cout << ans << endl;
    }
    else{
      ans = abs(ans - d);
      cout << ans << endl;

    }
}

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

using namespace std;

void print(vector<int> a) {
    for (int i = 0; i < a.size(); i++) {
        cout << a[i];
        if (i != a.size() - 1) cout << " ";
    }
    cout << endl;
}

void bubbleSort(vector<int> a) {
    int count = 0;
    for (int j = 0; j < a.size(); j++) {
        for (int i = 0; i < a.size() - 1; i++) {
            if (a[i] > a[i + 1]) {
                int tmp = a[i];
                a[i] = a[i + 1];
                a[i + 1] = tmp;
                count++;
            }
        }
    }
    print(a);
    cout << count << endl;
    return;
}

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


Measured memory_bytes: 3176
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])


II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


class UnionFind(object):
    """UnionFind (経路圧縮、ランクあり)"""
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n
        self._size = [1] * n

    def _set_parent(self, parent, child):
        self._size[parent] = self.size(parent) + self.size(child)
        self.parent[child] = parent

    def size(self, node):
        return self._size[self.root(node)]

    def union(self, n1, n2):
        r1, r2 = self.root(n1), self.root(n2)

        if r1 != r2:
            if self.rank[r1] < self.rank[r2]:
                self._set_parent(r1, r2)
            else:
                self._set_parent(r2, r1)
                if self.rank[r1] == self.rank[r2]:
                    self.rank[r1] += 1

    def root(self, node):
        p = self.parent[node]
        if p == node:
            return p
        p = self.root(p)
        self.parent[node] = p
        return p

    def same(self, n1, n2):
        return self.root(n1) == self.root(n2)


def main():
    N, M = MI()
    bridges = []
    for i in range(M):
        a, b = MI()
        bridges.append((a-1, b-1))

    costs = [N * (N-1) // 2]
    uf = UnionFind(N)
    for a, b in bridges[::-1]:
        if uf.same(a, b):
            costs.append(costs[-1])
        else:
            costs.append(costs[-1] - uf.size(a) * uf.size(b))
        uf.union(a, b)
    for c in costs[-2::-1]:
        print(c)


if __name__ == "__main__":
    main()


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

int main() {
  int n;

  while(1) {
    cin >> n;
    if (n == 0) break;

    int sum = 1, ans = 0;
    int s = 1, e = 2;
    while(s <= e && e <= n) {
      if (sum == n) ans++;
      else if(sum > n) {
        sum -= s;
        s++;
        continue;
      }
      sum += e;
      e++;
    }

    cout << ans << endl;
  }

}

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

int main() {
    long long h;
    cin >> h;
    long long num = 1;
    long long atk = 0;

    while (h) {
        atk += num;
        if (h == 1) {
            break;
        }
        h = h / 2;
        num *= 2;
    }

    cout << atk;
    return 0;
}


Measured memory_bytes: 256
import bisect
n=int(input())
a=[int(x) for x in input().split()]
y=sorted(a)
m=y[-1]
i = bisect.bisect_left(y,m/2.0)
if y[i]+y[i-1] >= m:
    print(str(m)+' '+str(y[i-1]))
else:
    print(str(m)+' '+str(y[i]))

Measured memory_bytes: 14052
#include <stdio.h>
int main(){
	int W,H,x,y,r,a,b;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r<=x && x<=W-r){
		if(r<=y && y<=H-r){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main(void){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    bool flag = true;
    for(int i=1;i<n;i++){
        if(h[i-1] <=h[i]-1){
            h[i]--;
            continue;
        }
        if(h[i-1] <= h[i]){
            continue;
        }
        flag = false;
    }

    // for(int i=0;i<n;i++){
    //     cout << h[i] << ' ';
    // }

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

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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) puts("Yes");
    else puts("No"); 
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] P = new int[M];
        int[] Y = new int[M];
        List<Pair> list = new ArrayList<Pair>();
        HashMap<Integer, Pair> map = new HashMap<>();
        for (int i = 0; i < M; i++) {
            P[i] = scan.nextInt();
            Y[i] = scan.nextInt();
            Pair p = new Pair();
            p.id = i+1;
            p.p = P[i];
            p.y = Y[i];
            list.add(p);
            map.put(i+1, p);
        }
        list.sort(new PairComparator());
        int prev_city = -1;
        int city_count = 0;
        for (Pair p : list) {
            if (p.p != prev_city) {
                city_count = 1;
                prev_city = p.p;
            }
            p.addr_id = String.format("%06d%06d", prev_city, city_count++);
        }
        for (int i = 1; i <= M; i++) {
            System.out.println(map.get(i).addr_id);
        }
    }
    class Pair {
        int id;
        int p;
        int y;
        String addr_id;
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.p == o2.p) {
                return Integer.compare(o1.y, o2.y);
            }
            return Integer.compare(o1.p, o2.p);
        }
    }
}


Measured memory_bytes: 175268
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

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

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int N , arr[10];
int main(){
//	BOOST();
	
	string s;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>s;
		if(s=="AC")arr[1]++;
		else if(s=="WA")arr[2]++;
		else if(s=="TLE")arr[3]++;
		else arr[4]++;
	}
	cout<<"AC x "<<arr[1]<<endl;
	cout<<"WA x "<<arr[2]<<endl;
	cout<<"TLE x "<<arr[3]<<endl;
	cout<<"RE x "<<arr[4]<<endl;
}







Measured memory_bytes: 3640
import sys

charas = 'abcdefghijklmnopqrstuvwxyz'

data = []
for line in sys.stdin:
    data.append(line)
for chara in charas:
    cnt = 0
    for row in data:
        cnt += row.count(chara)
        cnt += row.count(chara.upper())
    print('{} : {}'.format(chara, cnt))

Measured memory_bytes: 7372
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.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; }

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

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

//https://qiita.com/drken/items/a14e9af0ca2d857dad23

//N=1の時に自分で対応しなきゃいけないから注意
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main()
{
  ll A,B; cin>>A>>B;
  ll G=gcd(A,B); if(G==1) {cout<<1<<endl; return 0;}
  vector<pair<ll,ll>> vec=prime_factorize(G);
  cout<<vec.size()+1<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n) rep(j, n) rep(k, n) ans += gcd(i, gcd(j, k));
  cout << ans << endl;
  return 0;
}

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

fac_2 = 0
fac_4 = 0
for a in A:
    if a % 4 == 0:
        fac_4 += 1
    elif a % 2 == 0:
        fac_2 += 1

if fac_2 == 0:
    x = 1
else:
    x = 0

if fac_2 + fac_4*2 + x >= N:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11100
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t max_rest = INT32_MIN;
  int32_t time = 0;
  for (int32_t i = 0; i < 5; ++i) {
    int32_t a;
    cin >> a;
    int32_t rest = 10 - a % 10;
    if (rest == 10) {
      rest = 0;
    }
    max_rest = max(rest, max_rest);
    const int32_t rounded = (a % 10 == 0) ? a : ((a / 10) + 1) * 10;
    time += rounded;
  }
  time -= max_rest;
  cout << time << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define lop(b) for(int i = 1; i <= b; i++)
#define loop(j, a, b) for(int j = a; j < b; j++)

const int N = 1e5+4;
int w[4][N], n;
ll dp[4][N];

ll f(int j, int t)
{
    if(j > n)
        return 0;

    if(dp[t][j] != -1)
        return dp[t][j];

    ll ans[4] = {0};

    loop(i, 1, 4)
    {
        if(i == t) continue;

        ans[i] = f(j + 1, i) + w[i][j];
    }

    dp[t][j] = *max_element(ans, ans + 4);

    return dp[t][j];
}

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

    cin >> n;

    lop(n)
        cin >> w[1][i] >> w[2][i] >> w[3][i];

    memset(dp, -1, sizeof dp);

    cout << f(0, 0) << '\n';

    return 0;
}



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

int main() {
	while(true){
	int R,C;
	int cookie[11][10001];
	cin >> R >> C;
	if(R==C && C==0)
	break;
	for (int i=1;i<=R;i++){
		for(int j=1;j<=C;j++){
			cin >> cookie[i][j];
			cookie[0][j]+=cookie[i][j];
		}
	}
	int maxer=0;
	for(int i=0;i<(1 << R);i++){
			int biter[10]={};
			int sum=0;
		for(int j=0;j<R;j++){
			if(i & (1<<j)){
				biter[j]=1;
				sum++;
			}
		}
		if(sum<=R/2){
			int S=0;
			for(int j=1;j<=C;j++){
				int t=0;
				for(int k=1;k<=R;k++){
					t+=cookie[k][j] ^ biter[k-1];
				}
				S+=max(t,R-t);
			}
			maxer=max(maxer,S);
		}
	}
	cout << maxer << endl;
	}
	return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> current(n);
    vector<int> need(n);
    for(int i = 0; i < n; i++){
        current[i] = 0;
        cin >> need[i];
    }

    int count = 0;

    for(int i = 0; i < n; i++){
        while(current[i] < need[i]){
            int j;
            for(j = i; j < n; j++) {
                if (current[j] >= need[j]) break;
            }
            count++;
            for(int k = i; k < j; k++){
                current[k]++;
            }
        }
    }
    cout << count << endl;
}

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

Measured memory_bytes: 384
from itertools import cycle, islice

def fmt(t, o, l):
    i = o % l
    return "".join(islice(cycle(t), i, i+l))

def reader():
    target, offset, length, n = "", 0, 0, -1
    while True:
        s = input()
        if s == "-":
            if target != "":
                yield fmt(target, offset, length)
            break

        if s[0].isalpha():
            if target != "":
                yield fmt(target, offset, length)
            target, offset, length, n = s, 0, len(s), -1            
        else:
            if n < 0:
                n = int(s)
            else:
                offset += int(s)

for s in reader():
    print(s)

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

void solve(long long H, long long W, long long h, long long w){
    cout << (H - h) * (W - w) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

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

mod = 998244353

fact_list = [1]
for i in range(1, N + 1):
	fact_list.append((fact_list[-1]*i) % mod)

def pow(x, y, mod=1000000007):
	pow_list = [x]
	i = 1
	while 2**i <= y:
		a = pow_list[-1]**2
		if mod != 0:
			a = a % mod
		pow_list.append(a)
		i += 1
	ans = 1
	for bit in range(len(pow_list)):
		if (2**bit) & y != 0:
			ans *= pow_list[bit]
			if mod != 0:
				ans = ans % mod
	return ans

def fact(n, mod=1000000007):
	return fact_list[n]

inv_t = [0] + [1]
for i in range(2,N + 1):
	inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def mod_rev(x, mod):
	"""
	関数powが必要
	"""
	return inv_t[x]

inv_fact = [1] + [1]

for i in range(2, N + 1):
	inv_fact.append((inv_fact[-1] * inv_t[i]) % mod)


def comb(a, b, mod=1000000007):
	"""
	関数mod_rev, fact, powが必要
	"""
	if a < b or b < 0:
		return 0
	if a == b or b == 0:
		return 1
	a_fact = fact(a, mod)
	b_fact = fact(b, mod)
	a_b_fact = fact(a - b, mod)
	if mod != 0:
		return (a_fact * inv_fact[b] * inv_fact[a - b])%mod
	else:
		return a_fact//(b_fact*a_b_fact)

ans = 0
times = 0
for r in range(N + 1):
	rest = K - r * A
	if rest % B == 0 and rest // B >= 0 and rest // B <= N:
		b = rest // B
		ans += comb(N, r, mod)*comb(N, b, mod)
		ans %= mod
		times += 1

print(ans)

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

int main(){
    stringstream ss;
    int n; string s,cpy,fig;
    while(cin >> n,n){
        int r = 1; char a;  cin >> s;
        while(n--){
            a = s[0];
            for(int i=0;i<s.size()-1;i++){
                if(a != s[i+1]){
                    ss << r; ss >> fig; ss.clear(); cpy += fig;
                    ss << a; ss >> fig; ss.clear(); cpy += fig;
                    r = 1; a = s[i+1];
                }
                else r++;
            }
            ss << r; ss >> fig; ss.clear(); cpy += fig;
            ss << a; ss >> fig; ss.clear(); cpy += fig;
            s = cpy; cpy.erase();
            r = 1;
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1588
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
c=[-1]*(N+1)
c[0]=0
for i in range(1,N+1):
    ans=c[i-1]+1
    tmp=6
    while i-tmp>=0:
        ans=min(ans,c[i-tmp]+1)
        tmp*=6
    tmp=9
    while i-tmp>=0:
        ans=min(ans,c[i-tmp]+1)
        tmp*=9
    c[i]=ans
print(c[N])

Measured memory_bytes: 75344
#include<stdio.h>

int main()
{
	char s[4];
	int n;

	scanf("%s",s);

	if(s[0] == 'S' && s[1] == 'U')
		n=7;

	if(s[0] == 'S' && s[1] == 'A')
		n=1;

	if(s[0] == 'F')
		n=2;

	if(s[0] =='T' && s[1]=='H')
		n=3;

	if(s[0] =='W')
		n=4;

	if(s[0] =='T' && s[1]=='U')
		n=5;

	if(s[0] =='M')
		n=6;

	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    for(int i = n-1; i >=0; i--) {
        cout << a[i];
        if(i != 0) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

struct cnt {
	int x_, y_, z_;
};

vector<vector<P>> graph(100010, vector<P>());
vector<int> col(100010);
vector<bool> vis(100010);
vector<bool> ch(100010, true);
int ans = 0;

void dfs(int n, int p, int c) {
	bool ret = true;
	col[n] = c;
	vis[n] = true;
	for (P i_ : graph[n]) {
		int i = i_.first;
		int i2 = i_.second;
		if (i == p) continue;
		if (!vis[i]) {
			dfs(i, n, (c + i2) % 3);
		}
		else {
			if (col[i] != (c + i2) % 3) ch[i] = false;
		}
	}
}

vector<int> parent(100010);
vector<cnt> si(100010);

void init(int n) {
	for (int i = 0; i < n; i++) {
		parent[i] = i;
		if (col[i] == 0) si[i] = { 1,0,0 };
		if (col[i] == 1) si[i] = { 0,1,0 };
		if (col[i] == 2) si[i] = { 0,0,1 };
	}
}

int find(int x) {
	if (parent[x] == x) return x;
	else return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (si[x].x_ + si[x].y_ + si[x].z_ < si[y].x_ + si[y].y_ + si[y].z_) {
		parent[x] = y;
		si[y].x_ += si[x].x_;
		si[y].y_ += si[x].y_;
		si[y].z_ += si[x].z_;
	}
	else {
		parent[y] = x;
		si[x].x_ += si[y].x_;
		si[x].y_ += si[y].y_;
		si[x].z_ += si[y].z_;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]].pb(P(b[i], 1));
		graph[b[i]].pb(P(a[i], 2));
	}
	rep(i, n) {
		if (!vis[i]) {
			dfs(i, -1, 0);
		}
	}
	init(n);
	rep(i, m) {
		unite(a[i], b[i]);
	}
	rep(i, n) {
		if (!ch[i]) ch[find(i)] = false;
	}
	vector<bool> used(n);
	vector<int> edge(n);
	rep(i, m) {
		edge[find(a[i])]++;
	}
	rep(i, n) {
		int p = find(i);
		if (!used[p]) {
			if (ch[p]) {
				if (si[p].x_&&si[p].y_&&si[p].z_) {
					ans += si[p].x_ * si[p].y_ + si[p].y_ * si[p].z_ + si[p].z_ * si[p].x_;
				}
				else {
					ans += edge[p];
				}
			}
			else {
				ans += (si[p].x_ + si[p].y_ + si[p].z_) * (si[p].x_ + si[p].y_ + si[p].z_);
			}
			used[p] = true;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19840
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let mut v:Vec<i64> = (0..n).map(|_| read()).collect();
    v.sort();
    let mut cnt = 0;
    for i in 0..n {
        let mut k = i;
        for j in i+1..n {
            while k < n && v[k] < v[i] + v[j] {
                k += 1;
            }
            cnt += k as i64 - (j as i64 +1)
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 2104
N=int(input())
n=[]
S=set()
for i in range(N):
  A=input()
  n.append(A)
  S.add(A)
M=int(input())
m=[]
for i in range(M):
  A=input()
  m.append(A)
  S.add(A)
P=[0]
for i in S:
  P.append(n.count(i)-m.count(i))
print(max(P))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=1e6+5;
int n,k,mn=2000000005,AA[N];
inline int Read(){
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	n=Read();k=Read();--k;
	for(int i=0;i<n;++i)AA[i]=Read();
	for(int i=0;i+k<n;++i)
		if(AA[i+k]-AA[i]+min(abs(AA[i]),abs(AA[i+k]))<mn)mn=AA[i+k]-AA[i]+min(abs(AA[i]),abs(AA[i+k]));
	printf("%d",mn);
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.next());
        }
        boolean flag = false;
        Set<String> checkHash = new HashSet<String>();
        for(String str : list) {
            if(checkHash.contains(str)) {
                flag = true;
                break;
            } else {
                checkHash.add(str);
            }
        }

        if (flag) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }

    }
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll a, b;

	cin >> a >> b;

	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if (a < 0) {
		ll count = abs(a - b) + 1;
		if (count % 2 == 0) {
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
	else {
		cout << "Positive" << endl;
	}
}

Measured memory_bytes: 256
while True:
         n,x = map(int,input().split())
         if n == x == 0:
                  exit()
         ans = 0
         for i in range(1,n-1):
                  for j in range(i+1,n):
                           if j < (x-i-j) <= n:
                                    ans += 1
         print(ans)



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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int op(int x, int y) { return max(x, y); }

int e() { return -1; }

int val;
bool f(int x) { return x < val; }

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    segtree<int, op, e> st(a);
    rep(_, q) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x, v;
            scanf("%d%d", &x, &v);
            st.set(x - 1, v);
        } else if (t == 2) {
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%d\n", st.prod(l - 1, r));
        } else {
            int x;
            scanf("%d%d", &x, &val);
            printf("%d\n", st.max_right<f>(x - 1) + 1);
        }
    }
}

Measured memory_bytes: 6208
#include<stdio.h>
int main()
{
    int n,r,d;
    scanf("%d %d",&n,&r);
    if(n>=10)
    {
        printf("%d\n",r);
    }
    else
    {
    d=r+(100*(10-n));
    printf("%d\n",d);
    }
    return 0;
}

Measured memory_bytes: 128
fun main() {
    readLine()
    var result = 1L
    val limit = 1e18.toLong()
    val items = readLine()!!.split(' ').map { it.toLong() }
    if (items.contains(0)) {
        println(0)
        return
    }
    items.forEach {
        result *= it
        if (result > limit || result <= 0) {
            result = -1
            return@forEach
        }
    }
    println(result)
}

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

int main() {
    int H, W, d;
    cin >> H >> W >> d;

    char color[2][2] = {{'R', 'G'}, {'B', 'Y'}};
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << color[(i + j) / d % 2][(i - j + 1000 * d) / d % 2];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

int sum[505][505];

signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0; i<m; i++){
    int l,r;
    cin>>l>>r;
    sum[l][r]++;
  }
  
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      sum[i][j]+=sum[i][j-1];
    }
  }
  
  for(int i=0; i<q; i++){
    int l,r;
    cin>>l>>r;
    int ret=0;
    for(int j=l; j<=r; j++) ret+=sum[j][r]-sum[j][j-1];
    cout<<ret<<en;
  }
}




Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve()
{
  string s;
  cin >> s;
  ll d=0;
  for(int i=0;i<s.size();i++)
  {
      d+=s[i]-'0';
  }
  d%9==0?cout <<"Yes" : cout << "No" ;
}
int main()
{
  fast();
  solve();

return 0;
}


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

int n;
int a[101];

int main(void){
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int id=0;
    for(int i=0;i<n;i++){
        if(abs(sum-a[i]*n)<abs(sum-a[id]*n)){
            id=i;
        }
    }
    printf("%d\n",id);
    return 0;
}

Measured memory_bytes: 768
from itertools import combinations_with_replacement

N, M, Q = list(map(int, input().split()))
Q_ = [list(map(int, input().split())) for i in range(Q)]
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    ans = max(ans, sum([q[3] for q in Q_ if A[q[1] - 1] - A[q[0] - 1] == q[2]]))

print(ans)

Measured memory_bytes: 9196
#include <stdio.h>

#define N 100     
#define SUCCESS 1 // 成功
#define FAILURE 0 // 失敗
#define INFTY 1 << 21 // 到達不可能を表す大きな値

int queue[N]; // キューの本体
int queue_head = 0; // データ先頭
int queue_num; // データ個数

int node_num, M[N + 1][N + 1];
int d[N]; // 距離で訪問状態(color)を管理する

int enqueue(int enq_data) // キューにデータを追加する
{
  if (queue_head + queue_num < N) {
    queue[queue_head + queue_num] = enq_data;
    queue_num++;
    return SUCCESS;
  } else {
    return FAILURE;
  }
}

int dequeue(int *deq_data) // キューからデータを取り出す
{
  if (queue_num > 0) {
    *deq_data = queue[queue_head];
    queue_num--;
    queue_head++;
    return SUCCESS;
  } else {
    return FAILURE;
  }
}

void bfs(int s) {
  enqueue(s); // 始点をキューに入れる
  for (int i = 1; i <= node_num; i++) d[i] = INFTY; // とりあえず全部INFTYにする
  d[s] = 0; // 始点から自分自身までの距離は0
  int u, p;
  while(queue_num > 0) { // キューが空でない間繰り返す
    u = queue[queue_head]; // キューの先頭からノードを取り出し，訪問
    dequeue(&p); // 同上
    for (int v = 1; v <= node_num; v++) {
        if (M[u][v] == 0) continue; // キュー先頭のノードとvが繋がってないならこのループは終了
        if (d[v] != INFTY) continue; // 既に距離を決めているならこのループは終了
        d[v] = d[u] + 1; // 次に訪問するノードまでの距離は，それまでの距離+1
        enqueue(v); // uに繋がっているノードは将来訪問しないといけない
    }
  }
  for (int i = 1; i <= node_num; i++) { // 表示部
    if (d[i] == INFTY) d[i] = -1;
    printf("%d %d\n", i, d[i]);
  }
}

// mainの流れはdfsと同じ(隣接行列の初期化→隣接行列にノード間の接続関係を登録→bfsを呼び出す)
int main(void)
{
  int u, v, k, i, j;
  
  scanf("%d", &node_num);
  for (i = 0; i <= node_num; i++) {
    for(j = 0; j <= node_num; j++) M[i][j] = 0;
  }

  for (i = 0; i < node_num; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      M[u][v] = 1;
    }
  }

  bfs(1);
  
  return 0;
}


Measured memory_bytes: 2104
n = int(input())
p = list(map(int, input().split()))

a = 0

for i in range(n - 2):
  p_l = [p[i], p[i + 1], p[i + 2]]
  p_l2 = sorted(p_l)
  if p_l2[1] == p_l[1]:
    a += 1
    
print(int(a))

Measured memory_bytes: 3060
N,M=map(int, input().split())
AB=[list(map(int,input().split())) for _ in range(N)]
CD=[list(map(int,input().split())) for _ in range(M)]
for ab in AB:
    m=float('inf')
    for i,cd in enumerate(CD):
        if m>abs(ab[0]-cd[0])+abs(ab[1]-cd[1]):
            m=abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
            tmp=i+1
    print(tmp)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int l, r;
    cin >> l >> r;
    int n = 2019, ans = 1e9;
    rep(i, l, min(l + n, r)) {
        rep(j, i + 1, min(i + 1 + n, r)) {
            int cur = i * j % n;
            ans = min(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int a[20],b[2][20],c[20];
int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,n)scanf("%d",&a[i]);
	int cnt=0;
	rep(i,m){
		int d;scanf("%d",&d);
		rep(j,d){
			b[0][cnt]=i%2;
			b[1][cnt++]=!(i%2);
		}
	}
	int Min=INT_MAX;
	rep(i,2){
		rep(j,n)c[j]=a[j];
		int cnt=0;
		rep(j,n){
			if(c[j]!=b[i][j]){
				int k;
				for(k=j+1;k<n;k++){
					if(c[k]==b[i][j])break;
				}
				if(k==n){
					goto g;
				}
				for(int t=k;t>j;t--){
					cnt++;swap(c[t],c[t-1]);
				}
			}
		}
		Min=min(Min,cnt);
		g:;
	}
	printf("%d\n",Min);
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  vll h(n);
  rep(i,n) cin>>h[i];
  ll l=0;
  ll r=1e9;
  ll mid=(l+r)/2;
  while(l<r){
    ll cu=0;
    rep(i,n){
      if(h[i]-b*mid>0){
        cu+=(h[i]-b*mid+a-1-b)/(a-b);
      }
    }
    if(cu<=mid){
      r=mid;
    }
    else l=mid+1;
    mid=(l+r)/2;
  }
  COUT(l);
}


Measured memory_bytes: 1152
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = infiniteCoins

infiniteCoins :: IO ()
infiniteCoins = do
  n :: Int <- readLn
  a :: Int <- readLn
  if a < n `mod` 500
    then
    putStrLn "No"
    else
    putStrLn "Yes"

Measured memory_bytes: 508
# 2019-11-16 10:55:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *h = [int(x) for x in sys.stdin.read().split()]

    
    ans = 'Yes'
    maximum = h[0]
    for i in range(1, n):
        if maximum - h[i] >= 2:
            ans = 'No'
            break
        maximum = max(maximum, h[i])

    print(ans)
    



if __name__ == "__main__":
    main()


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll x;
	cin>>x;
	ll cnt=0;
	ll m = 100;
	while(m < x){
		cnt++;
		m += m/100;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		char tmp;
		cin >> tmp;
		if (tmp == 'Y')
		{
			cout << "Four" << endl;
			return;
		}
	}
	cout << "Three" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;

int main() {
	int k;
	cin >> k;
	int a, b;
	bool c=false;
	cin >> a >> b;
	for (int i = a;i <=  b;i++) {
		if (i % k == 0) {
			c = true;
			break;
		}

	}
	if (c)cout << "OK" << endl;
	else cout << "NG" << endl;
}

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

int main() {
    int numItems;
    cin >> numItems;
    int maxWeight;
    cin >> maxWeight;

    int items[numItems][2];
    for(int i = 0; i < numItems; i++) {
        cin >> items[i][0]; //weight
        cin >> items[i][1]; //value
    }

    vector<unsigned long int> maxValue(maxWeight+1, 0);
    
    for(int weight = items[0][0]; weight <= maxWeight; weight++) {
        maxValue[weight] = items[0][1];
    }

    for(int item = 1; item < numItems; item++) {
        for(int weight = maxWeight; weight >= 0; weight--) {
            if(items[item][0] > weight) {
                maxValue[weight] = maxValue[weight];
            } else {
                maxValue[weight] = max(maxValue[weight],  
                                       maxValue[weight - items[item][0]] + items[item][1]);
            }
        }
    }
    
    cout << maxValue[maxWeight];

    return 0;
}

Measured memory_bytes: 3640