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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vector(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------

template <class T>
int selection_sort(vector<T> &vec) {
    auto len = vec.size();
    int cnt  = 0;
    rep(i, 0, len) {
        auto minj = i;
        rep(j, i, len) {
            if (vec[j] < vec[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(vec[i], vec[minj]);
            cnt++;
        }
    }
    return cnt;
}

template <class T>
int bubble_sort(vector<T> &vec) {
    auto len = vec.size();
    int cnt  = 0;    // スワップ回数
    bool flg = true; // 逆の隣接要素が存在する
    while (flg) {
        flg = false;
        for (int i = len - 1; i >= 1; i--) {
            if (vec[i] < vec[i - 1]) {
                swap(vec[i], vec[i - 1]);
                flg = true;
                cnt++;
            }
        }
    }
    return cnt;
}

struct Card {
    string value;
    int idx;

    bool operator<(const Card &rhs) const {
        return value[1] < rhs.value[1];
    }
    bool operator==(const Card &rhs) const {
        return value == rhs.value;
    }
    bool operator!=(const Card &rhs) const {
        return value != rhs.value;
    }
    friend ostream &operator<<(ostream &os, const Card &x) {
        return os << x.value;
    }
};

//---------------------------------------------------------------------------------------------------

bool is_stable(const vector<Card> &sorted) {
    const auto len = sorted.size();
    bool ok        = true;
    rep(i, 0, len - 1) {
        if (sorted[i].value[1] == sorted[i + 1].value[1] && sorted[i].idx > sorted[i + 1].idx) {
            ok = false;
        }
    }
    return ok;
}

signed main() {
    int N;
    cin >> N;
    vector<Card> ls(N);
    rep(i, 0, N) {
        string s;
        cin >> s;
        ls[i].value = s;
        ls[i].idx   = i;
    }

    vector<Card> x(N);
    copy(all(ls), x.begin());
    bubble_sort(x);
    dump_vector(x);
    cout << (is_stable(x) ? "Stable" : "Not stable") << "\n";

    copy(all(ls), x.begin());
    selection_sort(x);
    dump_vector(x);
    cout << (is_stable(x) ? "Stable" : "Not stable") << "\n";
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
long long m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()
//nCk(comuseを使え)
long long combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//pCk(comuseを使え)
long long perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a,long long b){
  long long n;
  n=a/__gcd(a,b)*b;
  return n;
}

//auto A = div(n)
vector<long long> div(long long n){
  vector<long long> ret;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a,long long n,long long mod){
  long long ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

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

///////////////////////////////////////////////////////////



void Solve(){
  int N;
  string S,T;
  cin >> N >> S >> T;
  string ans;
  for(int i = 0; i < N; i++){
    ans += S[i];
    ans += T[i];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(ll &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const ll maxn = 300010;
#define lowbit(x) (x&-x)
ll c[maxn];
inline void modify(ll x){
    for(;x <= maxn-10;x += lowbit(x)) c[x] ++;
}
inline ll query(ll x){
    ll ret = 0;
    for(;x;x-=lowbit(x)) ret += c[x];
    return ret;
}
ll a[maxn],b[maxn];
int main(){
    ll n,k;read(n);read(k);
    ll ans = 0;
    rep(i,1,n){
	read(a[i]);a[i] -= k;
	a[i] += a[i-1];
	if(a[i] >= 0) ++ ans;
	b[i] = a[i];
    }
    sort(b+1,b+n+1);
    rep(i,1,n){
	a[i] = lower_bound(b+1,b+n+1,a[i]) - b;
    }
    rep(i,1,n){
	ans += query(a[i]);
	modify(a[i]);
    }printf("%lld\n",ans);
    return 0;
}


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

int M,K;
int main(){
    cin >> M >> K;
    if(K==0){
        for(int i=0;i<(1<<M);i++){
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    if((M==1 && K==1) || (1<<M)<=K){
        cout << -1 << endl;
        return 0;
    }
    deque<int> ans;
    ans.push_front(K);
    for(int i=0;i<(1<<M);i++){
        if(i==K) continue;
        ans.push_front(i);
        ans.push_back(i);
    }
    ans.push_back(K);
    for(auto x:ans) cout << x << " ";
    cout << endl;
}

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

typedef long long ll;

ll comb2(ll n) {
    if (n < 2) return 0;
    else if ((n & 1) == 0) return n / 2 * (n - 1);
    else return (n - 1) / 2 * n;
}

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

    int N, M; cin >> N >> M;
    map<int, ll> sum_modM_idx;
    
    int sum_modM = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        sum_modM += a;
        sum_modM %= M;
        if (sum_modM_idx.count(sum_modM) <= 0) sum_modM_idx[sum_modM] = 0;
        ++sum_modM_idx[sum_modM];
    }

    ll ans = sum_modM_idx.count(0) > 0 ? sum_modM_idx[0] : 0;
    for (auto it : sum_modM_idx) {
        ans += comb2(it.second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 998244353;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int s;
int a[3010];

ll dp[3010][3010];

ll solve() {
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 3000; j++) {
            dp[i][j] = 2*dp[i-1][j];
            if (j - a[i-1] >= 0) dp[i][j] += dp[i-1][j-a[i-1]];
            dp[i][j] %= mod;
        }
    }
    return dp[n][s];
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 73736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF = 1001001001;

int main(){
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> x(n);
  for(int i=0; i<n; ++i) cin >> x[i].first >> x[i].second;
  sort(x.begin(),x.end());
  queue<P> que;
  ll ans = 0;
  ll tdam = 0;
  for(int i=0; i<n; ++i){
    int xf = x[i].first, xs = x[i].second;
    
    while(!que.empty()){
      if(que.front().first < xf){
        tdam -= que.front().second;
        que.pop();
      }else break;
    }
    if((ll)xs <= tdam) continue;
    else xs -= (int)tdam;
    
    int sdam = ((xs -1) /a +1) *a;
    ans += (xs -1) /a +1;
    tdam += sdam;
    if((ll)xf + 2*d < INF) que.push(make_pair(xf + 2*d, sdam));
  }
  cout << ans << endl;
}

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

using namespace std;

int n,i,a,b,c[100005];

int main(){
	scanf("%d%d%d", &n, &a, &b);
	
	for(i = 0; i < n; i++)
	scanf("%d", &c[i]);
	
	long long res = 0;
	
	for(i = 1; i < n; i++){
		long long cost = (long long)(c[i] - c[i - 1]) * a;
		res += min(cost, (long long)b);
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 640
a,b,c,d = gets.chomp.split(" ").map(&:to_i);

ac=a*c
ad=a*d
bc=b*c
bd=b*d

ans=0
if ac >= ad && ac >= bc && ac >= bd then
	ans = ac
elsif ad >= bd && ad >= bd then
	ans =ad
elsif bc >= bd  then
	ans = bc
else
	ans = bd
end

puts ans


Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	IOS;
	
	string s; cin >> s;
	string t; cin >> t;

	int d = t.size();
	for(int i = 0 ; i < s.size() ; i++)
	{
		int c = 0;
		bool flag = false;
		for(int j = 0 ; j < t.size() ; j++)
		{
			if(i+j >= s.size()) {
				flag = true;
				break;
			}
			if(s[i+j] != t[j]) ++c;
		}
		if(!flag) d = min(c, d);
	}

	cout << d << '\n';
	return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int p,z,m;
ll a[100000];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,0,n-1,1)
	{
		ll x;
		scanf("%lld",&x);
		if(x==0)z++;
		else if(x>0)p++;
		else
		{
			m++;
			x*=-1;
		}
		a[i]=x;
	}
	sort(a,a+n);
	ll sum=accumulate(a,a+n,0LL);
	if(z || m%2==0)return !printf("%lld",sum);
	printf("%lld",sum-2*a[0]);
}

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

using namespace std;

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

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

    string s;cin>>s;
    ll k;cin>>k;
    int cnt=0;
    for(int i=0;i<(int)s.length();i++){
        if(s[i]=='1') cnt++;
        else break;
    }
    if(cnt>=k) cout<<1<<endl;
    else cout<<s[cnt]<<endl;
}


Measured memory_bytes: 256
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7
# 0以上の数
X = []
# 負の数
Y = []
for a in A:
    if a >= 0:
        X.append(a)
    else:
        Y.append(a)
X.sort(reverse=True)
X = deque(X)
Y.sort()
Y = deque(Y)
# print(X)
# print(Y)

nums = []
# 全部選ぶしかない場合
if K == N:
    nums = A
# どうやっても負にしかならない場合
# 絶対値が小さくなるように取っていく
elif len(Y) == N and K % 2 == 1:
    for _ in range(K):
        nums.append(Y.pop())
# 上位以外の場合、結果を0以上にすることが出来る
# 絶対値が大きくなるように and 負にならないように 取っていく
else:
    while len(nums) < K:
        if len(X) >= 2 and len(Y) >= 2:
            if X[0] * X[1] >= Y[0] * Y[1] or len(nums) == K - 1:
                nums.append(X.popleft())
            else:
                nums.append(Y.popleft())
                nums.append(Y.popleft())
        elif len(X) >= 2 and len(Y) <= 1:
            nums.append(X.popleft())
        elif len(X) == 1 and len(Y) >= 2:
            if X[0] >= Y[0] * Y[1] or len(nums) == K - 1:
                nums.append(X.popleft())
            else:
                nums.append(Y.popleft())
                nums.append(Y.popleft())
        elif len(X) == 1 and len(Y) <= 1:
            nums.append(X.popleft())
        elif len(X) == 0 and len(Y) >= 2:
            if len(nums) == K - 1:
                nums.append(Y.pop())
            else:
                nums.append(Y.popleft())
                nums.append(Y.popleft())
        elif len(X) == 0 and len(Y) <= 1:
            num.append(Y.pop())

ans = 1
for num in nums:
    ans *= num
    ans %= MOD
print(ans)


Measured memory_bytes: 108836
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        
        if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
            System.out.println("hon");
        }else if(N%10==0||N%10==1||N%10==6||N%10==8){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
        
    }
}


Measured memory_bytes: 35768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a)
	 cout<<a-k<<" "<<b;
	else if(k<=a+b)
	 cout<<"0 "<<b-(k-a);
	else
	 cout<<"0 0";
	return 0;

}

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

typedef long long LL;
typedef pair<int, int> PII;

#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define F first
#define S second

int n;
LL x;
LL a[2][2020];

int main() {
  scanf("%d%lld", &n, &x);
  LL ans = 0;
  REP(i, n) {
    scanf("%lld", &a[0][i]);
    ans += a[0][i];
  }
  int cur = 0;
  REP(i, n) {
    int nxt = cur ^ 1;
    LL sum = 0;
    REP(j, n) {
      int pre = j == 0 ? n - 1 : j - 1;
      a[nxt][j] = min(a[cur][j], a[cur][pre]);
      sum += a[nxt][j];
    }
    ans = min(ans, sum + (i + 1) * x);
    cur = nxt;
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define finc(i, a, b) for (int i = a, _b = (b); i <= _b; i++)
#define fdec(i, a, b) for (int i = a, _b = (b); i >= _b; i--)
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;

using namespace std;

inline void read(int &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void read(long long &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void writeln(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar('\n');}
inline void write(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar(' ');}

const int N = 100;

int n, m, l;

struct edge{
	int u, v, c;
	edge() {}
	edge(int u, int v, int c): u(u), v(v), c(c) {}
}e[N];

inline void AddEdge(int u, int v, int c){
	e[++m] = edge(u, v, c);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	// freopen("test.inp", "r", stdin);
	// freopen("test.out", "w", stdout);
	cin >> l; 
	n = log2(l) + 1;
	finc(i, 1, n - 1){
		AddEdge(i, i + 1, 0);
		AddEdge(i, i + 1, (1 << (i - 1)));
	}
	int rem = l - (1 << (n - 1));
	int top = l - 1;
	fdec(i, n, 1){
		if ((1 << (i - 1)) <= rem){
			AddEdge(i, n, top - (1 << (i - 1)) + 1);
			top -= (1 << (i - 1));
			rem -= (1 << (i - 1));
		}
	}
	cout << n << ' ' << m << endl;
	finc(i, 1, m)
		cout << e[i].u << ' ' << e[i].v << ' ' << e[i].c << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b;
  cin >> a >> b;
  vector<vi32> ans(100, vi32(100));
  rep(i, 50) rep(j, 100) {
    ans[i][j] = 1;
  }
  rep(i, a - 1) {
    int x = (i / 50) * 2;
    int y = (i % 50) * 2;
    ans[x][y] = 0;
  }
  rep(i, b - 1) {
    int x = (i / 50) * 2;
    int y = (i % 50) * 2;
    ans[99 - x][y] = 1;
  }
  cout << 100 << " " << 100 << endl;
  rep(i, 100) {
    rep(j, 100) {
      cout << (ans[i][j] ? '#' : '.');
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
if k >= n:
    print(h.count(1))
else:
    if k == 0:
        print(sum(h))
    else:
        h=sorted(h)
        ans = 0
        for i in range(len(h)-k):
            ans += h[i]
        print(ans)

Measured memory_bytes: 25768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b,x; cin >> a >> b >> x;
    if(a <= x && x <= a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;

    if(t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){
        cout << "infinity" << endl;
        return 0;
    }

    if(t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2){
        swap(a1, b1);
        swap(a2, b2);
    }
    if(t1 * a1 > t1 * b1){
        cout << 0 << endl;
        return 0;
    }

    ll gap1 = t1 * b1 - t1 * a1;
    ll gap2 = t1 * a1 + t2 * a2 - t1 * b1 - t2 * b2;

    ll x = 0;
    if(gap1 % gap2 == 0){
        x = gap1 / gap2 * 2 - 1;
    }
    else{
        x = gap1 / gap2 * 2;
    }
    cout << x + 1 << endl;


    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<string>
#include<climits>
using namespace std;
#define endl "\n"
#define M 1000000007
#define enter ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define mk(name,n,ty) ty* name=new ty[n]; 
typedef long long int ll;
const int MAX_N=100;
int main(){
    char a; cin>>a;
    if(a>=97&&a<=122){
    	cout<<"a"<<endl;
    }else{
    	cout<<"A"<<endl;
    }
	return 0;
  }

Measured memory_bytes: 3520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A= cin.ArrayLong(N,0);
        long[] newA0=new long[N];
        long[] newA1=new long[N];
        long ans=0;
        int i=0;
        long min=10000000000;
        int count=0;
        for(i=0;i<N;i++)
        {
           if(A[i]<0){A[i]=(-1)*A[i];count++;}
           ans+=A[i];
           if(A[i]<min)min=A[i];
           
        }
        
        if(count%2!=0)ans-=min*2;
        Console.WriteLine(ans);
        
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;
        
    }
}


Measured memory_bytes: 27228
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las


main = do
    h <- BC.getLine
    case h of
        "AAA" -> putStrLn "No"
        "BBB" -> putStrLn "No"
        _ -> putStrLn "Yes"




Measured memory_bytes: 380
def XOR_sum(n):
    m = n + 1
    if m % 4 == 0:
        return 0
    elif m % 4 == 1:
        return n
    elif m % 4 == 2:
        return 1
    else:
        return 1 ^ n
        

A, B = map(int, input().split())

a = XOR_sum(A - 1)
b = XOR_sum(B)

print(a ^ b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lli long long int
using namespace std;


int main()
{
	int n;
	
	cin >> n;
	
	int a[n+5], b[n+5];
	for(int i = 0; i < n; i++) {cin >> a[i]; b[i] = a[i];}
	
	sort(a, a+n);
	
	int mx = a[n-1], mn = a[n-2];
	
	for(int i = 0; i < n; i++){
		if(b[i] == mx) cout << mn << "\n";
		else cout << mx << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,N-2) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
      ans++;
      i+=2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
(H, W, K) = map(int, input().split())
DIVISOR = 1000000007

# the number of horizonal line pattens at moving from line i to line j
hlineptn = [[0 for j in range(W)] for i in range(W)]

# calculate the number of horizonal line patterns
for hlinedig in range(1 << (W-1)):
    # convert digit to bit
    bitlist = [0 for i in range(W-1)]
    for i in range(len(bitlist)):
        if hlinedig & 1 << ((W-2)-i):
            bitlist[i] = 1

    # check illegal horizonal line
    illegalflg = False
    for i in range(len(bitlist)-1):
        if bitlist[i] and bitlist[i+1]:
            illegalflg = True
            break
    if illegalflg:
        continue

    # loop for before line
    for i in range(W):
        # move to left
        if i-1 >= 0 and bitlist[i-1]:
            hlineptn[i][i-1] += 1
        # move to right
        elif i+1 < W and bitlist[i]:
            hlineptn[i][i+1] += 1
        # move to current
        else:
            hlineptn[i][i] += 1

# calculate the number of move patterns from line 0
# and divide it by DIVISOR to get division remainder
mvptn = [[0 for w in range(W)] for h in range(H+1)]
mvptn[0][0] = 1
for h in range(1, H+1):
    for w in range(W):
        # from above left line
        if w-1 >= 0:
            mvptn[h][w] += mvptn[h-1][w-1] * hlineptn[w-1][w]
        # from above current line
        mvptn[h][w] += mvptn[h-1][w] * hlineptn[w][w]
        # from above right line
        if w+1 < W:
            mvptn[h][w] += mvptn[h-1][w+1] * hlineptn[w+1][w]

        # format to division remainder
        if mvptn[h][w] > DIVISOR:
            mvptn[h][w] %= DIVISOR

ans = mvptn[H][K-1]
print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <set>
using namespace std;
const int MAX=1e9+1;

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

    set<long long> onPaper;

    long long A;
    for(int i=0; i<N; i++){
        cin >> A;
        auto c = onPaper.erase(A);
        if(c==0){
            onPaper.insert(A);
        }
    }
    
    cout << onPaper.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

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

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

typedef long long ll;

using namespace std;


class FF
{
public:
  struct edge{ll to,cap,rev;};
  vector<vector<edge>>G;
  vector<bool> used;
  FF(ll maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(ll from,ll to,ll cap,bool directed=1)
  {
    G[from].push_back({to,cap,(ll)G[to].size()});
    G[to].push_back({from,cap*(!directed),(ll)G[from].size()-1});
  }
  ll dfs(ll v,ll t,ll f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        ll d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  ll solve(ll s,ll t)
  {
    ll res=0;
    while(1)
    {
      for(ll i=0;i<used.size();i++)used[i]=0;
      ll f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};
int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  vector<ll>a(n+1);
  rep(i,n)cin>>a[i+1];
  ll gain=1e9;
  FF ff(n+2);
  ll s=0;ll t=n+1;
  repi(i,1,n+1)
  {
    ll ti=i*2;
    while(ti<n+1)
    {
      ff.add_edge(ti,i,gain*n);
      ti+=i;
    }
  }
  repi(i,1,n+1)
  {
    ff.add_edge(s,i,gain);
    ff.add_edge(i,t,gain-a[i]);
  }
  cout<<n*gain-ff.solve(s,t)<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
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*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  bool ja=false;
  rrep(i,9){
    rrep(j,9){
      if(i*j==n)ja=true;
    }
  }
  if(ja) yn;
}

Measured memory_bytes: 3588
n=int(input())
x,y=0,0
t=0
for i in range(n):
    T,X,Y=map(int,input().split())
    if((T-t)>=(abs(X-x)+abs(Y-y)) and (T-t)%2==(abs(x-X)+abs(Y-y))%2):
        x=X
        y=Y
        t=T
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 69764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

    if(n==10)
    {
        string a = to_string(n);
        cout<<a.size();
    }

    else
    {
       vector<int>b;
       while(n!=0)
       {
           n=n/k;
           b.push_back(n%k);
       }

       cout<<b.size()<<endl;
    }

    exit(0);
}


Measured memory_bytes: 3580
# D - Sum of Divisors

n = int(input())

# n以下の1の倍数 ... n個, それぞれk倍して加算 ... n * (n+1) // 2
# n以下のmの倍数 ... n//m個, それぞれk倍して加算 ... m * (n // m) * (n // m + 1) // 2

s = sum(m * (n // m) * (n // m + 1) // 2 for m in range(1, n + 1))
print(s)


Measured memory_bytes: 67492
#include<stdio.h>
#include<math.h>
#define PI 3.14159265

int main(void)
{
	double a, b, c, d, e, men, syu, taka;
	
	scanf("%lf %lf %lf", &a, &b, &c);
	
	d = c * PI / 180;
	
	e = (a*a) + (b*b) - (2*a*b*cos(d));
	
	men = 0.5 * a * b * sin(d);
	syu = a + b + sqrt(e);
	taka = b * sin(d);
	
	printf("%.9f\n%.9f\n%.9f\n", men, syu, taka);
}


Measured memory_bytes: 2052
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b ;
    ll c=b-a;
    cout << b+c <<endl;

}


Measured memory_bytes: 256
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if (s == "AC"):
        ac += 1
    elif (s == "WA"):
        wa += 1
    elif (s == "TLE"):
        tle += 1
    elif (s == "RE"):
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x "+str(re))


Measured memory_bytes: 9108
n = int(input())
l = list(map(int, input().split()))
Alice, Bob = 0, 0
for turn in range(0, n-1):
    if len(l) != 0:
        Alice += max(l)
        l.remove(max(l))
    if len(l) != 0:
        Bob += max(l)
        l.remove(max(l))
print(Alice-Bob)

Measured memory_bytes: 3060
#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 ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#define fastio
#else
#define openfile
#define deb(x...)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
void init()
{
    
}
void solve()
{
    ll l,r,d,i,j,ans = 0;
    cin>>l>>r>>d;
    fo(l,i,r+1)
    {   
        ans+=(i%d==0);
    }
    cout<<ans<<endl;
}
int main()
{
    init();
    // openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t l,r;
  cin>>l>>r;
    int64_t ans=10000000000;

  if(r-l>=2019){
    cout<<0<<endl;
  }

  else{
    for(int64_t i=l;i<r;i++){
      for(int64_t j=l+1;j<=r;j++){
        ans=min(ans,(i*j)%2019);
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  string s;cin>>s;
  int l=s.size();
  int ans=0;
  if(l%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  else{
    for(int i=0;i<l/2;i++){
      if(s[2*i]=='h'&&s[2*i+1]=='i'){
      }
      else{
        ans=1;
      }
    }
  }
  if(ans==0){
    cout<<"Yes"<<endl;
  }
  else{
    
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
int main(){

    int N,M;
    int h[1000],m[1000];
    int t = 0;
    cin>>N;
    for(int i = 0;i < N;i++)cin>>h[t]>>m[t],t++;
    cin>>M;
    for(int i = 0;i < M;i++)cin>>h[t]>>m[t],t++;

    for(int i = 0;i < N+M;i++){
        for(int j = 0;j < N+M;j++){
            if(h[i]*60+m[i] < h[j]*60+m[j]){
                swap(h[i],h[j]);
                swap(m[i],m[j]);
            }
        }
    }

    printf("%d:%02d",h[0],m[0]);
    for(int i = 1;i < N+M;i++){
        if(h[i] == h[i-1] && m[i] == m[i-1])continue;
        printf(" %d:%02d",h[i],m[i]);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<bool> vec(55555);
    vec[1] = false;
    for (int i = 2; i <= 55554; i++){
        vec[i] = true;
    }
    for(int i = 2; i <= 55554; i++){
        if (vec[i]){
            for (int j = 2; j * i <= 55554; j++){
                vec[i * j] = false;
            }
        }
    }
    vector<int> ans(0);
    for (int i = 1; i <= 55551; i += 5){
        if (vec[i]) ans.push_back(i);
    }
    rep(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;
struct rests{
  string city;
  int point;
  int index;
};
bool my_compare(rests a, rests b) {
    if(a.city != b.city){
      return a.city < b.city;
    }

    if(a.point != b.point){
        return a.point > b.point;
    }else{
        return true;
    }
}
int N;

int main(){
  cin >> N;
  vector<rests> S;
  string s;
  int p;
  rep(i,N){
    cin >> s >> p;
    rests r = {s, p, i+1};
    S.push_back(r);
  }
  sort(S.begin(),S.end(), my_compare);
  rep(i, S.size()){
    cout << S[i].index << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

_d = {}
for i, t in enumerate(T):
  if S[i] == _d.setdefault(t, S[i]):
    continue
  else:
    print('No')
    break
else:
  if len(set([k for k,v in _d.items()]))==len(set([v for k,v in _d.items()])):
  	print('Yes')
  else:
    print('No')



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

using namespace std;
typedef pair<int,int> ii;
struct data
{
    int dist,u,company;
};
map<int,int> d[N];
vector<vector<ii>> AdjList(N);

void dijistra()
{
    d[1][0] = 0;
    deque<data> q;
    q.push_back(data{0,1,0});

    while(!q.empty())
    {
        data f = q.front();
        q.pop_front();

        int dist = f.dist,u = f.u,c = f.company;
        if(dist!=d[u][c])
            continue;

        if(!d[u].count(0)||d[u].count(0)&&d[u][0]>dist)
        {
            d[u][0] = dist;
            q.push_front(data{dist,u,0});
        }

        if(c)
        {
            int pos = lower_bound(AdjList[u].begin(),AdjList[u].end(),ii(c,0)) - AdjList[u].begin() ;
            while(pos<AdjList[u].size()&&AdjList[u][pos].first==c)
            {
                int v = AdjList[u][pos].second;
                if(!d[v].count(c)||d[v].count(c)&&d[v][c]>dist)
                {
                    d[v][c] = dist;
                    q.push_front(data{dist,v,c});
                }
                pos++;
            }
        }
        else
        {
            for(auto i:AdjList[u])
            {
                int v = i.second,company = i.first;
                if(!d[v].count(company)||d[v].count(company)&&d[v][company]>dist+1)
                {
                    d[v][company] = dist+1;
                    q.push_back(data{dist+1,v,company});
                }
            }
        }
    }
}

signed main()
{
    int n,m;
    cin>>n>>m;

    while(m--)
    {
        int u,v,c;
        cin>>u>>v>>c;
        AdjList[u].push_back(ii(c,v));
        AdjList[v].push_back(ii(c,u));
    }

    for(int i=1;i<=n;i++)
        sort(AdjList[i].begin(),AdjList[i].end());

    dijistra();

    if(!d[n].count(0))
        cout<<-1;
    else
        cout<<d[n][0];
}


Measured memory_bytes: 37376
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int M,N;
  cin>>M>>N;
  int ans = 0;
  REP(i,M){
    int solved = 0;
    REP(i,N){
      int t; cin>>t;
      solved += t;
    }
    ans = max(ans, solved);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  int n, d, cnt = 0;
  ll x, y;
  cin >> n >> d;
  rep(i, n) {
    cin >> x >> y;
    if (sqrt(x * x + y * y) <= d) cnt++;
  }
  cout << cnt << endl;
}


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

int main() {
	int N, M, Q; scanf("%d%d%d", &N, &M, &Q);
	list<int>v(N);
	iota(v.begin(), v.end(), 0);
	auto pos = v.begin();
	rep(i, M) {
		int a; scanf("%d", &a);
		if (a & 1) {
			rep(j, a) {
				if (pos == v.begin())pos = --v.end();
				else pos--;
			}
			if (pos == --v.end()) {
				v.pop_back();
				pos = v.begin();
			}
			else pos = v.erase(pos);
		}
		else {
			rep(j, a) {
				if (pos == --v.end())pos = v.begin();
				else pos++;
			}
			if (pos == --v.end()) {
				v.pop_back();
				pos = v.begin();
			}
			else pos = v.erase(pos);
		}
	}
	rep(i, Q) {
		int q; scanf("%d", &q);
		printf("%d\n", binary_search(v.begin(), v.end(), q));
	}
}

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

int64_t gcd(int a,int b){
  while(b!=0){
    int tmp=b;
    b=a%b;
    a=tmp;
  }
  return a;
}

int main(){
  int A,B;
  cin >> A >> B;
  int64_t x=gcd(A,B);
  cout << A/x*B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;
    scanf("%d",&n);
    int ans = 1;
	for(int i = 1 ; i <= 3000 ; i++){
		if(ans * 2 > n) break;
		ans *= 2;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256