akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
int block[31];
void recur(int t, int b)
{
	if (b == 0)
	{
		int i;
		for (i = 0; block[i + 1]; ++i)
			printf("%d ", block[i]);
		printf("%d\n", block[i]);
		return;
	}

	for (int i = std::min(b, t ? block[t - 1] : 99); i > 0; --i)
	{
		block[t] = i;
		recur(t + 1, b - i);
		block[t] = 0;
	}
}
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		recur(0, n);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
long long a[200010],sum[200010],xr[200010];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],sum[i]=sum[i-1]+a[i],xr[i]=xr[i-1]^a[i];
    int r1=1;
    for(int i=1;i<=n;i++){
        ans+=r1-i+1;
        while(r1<n&&(sum[r1+1]-sum[i-1])==(xr[r1+1]^xr[i-1])) ans++,r1++;
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
listB=[]
for i in range(len(listA)):
    listB.extend(listA[i])
#print(listB)
listc=[]
listc=[listB.count(i) for i in range(1,5)]
#print(listc)
count1=listc.count(1)
#print(count1)
if min(listc) > 0 and sum(listc)>5 and count1 <3:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
n, d = gets.split.map(&:to_i)

a = Array.new(n).map{Array.new(d)}

for i in 0...n
    a[i] = gets.split.map(&:to_i)
end

ans = 0
for i in 0...n
    for j in i+1...n
        sum = 0
        for k in 0...d
            sum += (a[i][k] - a[j][k]) ** 2 
        end

        rt = Math.sqrt(sum).round.to_i
        if(rt ** 2 == sum)
            ans += 1
        end
    end
end

puts ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> p(N+1);
    int cnt=0;
    for (int i = 1; i<N+1; i++){
        cin >> p[i];
        if(p[i] == i){
            cnt+=1;
        }
    }
    if((cnt == N) || (cnt == N-2)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            if (iC > iB / iA) { iC = iB / iA; }

            // 出力
            System.Console.WriteLine("{0}", iC.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";
int X, Y;
int ans = 0;

string SetAns() {
	cin >> X >> Y;
	int v1 = 4 * X - Y;
	int v2 = Y - 2 * X;
	if (v1 < 0 || v2 < 0) return "No";
	if (v1 % 2 != 0 || v2 % 2 != 0) return "No";
	return "Yes";
}

int main() {
	
	cout << SetAns()<< endl;
	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int K;cin>>K;
    vector<int>A(K);
    REP(i,K)cin>>A[i];
    reverse(A.begin(),A.end());
    int MAX_N[K],MIN_N[K];//後半i回終了前の最大最小人数
  	REP(i,K)MAX_N[i]=MIN_N[i]=0;
    bool ok=true;
    REP(i,K){
        if(i==0){
            if(A[i]>2){
                ok=false;
                break;
            }
            MAX_N[0]=3;
            MIN_N[0]=2;
        }
        else{
            if(A[i]>MAX_N[i-1]){
                ok=false;
                break;
            }
            MAX_N[i-1]-=MAX_N[i-1]%A[i];
          	if(MIN_N[i-1]>MAX_N[i-1]){
              	ok=false;
              	break;
            }
            if(MIN_N[i-1]%A[i]!=0) MIN_N[i-1]+=A[i]-(MIN_N[i-1]%A[i]);
          	if(MIN_N[i-1]>MAX_N[i-1]){
              	ok=false;
              	break;
            }
            MAX_N[i]=MAX_N[i-1]+A[i]-1;
            MIN_N[i]=MIN_N[i-1];
        }
    }
    if(ok)cout<<MIN_N[K-1]<<" "<<MAX_N[K-1]<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 2560
N = int(input())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 20512
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

using Graph = vector<vector<int>>;
vector<bool> seen;
vector<int> point;
map<int, int> rp;

void dfs(const Graph &G, int v, int p) {
  seen.at(v) = true;
  point.at(v) = p;

  for (auto next_v : G[v]) {
    if (seen.at(next_v)) continue;
    dfs(G, next_v, p + rp[next_v]);
  }
}

void solve(ll N, ll Q, std::vector<ll> a, std::vector<ll> b, std::vector<ll> p,
           std::vector<ll> x) {
  seen.resize(N, false);
  point.resize(N, 0);

  Graph g(N);
  rep(i, N - 1) {
    g.at(a.at(i) - 1).push_back(b.at(i) - 1);  // 0-indexed
    g.at(b.at(i) - 1).push_back(a.at(i) - 1);  // 0-indexed
  }

  rep(i, Q) { rp[p.at(i) - 1] += x.at(i); }

  dfs(g, 0, rp[0]);
  rep(i, N - 1) { cout << point.at(i) << " "; }
  cout << point.at(N - 1) << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll Q;
  scanf("%lld", &Q);
  std::vector<ll> a(N - 1);
  std::vector<ll> b(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  std::vector<ll> p(Q);
  std::vector<ll> x(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &p[i]);
    scanf("%lld", &x[i]);
  }
  solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
  return 0;
}


Measured memory_bytes: 185984
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2500;
int a[N], b[N];
int dp[2][201][5201];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a = max(a, c);
    b = min(b, d);
    cout << max((int)0, b - a);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        bool debugFlg = false;
        if (debugFlg)
        {
            var exStdIn = new System.IO.StreamReader("stdin.txt");
            System.Console.SetIn(exStdIn);
        }
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int[] s = cin.ArrayInt(2);
        int K = s[0]; // Aまで入れられる
        int X = s[1]; // B入ってる
        
for (int i = X - K + 1; i < X + K; i++) {
if (i >= -1000000 && i <= 1000000) {
Console.WriteLine($"{i}");
}
}


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


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int dp[101][10004];

signed main(){
  int n,W;
  cin>>n>>W;
  vector<int> v(n),w(n);
  rep(i,n)cin>>v[i]>>w[i];

  loop(i,1,n+1){
    rep(j,W+1){
      if(j-w[i-1]>=0){
      dp[i][j]=max(dp[i][j-w[i-1]]+v[i-1],dp[i-1][j]);
      }else{
      dp[i][j]=dp[i-1][j];
      }
    }
  }

  cout<<dp[n][W]<<endl;

  return 0;
}

Measured memory_bytes: 10936
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    int count=0;
    rep(i,0,n){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') count++;
    }
    cout << count ENDL;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    string s;
    cin >> s;

    int sSize = s.size() - 1;
    if(sSize % 2){
        sSize = sSize - 1;
    }
    
    ll res = sSize/2;
    ll output = 0;
    for(int i = res; i >= 1; i--){
        string s0 = s.substr(0, i);
        string s1 = s.substr(i, i);
        // cout << s0 << " : " << s1 << endl;
        if(s0 == s1){
            output = i * 2;
            break;
        }
    }

    cout << output << endl;

}

Measured memory_bytes: 3560
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let (a,b,c):(usize,usize,usize);
    input!(a,b,c);
    if a+b>=c{
        println!("Yes");
    }else{
        println!("No");
    }
}

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

int main(void)
{

	int N,i;

	cin >> N;

	int H[N];
	int A[N]={};

	for(i=0;i<N;i++)
	{

		cin >> H[i];

	}
	
	A[N-1]=0;

	for(i=N-2;i>=0;i--)
	{

		if(H[i]>=H[i+1])
			A[i]=A[i+1]+1;

	}

	cout << *max_element(A,A+N) << endl;


}


Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ds(n);
    for(int i = 0; i < n; i++){
        cin >> ds[i];
    }
    vector<char> dp(1 << 24);
    dp[1] = true;
    for(int i = 0; i < n; i++){
        vector<char> next(1 << 24);
        int d = ds[i];
        if(!d){
            cout << 0 << '\n';
            return 0;
        }
        for(int bits = 0; bits < (1 << 24); bits++){
            if(!dp[bits]){ continue; }
            if((bits >> d & 1) == 0){
                next[bits | (1 << d)] = true;
            }
            if((bits >> (24 - d) & 1) == 0){
                next[bits | (1 << (24 - d))] = true;
            }
        }
        dp.swap(next);
    }
    int ans = 0;
    for(int bits = 0; bits < (1 << 24); bits++){
        if(!dp[bits]){ continue; }
        printb(bits);
        vector<int> v;
        for(int i = 0; i <= 24; i++){
            if(bits >> i & 1){
                v.push_back(i);
            }
        }
        prints(v);
        int cand = M;
        if(v.size() <= 1){ continue; }
        for(size_t i = 1; i < v.size(); i++){
            cand = min(cand, v[i] - v[(i - 1)]);
            printd(cand, i);
        }
        cand = min(cand, v[0] + 24 - v.back());
        ans = max(ans, cand);
    }
    cout << ans << '\n';
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

struct dice {
    int men1, men2, men3, men4, men5, men6;
    // コンストラクタ：構造体をオブジェクト化する時に引数をとった場合される処理
    dice(int men1_, int men2_, int men3_, int men4_, int men5_, int men6_){
        men1 = men1_; men2 = men2_; men3 = men3_;
        men4 = men4_; men5 = men5_; men6 = men6_;
    }

    void roll(char di){
        int ori_men1 = men1; int ori_men2 = men2;
        int ori_men3 = men3; int ori_men4 = men4;
        int ori_men5 = men5; int ori_men6 = men6;
        if(di == 'N'){
            men1 = ori_men2; men5 = ori_men1;
            men6 = ori_men5; men2 = ori_men6;
        }else if(di == 'E'){
            men1 = ori_men4; men3 = ori_men1;
            men6 = ori_men3; men4 = ori_men6;
        }else if(di == 'S'){
            men1 = ori_men5; men5 = ori_men6;
            men6 = ori_men2; men2 = ori_men1;
        }else if(di == 'W'){
            men1 = ori_men3; men3 = ori_men6;
            men6 = ori_men4; men4 = ori_men1;
        }
    }

    void display_1(){
        cout << men1 << endl;
    }
};

int main()
{
    int n1, n2, n3, n4, n5, n6;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    dice dice1(n1, n2, n3, n4, n5, n6);
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        char com = s[i];
        dice1.roll(com);
    }
    dice1.display_1();
}


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

#define fi first
#define se second

const int N = 2020;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int d[N * 2][N * 2];

void add(int &x, int y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        }
}

