akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// http://drken1215.hatenablog.com/entry/2019/03/28/014100

int main() {
    int N;
    cin >> N;
    vector<ll> L(3 * N);
    REP(i, 3 * N) {
        ll tmp;
        cin >> tmp;
        tmp = -tmp;
        L[i] = tmp;
    }
    sort(L.begin(), L.end());
    //大きいすぎる値と
    //小さすぎる値を
    //ペアにすると
    //損する
    // print(L);
    ll res = 0;
    REP(i, 2 * N) {
        if(i % 2 == 1) {
            res += L[i];
        }
    }
    cout << -res << endl;
    return 0;
}

Measured memory_bytes: 2560
package main

import "fmt"

const WHITE = "1"
const BLACK = "0"

func main() {

	var s string
	sum := 0
	fmt.Scan(&s)
	tiles := make([]string, len(s))
	runes := []rune(s)
	for i := 0; i < len(runes); i++ {
		tiles[i] = string(runes[i])
	}

	for i := range tiles {
		if i == 0 {
			continue
		}
		if tiles[i] == tiles[i-1] {
			if tiles[i] == WHITE {
				tiles[i] = BLACK
				sum++
			} else {
				tiles[i] = WHITE
				sum++
			}
		}

	}

	fmt.Println(sum)

}


Measured memory_bytes: 3712
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	A,B=map(int,input().split())
	if A<=8 and B<=8:
		print("Yay!")
	else:
		print(":(")
	
	
	






if __name__ == '__main__':
    main()

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

int main() {
	int num;
	string type;
	char comma;
	int a = 0, b = 0, ab = 0, o = 0;
	while (cin >> num >> comma >> type) {
		if (type == "A") {
			a++;
		}
		else if (type == "B") {
			b++;
		}
		else if (type == "AB") {
			ab++;
		}
		else if (type == "O") {
			o++;
		}
	}

	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;

	return 0;
}

Measured memory_bytes: 3108
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        char c[][]=new char[h][];
        for (int i = 0; i < h; i++) {
			c[i]=sc.nextString().toCharArray();
		}
        
        LinkedList<Integer> q = new LinkedList<>();
        int d[][]=new int[h][w];
        
        for (int i = 0; i < c.length; i++) {
			for (int t = 0; t < c[0].length; t++) {
				if(c[i][t]=='#') {d[i][t]=1; q.add(i*10000+t);}
			}
		}
        
        int ans=1;
        while(!q.isEmpty()) {
        	int p=q.poll();
        	int x=p/10000, y=p%10000;
        	for (int i = 0; i < 4; i++) {
				int xx=x+dx[i];
				int yy=y+dy[i];
				if(xx<0||yy<0||h==xx||w==yy|| d[xx][yy]!=0)continue;
				d[xx][yy]=d[x][y]+1;
				ans=max(d[xx][yy],ans);
				q.add(xx*10000+yy);
			}
        }

        out.println(ans-1);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}


//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 79760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int card[]=new int[100001];
		for (int i = 0; i < n; i++) {
			int x=sc.nextInt();
			card[x]++;
			if(card[x]==3)card[x]=card[x]-2;
		}
		int one=0;
		int two=0;
		for (int i = 0; i < 100001; i++) {
			if(card[i]==1)one++;
			else if(card[i]==2)two++;
		}
		if(two%2==0)System.out.println(one+two);
		else System.out.println(one+two-1);
		
		}
		
	}


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

