akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

                int N = scan.nextInt();
                long seki = 1;
                long limit = (long)Math.pow(10, 18);
                long temp;
                boolean isOver = false;
                boolean isZero = false;
                long[] A = new long[N];

                for (int i = 0; i < N; i++) {
                	A[i] = scan.nextLong();
                	if (A[i] == 0) {
                		isZero = true;
                	}
                }

                for (int i = 0; i < N; i++) {
                	temp = A[i];
                	if (limit%temp == 0) {
                		if (seki <= limit/temp) {
                			seki *= temp;
                		} else {
                			isOver = true;
                    		break;
                		}
                	} else {
                		if (seki <= limit/temp - 1) {
                			seki *= temp;
                		} else {
                			isOver = true;
                    		break;
                		}
                	}
                }

                if (isZero) {
                	System.out.println(0);
                } else if (isOver) {
                	System.out.println(-1);
                } else {
                	System.out.println(seki);
                }
        }

}

Measured memory_bytes: 61484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int H, W;
  string s;
  cin >> H >>W;
  for (int i=1; i<=H; i++) {
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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;}


int const INF = 1001001001;


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

ll n,a,b;
cin >> n >> a >> b;

if(n >= 2 && a <= b) cout << (n-2)*(b-a)+1 << endl;
else if(n == 1 && a == b) cout << 1 << endl;
else cout << 0 << endl;

