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

long long n, x, y, cnt[2003], dist[2003][2003];
vector<long long>adjl[2003];
queue<pair<long long, long long>>bfs;

int main(){
	for (int i=0;i<2003;i++){
		for (int j=0;j<2003;j++){
			dist[i][j]=1e9;
		}
	}
	memset(cnt,0,sizeof cnt);
	cin >> n >> x >> y;
	for (int i=1;i<n;i++){
		adjl[i].push_back(i+1);
		adjl[i+1].push_back(i);
	}
	adjl[x].push_back(y);
	adjl[y].push_back(x);
	for (int i=1;i<=n;i++){
		vector<bool>visit(n+1,0);
		bfs.push({i,0});
		while(!bfs.empty()){
			long long now=bfs.front().first;
			long long distnow=bfs.front().second;
			bfs.pop();
			if (visit[now]) continue;
			visit[now]=1;
			dist[i][now]=min(dist[i][now],distnow);
			for (long long next : adjl[now]){
				bfs.push({next,distnow+1});
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			cnt[dist[i][j]]++;
		}
	}
	for (int i=1;i<n;i++) cout << cnt[i] << "\n";
}

Measured memory_bytes: 31744
from collections import deque


n, q = map(int, input().split())
process = deque()
now = 0

for _ in range(n):
    name, time = input().split()
    process.append([name, int(time)])

while process:
    task = process.popleft()
    now += min(q, task[1])
    if q < task[1]:
        process.append([task[0], task[1] - q])
    else:
        print(task[0], now)



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

int main(){
int y,x;
  	cin >> x >> y;	
  for(int i = 0; i <= x; i++){
   	if((x-i)*2+i*4==y){
      cout << "Yes" << endl;
    	return 0;
    }
    }
  cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

string s;
int k;

//桁dp
ll dp[105][2][4];
ll solve(string s){
    //fill(dp,(ll)0);
    dp[0][0][0] = 1;
    //string s = to_string(n);
    rep(i,s.size()){            //各桁について調べる
        const int D = s[i]-'0';
        rep(j,2){               //その桁がもとの数字の桁の数と一致してるかどうか
            rep(k,4){           //そのdpが4か9をもつかどうか
                rep(d,(j?10:D+1)){
                    if(d == 0)dp[i + 1][j || (d < D)][k] += dp[i][j][k];
                    if(k == 3)continue;
                    if(d != 0)dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
                }
            }
        }
    }
    return dp[s.size()][0][k] + dp[s.size()][1][k];
}

int main(){
    cin >> s >> k;
    ll res = solve(s);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define mod 1000000007
using ld = long double;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ld p[n+1];
    int i, j;
    for(i=1;i<=n;i++)
        cin >> p[i];
    ld dp[n+1][n+1];
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j] = 0;
    // dp[i][j] = dp[i-1][j] + dp[i-1][j-1]*p[i]
    dp[0][0] = 1;
    dp[1][0] = 1 - p[1];
    for(i=2;i<=n;i++)
        dp[i][0] = dp[i-1][0]*(1 - p[i]);
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            dp[i][j] = dp[i-1][j]*(1 - p[i]) + p[i]*dp[i-1][j-1];
    ld ans = 0;
    for(i=1+n/2;i<=n;i++)
        ans = ans + dp[n][i];
   // cout << dp[3][3] << '\n';
    cout << fixed << setprecision(16) << ans;
}

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

int main() {
	
	// string A, B;
	int a, b;
	
	int power[14] = { 0,13,1,2,3,4,5,6,7,8,9,10,11,12 };
	
	// cin >> A;
	// cin >> B;
	
    cin >> a;
	cin >> b;
	
	// a = std::stoi(A);
	// b = std::stoi(B);
	
	if ( a == b ) { cout << "Draw" << endl; }
	else {
		cout << ( (power[a] > power[b]) ? "Alice" : "Bob" );
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, w, i, j, sum, wt[101], val[101]; long long ans[100001];
int main ()
{
    cin >> n >> w;
    for(i = 1; i <= n; i++) cin >> wt[i] >> val[i], sum += val[i];
    for(i = 1; i <= sum; i++) ans[i] = INT_MAX;
    for(i = 1; i <= n; i++)
    {
        for(j = sum; j >= val[i]; j--)
        {
            ans[j] = min(ans[j], ans[j-val[i]]+wt[i]);
        }
    }
    for(i = sum; i > 0; i--)
    {
        if(ans[i] <= w)
        {
            cout << i << endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  string s;
  cin >> n >> s >> k;
  rep(i, n) {
    if(s[i] == s[k - 1])
      cout << s[i];
    else
      cout << '*';
  }
  cout << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

bool comb(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll x, y;
	cin >> x >> y;

	ll ans = 0;
	while (x <= y) {
		ans++;
		x *= 2;
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x,y;
  while( cin>>x>>y ) {
  	if ( x ==0 && y== 0 ) break;
  	if ( x<y ) {
  		cout<<x<<" "<<y<<endl;
  	} else {
  		cout<<y<<" "<<x<<endl;
          }
}return 0;
}

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

int main() {
    int ans=0, X, N, tmp=2e9;
    cin >> X >> N;
    vector<int> p(N);
    vector<int> a(102, 1);

    for(int i=0; i<N; i++){
	cin >> p[i];
	a[p[i]]=0;
    }
    ans = X;

    for(int i=0; i<=101; i++){
	if(tmp>abs(X-i) && a[i]==1){
	    tmp = abs(X-i);
	    ans = i;
	}
    }

    cout << ans << endl;
} 




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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll dfs(vector<vvl> &dp, vl &v, int i, int j, int t) {
	if (i > j)return 0;
	if (dp[i][j][t] != -1)return dp[i][j][t];

	if (t == 0) {
		ll ret = -INF * INF;
		ret = max(ret, dfs(dp, v, i + 1, j, 1) + v[i]);
		ret = max(ret, dfs(dp, v, i, j - 1, 1) + v[j]);
		return dp[i][j][t] = ret;
	}
	else {
		ll ret = INF * INF;
		ret = min(ret, dfs(dp, v, i + 1, j, 0) - v[i]);
		ret = min(ret, dfs(dp, v, i, j - 1, 0) - v[j]);
		return dp[i][j][t] = ret;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int  n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	vector<vvl> dp(n, vvl(n, vl(2, -1)));
	dfs(dp, v, 0, n - 1, 0);
	cout << dp[0][n - 1][0] << endl;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<vector<int>> data(k, vector<int>(n));
    vector<int> gomi(200);
    
    for (int i = 0; i < k; i++) {
        cin >> gomi.at(i);
        for (int j = 0; j < gomi.at(i); j++) {
            cin >> data.at(i).at(j);
        }
    }

    int count = 0;
    int tr = 0;
    int p = 1;
    while(p <= n)
    {
        count = 0;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < gomi.at(i); j++) {
                if(p == data.at(i).at(j))
                    count++;
            }
        }
        if(count == 0)
            tr++;
        p++;
    }
    cout << tr;
}


Measured memory_bytes: 3660
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int n;
  cin >> n;
  ll m = 0, a = 0, r = 0, c = 0, h = 0;
  rep(i, n){
    string s;
    cin >> s;
    if (s[0] == 'M') m++;
    else if (s[0] == 'A') a++;
    else if (s[0] == 'R') r++;
    else if (s[0] == 'C') c++;
    else if (s[0] == 'H') h++;
  }

  ll ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  cout << (ll)ans << endl;

}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0 for i in range(n + 1)]
        self.member = [1 for i in range(n + 1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.member[y] += self.member[x]
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.member[x] += self.member[y]
        else:
            self.par[y] = x
            self.rank[x] += 1
            self.member[x] += self.member[y]

    def size(self, x):
        return self.member[self.par[x]]

n, m = map(int, input().split())
E = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(m + 1)]
ans[-1] = n * (n - 1) // 2
tree = UnionFind(n)
for i, e in enumerate(E[::-1]):
    if tree.check(*e):
        ans[-(i + 2)] = ans[-(i + 1)]
    else:
        ans[-(i + 2)] = ans[-(i + 1)] -  tree.size(e[0]) * tree.size(e[1])
        tree.union(*e)
for a in ans[1:]:
    print(a)


Measured memory_bytes: 35780
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
  
void main() 
{
	string l;
	while((l = readln()).length >= 2)
	{
		float a, b, c, d, e, f;
		a = to!float(l.split()[0]), b = to!float(l.split()[1]), c = to!float(l.split()[2]);
		d = to!float(l.split()[3]), e = to!float(l.split()[4]), f = to!float(l.split()[5]);
		float x, y;
		y = (c * d - a * f)/(b * d - a * e)+0;
		x = (b * f - c * e)/(b * d - a * e)+0;
		writefln("%.3f %.3f" , x,y);
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   int a, b;
   cin >> a >> b;
   if(a<b) cout << "a < b" << endl;
   else if(a==b) cout << "a == b" << endl;
   else if(a>b) cout << "a > b" << endl;
   return 0;
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    cout << "a"; 
    if(a < b){
        cout << " < "; 
    }else if(a > b){
        cout << " > ";
    }else{
        cout << " == ";
    }
    cout << "b" << endl;
    return 0;
    
}

Measured memory_bytes: 3044
n = int(input())
c = 0
l = list(map(int, input().split()))
for i in range(1,n-1,1):
    m = max(l[i-1],l[i+1],l[i]); n = min(l[i-1],l[i],l[i+1])
    if l[i]!= m and l[i]!= n:
        c += 1
print(c)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define int long long 
using namespace std;
 
signed main() {
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if( U == S ) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(t*s>=d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
$h={}
def f l,n,s
s>n*100?0:n<2?1:$h[[l,n,s]]||=(l+1..[100,s].min).inject(0){|t,i|t+(i<s-i ?f(i,n-1,s-i):0)}end
p f(-1,*$_.split.map(&:to_i))while gets[0]>?0

Measured memory_bytes: 21068
use std::io;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let mut A: i32 = iter.next().unwrap().parse().unwrap();
    let mut B: i32 = iter.next().unwrap().parse().unwrap();
    if A == 1 {A+=13;}
    if B == 1 {B+=13;}
    let res = if A>B { "Alice" } else { if A<B { "Bob" } else { "Draw" } };
    println!("{}", res);
}


Measured memory_bytes: 4352
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W = in.readLine();
//						int num = Integer.parseInt(W.split(" ")[0]);

				Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();

		long ans = 0;

		long thisHeight;
		long tmpValue = 0;
		Map<Long, Integer> conditionMap = new HashMap<Long, Integer>();
		for (long i = 0; i < N; i++) {
			thisHeight = sc.nextInt();

			if (conditionMap.containsKey(i - thisHeight)) {
				tmpValue = conditionMap.get(i - thisHeight);
				ans += tmpValue;
			}
			if (conditionMap.containsKey(i + thisHeight)) {
				conditionMap.put(thisHeight + i, conditionMap.get(i + thisHeight)+1);
			} else {
				conditionMap.put(thisHeight + i, 1);
			}
		}
		System.out.println(ans);
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

}


Measured memory_bytes: 70848
from itertools import product

N = int(input())
ans = 0
for j in range(3, len(str(N))+1):
    for i in product("357", repeat=j):
        x = "".join(i)
        if 357 <= int(x) <= N and len(set(x)) == 3:
            ans += 1
print(ans)

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

int main() {
  int N;
  
  cin >> N;
  
  if ((N / 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 111) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 222) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 333) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 444) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 555) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 666) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 777) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 888) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N - 999) % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),m=sc.nextInt(),e=0;
    long[] a=new long[n],b=new long[n],c=new long[m],d=new long[m];
    long min=1000000000;
    for(int i=0;i<n;i++){
      a[i]=sc.nextLong();
      b[i]=sc.nextLong();
    }
    for(int j=0;j<m;j++){
      c[j]=sc.nextLong();
      d[j]=sc.nextLong();
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        long f=(long)Math.abs((double)(a[i]-c[j]))+(long)Math.abs((double)(b[i]-d[j]));
        if(min>f){
          e=j+1;
          min=f;
        }
      }
      System.out.println(e);
      min=1000000000;
      e=0;
    }
  }
}