int main()
{
    int A,B;
    cin >> A >> B;

    if(A == 1 && B == 2)
        cout << 3;
    else if(A == 1 && B == 3)
        cout << 2;
    else if(A == 2 && B == 1)
        cout << 3;
    else if(A == 2 && B == 3)
        cout << 1;
    else if(A == 3 && B == 1)
        cout << 2;
    else if(A == 3 && B == 2)
        cout << 1;
    
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

//main code

int main(int argc, char *argv[])
{
	int n;
	string s;
	cin >> n >> s;
	int c = 0;
	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') {
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

class UnionFind{
public:
	Int n;
	vector<Int> u;
	UnionFind(Int _n = 0){
		n = _n;
		u = vector<Int>(n, -1);
	}
	Int r(Int x){
	    if(u[x] < 0)return x;
	    return u[x] = r(u[x]);
	}
	void unite(Int x, Int y){
	    x = r(x);
	    y = r(y);
	    if(x != y){
            u[y] += u[x];
            u[x] = y;
        }
	}
    Int size(Int x){
        x = r(x);
        return -u[x];
    }
};

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

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

vector<P> edges;

int main(){
    Int n, m, q, a, b, c;
    cin >> n >> m >> q;
    UnionFind uf(n);
    for(Int i = 0;i < q;i++){
        cin >> a >> b >> c;
        if(c == 0){
            uf.unite(a, b);
        }
        else{
            edges.push_back(P(a, b));
        }
    }
    vector<Int> nums;
    for(auto &p: edges){
        p.first = uf.r(p.first);
        p.second = uf.r(p.second);
        if(p.first == p.second)ng();
    }
    if(m == n-1){
        if(edges.empty())ok();
        else ng();
    }
    Int base = 0;
    for(Int i = 0;i < n;i++){
        if(uf.u[i] < 0){
            nums.push_back(-uf.size(i));
            base += uf.size(i) - 1;
        }
    }
    sort(nums.begin(), nums.end());
    Int k = nums.size();
    if(base + k * (k-1)/2 >= m)ok();
    else ng();
    return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
#include <atcoder/all>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;
using namespace atcoder;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

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

int main(void)
{
    int N,Q; cin>>N>>Q;
    fenwick_tree<ll> fw(N);
    rep(i,N){
        int a; cin>>a;
        fw.add(i,a);
    }
    while(Q--){
        int t,x,y; cin>>t>>x>>y;
        if (t==0){
            fw.add(x,y);
        }else{
            cout<<fw.sum(x,y)<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 8204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <queue>

using namespace std;

using ll = long long;

ll N;
ll ans = 0;
string S;
ll r[4005];
ll g[4005];
ll b[4005];
ll n[4005];

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

    if(N < 3)
    {
        cout << 0 << endl;
        return 0;
    }
    if(S[0]=='R')r[0]++;
    if(S[0]=='G')g[0]++;
    if(S[0]=='B')b[0]++;
    for(int i = 1;i < N;i++)
    {
        r[i] = r[i-1];
        g[i] = g[i-1];
        b[i] = b[i-1];
        if(S[i]=='R')r[i]++;
        if(S[i]=='G')g[i]++;
        if(S[i]=='B')b[i]++;
    }
    for(int i = 0;i < N;i++)
    {
        if(S[i]=='R')n[i] = 1;
        if(S[i]=='G')n[i] = 10;
        if(S[i]=='B')n[i] = 100;
    }

    for(int i = 0;i < N-2;i++)
    {
        for(int j = i+1;j < N-1;j++)
        {
            ll ps = n[i] + n[j];
            ll t = 0;
            if(ps == 11)
            {
                t += b[N-1] - b[j];
                if(j - i + j < N && n[j - i + j] == 100)t--;
            }
            if(ps == 101)
            {
                t += g[N-1] - g[j];
                if(j - i + j < N && n[j - i + j] == 10)t--;
            }
            if(ps == 110)
            {
                t += r[N-1] - r[j];
                if(j - i + j < N && n[j - i + j] == 1)t--;
            }
            ans += t;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<vector<int>> s(m);
  rep (i, m) {
    int k;
    cin >> k;
    s[i] = vector<int>(k);
    rep (j, k) cin >> s[i][j];
  }

  vector<int> p(m);
  rep (i, m) cin >> p[i];

  int ans = 0;

  rep (on, (1 << n)) {
    bool flg = true;
    rep (i, m) {
      int sum = 0;
      rep (j, s[i].size()) {
        sum += (on >> (s[i][j] - 1)) & 1;
      }
      if (sum % 2 != p[i]) flg = false;
    }
    ans += flg;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (max(a - c, c - a) <= d || (max(a - b, b - a) <= d && max(c - b, b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

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

  int64_t result = 0;
  rep(i, K) rep(j, K) rep(k, K) { result += gcd(i + 1, gcd(j + 1, k + 1)); }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3604
// AtCoder agc002

#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define iii pair<int,ii>
#define se second
#define fi first
using namespace std;
ll a[100010];
ll s1[100010], s2[100010];
int main(){
    //cout.precision(12);
    //ifstream fin("in");
    int n; ll len;
    cin>>n>>len;
    int ind=-1;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>=len)ind=i;
    }
    if(ind==-1){
        cout<<"Impossible"<<endl; return 0;
    }
    cout<<"Possible"<<endl;
    for(int i=1;i<ind;i++)cout<<i<<endl;
    for(int i=n-1;i>=ind;i--)cout<<i<<endl;
}


Measured memory_bytes: 1664
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<List<Integer>> D = new ArrayDeque<>();
		List<Integer> tmp = new ArrayList<Integer>();

		int N=sc.nextInt();
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			tmp.add(a);
			tmp.add(b);
			D.add(tmp.stream().collect(Collectors.toList()));
			tmp.clear();
		}
		tmp=null;

		int cnt=0;
		while(D.size()!=0 && cnt<3){
			List<Integer> d =D.poll();
			if(d.get(0)==d.get(1)) {
				cnt+=1;
			}
			else {
				cnt=0;
			}
		}
		if(cnt>=3) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		sc.close();
	}
}












Measured memory_bytes: 36228
use proconio::{fastout, input};
use std::collections::BinaryHeap;
use std::cmp::Reverse;

#[fastout]
fn main() {
    input! {
        q: usize,
    }

    let mut fpq : BinaryHeap<i64> = BinaryHeap::new();
    let mut lpq : BinaryHeap<Reverse<i64>>= BinaryHeap::new();

    let mut b_sum : i64= 0;
    let mut f_sum : i64= 0;
    let mut l_sum : i64= 0;

    for _ in 0..q{
        input!{t : usize}
        if t == 1{
            input!{a : i64, b: i64}
            b_sum += b;
            if fpq.len() > lpq.len(){
                let x = fpq.pop().unwrap();
                if x > a{
                    lpq.push(Reverse(x));
                    fpq.push(a);
                    f_sum -= x;
                    f_sum += a;
                    l_sum += x;
                }else{
                    lpq.push(Reverse(a));
                    fpq.push(x);
                    l_sum += a;
                }
            }else{
                if fpq.is_empty(){
                    fpq.push(a);
                    f_sum += a;
                }else{
                    let x = lpq.pop().unwrap().0;
                    if x > a{
                        fpq.push(a);
                        lpq.push(Reverse(x));
                        f_sum += a;
                    }else{
                        fpq.push(x);
                        lpq.push(Reverse(a));
                        f_sum += x;
                        l_sum -= x;
                        l_sum += a;
                    }
                }
            }
        }else{
            let x = fpq.pop().unwrap();
            fpq.push(x);
            // println!("{} {}", f_sum, l_sum);
            let res : i64= (x * (fpq.len() as i64) - f_sum) + (l_sum - x*(lpq.len() as i64)) + b_sum;
            println!("{} {}",x,res);
        }
    }

}


Measured memory_bytes: 8876
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var restaurant = new Restaurant[N];
            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split(' ').ToArray();
                restaurant[i] = new Restaurant(i, input[0], int.Parse(input[1]));
            }
            var sortList = restaurant.OrderBy(x => x.s).ThenByDescending(x => x.p);

            foreach (var r in sortList)
            {
                Console.WriteLine(r.id + 1);
            }
        }
    }

    class Restaurant
    {
        public int id;
        public string s;
        public int p;

        public Restaurant(int id, string s, int p)
        {
            this.id = id;
            this.s = s;
            this.p = p;
        }
    }
}


Measured memory_bytes: 13652
#include <iostream>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

int a, b, c, k, ans;
int main() {
	cin >> a >> b >> c >> k;
	
	ans += min(a,k);
	k -= min(a,k);
	
	if(k <= 0){
		cout << ans << endl;
		return 0;
	}
	
	k -= min(b,k);
	
	if(k <= 0){
		cout << ans << endl;
		return 0;
	}
	
	ans -= min(c,k);
	k -= min(c,k);
	
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3144
def C(n, r, m):
    num, den = 1, 1
    for i in range(1, r + 1):
        num = num * (n - i + 1) % m
        den = den * i % m
    return (num * pow(den, m - 2, m)) % m

x, y = map(int, input().split())
m = (2*x - y) // 3
n = (-x + 2*y) // 3
if (x + y) % 3 != 0 or m < 0 or n < 0:
    print(0)
else:
    print(C(n + m, n, 10**9 + 7))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	int a, b, c;
	cin>>a>>b>>c;
	cout<<int(ceil(double(a)/double(b))*c);
	
	return 0;
}

Measured memory_bytes: 3644
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l=sorted(l,key=lambda x:x[1], reverse=True)

p=0
comp=[]
for b,c in l:
  comp+=[c]*b
  p+=b
  if p>=n:
    break

ans=0
for i in range(n):
  if i<len(comp):
    ans+=max(a[i],comp[i])
  else:
    ans+=a[i]
print(ans)

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

const int MAX_ITEM = 100;
const int MAX_VALUE_SUM = 100000;

const long long INF = (1LL<<60);

int N, W;
long long w[MAX_ITEM];
int v[MAX_ITEM];

// dp[i][sum_v] := i番目まで選択対象とした場合に、価値合計がsum_v以上を達成する場合の、
//                 重さの合計sum_wの最小値
long long dp[MAX_ITEM + 1][MAX_VALUE_SUM + 1];

int main()
{
	cin >> N >> W;
	for ( int i = 0; i < N; ++i ) {
		cin >> w[i] >> v[i];
	}

	for ( int sum_v = 0; sum_v <= MAX_VALUE_SUM; ++sum_v ) {
		dp[0][sum_v] = INF;
	}
	dp[0][0] = 0;

	for ( int i = 0; i < N; ++i ) {
		for ( int sum_v = 0; sum_v <= MAX_VALUE_SUM; ++sum_v ) {
			if ( sum_v < v[i] ) {
				dp[i + 1][sum_v] = dp[i][sum_v];
			}
			else {
				dp[i + 1][sum_v] = ::min( dp[i][sum_v],
										  dp[i][sum_v - v[i]] + w[i] );
			}
		}
	}

	int res = 0;
	for ( int sum_v = 0; sum_v <= MAX_VALUE_SUM; ++sum_v ) {
		if ( dp[N][sum_v] <= W ) res = sum_v;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
using namespace std;
bool isPrime(vector<int> v, int n) {
    for (int i=0; i<v.size(); i++) {
        if (n % v[i] == 0) {
            return false;
        }
    }
    return true;
} 

int main() {
    vector<int> vp = {2};
    for (int i=3; i<=100003; i++) {
        if (isPrime(vp, i)) {
            vp.push_back(i);
        }
    }
    int x;
    cin >> x;
    int i = 0;
    while(vp[i] < x) {
        i++;
    }
    cout << vp[i] << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main{

	public static void main(String args[]) throws IOException{
		Scanner sc=new Scanner();
		PrintWriter pw=new PrintWriter(System.out);
		String s=sc.next();
		int i=0;
		long rta=0;
		for (int j = 0; j < s.length(); j++) {
			if(s.charAt(j)=='W'){
				rta+=j-i;
				i++;
			}
		}
		pw.println(rta);
		pw.close();
		
	}
	static class Scanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		int spaces = 0;

		public String nextLine() throws IOException {
			if (spaces-- > 0) return "";
			else if (st.hasMoreTokens()) return new StringBuilder(st.nextToken("\n")).toString();
			return br.readLine();
		}

		public String next() throws IOException {
			spaces = 0;
			while (!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public boolean hasNext() throws IOException {
			while (!st.hasMoreTokens()) {
				String line = br.readLine();
				if (line == null) return false;
				if (line.equals("")) spaces = Math.max(spaces, 0) + 1;
				st = new StringTokenizer(line);
			}
			return true;
		}
	}
}

Measured memory_bytes: 25648
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for (int i = 1; i <= num; i++) {
            if (i%3 == 0) {
                System.out.print(" " + i);
            } else {
                String str = String.valueOf(i);
                if (str.contains("3")) {
                    System.out.print(" " + i);
                }
            }
        }
        System.out.println();
    }
}


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

using namespace std;

int main() {
    int n,k,q,tmp;
    cin >> n >> k >> q;
    vector<int> N(n);
    for (int i=0; i<n; ++i)
        N.at(i) = k;

    for (int cnt = 0; cnt < q; ++cnt) {
        cin >> tmp;
        N.at(tmp-1) += 1;
    }

    for (auto& it : N) {
        if(it <= q)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
    string S;
    int K;
    cin >> S >> K;

    vector<char> moji(S.size());
    for (int i = 0; i < S.size(); i++) {
        moji[i] = S[i];
    }
    sort(moji.begin(), moji.end());

    vector<string> ans = {};
    for (int i = 0; i < S.size(); i++) {
        if (moji[i] == moji[i - 1]) {
            continue;
        }
        else {
            for (int j = 0; j < S.size(); j++) {
                if (moji[i] == S[j]) {
                    for (int k = 0; k < 5 && j + k < S.size(); k++) {
                        ans.push_back(S.substr(j, k + 1));
                    }
                }
            }
        }
    }

    sort(ans.begin(), ans.end());
    int cnt = 1;
    for (int i = 0; i < ans.size(); i++) {
        if (i > 0 && ans[i] == ans[i - 1]) {
            continue;
        }
        else {
            if (cnt == K) {
                cout << ans[i] << endl;
            }
            cnt++;
        }
    }
}

Measured memory_bytes: 1660
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    int n;
    string s;
    cin >> n;
    int ans = 0;
    REP(i,n){
        int l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
 
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int x = b-a;
    int s = (1 + (b-a)) * (b - a);
    s /= 2;
    cout << s - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int>> dp(32, vector<int>(n));
  rep(i, n) {
    if (s[i] == 'L')
      dp[0][i] = i-1;
    else
      dp[0][i] = i+1;
  }
  for (int i = 1; i < 32; i++) {
    rep(j, n)
      dp[i][j] = dp[i-1][dp[i-1][j]];
  }
  vector<int> ans(n);
  rep(i, n)
    ans[dp[31][i]]++;
  rep(i, n)
    printf("%d%c", ans[i], i<n-1?' ':'\n');
  return 0;
}

Measured memory_bytes: 13512
def divisor(n):
  i = 1
  table = []
  while i * i <= n:
    if n % i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

n = int(input())
#print(divisor(n))
ans = []
for j in divisor(n):
  a = j
  b = int(n/a)
  #print(a,b)
  ans.append(max(len(str(a)), len(str(b))))
  #print(min(ans))
print(min(ans))

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

int main(){
    string a,b;
    cin>>a>>b;
    int f=0;
    for(int i=0;i<a.length();i++){
        if(a[i]==b[a.length()-1-i])continue;
        else f=1;
    }
    if(f==0)cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy, y3 = y2 + dx;
    int x4 = x1 - dy, y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

int[] di = [-1, 0, 1, -1, 0, 1, -1, 0, 1];
int[] dj = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
alias Block = Tuple!(int, "i", int, "j");

void main() {
    int n, m;
    scan(n, m);
    auto a = readArr!(int);
    auto b = readArr!(int);
    auto as = a.sort();
    auto bs = b.sort();

    if (as.length > as.uniq.count || bs.length > bs.uniq.count) {
        writeln(0);
        return;
    }

    long ans = 1;

    foreach (x ; 1 .. n * m + 1) {
        auto inA = as.contains(x);
        auto inB = bs.contains(x);

        auto bux = bs.upperBound(x).length.to!long;
        auto aux = as.upperBound(x).length.to!long;

        if (inA && inB) {

        }
        else if (inA) {
            ans *= bux;
            ans %= mod;
        }
        else if (inB) {
            ans *= aux;
            ans %= mod;
        }
        else {
            ans *= (aux * bux % mod - (n * m - x) + mod) % mod;
            ans %= mod;
        }

    }

    writeln(ans);
}





void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2300
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

#define MAXN 100000
int a[MAXN+10];
bool b[MAXN+10];
void solve(long long N, long long M, vector<long long> x, vector<long long> y){
	memset(b,false,sizeof(b));
	b[1]=true;
	for(int i=1; i<=N; ++i) {
		a[i]=1;
	}
	for(int i=0; i<M; ++i) {
		a[x[i]]--;
		a[y[i]]++;
		if (b[x[i]]) b[y[i]]=true;
		if (a[x[i]]==0) b[x[i]]=false;
	}	
	int ans=0;
	for(int i=1; i<=N; ++i) {
		if (b[i]) ++ans;
	}
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> x(M-1+1);
	vector<long long> y(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, M, x, y);
	return 0;
}



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

int main() {
  
  vector<int> x(5);
  
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }
  
  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      cout << i + 1;
      break;
    }
  }
  
}

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

int main(void)
{
    int n=1, i, j,k,x[1000],y[1000];
    double distance1 = 0,distance2=0,distance3=0,distance=0,max=0;

    scanf("%d", &n);

    for (i = 1;i <= n;i++)
    {
        scanf("%d", &x[i]);
    }

    for (j = 1;j <= n;j++)
    {
        scanf("%d", &y[j]);
    }
    
    for (k = 1;k <= n;k++)
    {
        distance1 = distance1 + sqrt(pow((x[k] - y[k]), 2));
        distance2 = distance2 + pow((x[k] - y[k]), 2);
        distance3 = distance3 + pow((fabs((x[k] - y[k]))),3);
        
        if (max < fabs(x[k] - y[k]))
        {
            max = fabs(x[k] - y[k]);
        }
    }
    
    printf("%.8f %.8f %.8f %.8f\n", distance1,sqrt(distance2),pow(distance3,0.333333333333),max);

    return 0;

}


Measured memory_bytes: 2104
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<vector<pii>> a(n);
    rep(i,n){
        int x;
        cin >> x;
        a[i].resize(x);
        rep(j,x){
            int b, c;
            cin >> b >>c;
            a[i][j] = pii(b-1,c);
        }
    }
    int ans = 0;
    rep(bit, 1 << n){
        bool flag = true;
        rep(i,n){
            bool k = false;
            if(bit >> i & 1)k = true;
            rep(j,a[i].size()){
                int b = a[i][j].first;
                int c = a[i][j].second;
                if(k){
                    if(bit >> b & 1){
                        if(c == 0)flag = false;
                    }else{
                        if(c == 1)flag = false;
                    }
                }else{
//                    if(bit >> b & 1){
//                        if(c == 1)flag = false;
//                    }else{
//                        if(c == 0)flag = false;
//                    }
                }
            }
        }
        if(flag){
            ans = max(ans, __builtin_popcount(bit));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
 
int main() {
    string s;
	
	cin >> s;
	
	string t1, t2;
	
	t1 = s[0];
	int cut = 1;
	int count = 1;
	//cout << t1 << " ";
	for(int i = 1; i < s.size(); i++){
		int width = i - cut + 1; 
		t2 = s.substr(cut, width);
				//	cout << t2 << " ";
		if(t1 != t2){
			cut = i + 1;
			count++;
			//cout << "/";
			t1 = t2;
		}
		
		
	}
	
	cout << count << endl;  
    
    
    
    
    return 0;
}

Measured memory_bytes: 640
n, m = map(int,input().split())
a = list(map(int, input().split()))
bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))

a.sort()
bc = sorted(bc, key=lambda x:x[1])
bc.reverse()

cnt = 0
p = 0
for i in range(n):
    if p == m:
        break
    if a[i] < bc[p][1]:
        a[i] = bc[p][1]
        cnt += 1
    if cnt == bc[p][0]:
        p += 1
        cnt = 0
print(sum(a))

Measured memory_bytes: 82412
n = int(input())
a1 = input()
A1 = a1.split()
a2 = input()
A2 = a2.split()

i = 0
j = 0
s = 0
s1 = 0
while i < n:
    while j <= i:
        s += int(A1[j])
        j += 1
    k = i
    while k < n:
        s += int(A2[k])
        k += 1
    if s1 < s:
        s1 = s
    j = 0
    s = 0
    i += 1
print(s1)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;


public class Main {
    static long mod = 1000000000+7;
    static long n,a,b,k;
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        int n = sc.nextInt(), k = sc.nextInt();
        double ans = 0.0;
        TreeMap<Integer,Integer> tm = new TreeMap<>();
        for(int i=0;i<25;i++){
            tm.put(1<<i,i);
        }
        for(int i=1;i<=n;i++){
            if(i>=k) ans += 1.0;
            else{
                int upper = k%i==0?k/i:(k/i+1);
                Integer key = tm.ceilingKey(upper);
                int step = tm.get(key);
                double cur = Math.pow(0.5,step);
                ans += cur;
            }
        }
        ans = ans/((double) n);
        System.out.println(ans);
    }

}



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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    rep(i, 0, n) {
        ll x, y;
        cin>>x>>y;
        if (x==y) arr[i]=1;
        else arr[i]=0;
    }
    bool flag=0;
    rep(i, 0, n-2) {
        if (arr[i]==1 && arr[i+1]==1 && arr[i+2]==1) flag=1;
    }
    if (flag) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d); //scanf("%d", b);  scanf("%d", c);  scanf("%d", d); 
  if(a+b>c+d)printf("Left");
  if(a+b<c+d)printf("Right");
  if(a+b==c+d)printf("Balanced");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String n = scanner.nextLine();
        if (n.contains("7"))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

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

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  vector<int> a(n, 1);

  int i = 0;

  while (i < n) {
    if (s[i] == 'R') {
      i++;
      continue;
    }
    int j = i++;
    while (s[i] == 'L') {
      a[(i - j) % 2 == 0 ? j : j - 1] += a[i];
      a[i] = 0;
      i++;
    }
  }

  i = n - 1;

  while (i >= 0) {
    if (s[i] == 'L') {
      i--;
      continue;
    }
    int j = i--;
    while (s[i] == 'R') {
      a[(j - i) % 2 == 0 ? j : j + 1] += a[i];
      a[i] = 0;
      i--;
    }
  }

  for (auto&& e : a) {
    cout << " " << e;
  }
  cout << endl;
}


Measured memory_bytes: 1024
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]
count_list = []