void sub(int &x, int y)
{
        x -= y;
        if(x < 0){
                x += mod;
        }
}

int pw(int x, int n)
{
        int res = 1;
        while(n > 0){
                if(n & 1){
                        res = 1ll * res * x % mod;
                }
                x = 1ll * x * x % mod;
                n /= 2;
        }
        return res;
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        vector < pair < int, int > > a(n);
        for(int i = 0; i < n; i++){
                cin >> a[i].fi >> a[i].se;
                d[N - a[i].fi][N - a[i].se] += 1;
        }
        vector < int > f(4 * N);
        f[0] = 1;
        for(int i = 1; i < 4 * N; i++){
                f[i] = 1ll * f[i - 1] * i % mod;
        }
        for(int i = 1; i < 2 * N; i++){
                for(int j = 1; j < 2 * N; j++){
                        add(d[i][j], d[i - 1][j]);
                        add(d[i][j], d[i][j - 1]);
                }
        }
        int res = 0;
        for(int i = 0; i < n; i++){
                int x = a[i].fi, y = a[i].se;
                add(res, d[x + N][y + N]);
                sub(res, 1ll * f[2 * (x + y)] * pw(f[x + x] * 1ll * f[y + y] % mod, mod - 2) % mod);
        }
        res = 1ll * res * pw(2, mod - 2) % mod;
        cout << res << "\n";
}


