akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];
int main()
{
    scanf("%d %d ", &N, &M);
    rep(i, M) scanf("%d %d ", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    rep(i, N) sort(yd[i + 1].begin(), yd[i + 1].end());

    rep(i, M) printf("%012lld\n ", ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const int MAX_N = 100000;
vector<int> adj [MAX_N];

int dfs(int curr,int prev = -1)
{
	int res = 0;
	for(const auto& it : adj [curr]) if(it != prev){
		res ^= dfs(it,curr) + 1;
	}
	return res;
}

int main()
{
	scanf("%d",&N);
	FOR(i,0,N - 1){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		adj [u].push_back(v);
		adj [v].push_back(u);
	}

	int res = dfs(0);
	if(res){
		puts("Alice");
	}
	else{
		puts("Bob");
	}

	return 0;
}


Measured memory_bytes: 10368
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,M;
    R(N,M);
    LL an=(N-M)*100+M*1900;
    W(an*(1<<M));
    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int count = 0;
  if (A == B){
    count+= 1;
  }
  if (B == C){
    count+= 1;
  }
  if (C == A){
    count+= 1;
  }
  
  if (count == 1){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
	int n; cin>>n;
	vector<int> sieve(55556,true);
	sieve[0]=false;
	sieve[1]=false;
	for (int i=2; i*i<=55555; i++)
		for (int j=i; j*i<=55555; j++)
			sieve[i*j]=false;

	vector<int> out;
	for (int i=1; i<55556; i+=10)
		if (sieve[i]) out.push_back(i);

	for (int i=0; i<n; i++)
		cout << out[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
    c = input()
    if c == 'AC':
        c0 += 1
    elif c == 'WA':
        c1 += 1
    elif c == 'TLE':
        c2 += 1
    else:
        c3 += 1
print(f'AC x {c0}')
print(f'WA x {c1}')
print(f'TLE x {c2}')
print(f'RE x {c3}')


Measured memory_bytes: 9184
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/13/20 20:47:40
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll x[2], y[2]; cin>>x[0]>>x[1]>>y[0]>>y[1];
  ll ans = -1e18-1;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ans = max(ans, x[i]*y[j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
import numpy as np
from numba import jit

@jit # TLE, without this!!!
def solve():
    
    n = int(input())
    
    divisors = np.zeros(n+1, np.int64)
    
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            divisors[j] += 1
    #print(divisors)
    
    ans = 0
    for k in range(n+1):
        ans += (k * divisors[k])
    
    print(ans)

solve()


Measured memory_bytes: 191424
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*a+2*b;
        System.out.println(area +" "+ length);
    }
}


Measured memory_bytes: 26148
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	if len(res)==0:
		res = [n]
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	#data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	#ans = data[:]
	return ans

n = readInt()
a = readInts()
a.sort()

max_a = 10**6
ans = [0]*(max_a+1)

for i in a:
	ans[i]+=1
for i in set(a):
	if ans[i]>0:
		for j in range(i*2,len(ans),i):
			ans[j]+=2

count = 0


print(ans.count(1))

Measured memory_bytes: 41764
n = int(input())
ans = [0]*n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)

Measured memory_bytes: 9248
#include <iostream>
#include <vector>

int n, q;

class DisjointSet {
public:
    DisjointSet(int size) {
        rank_.resize(size, 0);
        p_.resize(size, 0);
        for (int i = 0; i < size; i++) {
            p_[i] = i;
            rank_[i] = 0;
        }
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    };

    void link(int x, int y) {
        if (rank_[x] > rank_[y]) {
            p_[y] = x;
        } else{
            p_[x] = y;
            if (rank_[x] == rank_[y]) {
                rank_[y]++;
            }
        }
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    int findSet(int x) {
        if (x != p_[x]) {
            p_[x] = findSet(p_[x]);
        }
        return p_[x];
    }

    std::vector<int> rank_, p_;
};

int main() {
    std::cin >> n >> q;
    DisjointSet DS(n);
    for (int i = 0; i < q; i++) {
        int c, x, y;
        std::cin >> c >> x >> y;
        if (c) {
            if (DS.same(x, y)) {
                std::cout << 1 << std::endl;
            }else{
                std::cout << 0 << std::endl;
            }
        }
        else {
            DS.unite(x, y);
        }
    }
}


Measured memory_bytes: 3220
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

class Main {

	/*
	 * 最初は10番目のテストケースでTLEになったのがショックでした。
	 * 色々と考えてオートボクシングやアンボクシングの処理をなるだけ減らしたり
	 * 違うキューのクラスを使う事も考えましたが、
	 * インターネットで調べたところJavaのScannerを使った処理が重いということが判明しました。
	 * Scanner#nextInt()を使わないことでACになりました。
	 *
	 * 参考にしたサイト：
	 * Java競技プログラミングメモ-Quita
	 * https://qiita.com/p_shiki37/items/65c18f88f4d24b2c528b
	 * 2019/5/28閲覧
	 */

	public static void main(String[] args) throws Exception {
		//入力と準備
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(br.readLine());
		int n = Integer.parseInt(scanner.next());
		int quantum = Integer.parseInt(scanner.next());
		scanner.close();
		String name[] = new String[n];
		int time[] = new int[n];
		Queue<Integer> queue = new ArrayDeque<Integer>();
		for(int i=0; i<n; i++) {
			scanner = new Scanner(br.readLine());
			name[i] = scanner.next();
			time[i] = Integer.parseInt(scanner.next());
			scanner.close();
			queue.add(i);
		}
		int currentTime =  0;
		//順に処理
		for(;!queue.isEmpty();) {
			int taskNo = queue.poll();
			time[taskNo] -= quantum;
			currentTime += quantum;
			if(time[taskNo] <= 0) {
				currentTime += time[taskNo];//超過しているので戻す
				System.out.println(name[taskNo]+" "+String.valueOf(currentTime));
				continue;
			}
			queue.add(taskNo);
		}

	}

}



Measured memory_bytes: 182664
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        sc.nextInt();
        String[] S = new String[N];
        for (int i = 0; i < S.length; ++i) {
            S[i] = sc.next();
        }

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String[] S) {
        return Arrays.stream(S).sorted().collect(Collectors.joining());
    }
}

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

using namespace std;
int main()
{
	string s;
	cin>>s;
	long long cont=0,res=0;
	for(long long i=0;i<s.size();i++){
		if(s[i]=='W')
			res+=cont;
		else
			cont++;
	}
	cout<<res<<endl;
	return 0;
}

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

class combination
{
public:

	//N????????§?????????????????°??£??\??????
	combination( long long int combinationThreshold = 1e7 ) {
		(*this).combinationThreshold = combinationThreshold;
	}

	//a^p % mod
	long long int powmod( long long int A, long long int P, long long int M = LLONG_MAX ) {
		long long int ans = 1;
		long long int mul = A;
		for( ; P > 0; P >>= 1, mul = (mul*mul) % M ) {
			if( (P & 1) == 1 ) ans = (ans*mul) % M;
		}
		return ans;
	}

	//nCk mod m
	long long int cb( long long int N, long long int K, long long int M = LLONG_MAX ) {
		if( N < combinationThreshold ) {// ???????¨????O(N)??????????????????O(1)
			if( inv.size() == 0 ) {
				inv = vector<long long int>( combinationThreshold );
				inv[1] = 1;
				for( long long int i = 2; i < combinationThreshold; i++ ) {
					inv[i] = M - (M / i)*inv[M%i] % M;
				}
				fact = vector<long long int>( combinationThreshold );
				fact[0] = 1;
				revFact = vector<long long int>
					( combinationThreshold );
				revFact[0] = 1;
				for( long long int i = 1; i < combinationThreshold; i++ ) {
					fact[i] = (fact[i - 1] * i) % M;
					revFact[i] = (revFact[i - 1] * inv[i]) % M;
				}
			}
			return (((fact[N] * revFact[K]) % M)*revFact[N - K]) % M;
		} else {
			return cbOnce( N, K, M );
		}
	}

	//???????????????????????? O(K + log(M))
	long long int cbOnce( long long int N, long long int K, long long int M = LLONG_MAX ) {
		if( K > N / 2 ) return cb( N, N - K, M );
		long long int ans = 1;
		long long int div = 1;
		for( long long int i = 0; i < K; i++ ) {
			ans *= N - i;
			ans %= M;
			div *= i + 1;
			div %= M;
		}
		ans *= powmod( div, M - 2, M );
		return ans%M;
	}

private:
	vector<vector<long long int>>C;//3000??\????????????
	vector<long long int>fact;//??????
	vector<long long int>revFact;//???????????????
	vector<long long int>inv;//mod p??§?????????

	long long int combinationThreshold;//N????????§?????????????????°??\?????????
};

int main() {
	combination cb;
	long long int m, n;
	cin >> m >> n;
	cout << cb.powmod( m, n, 1000000007LL ) << endl;
}

Measured memory_bytes: 3096
import Control.Monad

data Plate = Plate {
  height :: Int,
  width :: Int
} deriving (Show)

searchUsablePlates :: Plate -> [Plate] -> [Plate]
searchUsablePlates targetPlate plates = filter (isUsable targetPlate) plates
  
isUsable :: Plate -> Plate -> Bool
isUsable targetPlate plate = do
  height targetPlate <= height plate && width targetPlate <= width plate

main = do
  [n,h,w] <- map read . words <$> getLine :: IO [Int]
  plates <- replicateM n $ do
    [a, b] <- fmap (map read .words) getLine
    return Plate {height=a, width=b}
  let targetPlate = Plate{height=h, width=w}
  putStrLn $ show $ length $ searchUsablePlates targetPlate plates
  
  

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    ll n,x,t;
    cin>>n>>x>>t;

    if(n%x==0)
        x=n/x;
    else
        x=(n/x)+1;

    cout<<x*t<<endl;




    return 0;
}


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

int main(void){
	int a,b;
	cin >> a >> b;
	if( a <= 0 && 0 <= b ){
		cout << "Zero" << endl;
	}else{
		if(a>0){
			cout << "Positive" << endl;
		}else{
			if( (b-a+1) % 2 == 0 )cout << "Positive" << endl;
			else cout << "Negative" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int a[23][23];
ll dp[(1<<22)];

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           rep(i,0,n)rep(j,0,n)cin>>a[i][j];
           dp[0]=1;
           rep(i,0,(1<<n)){
             int popcnt;  //男 popcnt人目について考える
             popcnt=__builtin_popcount(i);
             popcnt--;
             rep(j,0,n){
               if(i & (1<<j)){ //集合にjが含まれていたら
                dp[i]+=dp[i-(1<<j)]*(a[popcnt][j]); 
               }
             }
             dp[i]%=inf;
           }
           cout<<dp[(1<<n)-1]<<endl;
}

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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; 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 vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

ll pow_mod(ll n, ll k, ll m) {
    ll r = 1;
    for (; k > 0; k >>= 1) {
        if (k & 1) r = (r * n) % m;
        n = (n * n) % m;
    }
    return r;
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    ll N;
    cin >> N;
    map<ll, ll> m;
    rep(i, N) {
        ll A;
        cin >> A;
        m[A]++;
    }
    for (auto x:m) {
        if ((N & 1) && x.first == 0) {
            if (x.second != 1) {
                cout << 0 << endl;
                return 0;
            }
        } else if (x.second != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << pow_mod(2, N / 2, mod) << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a, b;
  cin >> a >> b;
  ll result;
  if(a == b)
    result = a + b;
  else
    result = 2 * max(a, b) - 1;
  cout << result << endl;

  return 0;
}

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

ll a, b, c, d;

ll gcd(ll c, ll d){
  return d ? gcd(d, c%d) : c;
}

ll lcm(ll c, ll d){
  return c/gcd(c,d)*d;
}

int main(){
  cin >> a >> b >> c >> d;
  a--;
  ll ada = a - (a/c + a/d - a/lcm(c,d));
  ll adb = b - (b/c + b/d - b/lcm(c,d));
  
  cout << adb - ada << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

int main()
{
	static const int MAX = 100000;
	long long n, m, a, b, price = 0, sumb = 0;
	pair<long long, long long> p[MAX];
	
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < n; i++)
		scanf("%d%d", &p[i].first, &p[i].second);
	
	sort(p, p+n);
	
	int i = 0;
	while (sumb < m) {
		price += p[i].first*p[i].second;
		sumb += p[i].second;
		i++;
	}
	
	price -= p[i-1].first*(sumb-m);
	
	printf("%lld\n", price);
	
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,mm;
    cin>>n;
    long long m[5]={};
    mm=n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s[0]=='M')
        {
            m[0]++;
        }
        else if(s[0]=='A')
        {
            m[1]++;
        }
        else if(s[0]=='R')
        {
            m[2]++;
        }
        else if(s[0]=='C')
        {
            m[3]++;
        }
        else if(s[0]=='H')
        {
            m[4]++;
        }
    }
    long long cnt=0;
    for(int i=0;i<5;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            for(int k=j+1;k<5;k++)
            {
                cnt+=(m[i]*m[j]*m[k]);
            }
        }
    }
    cout<<cnt<<NL;
    return 0;
}


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

ll fibo(int n,vector<ll> &memo){
    if(memo[n] != -1) return memo[n];
    else if(n==0) return 1;
    else if(n==1) return 1;
    return memo[n]=(fibo(n-1,memo)+fibo(n-2,memo))%(ll)1000000007;
}


int main(){
    vector<ll> memo(100010,-1);
    int n,m; cin >> n >> m;
    rep(i,m){
        int tt;
        cin >> tt;
        memo[tt]=0;
    } 
    cout << fibo(n,memo) << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N,K;
  cin >> N >> K;
  vector<ll>pts(3);
  cin >> pts[0] >> pts[1] >> pts[2];
  vector<char>h(3);
  h[0]='s';h[1]='p';h[2]='r';
  string T;cin >> T;
  ll ans=0;
  rep(i,K){
    string now="";
    for(int j=i;j<N;j+=K)now+=T[j];
    int L=now.size();
    vector<ll>dp(L+1,0);
    dp[0]=0;
    rep(j,L){
      ll ad=now[j]=='s'?pts[0]:(now[j]=='p'?pts[1]:pts[2]);
      if(j==0)dp[j+1]=dp[j]+ad;
      else{
        if(now[j-1]==now[j])dp[j+1]=max(dp[j],dp[j-1]+ad);
        else dp[j+1]=max(dp[j],dp[j-1])+ad;
      }
    }
    ans+=dp[L];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long m;
	cin >> n >> m;
	vector<long long> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a.begin(),a.end());
	vector<long long> b(n+1);
	long long tt=0;
	for(int i=0;i<n;i++){
		tt+=a[i];
		b[i+1]=tt;
	}
	
	long long left=0,right=1010101;
	long long pcnt=0,psum=0;
	while(left<right){
		long long mid=(left+right+1)/2;
		long long cnt=0,sum=0;
		
		int ind=0;
		for(int i=n-1;i>=0;i--){
			while(ind<=i && (a[i]+a[ind])<mid) ind++;
			if(ind>i) break;
			cnt+=(i-ind+1)+(i-ind);
			//sum a[ind] to a[i-1]
			sum+=a[i]*((i-ind+1)+(i-ind))+2*(b[i]-b[ind])+a[i];
		}
		if(cnt<m){
			right=mid-1;
		}else{
			left=mid;
		}
		pcnt=cnt;
		psum=sum;
	}
	{
		long long mid=left;
		long long cnt=0,sum=0;
		
		int ind=0;
		for(int i=n-1;i>=0;i--){
			while(ind<=i && (a[i]+a[ind])<mid) ind++;
			if(ind>i) break;
			cnt+=(i-ind+1)+(i-ind);
			//sum a[ind] to a[i-1]
			sum+=a[i]*((i-ind+1)+(i-ind))+2*(b[i]-b[ind])+a[i];
		}
		pcnt=cnt;
		psum=sum;
	}
	//cout << left << " " << pcnt << " " << psum << "\n";
	
	long long res=psum-(pcnt-m)*left;
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define f first
#define s second

using namespace std;
typedef long long ll;

const int N = 3e3+3;
ll ar[N][N], dp[N][N][3];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int r,c,k;
	cin >> r >> c >> k;
	for(int i=0;i<k;i++){
		int a,b,c;
		cin >> a >> b >> c;
		ar[a][b] = c;
	}
	ll res = 0;
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			for(int k=0;k<3;k++){
				dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]);
				dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k]);
				if(k > 0){
					dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k-1]+ar[i][j]);
				}else{
					dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][0]+ar[i][j]);
					dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][1]+ar[i][j]);
					dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][2]+ar[i][j]);
				}
				res = max(res,dp[i][j][k]);
			}
		}
	}
	cout << res << '\n';

	return 0;
}

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