return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  if (s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll h,w;
vector<string> a;

int main(){
    cin >> h >> w;
    a.resize(h);
    rep(i,h) cin >> a[i];

    map<int,int> mp;
    rep(i,h) rep(j,w) mp[a[i][j]-'a']++;

    vi cnt;
    for(auto p : mp){
        cnt.pb(p.se);
    }
    sort(all(cnt));

    if(h%2==0 and w%2==0){
        for(int v:cnt){
            if(v%4>0){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else if(h%2==1 and w%2==1){
        // NG
        int a = 0;
        int b = 0;
        for(int v :cnt){
            if(v%4==2) a++;
            if(v%4==1) b++;
        }

        if(b!=1){
            // OK
            cout << "No" << endl;
            return 0;
        }
        if(a>(w/2)+(h/2)){
            // NG
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        if(w%2==0) swap(h,w);   // h%2==0
        int a=0;
        int b=0;
        int c=0;
        for(int v : cnt){
            if(v%4==1) a++;
            if(v%4==3) b++;
            if(v%4==2) c++;
        }
        if(a>0 or b>0){
            cout << "No" << endl;
            return 0;
        }
        if(c>h/2){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int n,i;
	char s[102];
	
	scanf("%d", &n);
	scanf("%s", &s);
	
	if(n%2 != 0){
		printf("No");
		return 0;
	}
	
	for(i = 0; i < n/2; i++){
		if(s[i] != s[n/2 + i]){
			printf("No");
			return 0;
		}
	}
	
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n;
	int p,c,m=0,s[100];
	cin>>n;
	cin>>p;
	while (n!=0)//数制转换，结果存入数组s[m]
	{
		c=n%p;
		n=n/p;
		m++;s[m]=c;   //将余数按顺序存入数组s[m]中
	}
 /*
	for(int k=m;k>=1;k--)//输出转换后的序列
	{
		if(s[k]>=10) //若为十六进制等则输出相对应的字母
			cout<<(char)(s[k]+55);
		else         //否则直接输出数字
			cout<<s[k];
	}
 */
	cout<<m;
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	ll s = n * (n + 1) / 2;
	ll x, y, z;
	x = n / 3;
	y = n / 5;
	z = n / 15;
	cout << s - (3 * x * (x + 1) / 2 + 5 * y * (y + 1) / 2 - 15 * z * (z + 1) / 2);
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, fr, reizoko_n, road, start, goal;
	while (cin >> n >> fr >> reizoko_n >> road >> start >> goal, n) {
		set<int> reizoko;
		REP(i, reizoko_n) {
			int a;
			cin >> a;
			reizoko.insert(a);
		}
		vvi roadv(n, vi(n, -1));
		REP(i, road) {
			int x, y, t;
			cin >> x >> y >> t;
			roadv[x][y] = t;
			roadv[y][x] = t;
		}
		int clear = -1;
		vvi G(n, vi(101, 1e9));
		G[start][fr] = 0;
		priority_queue<pair<pii, int>> Q;
		Q.push({ {0,fr}, start });
		while (!Q.empty()) {
			pair<pii, int> q = Q.top();Q.pop();
			q.first.first *= -1;
			if (q.second == goal) {
				clear = q.first.first;
				break;
			}
			REP(i, n)
				if (roadv[q.second][i] != -1 && q.first.second - roadv[q.second][i] >= 0) {
					if (G[i][q.first.second - roadv[q.second][i]] > q.first.first + roadv[q.second][i]) {
						G[i][q.first.second - roadv[q.second][i]] = q.first.first + roadv[q.second][i];
						Q.push({ {-q.first.first - roadv[q.second][i],q.first.second - roadv[q.second][i] }, i });
						if (EXIST(reizoko, i))
							for (int j = 1;roadv[q.second][i], q.first.second - roadv[q.second][i] + j <= fr;j++) {
								if (G[i][q.first.second - roadv[q.second][i] + j] > q.first.first + roadv[q.second][i] + j) {
									G[i][q.first.second - roadv[q.second][i] + j] = q.first.first + roadv[q.second][i] + j;
									Q.push({ { -q.first.first - roadv[q.second][i] - j,q.first.second - roadv[q.second][i] + j }, i });
								}
							}
					}
				}
		}
		if (clear != -1)
			cout << clear << endl;
		else
			cout << "Help!" << endl;
	}
}

Measured memory_bytes: 3264
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n,n){
		priority_queue<pii> data;
		for(int i =0;i < n;i++){
			int p,d1,d2;
			cin>>p>>d1>>d2;
			data.push(pii(d1+d2,p));
		}
		cout <<data.top().second<<" "<<data.top().first<<endl;
		//cout <<data.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    double N,X,sum;
    sum = 0;
    cin >> N;
     rep(i, N) {
        cin >> X;
        sum += 1 / X;
    }
     cout << 1 / sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline void selectionSort(vi a, int n) {
	int cnt = 0;
	rep(i, 0, n) {
		int minj = i;
		rep(j, i, n) {
			if(a[j] < a[minj]) minj = j;
		}
		if(i != minj) {
			swap(a[i], a[minj]);
			++cnt;
		}
	}
	rep(i, 0, n) cout << a[i] << (i + 1 == n ? "\n" : " ");
	P(cnt);
}
int main() {
	int n; cin >> n;
	vi v(n); rep(i, 0, n) cin >> v[i];
	selectionSort(v, n);
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,p=0;;
    cin>>n;
    if(n==1)
    p=1;
    else if(n==2)
    p=8;
    else
    p=n*n*n;
    
    cout<<p<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
            a: u32,
            s: chars,
        }
    
    let s: String = s.iter().cloned().collect();
    let s: &str = &s;

    println!("{}", if a < 3200 { "red" } else { s } );
}

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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

using namespace atcoder;

typedef struct UnionFindTree {
    vector<int> par;

    UnionFindTree(int n) { par.resize(n, -1); }

    bool is_root(int x) { return par[x] < 0; }

    int find(int x) {
        if (is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x) { return -par[find(x)]; }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

int main() {
    int n;
    scanf("%d", &n);
    int y_id[n + 1];
    pii p[n];
    rep(i, n) {
        scanf("%d%d", &p[i].fi, &p[i].se);
        y_id[p[i].se] = i;
    }
    sort(p, p + n);
    UF uf(n);
    set<int> S;
    rep(i, n) {
        int tmp = p[i].se;
        while (!S.empty() && *S.begin() < p[i].se) {
            chmin(tmp, *S.begin());
            uf.unite(y_id[*S.begin()], y_id[p[i].se]);
            S.erase(S.begin());
        }
        S.insert(tmp);
    }
    rep(i, n) printf("%d\n", uf.size(i));
}

Measured memory_bytes: 11276
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int num;

int main(){
	string n;
	cin >> n;
	rep(i,n.length()){
		num+=atoi(n.substr(i,1).c_str());
		num%=9;
	}
	if(num==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int na,nb,n;
  scanf("%d%d%d",&na,&nb,&n);
  vi a(na), b(nb);
  cin>>a>>b;
  int ans = INF;
  rep(i,n) {
    int s,t,x;
    scanf("%d%d%d",&s,&t,&x);
    --s; --t;
    mins(ans, a[s]+b[t]-x);
  }
  sort(rng(a));
  sort(rng(b));
  mins(ans, a[0]+b[0]);
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define fi first
#define se second

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

const int N = 1e3 + 50;
const int mod = 1e9 + 7;
int n, m;
vector<string> grid(N);
vector<vi> path(N, vi(N, 0));

int main()
{
	fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n >> m;

	for (int i = 0; i < n; i++) cin >> grid[i];

	path[0][0] = 1;

	for (int i = 0; i < n; i++)
	{
		if (grid[i][0] == '#') break;
		path[i][0] = 1;
	}

	for (int i = 0; i < m; i++)
	{
		if (grid[0][i] == '#') break;
		path[0][i] = 1;
	}

	for (int i = 1; i < n; i++)	
	{
		for (int j = 1; j < m; j++)
		{
			if (grid[i][j] == '#') continue;
			path[i][j] = (path[i - 1][j] + path[i][j - 1]) % mod;
		}
	}

	cout << path[n - 1][m - 1];

	return 0;

}

Measured memory_bytes: 9020
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    int A,B;
    cin >> A >> B;
    cout << (gcd(A,B)==A ? A+B : B-A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N, a, p{}, q{};
  cin >> N;
  while(cin >> a) {
    if (a % 4 == 0) ++p;
    else if (a % 2) ++q;
  }
  cout << (q <= p + !(N-p-q) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    VEC(Pii) ops;
    
    int mxi = max_element(ALL(A)) - BEGIN(A);
    int mni = min_element(ALL(A)) - BEGIN(A);

    if (A[mxi] + A[mni] >= 0) {
        FOR(i, 0, N) if (i != mxi) {
            ops.PB(Pii(mxi, i));
            A[i] += A[mxi];
        }

        // all A are non-negative.
        int besti = 0;
        FOR(i, 1, N) {
            if (A[i] < A[besti]) {
                A[i] += A[besti];
                ops.PB(Pii(besti, i));
            }

            if (A[i] > A[besti])
                besti = i;
        }
    } else {
        FOR(i, 0, N) if (i != mni) {
            ops.PB(Pii(mni, i));
            A[i] += A[mni];
        }

        // all A are negative.
        int worsti = N - 1;
        FORD(i, N - 2, -1) {
            if (A[i] > A[worsti]) {
                A[i] += A[worsti];
                ops.PB(Pii(worsti, i));
            }

            if (A[i] < A[worsti])
                worsti = i;
        }
    }

    cout << SZ(ops) << endl;
    FOR(i, 0, SZ(ops))
        cout << (ops[i].FIR + 1) << " " << (ops[i].SEC + 1) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

//int checker[4];
//int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	//int check[4];
	State() {}
	//	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		/*
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
		*/
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;
/*
inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}
*/
inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}
	/*
		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}
	*/
		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		//ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			//copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
				/*
					if ( check( i ) ) {
						ncopy();
						add(i);
						*/
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
//					}
				}
			}
		}
	}
}

Measured memory_bytes: 31000
class Node:
    def __init__(self):
        self.c = []
        self.p = -1
        self.sib = -1

def main():
    n = int(input())
    t = [Node() for _ in range(n)]
    for _ in range(n):
        a,b,c = map(int,input().split())
        t[a].c = [b,c]
        if b!=-1:
            t[b].p = a
            t[b].sib = c
        if c!=-1:
            t[c].p = a
            t[c].sib = b

    def depth(i):
        res = 0
        while t[i].p!=-1:
            i = t[i].p
            res+=1
        return res

    def height(i):
        res = 0
        if t[i].c[0]!=-1:res = max(res,height(t[i].c[0])+1)
        if t[i].c[1]!=-1:res = max(res,height(t[i].c[1])+1)
        return res

    for i in range(n):
        print ('node %d: parent = %d, sibling = %d, degree = %d, '%(i, t[i].p, t[i].sib, 2-t[i].c.count(-1)),end='')
        print ('depth = %d, height = %d, '%(depth(i),height(i)),end='')
        if t[i].p==-1           :print ('root')
        elif t[i].c.count(-1)==2:print ('leaf')
        else                    :print ('internal node')


if __name__ == '__main__':
    main()




Measured memory_bytes: 5620
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BRACK 2

int **matrix;
int *color;
int *disc;
int *fin;
int n;
int time;

void dps(void);
void visit(int);


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

  scanf("%d",&n);
  
  color = malloc((n+1) * sizeof(int));
  disc = malloc((n+1) * sizeof(int));
  fin = malloc((n+1) * sizeof(int));
  
  matrix = malloc((n+1) * sizeof(int *));
  for(i=0;i<n+1;i++) matrix[i] = malloc((n+1) * sizeof(int));
  
  
  for(i=1;i<n+1;i++)
    for(j=1;j<n+1;j++)
      matrix[i][j] = 0;
  
  
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      matrix[u][v] = 1;
    }
  }
  
  dps();

  for(i=1;i<n+1;i++) printf("%d %d %d\n",i,disc[i],fin[i]);

  free(matrix);

  return 0;
}

void dps(){
  int i;

  for(i=1;i<n+1;i++) color[i] = WHITE;
  time = 0;

  for(i=1;i<n+1;i++)
    if(color[i] == WHITE ) visit(i);
}

void visit(int u){
  int i;

  color[u] = GRAY;
  disc[u] = ++time;

  for(i=1;i<n+1;i++)
    if(matrix[u][i] == 1 && color[i] ==  WHITE ) visit(i);

  color[u] = BRACK;
  fin[u] = ++time;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc126_d
import collections


N = int(input())
triples = [tuple(map(int, input().split())) for _ in range(N - 1)]

connected = collections.defaultdict(list)
for (a, b, _) in triples:
    connected[a].append(b)
    connected[b].append(a)

dist = dict()
for (u, v, d) in triples:
    dist[u, v] = d
    dist[v, u] = d

ini, _, _ = triples[0]
stack = [ini]
color = dict()
color[ini] = False

while stack:
    state = stack.pop()
    for new_state in connected[state]:
        if new_state not in color:
            d = dist[state, new_state]
            color[new_state] = color[state] if d % 2 == 0 else (not color[state])
            stack.append(new_state)


for i in sorted(color):
    print(int(color[i]))


Measured memory_bytes: 75488
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
         
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[] imos = new int[n+1];
        
        for(int i=0;i<m;i++){
        	imos[sc.nextInt()-1] += 1;
        	imos[sc.nextInt()] -= 1;
        }
        
        for(int i=0;i<n;i++){
        	imos[i+1] += imos[i];
        }
        
        int ans =0;
        for(int i=0;i<n;i++){
        	if(imos[i] == m){
        		ans += 1;
        	}
        }
        
        System.out.println(ans);
    }
	
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main(){
  long long int n,k;
  cin >> n >> k;
  vector<long long int> a(n);
  rep(i, n, 0) cin >> a[i];
  
  long long int ans = 0, x, y;
  x = k*(k+1)/2;
  y = k*(k-1)/2;
  rep(i, n, 0){
    rep(j, n, i+1){
      if(a[i] > a[j]) ans += x;
      ans %= mod;
      if(a[i] < a[j]) ans += y;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int64_t K, ans = 0;
  cin >> K;
  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        ans += __gcd(__gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <iomanip>
using namespace std;

struct Point { double x, y; };

void koch(int n, Point a, Point b){
    if(n == 0) return;
    Point s,t,u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2*a.x + b.x)/3;
    s.y = (2*a.y + b.y)/3;
    t.x = (a.x + 2*b.x)/3;
    t.y = (a.y + 2*b.y)/3;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    koch(n-1, a, s);
    cout << fixed << setprecision(8) << s.x << " " << s.y << endl;
    koch(n-1, s, u);
    cout << fixed << setprecision(8) << u.x << " " << u.y << endl;
    koch(n-1, u, t);
    cout << fixed << setprecision(8) << t.x << " " << t.y << endl;;
    koch(n-1, t, b);    
    }    

int main()
{
    Point a, b;
    a.x = 0.0; a.y = 0.0;
    b.x = 100.0; b.y = 0.0;
    int n;
    cin >> n;
    cout << fixed << setprecision(8) << 0.0 << " " << 0.0 << endl;;
    koch(n, a, b);
    cout << fixed << setprecision(8) << 100.0 << " " << 0.0 << endl;;
    return 0;
}



Measured memory_bytes: 3276
//
// Created by user on 3/9/2020.
//
#include <bits/stdc++.h>
using namespace std;
struct Struct{
    int index;
    int F;
    char c;
};
int main() {
    ios_base :: sync_with_stdio(0); cin.tie(0);
    string String;
    cin >> String;
    int q;
    cin >> q;
    vector<Struct> operationT2;
    vector<int> operationT1;
    int reverseOriginalString = 0;
    for (int i = 1; i <= q; ++i) {
        int T;
        cin >> T;
        if (T == 1) {
            ++reverseOriginalString;
            operationT1.emplace_back(i);
        }
        if (T == 2) {
            int F;
            char c;
            cin >> F >> c;
            Struct tempStruct;
            tempStruct.index = i;
            tempStruct.F = F;
            tempStruct.c = c;
            operationT2.emplace_back(tempStruct);
        }
    }
    if (reverseOriginalString % 2 == 1) {
        reverse(String.begin(), String.end());
    }
    string beforeString = "", afterString = "";
    operationT1.emplace_back(2e9);
    for (int i = 0, j = 0; i < operationT2.size(); ++i) {
        if (operationT1.size() - 1 > 0) {
            while (operationT2[i].index > operationT1[j]) {
                ++j;
            }
        }
        int countReverse = operationT1.size() - 1 - j;
        //cout << countReverse << '\n';
        //cout << operationT2[i].F << " " << operationT2[i].c << " " << operationT2[i].countReverse << '\n';
        if (operationT2[i].F == 1) {
            if (countReverse % 2 == 0) {
                beforeString = operationT2[i].c + beforeString;
            } else {
                afterString += operationT2[i].c;
            }
        } else {
            if (countReverse % 2 == 0) {
                afterString += operationT2[i].c;
            } else {
                beforeString = operationT2[i].c + beforeString;
            }
        }
    }
    cout << beforeString + String + afterString;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> a(n);

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


    sort(a.begin(), a.end());
    int maxv = a[n - 1];
    std::vector<int> check(maxv + 1, 0);
    int out = 0;
    for (int i = 0; i < n; i++) {
        int now = a[i];
        if (check[now] == 1) {
            continue;
        }
        for (int j = 2 * now; j <= maxv; j += now) {
            check[j] = 1;
        }
    }
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            check[a[i]] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        if (check[a[i]] == 0) {
            if (i == n - 1 || a[i] != a[i + 1]) {
                out++;
            }
        }
    }
    cout << out << endl;


    return 0;
}

Measured memory_bytes: 12640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

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

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

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    string S,T;
    cin >> S >> T;
    int ret = Inf;
    for(int i = 0;i < S.size() - T.size() + 1;i++) {
        int cnt = 0;
        for(int j = 0;j < T.size();j++) {
            if(S.at(i + j) != T.at(j)) {
                cnt++;
            }
        }
        chmin(ret,cnt);
    }
    cout << ret << endl;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const long long INF  = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    bool ans = false;
    int cnt =0 ;
    for(int i=0;i<n;i++)
    {
        int d1,d2;
        cin>>d1>>d2;
        if(d1==d2)
            cnt++;
        else
        {
            cnt =0 ;
        }
        //debug(i,cnt);
        if(cnt>=3)
            ans = true;
        
        
    }
    if(ans)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}
//https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 3664
#include <stdio.h>

int main(void){
	int n, d, x, i, j, cho, count;
	int a[100];

	scanf("%d", &n);
	scanf("%d %d", &d, &x);
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
//	printf("%d %d %d\n", n, d, x);

	cho = 0;
	for(i=0; i<n; i++){
		j = 0;
		count = 0;
		while(a[i]*j+1<=d){
			j++;
		//	printf("pacpac  %d\n", j);
		}
		cho += j;
	}
	cho += x;
	printf("%d\n", cho);

	return 0;
}


Measured memory_bytes: 128
//
// Created by HandwerSTD.
// Copyright (c) 2019 HandwerSTD. All rights reserved.
//
// sto Qingyu orz
// 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴，
// 使其天天爆零
// 我不由自主地膜拜真神sqy。
//

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>

#define FILE_IN(__fname) freopen(__fname, "r", stdin)
#define FILE_OUT(__fname) freopen(__fname, "w", stdout)
#define rap(a,s,t,i) for (int a = s; a <= t; a += i)
#define down(a,t,s,i) for (int a = t; a >= s; a -= i)
#define IMPROVE_IO() std::ios::sync_with_stdio(false)

using std::cin;
using std::cout;
using std::endl;

typedef long long int lli;

int getint() { int x; scanf("%d", &x); return x; }
lli getll() { long long int x; scanf("%lld", &x); return x; }

int n, m;

int main() {
    n = getint(); m = getint();
    if (n <= 9 && m <= 9) printf("%d\n", n * m);
    else printf("-1\n");
    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.math;

void main(){
	auto ip = readln.split.to!(int[]);
	if(ip[0] * ip[1] < ip[2] * ip[3]){
		writeln(ip[2] * ip[3]);
	} else if(ip[0] * ip[1] > ip[2] * ip[3]){
		writeln(ip[0] * ip[1]);
	} else {
		writeln(ip[2] * ip[3]);
	}
}

Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)

t=n-1
ans=0
for i in range(n):
    lim=2
    if(i==0):lim=1
    for j in range(lim):
        if(t>0):
            ans+=a[i]
            t-=1
print(ans)

Measured memory_bytes: 105432
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	ll maxi = -1;
	rep(i,n) {
		cin >> a[i];
		chmax(maxi,a[i]);
	}
	ll times = 0;
	while(maxi > 0) {
		maxi /= 2;
		times++;
	}
	ll sum = 0;
	ll hoge[80][2];
	memset(hoge, 0, sizeof(hoge));
	rep(i,n) {
		ll t = a[i];
		int j=0;
		while(j < times) {
			if(t & 1) hoge[j][1]++;
			else hoge[j][0]++;
			t /= 2;
			j++;
		}
	}
	ll fuga = 1;
	rep(i,times) {
		//cout << i << " " <<  hoge[i][0] << " " << hoge[i][1] << endl;
		ll temp = 1;
		temp *= fuga;
		temp %= MOD;
		temp *= hoge[i][0];
		temp %= MOD;
		temp *= hoge[i][1];
		temp %= MOD;
		sum += temp;
		sum %= MOD;
		fuga *= 2;
		fuga %= MOD;
	}
	cout << sum << endl;
	/*rep(i,n-1) {
		for(int j=i+1; j<=n-1; j++) {
			sum += a[i] ^ a[j];
			sum %= MOD;
		}
	}*/
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
 
int main(){
  int n;
  int ans = 0;
  cin >> n;
  rep1(i,n){
    ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int main()
{
       int x, y, z, t;
 
       scanf("%d %d %d", &x, &y, &z);
 
       t = x;
       x = z;
       z = y;
       y = t;
       printf("%d %d %d\n", x, y, z);
 
 
 
       return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define mark -10
int H;
int s[2000000];

void maxheapfy(int i){
     int left = 2*i;
    int right = 2*i +1;
    int largest;
    if(s[i]<s[right] && right<=H) largest = right;
    else largest = i;
    if(s[left]>s[largest] && left<=H ) largest = left;
    
    if(largest != i){
        int tmp = s[largest];
        s[largest] = s[i];
        s[i] = tmp;
        maxheapfy(largest);
    }
    
}

void increasekey(int i,int key){
    if(key<s[i])return;
    s[i] = key;
    while(i>1 && s[i/2]<s[i] ){
        int tmp = s[i];
        s[i] = s[i/2];
        s[i/2] = tmp;
        i = i/2;
    }
    
}
void insert(int a){
    H++;
    s[H] = mark;
    increasekey(H,a);
}

int extract(){
    int maxkey;
    if(H<1)return mark;
    maxkey = s[1];
    s[1] = s[H--];
    maxheapfy(1);
    return maxkey;
    
}
int main(){
    // Your code here!
    int i,k;
    char com[20];
    

   while(1){
        scanf("%s",com);
        if(com[0]=='i'){scanf("%d",&k);
            insert(k);
        }
        if(com[1]=='x'){
        int ex =    extract();
        printf("%d\n",ex);
        }
        if(com[2]=='d'){
            
            break;
        }
        
    }
 
    
}


Measured memory_bytes: 5644