Measured memory_bytes: 65664
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;




int main()
{
	int  N,K,R,S,P;
	cin >> N >> K >> R>>S>>P;
	char t[100000];
	int sum = 0;
	int cntr = 0,cnts = 0,cntp = 0;
	char cnt[100000];

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

	}
	
	for (int i = 0; i < N; i++) {

		if (i < K) {

			if (t[i] == 'r') {

				sum = sum + P;
				cnt[i] = 'r';
			}
			if (t[i] == 's') {

				sum = sum + R;
				cnt[i] = 's';
			}
			if (t[i] == 'p') {

				sum = sum + S;
				cnt[i] = 'p';
			}

		}
		if (i >= K) {
			if (t[i] == 'r'  && cnt[i-K] != 'r') {

				sum = sum + P;
				cnt[i] = 'r';
			}
			if (t[i] == 's'  && cnt[i - K] != 's') {

				sum = sum + R;
				cnt[i] = 's';
			}
			if (t[i] == 'p'  && cnt[i - K] != 'p') {

				sum = sum + S;
				cnt[i] = 'p';
			}
			if (t[i] == 'r'  && cnt[i - K] == 'r') {

				cnt[i] = 'a';
			}
			if (t[i] == 's'  && cnt[i - K] == 's') {
				cnt[i] = 'a';
			}
			if (t[i] == 'p'  && cnt[i - K] == 'p') {

				
				cnt[i] = 'a';
			}
		}
	}

	cout << sum;
}




Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n)cin >> a[i];
    loop(i,k,n){
        if(a[i-k] < a[i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  ll ans;
  ll a = 1;
  ll b = 1;
  ll c = 1;
  ll acnt = 0;
  ll bcnt = 0;
  ll ccnt = 0;
  
  rep(i, n){
    ll A, B, C;
    A = a;
    B = b;
    C = c;
    a = a*10%1000000007;
    if(a != A*10) acnt++;
    b = b*9%1000000007;
    if(b != B*10) bcnt++;
    c = c*8%1000000007;
    if(c != C*10) ccnt++;
  }
  
  ans = a-2*b+c;
  if(ans < 0) ans += 1000000007;
  if(ans < 0) ans += 1000000007;
  
  
  cout << ans%1000000007 << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
string U[310], T[310];

void _main() {
    cin >> N;
    set<string> st;
    REP (i, N) {
        cin >> U[i];
        st.insert(U[i]);
    }
    cin >> M;
    bool open = false;
    REP (i, M) {
        cin >> T[i];
        if (st.count(T[i]) == 0) {
            cout << "Unknown " << T[i] << endl;
        } else if (open) {
            cout << "Closed by " << T[i] << endl;
            open = false;
        } else {
            cout << "Opened by " << T[i] << endl;
            open = true;
        }
    }
}

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


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

//cost_map[vertex] pll -> <to, cost>
bool bellman_ford(ll s, vector<vector<pll>>& cost_map, vector<ll>& result){
    ll N = cost_map.size();
    vector<ll> d(N, MAXINF);
    d[s] = 0;
    REP(k, N){
        REP(i, N){
            if(d[i]==MAXINF)continue;
            for(auto&& v : cost_map[i]){
                if(d[v.fi] > d[i] + v.se){
                    d[v.fi] = d[i] + v.se;
                    if(k==N-1)
                        return false;
                }
            }
        }
    }
    result = d;
    return true;
}

int main(void)
{
    int N,M,P;
    cin >> N >> M >> P;
    vector<vector<pll>> cost(N);
    vector<vector<int>> m(N);
    REP(i, M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        cost[a].pb(pll(b, -c+P));
        m[b].pb(a);
    }

    //ゴールに到達できない頂点を削除
    // Rep(i, 1, N-1){
    //     queue<int> q;
    //     q.push(i);
    //     vector<int> ok(N, 0);
    //     while(!q.empty()){
    //         auto f = q.front();q.pop();
    //         ok[f] = 1;
    //         for(auto&& i : cost[f]){
    //             if(ok[i.fi])continue;
    //             q.push(i.fi);
    //         }
    //     }
    //     if(!ok[N-1]){
    //         cost[i].clear();
    //         break;
    //     }
    // }
    queue<int> q;
    q.push(N-1);
    vector<int> ok(N, 0);
    while(!q.empty()){
        auto f = q.front();q.pop();
        ok[f] = 1;
        for(auto&& i : m[f]){
            if(ok[i]) continue;
            q.push(i);
        }
    }
    REP(i, N){
        if(!ok[i])
            cost[i].clear();
    }

    vector<ll> res;
    if(bellman_ford(0, cost, res)){
        if(res[N-1]>0) {
            pr(0);
        }else{
            pr(-res[N-1]);
        }
    }else{
        pr(-1);
    }
}

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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define OF(i,a,b) for (int (i) = (a)-1; (i) >= (b); --(i))
#define SZ(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

const ll MOD = 1000000007;

ll N, M, K;
ll dp[2005][2005];
ll ans;


int main() {
    scanf ("%lld %lld %lld", &N, &M, &K);
    FO (i,0,K) dp[K-i][i] = 1;
    FO (nz,0,N+1) {
        for (int n1 = (1-nz+N*(K-1))%(K-1); n1 <= M; n1 += K-1) {
            //fprintf (stderr, "%d %d\n", nz, n1);
            //assert((nz+n1)%(K-1) == 1%(K-1));
            FO (t,0,K) {
                int new1 = n1+t;
                int newz = nz+(K-t)-1;
                if (newz <= N && new1 <= M) {
                    dp[newz][new1] = (dp[newz][new1] + dp[nz][n1])%MOD;
                }
            }
        }
    }
    FO (nz,0,N+1) {
        FO (n1,0,M+1) {
            //printf ("dp[%d][%d]: %lld\n", nz, n1, dp[nz][n1]);
            if (n1 % (K-1) == M % (K-1) && n1 >= 1 && nz+(K-1) > N) {
                ans = (ans + dp[nz][n1])%MOD;
            }
        }
    }
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 31616
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  string s;
  cin >> s;

  cout << s.substr(0,4) << " " << s.substr(4) << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= 3000;i++){
        for (int j = 0; j <= 3000;j++){
            if((n-i*r-j*g)>=0&&(n-i*r-j*g)%b==0)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int x; cin>>x;
	int ans = -1;
	if(x >= 400 && x < 600) ans = 8;
	if(x >= 600 && x < 800) ans = 7;
	if(x >= 800 && x < 1000) ans = 6;
	if(x >= 1000 && x < 1200) ans = 5;
	if(x >= 1200 && x < 1400) ans = 4;
	if(x >= 1400 && x < 1600) ans = 3;
	if(x >= 1600 && x < 1800) ans = 2;
	if(x >= 1800 && x < 2000) ans = 1;
	
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    
    if (x <= 5){
      System.out.print(0);
    }else if (x <= 12){
      System.out.print(y/2);
    }else{
      System.out.print(y);
    }
  }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    stack<char>st;
    int ans = 0;
    st.push(s[0]);
    rep1(i, s.size()-1){
        if(st.empty()){st.push(s[i]);continue;}
        if(st.top()!=s[i]){st.pop();ans+=2;}
        else{st.push(s[i]);}
    }
    co(ans);
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<iostream>
#include<map>

using namespace std;

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

typedef long long ll;
class T{
public:
  int f;
  int s;
  int r;
  int l;
};

T tree[101];

ll sk(ll a,ll b){
  ll nx,nm;
  nx=a;
  nm=b;
  if(a<b){
    swap(a,b);
  }
  while(1){
    if(a%b==0)break;
    ll temp;
    temp=b;
    b=a%b;
    a=temp;
  }
  return nx/b*nm;
}
ll saiki(ll num){
  ll a=1,b=1;
  if(tree[num].f!=0){
    a=saiki(tree[num].f);
  }
  if(tree[num].s!=0){
    b=saiki(tree[num].s);
  }

  ll nn=sk(tree[num].r*a,tree[num].l*b);
  return nn/tree[num].r + nn/tree[num].l;
}
int main(){
  while(1){
  int n;
  scanf("%d",&n);
  if(n==0)break;
  int get[111];
  reps(i,n){
    get[i]=0;
  }
  reps(i,n){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    tree[i].r=a;
    tree[i].l=b;
    tree[i].f=c;
    tree[i].s=d;
    get[c]=get[d]=1;
  }
  int st=-1;
  reps(i,n){
    if(get[i]==0){
      st=i;
    }
  }
  ll ans=saiki(st);
  printf("%lld\n",ans);
  }
}

Measured memory_bytes: 0
n,m,x = map(int,input().split())

ar = [[0]*(m+1)]*n

for i in range(n):
    ar[i] = [int(s) for s in input().split()]


#print(ar)

smp = 111

def goukei(bitt):
    bitt = str(bitt)
    cnt = 0
    mn = 0
    skl = [0]*m
    for i in bitt:
        if(i == "1"):
            mn += ar[cnt][0]
            skl = [x + y for (x, y) in zip(skl, ar[cnt][1:])]
            #skl += ar[cnt][1:]
        cnt += 1
    
    #print(bitt,mn,skl)    
    flag = 1
    if any(ss < x for ss in skl):
        flag = 0
    
    
    return mn,flag


#print(goukei(smp))
            

mx = 2**n 


mnmn = []

for i in range(mx+1):
    bit_sentaku = str(bin(i))
    bit_sentaku = bit_sentaku[2:]
    bit_sentaku = bit_sentaku.zfill(n)
    #print(goukei(bit_sentaku))
    if(goukei(bit_sentaku)[1] == 1):
        mnmn.append(goukei(bit_sentaku)[0])

if not(len(mnmn) == 0):
    print(min(mnmn))
else:
    print(-1)



Measured memory_bytes: 9148
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC110C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string S = Input.String();
            string T = Input.String();

            Dictionary<Char, Char> map = new Dictionary<char, char>();
            Dictionary<Char, Char> map2 = new Dictionary<char, char>();
            
            for (int i = 0; i < S.Length; i++)
            {
                if (map.ContainsKey(S[i]))
                {
                    if (T[i] != map[S[i]])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    map.Add(S[i], T[i]);
                }

                if (map2.ContainsKey(T[i]))
                {
                    if (S[i] != map2[T[i]])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    map2.Add(T[i], S[i]);
                }
            }
            Console.WriteLine("Yes");
        }
    }
    
    
    internal static class Input
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

//g鏁扮粍
vector<int>G;
long long cnt;
int A[1000000 + 10];

// 闂撮殧涓篻鐨勬彃鍏ユ帓搴?
void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}
//甯屽皵鎺掑簭
void shellsort(int A[], int n) {
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

// 鐢熸垚g鏁扮粍
void getArray(int n) {
    for (int h = 1; h <= n;) {
        G.push_back(h);
        h = 3 * h + 1;
    }
}


int main() {

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    getArray(n);
    shellsort(A,n);

    int len = G.size();
    printf("%d\n", len);
    for (int i = len - 1; i >= 0; i--)
        printf("%d%c", G[i], i == 0 ? '\n' : ' ');
    printf("%lld\n", cnt);
    for (int i = 0; i < n; i++)
        printf("%d\n", A[i]);
    return 0;
}


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

int rec(int a,int b,int c,bool &flag,int cnt,int k) {
  if (a < b && b < c) {
    flag = true;
  }
  cnt++;
  if (cnt > k) {
    return 0;
  }
  rep(i,0,3) {
    if (i == 0) {
      rec(a*2,b,c,flag,cnt,k);
    } else if (i == 1) {
      rec(a,b*2,c,flag,cnt,k);
    } else {
      rec(a,b,c*2,flag,cnt,k);
    }
  }
  return 0;
}

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

Measured memory_bytes: 3632
import sys

n=int(input())
a=[int(input())for _ in range(n)]
a.sort()
ans=0

if sum(a)%10==0:
  for i in a:
    if i%10!=0:
      print(sum(a)-i)
      sys.exit()
  print(0)
      
else:
  print(sum(a))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

void printver(double s[], double e[], int n)
{
    if (n == 0) {
        printf("%f %f\n", s[0], s[1]);
        return ;
    }
    double left[2], right[2], center[2];

    left[0] = s[0] + (e[0] - s[0]) / 3;
    left[1] = s[1] + (e[1] - s[1]) / 3;

    right[0] = e[0] - (e[0] - s[0]) / 3;
    right[1] = e[1] - (e[1] - s[1]) / 3;

    center[0] = (right[0] - sqrt(3) * right[1] + left[0] + sqrt(3) * left[1]) / 2;
    center[1] = (sqrt(3) * right[0] + right[1] - sqrt(3) * left[0] + left[1]) / 2;

    printver(s, left, n - 1);
    printver(left, center, n - 1);
    printver(center, right, n - 1);
    printver(right, e, n - 1);
}

int main(void)
{
    int n;
    scanf("%d", &n);
    double start[2] = {0.00000000, 0.00000000};
    double end[2] =  {100.00000000, 0.00000000};

    printver(start, end, n);
    printf("100.00000000 0.00000000\n");
    return 0;
}


Measured memory_bytes: 2708
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

signed main() {
	Int l, r;
	cin >> l >> r;
	Int res = 1e10;
	for (Int i = l; i <= min(2019 + l, r); i++) {
		for (Int j = i + 1; j <= min(2019 + l, r); j++) {
			res = min(res, i * j % 2019);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int best[100000][17],N,L,Q;
vi X;

void fill() {
	F0R(i,N) {
		if (i != 0) best[i][0] = best[i-1][0];
		while (best[i][0]<(N-1) && (X[best[i][0]+1]-X[i]) <= L) best[i][0]++;
	}
	FOR(j,1,17) F0R(i,N) best[i][j] = best[best[i][j-1]][j-1];
}

int query(int a, int b) {
	int cur = 16, ans = 0;
	while (a < b) {
		while (best[a][cur] >= b && cur >= 0) cur--;
		if (cur < 0) break;
		ans += (1<<cur);
		a = best[a][cur];
	}
	if (a != b) ans ++;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N; X.resize(N);
	F0R(i,N) cin >> X[i];
	cin >> L >> Q;
	fill();
	F0R(i,Q) {
		int a,b; cin >> a >> b;
		a--,b--;
		if (a>b) swap(a,b);
		cout << query(a,b) << "\n";
	}
}

Measured memory_bytes: 7936
#!/usr/env/python3
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)

def f(N, X):
	if N == 0:
		#return 0 if X == 0 else 1
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))


Measured memory_bytes: 3064
function Main(input) {
    var S = parseInt(input); //46979 
    var h = Math.floor(S / 3600); //13
    var x = S % 3600 ; //179
    var m = Math.floor(x / 60); //2
    var z = x % 60; //59
    var s = z; //59
    console.log(h + ":" + m + ":" + s);
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15132
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
#define ull unsigned long long
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

using namespace std;
int main() {

long long n,m;
cin >> n >> m;

vector<pair<int,int> > v;

for(int i = 0 ; i < n ; i++)
 {
 	int a,b;
 	cin >> a >> b;
 	v.push_back({a,b});

 }
 
 sort(v.begin(),v.end());
 long long cnt = 0;
 bool k = 0;
 for(auto &k : v)
 	 {
      cnt+=k.second;
      if(cnt >= m)
      	 {  
      	 	cout << k.first;
      	 	break;
      	 }
 	 }





} 

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string word;
    getline(cin,word);
    if(word=="Sunny")
        cout<<"Cloudy";
    else if(word=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 105
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int AM[N][N];
int color[N], d[N], f[N], time;

void DFS(void);
void DFS_visit(int);

int main(){
  int i, j, u, k, v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      AM[i][j] = 0;
    }
  }

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

  DFS();

  return 0;
}


void DFS_visit(int u){
  int i;

  color[u] = GRAY;
  d[u] = ++time;
  for(i = 0 ; i < n ; i++){
    if(AM[u][i] ==  0) continue;
    if(color[i] == WHITE){
      DFS_visit(i);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}
void DFS(){
  int i;
  for(i = 0 ; i < n ; i++){
    color[i] = WHITE;
  }

  time = 0;

  for(i = 0 ; i < n ; i++){
    if(color[i] == WHITE) DFS_visit(i);
  }

  for(i = 0 ; i < n ; i++){
    printf("%d %d %d\n",i+1, d[i],f[i]);
  }
}



Measured memory_bytes: 2124
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0;
int a=0,b=0;
std::cin >> a>>b;
if(a==0){
  if(1911>=b)std::cout << "M"<<b-1867 << '\n';
  else if(1925>=b)std::cout << "T"<<b-1911 << '\n';
  else if(1988>=b)std::cout << "S" <<b-1925<< '\n';
  else std::cout << "H" <<b-1988<< '\n';
}else if(a==1)std::cout <<b+1867<< '\n';
else if(a==2)std::cout << b+1911 << '\n';
else if(a==3)std::cout << b+1925 << '\n';
else std::cout << b+1988 << '\n';
}



Measured memory_bytes: 3112
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

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

int A[100010];

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> A[i];

    set<int>st;

    rep(i, N) {
        if (st.find(A[i]) == st.end()) {
            st.insert(A[i]);
        }
        else {
            st.erase(A[i]);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<< endl;
#define int ll
int aa[N];
signed main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	// cout << "Started" << endl;
	cin >> n >> k;

	vector<ll> a;
	// trace(n);
	a.push_back(-1e18);
	for(i = 1;i <= n;i++) {
		cin >> aa[i];
		// trace(aa[i]);
		if(aa[i] == 0) {
			k--;
		}
		else {
			a.push_back(aa[i]);
		}
	}
	// trace(k);
	if(k <= 0) {
		cout << "0" << endl;
		return 0;
	}
	// debug(a);
	n = a.size() - 1;
	vector<int> left,right;
	for(i = 1;i <= n;i++) {
		if(a[i] < 0) {
			left.push_back(a[i]);
		}
		else {
			right.push_back(a[i]);
		}
	}
	reverse(left.begin(),left.end());
	// debug(left); 
	// debug(right);
	ll ans = 1e18;
	for(int le = 0;le <= k;le++) {
		int ri = k-le;
		if(le > left.size() || ri > right.size()) {
			continue;
		}
		// trace(le);
		if(le == 0) {
			ans = min(ans,1LL*right[ri-1]);
		}
		else if(ri == 0) {
			ans = min(ans,1LL*(-left[le-1]));
		}
		else {
			ans = min({ans,2LL*(-left[le-1]) + right[ri-1],-left[le-1] + 2LL*right[ri-1]});
		}
	}
	cout << ans << endl;
 }

Measured memory_bytes: 3700