Measured memory_bytes: 23892
/**
 *    author:  zjsdut
 *    created: 2020/01/20 06:26:43
**/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec) stream >> x;
  return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template<typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
  print(t);
  print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n,m;
  scan(n, m);
  println(n == m ? "Yes" : "No");
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    ll table[n][n];
    bool del[n][n];
    ll ans = 0LL;

    int i, j, k, len = n - 1;

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            cin >> table[i][j];

            del[i][j] = false;
        }
    }

    for (k = 0; k < n; k++) {
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                if (i == j || j == k || k == i) continue;

                if (table[i][k] + table[k][j] < table[i][j]) {
                    cout << -1 << '\n';

                    return 0;
                }

                if (table[i][k] + table[k][j] == table[i][j]) del[i][j] = true;
            }
        }
    }

    for (i = 0; i < len; i++) {
        for (j = i + 1; j < n; j++) {
            if (!del[i][j]) ans += table[i][j];
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, capacity) = (line[0], line[1]);
    let mut objects: Vec<Vec<u64>> = vec![vec![];4];

    let line = read_as_vec::<usize>();
    let (w, v) = (line[0], line[1] as u64);

    let mut bias = w;
    objects[0].push(v);

    for i in 1..n{
        let line = read_as_vec::<usize>();
        let (w, v) = (line[0], line[1] as u64);

        objects[w-bias].push(v);
    }

    for i in 0..4{
        objects[i].sort();
        objects[i].reverse();
    }

    let mut acc_obj: Vec<Vec<u64>> = vec![vec![];4];

    for i in 0..4{
        acc_obj[i] = vec![0;objects[i].len()+1];
    }

    for i in 0..4{
        let mut acc = 0;
        for j in 0..objects[i].len(){
            acc += objects[i][j];
            acc_obj[i][j+1] = acc;
        }
    }

    //println!("{:?}", acc_obj);
    let mut ans = 0;
    for n0 in 0..acc_obj[0].len(){
        if n0 * bias > capacity{
            continue;
        }
        for n1 in 0..acc_obj[1].len(){
            if n0* bias + n1 * (bias+1)> capacity{
                continue;
            }
            for n2 in 0..acc_obj[2].len(){
                if n0* bias + n1 * (bias+1) + n2*(bias+2) > capacity{
                    continue;
                }

                let n3 = (capacity - n0* bias - n1 * (bias+1) - n2*(bias+2))/(bias+3);
                //println!("{}, {}, {}, {}", n0, n1, n2, n3);
                if n3 >= acc_obj[3].len(){
                    ans = cmp::max(ans, acc_obj[0][n0] + acc_obj[1][n1] + acc_obj[2][n2]);
                }else{
                    ans = cmp::max(ans, acc_obj[0][n0] + acc_obj[1][n1] + acc_obj[2][n2] + acc_obj[3][n3]);
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
using namespace std;
int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if(A>=9){
        printf(":(\n");
    }
    else if(B>=9){
        printf(":(\n");
    }
    else{
        printf("Yay!\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
//char ch[100001];
void solve()
{
    string s;
    cin>>s;
    int n=s.size();
    int cr=1,cp=0;int ans=0;
    if(s[0]=='p')
    ans=-1;
    for(int i=1;i<n;i++)
    {
        if(cp==cr)
        {
            if(s[i]=='p')
            ans--;
            cr++;
        }
        else
        {
            cp++;
            if(s[i]=='g')
            ans++;
        }
        //cout<<ans<<" ";
    }
    cout<<ans<<endl;
}
int main()
{
    
    solve();
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Main {
    public static void main(String[] args) {
      // AC,TLE,WA,RE
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      N = Integer.parseInt(List[0]);
  //    System.out.println(N);
      String ce[] = new String[N];
      while(i < N){
        ce[i] = list.get(i + 1);
        i++;
      }
 //     System.out.println(ce[5]);
      check(ce,N);
   
      scan.close();
    }
  
  public static void check(String[] ce,int n){
    // AC,TLE,WA,RE
    int countA = 0, countT = 0, countW = 0, countR = 0;
   // System.out.println(n);
    int i = 0;
    while(i < n){
  //    System.out.println("ok");
      if(ce[i].equals("AC")){
        countA = countA + 1;
      }else if(ce[i].equals("TLE")){
        countT = countT + 1;
      }else if(ce[i].equals("WA")){
        countW = countW + 1;
      }else if(ce[i].equals("RE")){
        countR = countR + 1;
      }
      i++;
    }
    System.out.println("AC x "+countA);
    System.out.println("WA x "+countW);
    System.out.println("TLE x "+countT);
    System.out.println("RE x "+countR);
    return;
      }
}
    

Measured memory_bytes: 67516
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a[2222];

int main(){
	scanf("%d",&n);
	n*=2;
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int res=0;
	for(int i=0; i<n; i+=2)
		res+=a[i];
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;



int main() {

	stack<int> st;
	vector <string> vec;
	string s;


	while (cin >> s) {
		vec.push_back(s);
	}

	for (int i = 0; i < (int)vec.size(); i++) {

		if (vec[i] == "+") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			int c = a + b;
			st.push(c);
		}

		else if (vec[i] == "-") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			int c = b - a;
			st.push(c);
		}

		else if (vec[i] == "*") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			int c = a * b;
			st.push(c);
		}

		else {
			int num = stoi(vec[i]);
			st.push(num);
		}



	}

	int ans = st.top();

	cout << ans << endl;








	return 0;
}





Measured memory_bytes: 3228
#include <stdio.h>

int min(int a, int b)
{
    return a < b? a: b;
}

int main(void)
{
    int n, y;
    scanf("%d%d", &n, &y);
    //1k-yen only.
    int yen_1k = y / 1000;
    int yen_5k = 0;
    int yen_10k = 0;
    int cnt = yen_1k + yen_5k + yen_10k;
    if (cnt == n) printf("%d %d %d\n", yen_10k, yen_5k, yen_1k);
    else if (cnt < n) printf("-1 -1 -1\n");
    //1k-yen and 5k-yen.
    else {
        int dif = cnt - n;
        int y1k_2_y5k = min(dif / 4, yen_1k / 5);
        yen_5k += y1k_2_y5k;
        yen_1k -= y1k_2_y5k * 5;
        cnt = yen_1k + yen_5k + yen_10k;
        if (cnt == n) printf("%d %d %d\n", yen_10k, yen_5k, yen_1k);
        //1k-yen, 5k-yen and 10k-yen.
        else {
            dif = cnt - n;
            int y5k_2_y10k = min(dif, yen_5k / 2);
            yen_10k += y5k_2_y10k;
            yen_5k -= y5k_2_y10k * 2;
            cnt = yen_1k + yen_5k + yen_10k;
            if (cnt == n) printf("%d %d %d\n", yen_10k, yen_5k, yen_1k);
            else printf("-1 -1 -1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    Deque<Integer> deq = new ArrayDeque<>();
    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == '0'){
        deq.push(0);
      }else if(S.charAt(i) == '1'){
        deq.push(1);
      }else if(deq.size() > 0){
        deq.pop();
      }
    }
    String ans = "";
    while(deq.size() > 0){
      ans = deq.pop() + ans;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 25556
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
char c[110];
stack<char> q;
int a[5];

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d", &n);
	scanf("%s\n", c);
	string s = c;
	for(int i = 0; i < sz(s); ++i){
		if(q.empty()){
			q.push(s[i]);
			continue;
		}
		if(s[i] == '('){
			q.push(s[i]);
		}else{
			if(q.top() == '(')
				q.pop();
			else
				q.push(s[i]);
		}
	}
	while(!q.empty()){
		if(q.top() == '(')
			a[0]++;
		else
			a[1]++;
		q.pop();
	}
	for(int i = 0; i < a[1]; ++i)
		printf("(");
	printf("%s", s.c_str());
	for(int i = 0; i < a[0]; ++i)
		printf(")");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void){
    char a[10];
    char b[1000];
    int j,count;
    count=0;
    scanf("%s",a);
    for(;;){
        scanf("%s",b);
        if(strcmp(b,"END_OF_TEXT")==0) break;
        for(j=0;j<1000;j++){
            if('A'<=b[j]&&b[j]<='Z') b[j]+=32;
        }
        if(strcmp(a,b)==0) count+=1;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2052
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
int dp[1000][10000];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,k;cin>>n>>k;
  vector<int> A(n);
  for(int i = 0; n > i; i++)cin>>A[i];
  vector<int> tmp;
  int ans = 0;
  for(int i = -1; min(k,n) > i; i++){
    for(int j = n; max(min(n-k,n-n),i)< j; j--){
      //左端~i番目
      //j番目~右端
      
      int era = k-((i+1)+(n-j));
      if(era < 0)continue;
      int sm = 0;
      for(int k = 0; i >= k; k++){
        tmp.push_back(A[k]);
        sm += A[k];
      }
      for(int k = n-1; j <= k; k--){
        tmp.push_back(A[k]);
        sm += A[k];
      }
      sort(tmp.begin(),tmp.end());
      int z = 0;
      while(z < tmp.size() && z < era && tmp[z] < 0){
        sm -= tmp[z];z++;
      }
      ans = max(ans,sm);
      tmp.clear();
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int forw[505][505];
int back[505][505];
int n;
int dp[505][505];

int getf(int x, int xx, int y, int yy)
{
	if(x>xx||y>yy) return 0;
	return forw[xx][yy]-forw[x-1][yy]-forw[xx][y-1]+forw[x-1][y-1];
}

int getb(int x, int xx, int y, int yy)
{
	if(x>xx||y>yy) return 0;
	return back[xx][yy]-back[x-1][yy]-back[xx][y-1]+back[x-1][y-1];
}

signed main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<i; j++)
		{
			cin>>back[i][j];
		}
		for(int j=i+1; j<=n; j++)
		{
			cin>>forw[i][j];
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			forw[i][j]=forw[i][j]+forw[i-1][j]+forw[i][j-1]-forw[i-1][j-1];
			back[i][j]=back[i][j]+back[i-1][j]+back[i][j-1]-back[i-1][j-1];
//			cout<<forw[i][j]<<endl;
//			cout<<back[i][j]<<endl;
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=n; j++)
		{
			dp[i][j]=1000000000000000;
		}
	}
	dp[0][0]=0;
	int ans=1000000000000000;
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<i; j++)
		{
			for(int k=0; k<=j; k++)
			{
				dp[i][j]=min(dp[i][j], dp[j][k]+getf(j+1,i,j+1,i)+getb(i+1, n, k+1, j));
			}
			if(i==n)
			{
//				cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
				ans=min(ans, dp[i][j]);
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 6144
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
int H , W , h , w , ans[3];
int32_t main()
{
	cin >> H >> W >> h >> w;
	if(!(H % h) and !(W % w))
		return cout << "No" << endl , 0;
	cout << "Yes" << endl;
	ans[0] = H * W - (H / h) * h * (W / w) * w , ans[1] = (H / h) * (W / w) / ans[0] + 1 , ans[2] = -1 * (h * w - 1) * ans[1] - 1;
	for(int i = 0 ; i < H ; i ++)
			for(int j = 0 ; j < W ; j ++)
			{
				cout << (i % h == h - 1 and j % w == w - 1 ? ans[2] : ans[1]);
				if(j + 1 == W)
					cout << endl;
				else
					cout << " ";
			}
	return 0;
}



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

using namespace std;

int main(void){

    int N,K,x[N+1],ans=0;

    cin >> N >> K;

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

    for(int i = 0; i < N; i++){
        ans += min(x[i],K-x[i]);
    }

    cout << ans * 2 << "\n";

return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long long int x;
  long long int money = 100;
  long long int year = 0;
  
  scanf("%lld",&x);
  
  while(money < x){
    money = money * 1.01;
    year++;
    //printf("%lld\n",money);
  }
  
  printf("%lld\n",year);
  
  return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

vector<vector<int> > lis;
int n, m, q;
ll ans = 0;

void solve(vector<int> ch, int num){
    if(num == n){
        ll mid = 0;
        REP(i, 0, q){
            int a = lis[i][0]-1, b = lis[i][1]-1;
            if(ch[b] - ch[a] == lis[i][2]){
                mid += lis[i][3];
            }
        }
        ans = max(ans, mid);
        return;
    }else{
        REP(i, 0, m){
            ch[num] = ch[num-1] + i;
            if(ch[num] > m){
                break;
            }
            solve(ch, num+1);
        }
        return;
    }
}

int main(){
    cin >> n >> m >> q;
    lis = vector<vector<int> >(q, vector<int>(4, 0));
    REP(i, 0, q){
        cin >> lis[i][0] >> lis[i][1] >> lis[i][2] >> lis[i][3];
    }
    vector<int> ch(n, 0);
    ch[0] = 1;
    solve(ch, 1);
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

string S;
long long N, A[1000009];
long long dp[1000009][2];

int main() {
	cin >> S; N = S.size();
	for (int i = 0; i < S.size(); i++) A[N - 1 - i] = (S[i] - '0');
	for (int i = 0; i <= N + 1; i++) { dp[i][0] = (1LL << 60); dp[i][1] = (1LL << 60); }

	dp[0][0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < 2; j++) {
			if (dp[i][j] == (1LL << 60)) continue;
			for (int k = 0; k < 10; k++) {
				dp[i + 1][(j + A[i] + k) / 10] = min(dp[i + 1][(j + A[i] + k) / 10], dp[i][j] + k + ((j + A[i] + k) % 10));
			}
		}
	}

	cout << min(dp[N + 1][0], dp[N + 1][1]) << endl;
	return 0;
}

Measured memory_bytes: 24836
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll d, t, s;
		cin>>d>>t>>s;
		if(t*s>=d)
		cout<<"Yes\n";
		else
		cout<<"No\n";
		return 0;
	
	}


Measured memory_bytes: 3616
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> x(26);
		bool flag = false;
		for (int i = 1; i <= n && !flag; i++) {
			string s; cin >> s;
			x[s[0] - 65]++;
			vector<int> y = x;
			sort(y.begin(), y.end(), greater<int>());
			if (y[0] > y[1] + (n - i)) {
				int z = max_element(x.begin(), x.end()) - x.begin();
				for (int j = i + 1; j <= n; j++) cin >> s;
				cout << (char)(z + 65) << ' ' << i << endl;
				flag = true;
			}
		}
		if (!flag) cout << "TIE" << endl;
	}
}

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

int main(){
  int N, M, K;
  
  cin >> N >> M;
  
  vector<int> cnt(M);
  for(int i = 0;i < N;i++){
    cin >> K;
    for(int j = 0;j < K;j++){
      int a;
      cin >> a;
      cnt.at(a-1)++;
    }
  }
  
  int ans = 0;
  for(int i = 0;i < cnt.size();i++) if(cnt.at(i) == N) ans++;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, A, B, fa[N], fac[N], ifac[N];
vector<pii> g[N];
map<int,int> h[N], sz;
int Find(int x) {return fa[x]?fa[x]=Find(fa[x]):x;}
void add(int x, int y) {
	x=Find(x),y=Find(y);
	if (x!=y) fa[x]=y;
}

int main() {
	scanf("%d%d%d", &n, &A, &B);
	REP(i,1,n) {
		int c, w;
		scanf("%d%d",&c,&w);
		g[c].pb(pii(w,i));
	}
	REP(i,1,n) if (g[i].size()) {
		sort(g[i].begin(),g[i].end());
		for (int j=1; j<g[i].size(); ++j) {
			if (g[i][0].x+g[i][j].x<=A) {
				add(g[i][0].y,g[i][j].y);
			}
		}
	}
	int mi = 1e9, pos = 0;
	REP(i,1,n) if (g[i].size()) {
		if (g[i][0].x<mi) mi=g[i][0].x,pos=i;
	}
	REP(i,1,n) if (g[i].size()&&pos!=i) {
		for (auto t:g[i]) if (t.x+g[pos][0].x<=B) { 
			add(t.y,g[pos][0].y);
		}
	}
	int mi2 = 1e9, pos2 = 0;
	REP(i,1,n) if (g[i].size()&&i!=pos) {
		if (g[i][0].x<mi2) mi2=g[i][0].x,pos2=i;
	}
	if (pos2) {
	REP(i,1,n) if (g[i].size()&&pos2!=i) {
		for (auto t:g[i]) if (t.x+g[pos2][0].x<=B) {
			add(t.y,g[pos2][0].y);
		}
	}
	}
	fac[0] = ifac[0] = 1;
	REP(i,1,n) fac[i]=(ll)fac[i-1]*i%P,ifac[i]=inv(fac[i]);
	REP(i,1,n) for (auto j:g[i]) { 
		++h[Find(j.y)][i];
		++sz[Find(j.y)];
	}
	ll ans = 1;
	for (auto t:sz) {
		ans = ans*fac[t.y]%P;
		for (auto e:h[t.x]) { 
			ans=ans*ifac[e.y]%P;
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 98304
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

$N = input();
$array = input_array();
$array = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, $array);
echo implode(' ', $array) . "\n";
for ($i = 1, $count = count($array); $i < $count; $i++) {
    $key = $array[$i];
    $j = $i - 1;
    while ($j >= 0 && $array[$j] > $key) {
        $array[$j + 1] = $array[$j];
        $j--;
    }
    $array[$j + 1] = $key;
    echo implode(' ', $array) . "\n";
}


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

using namespace std;

int main()
{
    char a[11],b[11],c[11];
    char n,m,p,q;
    cin>>a>>b>>c;


    n=a[strlen(a)-1];
    m=b[0];
    p=b[strlen(b)-1];
    q=c[0];

    if(n==m && p==q)
    {
        cout<<"YES"<<endl;
    }
    else
    {

        cout<<"NO"<<endl;

    }



    return 0;


}

Measured memory_bytes: 256
/*
ID: duttonl1
TASK: Vacation.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int A[100005][3];

void run() {
    int n;
    cin >> n;
    fr(i,n) cin >> A[i][0] >> A[i][1] >> A[i][2];
    int a = A[0][0], b = A[0][1], c = A[0][2];
    frab(i,1,n) {
        int ta, tb, tc;
        ta = A[i][0] + max(b,c);
        tb = A[i][1] + max(a,c);
        tc = A[i][2] + max(a,b);
        a = ta; b = tb; c = tc;
    }
    cout << max(a,max(b,c)) << endl;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w,k;
    cin >> h >> w>>k;
    
    vector<vector<char>> vec(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> vec.at(i).at(j);
        }
    }
    int count =0;
    

    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            
            int subcount=0;
            
            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
                    int x=(i>>m)&1;
                    int y= (j>>n)&1;
                    if(x==0 && y==0){//これええええええええええええ
                        if(vec.at(m).at(n)=='#') {
                            subcount++;
                        }
                    }
                }
            }
            if(subcount==k){
                count++;
            }
        }
    }
    cout << count << endl;
   
}


Measured memory_bytes: 3600
#include <stdio.h>
char s[4];
int main() {
	scanf("%s", &s);
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		printf("3\n");
		return 0;
	}
	if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		printf("2\n");
		return 0;
	}
	if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		printf("1\n");
		return 0;
	}
	printf("0\n");
}

Measured memory_bytes: 1648