int main(){
    // あとで消す
    //std::ifstream in("ain2.txt");
    //std::cin.rdbuf(in.rdbuf());

    int a;
    cin >> a;

    string s;
    cin >> s;

    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, D, A, X[201010], H[201010];
ll buf[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> D >> A;
	rep(i, 0, N) cin >> X[i] >> H[i];

	D *= 2;

	vector<pair<int, int>> xh;
	rep(i, 0, N) xh.push_back({X[i], H[i]});
	sort(all(xh));

	ll ans = 0;
	int R = 0;
	rep(L, 0, N) {
		if (L) buf[L] += buf[L - 1];

		int x = xh[L].first;
		int h = xh[L].second;

		if (buf[L] < h) {
			chmax(R, L + 1);
			while (R < N and xh[R].first - x <= D) R++;

			ll d = h - buf[L];

			ll cnt = (d + A - 1) / A;

			buf[L] += cnt * A;
			buf[R] -= cnt * A;
			ans += cnt;
		}
	}

	cout << ans << endl;
}







Measured memory_bytes: 5360
n,t = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(n)]
ct=sorted(ct, key=lambda cti : cti[0])
for i in range(n):
    if ct[i][1]<=t:
        print(ct[i][0])
        exit()
print('TLE')        
        
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n, arr[1000000];
long dp[1000000];