for i in range(2**D):
  point = 0
  count = 0
  bin_i = bin(i)[2:].zfill(D)
  for j in range(D):
    if bin_i[j] == '1':
      point += 100 * (j+1) * pc[j][0] + pc[j][1]
      count += pc[j][0]
  if point >= G:
    count_list.append(count)
  else:
    index = bin_i.rindex('0')
    for j in range(pc[index][0]-1):
        point += 100 * (index+1)
        count += 1
        if point >= G:
          count_list.append(count)
          break
          
print(min(count_list))


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	P(min(a*b,c));
}

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


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

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> arr(n), pre(n), suf(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    pre[0] = arr[0];
    suf[n-1] = arr[n-1];
    for(int i = 1; i < n; i++)
        pre[i] = max(pre[i-1], arr[i]);
    for(int i = n-2; i >= 0; i--)
        suf[i] = max(suf[i+1], arr[i]);
    vector<int> res(n);
    res[0] = suf[1];
    res[n-1] = pre[n-2];
    for(int i = 1; i < n-1; i++)
        res[i] = max(pre[i-1], suf[i+1]);

    for(int i = 0; i < n; i++)
        cout << res[i] << (i == n-1 ? "" : "\n");
    return 0;
}

Measured memory_bytes: 4736
N, W = [int(i) for i in input().split()]
weight = []
value = []
for i in range(N):
  w, val = [int(i) for i in input().split()]
  weight.append(w)
  value.append(val)
# changing to value max as W_max ~ 10^9 and val_max ~= 1000 * next
val_max = 0
for i in range(N):
  val_max += value[i]
dp = [float('inf') for i in range(val_max+1)] # dp[i] is the min weight required for the value 
# hence our ans would be in the max value where the weight < knapsack weight
dp[0] = 0
for i in range(N):
  for v in range(val_max-value[i], -1, -1): # range of kanpsack weight in which i can push the current item
    dp[v + value[i]] = min(dp[v + value[i]], dp[v] + weight[i])
    #print(dp)
sol = 0
for i in range(val_max+1):
  if dp[i] <= W:
    sol = i
print("%s" % sol)


Measured memory_bytes: 92496
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0;
    return 0;
  }
  int X[M];

  for (int i = 0; i < M; i++) cin >> X[i];
  sort(X, X + M, greater<int>());

  int subs[M - 1];
  int sum_move = 0;
  for (int i = 0; i < M - 1; i++) {
    subs[i] = X[i] - X[i + 1];
    sum_move += subs[i];
  }
  sort(subs, subs + M - 1, greater<int>());

  for (int i = 0; i < N - 1; i++) sum_move -= subs[i];
  cout << sum_move << endl;
  return 0;
}


Measured memory_bytes: 1024