long solve(int i) {

	if (i >= n-1) {
		return 0;
	}

	if (dp[i] != -1)
		return dp[i];
  	if(i==n-2)
      dp[i] = abs(arr[i]-arr[i+1]);               
	else
	dp[i] = min(abs(arr[i] - arr[i + 1]) + solve(i + 1), abs(arr[i] - arr[i + 2]) + solve(i + 2));
                 
	return dp[i];
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0);

	return 0;
}


Measured memory_bytes: 14948
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000009;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int a[3];for(int i=0;i<3;i++)cin>>a[i];
	int k;cin>>k;
	int s=1;
	for(int i=0;i<k;i++){
		s*=2;
	}
	sort(a,a+3,greater<int>());
	a[0]*=s;
	int ans=0;
	for(int i=0;i<3;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int H,N,re = 0;
    int A[100000];
    scanf("%d %d",&H,&N);
    for(int i = 0;i < N;i++)
    {
        scanf("%d",&A[i]);
        re += A[i];
    }
    if(H <= re)printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    double N;
    cin >> N;
    for(long long i = 1;i<=3500;i++){
        for(long long j = 1;j<=3500;j++){
            double a = i,b = j;
            if(4.0*a*b-N*a-N*b == 0) continue;
            double betaC = (N*a*b)/(4.0*a*b-N*a-N*b);
            //cout << betaC << endl;
            bool ok = false;
            if(floor(betaC) == betaC == 1) ok = true;
            if(ok && betaC > 0){
                long long C = betaC;
                cout << i << " " << j << " " << C << endl;
                return 0;
            }
        }
    }
}


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

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

    map<string, int> vote;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(vote.count(s) == false) vote[s] = 1;
        else vote[s] += 1;
    }

    vector<pair<int, string>> result;
    for(auto v : vote){
        result.push_back({-v.second, v.first});
    }
    sort(result.begin(), result.end());
    cout << result[0].second << endl;

    for(int i=1; i<result.size(); i++){
        if(result[i].first != result[i-1].first) return 0;
        cout << result[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 29296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
const int MAX = 510000;

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;
}
signed main(){
  COMinit();
  int N; cin>>N;
  map<int,int> M;
  int X,Y;
  rep(i,0,N+1){
    int Z; cin>>Z;
    if(M.count(Z)){
      X=M[Z];
      Y=N-i;
      break;
    }
    M[Z]=i;
  }
  cout<<N<<endl;
  REP(i,2,N+1){
    int ans=COM(N+1,i);
    ans+=MOD;
    ans-=COM(X+Y,i-1);
    ans%=MOD;
    cout<<ans<<endl;
  }
  }


Measured memory_bytes: 19456
#include<iostream>
using namespace std;
int main(){
    int a[3],i,h,n;
    for(i=0;i<3;i++){
    cin>>a[i];
    }
    for(i=0;i<3;i++){
    	for(h=i+1;h<3;h++){
    		if(a[i]>a[h]){ 
    		n=a[h];
    		a[h]=a[i];
    		a[i]=n;
    		}
    	  }
     }
    	  cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    }

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

int main(){
  int n;	cin >> n;
  vector<long long>	a(n);
  rep(i,n)	cin >> a[i];
  
  long long b;
  b=a[0];
  for(int i=1;i<n;i++){
    b^=a[i];
  }
  
  rep(i,n){
    long long x=a[i]^b;
    cout << x << endl;
  }
  
}

Measured memory_bytes: 4816
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string ans = "";
	string acl = "ACL";
	
	int k;cin>>k;
	for(int i = 0;i<k;i++)
	{
		ans+=acl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main()
{
  string S;
  cin >> S;
  if (S[0] == S[1] && S[2] == S[1] && S[0] == S[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    map<ll, ll> m;
    ll c = 0;
    ll N;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        if(temp >= 3200) {
            c++;
        } else {
            m[temp / 400] += 1;
        }
    }
    cout << m.size() + ((m.size() == 0 && c > 0) ? 1 : 0) << ' ' << m.size() + c << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  s = list(map(int,input().split()))
  n = [0]*s[0]
  for k in range(0,s[1],1):
    d = int(input())
    a = list(map(int,input().split()))
    #print(a)
    for i in range(0,d,1):
      #print(a[i])
      n[a[i]-1] = 1
      #print(n)
      
  sum=0
  #print(n)
  
  for k in range(0,s[0],1):  
    if(n[k]==0): sum = sum+1
 
  print(sum)
  
main()

Measured memory_bytes: 9208
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

types = []
last = [-1] * 26
S = 0
for d in range(D):
    # search type
    M = -float('inf')
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        if tmp > M:
            M = tmp
            M_tt = tt

    S += s[d][M_tt]

    last[M_tt] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    types.append(M_tt)


last = [-1] * 26
S = 0
for d in range(D):
    seq = []
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        seq.append([tmp, tt])

    seq.sort(reverse=True)

    tmpmax = -float('inf')
    for i in range(20):
        tt = seq[i][1]
        _last = last[:]
        _types = types[:]
        _types[d] = tt
        _S = S

        for dd in range(d, D):
            _S += s[dd][_types[dd]]
            _last[_types[dd]] = dd
            for i in range(26):
                _S -= c[i] * (dd - _last[i])

        if _S > tmpmax:
            cand = tt
            tmpmax  = _S

    S += s[d][cand]
    last[cand] = d
    for i in range(26):
        S -= c[i] * (d - last[i])

    print(cand + 1)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


int lb(const vector<int>&a,int t){
	int left=-1,right=a.size();
	while(right-left>1){
		int mid=(left+right)/2;
		if(a[mid]>=t)right=mid;
		else left=mid;
	}
	return right;
}


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

	int q;
	cin>>q;
	int ans=0;
	while(q--){
		int t;
		cin>>t;
		
		int k=lb(a,t);
		if(k<n&&a[k]==t)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3496
def main():
    n = int(input())
    print(solve(n))

def solve(n):
    c = 0
    for p in (10, 1000, 100000):
        if n >= p:
            c += p * 9 // 10
        elif n * 10 >= p:
            c += n - p // 10 + 1
    return c

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<pair<int,int>,int> P;
vector<P> v;
vector<pair<int,int>> vv;
int a[1000];
int main(){
    int l;cin>>l;
    int n,m=0;
    int s=1;
    for(int i=1;i<=100;i++){
        s*=2;
        if(s>l){
            n=i;
            break;
        }
    }
    for(int i=0;i<n-1;i++){
        v.push_back(P(make_pair(i+1,i+2),(1<<i)));
        v.push_back(P(make_pair(i+1,i+2),0));
    }
    s=(1<<(n-1));
    for(int i=0;i<n-1;i++){
        if(l&(1<<i)){
            v.push_back(P(make_pair(i+1,n),s));
            s+=(1<<i);
        }
    }
    m=v.size();
    cout<<n<<" "<<m<<endl;
    for(int i=0;i<m;i++){
        cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

void solve()
{
    ll n;
    cin >> n;
    ll i, j;
    array<ll, 2> p;
    ll mini = 1e18, maxi = -1e18;
    ll mini2 = 1e18, maxi2 = -1e18;

    for (i = 0; i < n; i++)
    {
        cin >> p[0] >> p[1];
        mini = min(mini, p[0] + p[1]);
        maxi = max(maxi, p[0] + p[1]);
        mini2 = min(mini2, p[0] - p[1]);
        maxi2 = max(maxi2, p[0] - p[1]);
    }
    cout<<max(llabs(mini-maxi),llabs(mini2-maxi2))<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int dp[2][2019];

int main() {
  string S;
  cin >> S;
  long long ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    int curr = i % 2;
    int prev = 1 - curr;
    for (int j = 0; j < 2019; ++j) {
      dp[curr][j] = 0;
    }
    int digit = S[i] - '0';
    dp[curr][digit] = 1;
	if (i > 0) {
      for (int j = 0; j < 2019; ++j) {
        dp[curr][(j * 10 + digit) % 2019] += dp[prev][j];
      }
    }
    ans += dp[curr][0];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3720
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		Scanner sc = new Scanner(System.in);

		int[] x = new int[4];
		int[] y = new int[4];

		x[0] = sc.nextInt();
		y[0] = sc.nextInt();
		x[1] = sc.nextInt();
		y[1] = sc.nextInt();

		int dx = x[1] - x[0];
		int dy = y[1] - y[0];

		x[2] = x[1] - dy;
		y[2] = y[1] + dx;
		x[3] = x[2] - dx;
		y[3] = y[2] - dy;
		
		System.out.println(x[2]);
		System.out.println(y[2]);
		System.out.println(x[3]);
		System.out.println(y[3]);

	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  char base[4] = "abc";

cin >> base;

  string str = base;

  bool result = false;
  if (str.find('a') != string::npos) {
    if (str.find('b') != string::npos) {
      if (str.find('c') != string::npos) {
        result = true;
      }
    }
  }

  cout << (result?"Yes":"No");

  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBattle solver = new BBattle();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBattle {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int a = s.nextInt(), b = s.nextInt(), c = s.nextInt(), d = s.nextInt();
            boolean turn = true;
            while (a > 0 && c > 0) {
                if (turn) c -= b;
                else a -= d;
                turn = !turn;
            }
            w.println(a <= 0 ? "No" : "Yes");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25476
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a * b == 15) return "*";
            if (a + b == 15) return "+";
             return "x";
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 27104