akhauriyash/Code-Regression huggingface dataset:
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> II;
typedef pair<LL, II> LII;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		const LL MAX = 1LL << 60;
		const int MAX_SILVER = 2500;
		int n = -1, m, s;
		cin >> n >> m >> s;
		if (n < 0) return 0;
		vector<vector<int>> edge(n);
		vector<vector<int>> fare(n);
		vector<vector<int>> dist(n);
		vector<int> rate(n);
		vector<int> time(n);
		vector<vector<LL>> mincost(n, vector<LL>(2501, MAX));
		for (int i = 0; i < m; ++i) {
			int u, v, a, b;
			cin >> u >> v >> a >> b;
			--u, --v;
			edge[u].push_back(v);
			edge[v].push_back(u);
			fare[u].push_back(a);
			fare[v].push_back(a);
			dist[u].push_back(b);
			dist[v].push_back(b);
		}
		for (int i = 0; i < n; ++i) {
			cin >> rate[i] >> time[i];
		}
		priority_queue<LII, vector<LII>, greater<>> q;
		auto push = [&](int pos, int silver, LL cost) {
			for (; ; silver += rate[pos], cost += time[pos]) {
				silver = min(silver, MAX_SILVER);
				if (cost < mincost[pos][silver]) {
					mincost[pos][silver] = cost;
					q.emplace(make_pair(cost, make_pair(silver, pos)));
				}
				if (silver >= MAX_SILVER) break;
			}
		};
		vector<LL> ans(n, MAX);
		push(0, s, 0);
		while (!q.empty()) {
			LII top = q.top();
			q.pop();
			LL cost = top.first;
			int silver = top.second.first;
			int pos = top.second.second;
			if (cost > mincost[pos][silver]) continue;
			ans[pos] = min(ans[pos], cost);
			for (size_t i = 0; i < edge[pos].size(); ++i) {
				if (silver >= fare[pos][i]) {
					push(edge[pos][i], silver - fare[pos][i], cost + dist[pos][i]);
				}
			}
		}
		for (int i = 1; i < n; ++i) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 69080
#include <iostream>

using namespace std;

int main() {
  constexpr char v[] = {'a', 'e', 'i', 'o', 'u'};

  char c;
  cin >> c;
  for (char e : v) {
    if (c == e) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  char s[H][W];
  REP(h,H)REP(w,W)cin>>s[h][w];
  int t=1;
  int fh=H;
  int ans[H][W];
  REP(h,H){
    bool f=false;
    REP(w,W)if(s[h][w]=='#')f=true;
    if(f){
      if(fh==H)fh=h;
      bool g=false;
      REP(w,W){
        if(s[h][w]=='#'){
          if(g)t++;
          else g=true;
        }
        ans[h][w]=t;
      }
      t++;
    }else{
      if(fh<H)REP(w,W)ans[h][w]=ans[h-1][w];
    }
  }
  for(int h=fh-1;h>=0;h--){
    REP(w,W)ans[h][w]=ans[h+1][w];
  }
  REP(h,H){
    REP(w,W)cout<<ans[h][w]<<" ";
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll h=in(),w=in(),k=in();
    vector<string>c(h);
    ll ans=0;
    for(ll i=0;i<h;++i)cin>>c[i];
    for(ll i=0;i<1<<h;++i){
        for(ll j=0;j<1<<w;++j){
            auto cc=c;
            for(ll ii=0;ii<h;++ii){
                if(i&(1<<ii)){
                    cc[ii]=string(w,'R');
                }
            }
            for(ll jj=0;jj<w;++jj){
                if(j&(1<<jj)){
                    for(ll ii=0;ii<h;++ii){
                        cc[ii][jj]='R';
                    }
                }
            }
            ll cnt=0;
            for(ll ii=0;ii<h;++ii)cnt+=count(cc[ii].begin(),cc[ii].end(),'#');
            if(cnt==k)++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

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

int main(void){
    int N;
    scanf("%d", &N);

    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;

    char S[5];

    rep(i,N){
        scanf("%s", S);
        if(!strcmp(S, "AC")) AC++;
        if(!strcmp(S, "WA")) WA++;
        if(!strcmp(S, "TLE")) TLE++;
        if(!strcmp(S, "RE")) RE++;
    }

    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);

    return 0;
}

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

int N, W;
vector<int> value(101, 0);
vector<int> weight(101, 0);
vector<int> dp(10001, -1);
 
int main(void){
	
	cin >> N >> W;
	for(int i = 0; i < N; ++i) cin >> value[i] >> weight[i];
	
	dp[0] = 0;
    for(int w = 0; w < W; ++w){
        if(~dp[w]){
            for(int i = 0; i < N; ++i){
                if(w + weight[i] <= W) dp[w + weight[i]] = max(dp[w + weight[i]], dp[w] + value[i]);
            }
        }
    }
	
	int ans = 0;
	for(int w = 0; w <= W; ++w) ans = max(ans, dp[w]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

struct intr {
	int a, b;
	intr() {
		a = b = 1;
	}
	intr(int x) {
		a = x; b = 1;
	}
	intr(int x, int y) {
		a = x; b = y;
	}
	bool operator<(const intr &r)const {
		return a * r.b < b*r.a;
	}
	bool operator!=(const intr &r)const {
		return a * r.b != b * r.a;
	}
};
int cnt[50];
int t[50],c[50];
typedef pair<intr, int> speP;
bool comp(int i, int j) {
	return t[i] < t[j];
}
bool comp2(speP x, speP y) {
	if (x.first != y.first)return x.first < y.first;
	return t[x.second] < t[y.second];
}
void solve() {
	int n;
	while (cin >> n, n) {
		fill(cnt, cnt + n, 0);
		rep(i, n) {
			cin >> t[i] >> c[i];
		}
		vector<speP> lane[2],coplane[2];
		vector<int> fin[2],cop[2];
		rep(i, n) {
			fin[0].push_back(i);
		}
		int num = n; int tmp = 0;
		while (num) {
			tmp++;
			rep(j, 2) {
				cop[j].clear(); coplane[j].clear();
			}
			rep(j, 2) {
				intr ma(1,1);
				sort(lane[j].begin(), lane[j].end(),comp2);
				per(i, lane[j].size()) {
					speP p = lane[j][i];
					int id = p.second;
					intr r = p.first;
					r.a++;
					if (ma < r) {
						r = ma;
					}
					if (r.a == r.b) {
						if (j == 1) {
							cnt[id]++;
							if (cnt[id] == c[id]) {
								num--; continue;
							}
						}
						cop[j ^ 1].push_back(id);
					}
					else {
						coplane[j].push_back({ r,id });
					}
					ma = r;
				}
				sort(fin[j].begin(), fin[j].end(), comp);
				rep(i, fin[j].size()) {
					int id = fin[j][i];
					intr r(1, t[id]);
					if (ma < r)r = ma;
					if (r.a == r.b) {
						if (j == 1) {
							cnt[id]++;
							if (cnt[id] == c[id]) {
								num--; continue;
							}
						}
						cop[j ^ 1].push_back(id);
					}
					else {
						coplane[j].push_back({ r,id });
					}
				}
			}
			rep(j, 2)fin[j] = cop[j];
			rep(j, 2)lane[j] = coplane[j];
		}
		cout << tmp << endl;
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int rec[26];
int main()
{
    int H,W;
    scanf("%d %d",&H,&W);
    int two = 0,four = 0,one = 0;
    for(int i = 0; i < H/2; ++i)
        for(int j = 0; j < W/2; ++j)
            ++four;

    if(H&1 && W&1)
        two = two + H/2 + W/2;
    else if(H&1)
        two += W/2;
    else if(W&1)
        two += H/2;

    if(H&1 && W&1)
        one = 1;
    char ch;
    for(int i = 0; i < H; ++i)
    {
        for(int j = 0; j < W; ++j)
        {
            scanf(" %c",&ch);
            rec[ch-'a']++;
        }
    }

    for(int i = 0; i < 26; ++i)
    {
        while(rec[i] >= 4 && four > 0)
        {
            rec[i] -= 4;
            four--;
        }
    }
    if(four != 0)
    {
        printf("No\n");
        return 0;
    }
    for(int i = 0; i < 26; ++i)
    {
        while(rec[i] >= 2 && two > 0)
        {
            rec[i] -= 2;
            two--;
        }
    }
    if(two != 0)
    {
        printf("No\n");
        return 0;
    }

    int sum = accumulate(rec,rec+26,0);
    if(H&1 && W&1 && sum == 1)
        printf("Yes\n");
    else if(H&1 && W&1 && sum != -1)
        printf("No\n");
    else if(sum == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i)
{
    return i % 2;
}

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b)
{
    return __gcd(a, b);
}
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f)
{
    if (f)
        printf("Yes\n");
    else
        printf("No\n");
}
void YES_NO(bool f)
{
    if (f)
        printf("YES\n");
    else
        printf("NO\n");
}

template <typename T>
void deb1(T x)
{
    cout << x << "\n";
}

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
//-------------------ここから回答する-----------------------

void solve(void)
{
    int x;
    cin >> x;
    cout << (x + 1) % 2 << endl;
}
int main(void) { solve(); }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

ll esq[200005], dir[200005], val[200005];
ll tree[800005], lazy[800005];
vector<ii> adj[200005];

ll left(ll u){return (u << 1);}
ll right(ll u){return (u << 1) + 1;}

void push(ll u, ll L, ll R){
    if(lazy[u]) tree[u] += lazy[u];
    if(L != R){
        lazy[left(u)] += lazy[u];
        lazy[right(u)] += lazy[u];
    }
    lazy[u] = 0;
}

void update(ll u, ll L, ll R, ll i, ll j, ll x){
    push(u, L, R);
    if(R < i || L > j) return;
    if(L >= i and R <= j){
        lazy[u] += x;
        push(u, L, R);
        return;
    }
    ll mid = (L+R)/2;
    update(left(u), L, mid, i, j, x);
    update(right(u), mid+1, R, i, j, x);
    tree[u] = max(tree[left(u)], tree[right(u)]);
}

ll query(ll u, ll L, ll R, ll i, ll j){
    push(u, L, R);
    if(R < i || L > j) return -1e18;
    if(L >= i and R <= j) return tree[u];
    ll mid = (L+R)/2;
    ll r1 = query(left(u), L, mid, i, j);
    ll r2 = query(right(u), mid+1, R, i, j);
    return max(r1,r2);
}

int main(){
    ll n, m; cin >> n >> m;
    for(ll i = 0; i < m; i++){
        cin >> esq[i] >> dir[i] >> val[i];
        adj[dir[i]].push_back({esq[i], val[i]});
    }
    //update(1, 1, n, 1, n, -1e7);
    for(ll i = 1; i <= n; i++){
        ll x = query(1, 1, n, 1, n);
        //cout << i << " = " << x << endl;
        update(1, 1, n, i, i, x);
        //prllf("update %d %d %d %d %d %d\n", 1, 1, n, i, i, x);
        for(ii par : adj[i]){
            update(1, 1, n, par.first, i, par.second);
            //prllf("update %d %d %d %d %d %d\n", 1, 1, n, par.first, i, par.second);
        }
    }
    
    ll res = 0;
    for(int i = 1; i <= n; i++) res = max(res, query(1, 1, n, i, i));
    cout << res << endl;
    return 0;
}

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

int main(){
 
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    vector<int> a(m);
    for(int i=0;i<m;i++){
      cin>>a[i];
    }
    int f=0;
    for(int j=0;j<m;j++){
      f+=a[j]*b[j];
    }
    if((f+c)>0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, a=0, w=0, t=0, r=0;
  	cin>>n;
  	string s[n];
  	for(int i=0; i<n; i++)
    {
    	cin>>s[i];
      	if(s[i]=="AC")
        {
          a++;
        }
      	else if(s[i]=="WA")
        {
          w++;
        }
      	else if(s[i]=="TLE")
        {
          t++;
        }
      	else if(s[i]=="RE")
        {
          r++;
        }
    }
  	cout<<"AC x "<<a<<"\n";
  	cout<<"WA x "<<w<<"\n";
  	cout<<"TLE x "<<t<<"\n";
  	cout<<"RE x "<<r<<"\n";

}


Measured memory_bytes: 6752
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	using Query = tuple<int, int, int, int>;
	auto e = vector<Query>(q);
	for(auto&& ee : e){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		ee = tie(a, b, c, d);
	}
	auto s = vector<int>(n + 1);
	auto rec = [&](auto rec, int i, int p) -> int {
		int res = 0;
		if(i > n){
			int sum = 0;
			for(int j = 0; j < q; ++j){
				int a, b, c, d;
				tie(a, b, c, d) = e[j];
				if(s[b] - s[a] == c) sum += d;
			}
			return sum;
		}
		for(int j = p; j <= m; ++j){
			s[i] = j;
			res = max(res, rec(rec, i + 1, j));
		}
		return res;
	};
	cout << rec(rec, 1, 1) << endl;
	return 0;
}

Measured memory_bytes: 3624
//package abc178;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());
		
		System.out.println(1-x);	
	}
}


Measured memory_bytes: 32700
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

using P = pair<int, int>;

int N, M;
int main()
{
  cin >> N >> M;
  vector<P> p(M);
  REP(i, M)
  cin >> p[i].first >> p[i].second;
  REP(x, 1000)
  {
    int keta = 1;
    int nx = x / 10;
    vector<int> d(1, x % 10);
    while (nx)
    {
      keta++;
      d.push_back(nx % 10);
      nx /= 10;
    }
    if (keta != N)
      continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    REP(i, M)
    {
      if (d[p[i].first - 1] != p[i].second)
        ok = false;
    }
    if (ok)
    {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, k = MII()
    aa = MIIZ()
    idx = [-1]*n
    next_t = 0
    idx[next_t] = next_t
    visit = [0]
    loop_flag = False
    for i in range(k):
        next_t = aa[next_t]
        visit.append(next_t)
        if idx[next_t] == -1:
            idx[next_t] = i+1
        else:
            loop_flag = True
            break
    if loop_flag:
        l = visit.index(visit[-1])
        loop = visit[l:-1]
        i = (k-l)%len(loop)
        print(loop[i]+1)
    else:
        print(visit[-1]+1)


if __name__ == '__main__':
    main()

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

int main(){
  int a,b,c; cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;

  return 0;
 }

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

template<typename T>
T gcd(T p, T q)
{
	while(q != 0)
	{
		T temp = p % q;
		p = q;
		q = temp;
	}

	return p;
}

template<typename T>
T lcm(T p, T q)
{
	return p / gcd(p, q) * q;
}

int main()
{
	unsigned long long a, b;
	while(cin >> a >> b)
		cout << gcd(a, b) << " " << lcm(a, b) << endl;

	return 0;
}

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

int main() {
    while(1){
        int H, W;
        char c[2] = {'#', '.'};
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << c[(i+j) % 2];
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
n = int(input())
nums = list(map(int, input().split(' ')))
nums.sort()

bunshi = nums[0] + nums[1]
bunbo = pow(2, n - 1)

for idx in range(2, len(nums)):
    bunshi = bunshi + nums[idx] * pow(2, idx - 1)
print (bunshi/bunbo)


Measured memory_bytes: 3064
n,k=map(int, input().split())
a=[]
for i in range(k):
    d=int(input())
    a_temp=list(map(int, input().split()))
    a.append(a_temp)

a_new=set(sum(a, []))

b=[]
for i in range(n):
    b.append(i+1)
b_new=set(b)

print(len(b_new-a_new))


Measured memory_bytes: 9252
#include <cstdio>
#include <map>
#define maxn 200010
#define LL long long
using namespace std;
int a[maxn],n;
LL ans;
map<int,int> mp;
int main(){
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		if(i-a[i]>0)mp[i-a[i]]++;//记录i-a[i]的数量
	for(i=1;i<=n;i++)
		if(mp[a[i]+i])ans+=mp[a[i]+i];//查重
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14356
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mpi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
	char c;cin >> c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
	{
		
		cout << "vowel\n";
}
else
{cout << "consonant\n";}
	return 0;
}


Measured memory_bytes: 3608
while True:
    n = int(input())
    if n == 0: break
    
    pairs = []
    for _ in range(n):
        p, h, w = map(int, input().split())
        bmi = w / (h / 100) ** 2
        pairs.append((p, bmi))
    pairs.sort()
    print(min(pairs, key=lambda x: abs(x[1]-22))[0])



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

typedef long long ll;

int main()
{
    ll l, r;
    cin >> l >> r;
    
    ll res = 10000000;
    
    for(ll i = l; i < r; ++i)
    {
        for(ll j = i + 1; j <= r; ++j)
        {
            ll tmp = (i * j) % 2019;
            res = min(tmp, res);
            if(res == 0) {cout << 0; return 0;}
            //cout << i << " * " << j << " = " << ((i * j) % 2019) << "\n";
        }
    }
    
    cout << res;
    
    return 0;
}

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

using namespace std;

#define M 1005
#define MOD 1000000007
#define lim 1e18
#define ll long long
#define mp make_pair
#define fi first
#define se second

int k = 1, T, mx;
ll x, y, res, fib[M];

vector< pair<ll, ll> > exellent[M];

inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	fib[0] = fib[1] = 1;
	while (fib[k] + fib[k-1] <= lim)
	{	k++; fib[k] = fib[k-1] + fib[k-2]; }

	exellent[1].push_back(mp(1, 2));
	for (int i = 2; i <= k; i++)
	{
		for (pair<ll, ll> p : exellent[i-1])
			exellent[i].push_back(mp(p.se, p.fi + p.se));
		exellent[i].push_back(mp(fib[i+1], fib[i+1] + fib[i-1]));
	}

	T = read();
	while (T--)
	{
		x = read(), y = read(); mx = 1, res = 0;
		if (x > y) swap(x, y);
		while (mx+2 <= k && fib[mx+1] <= x && fib[mx+2] <= y) mx++;
		for (pair<ll, ll> p : exellent[mx])
		{
			if (p.fi <= x && p.se <= y)
				(res += (y - p.se) / p.fi + 1) %= MOD;
			if (p.se <= x)
				(res += (x - p.se) / p.fi + 1) %= MOD;
		}
		if (mx == 1) res += x;
		printf("%d %lld\n", mx, res);
	}

	return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 char a,b;
 string s;
 cin>>a>>b;
 
 
 if(a<b)
 	cout<<"<"<<endl;
 else if(a==b)
 	cout<<"="<<endl;
 else
 	cout<<">"<<endl;
 
 return 0;
 }

Measured memory_bytes: 256
from collections import defaultdict, deque
N, u, v = map(int, input().split())
u -= 1
v -= 1
dic = defaultdict(list)
for i in range(N-1):
  a, b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]
dist1 = [float('inf')]*N
dist2 = [float('inf')]*N
q1 = deque([u])
q2 = deque([v])
dist1[u] = 0
dist2[v] = 0
while q1:
  e = q1.popleft()
  for p in dic[e]:
    if dist1[p]>dist1[e]+1:
      dist1[p] = dist1[e]+1
      q1 += [p]

while q2:
  e = q2.popleft()
  for p in dic[e]:
    if dist2[p]>dist2[e]+1:
      dist2[p] = dist2[e]+1
      q2 += [p]

ans = -1
j = 0
for i in range(N):
  if ans<dist2[i]-1 and dist1[i]<dist2[i]:
    ans = dist2[i]-1
if u==v:
  ans = 0
print(ans)

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

int main() {
  int n;
  cin >> n;
  int a, ans = 100000;
  for (int i = 0; i < n; i++) {
    cin >> a;
    int cnt = 0;
    while (!(a % 2)) {
      a /= 2;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
def primesFactraizar(n):
    is_prime = [True] * (n + 1) #まずは[1]*nを用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, n + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = primesFactraizar(10**5+1)

cumSum = [0]*(10**5+1)
tmp = 0
for i in range(10**5+1):
    if i in primes and (i+1)//2 in primes:
        tmp += 1 
    cumSum[i] = tmp


for l,r in lr:
    print(cumSum[r]-cumSum[l-1])

Measured memory_bytes: 93084
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string>ss;
	vector<string>sv;
	for (int i = 0; i < s.size(); i++)
	{
		for (int j = i; j < s.size(); j++)
		{
			string ssub = s.substr(i, j - i + 1);
			if (ssub.size()<=k)
			{
				ss.insert(ssub);
			}
		}
	}
	for (auto x:ss)
	{
		sv.push_back(x);
	}
	sort(ALL(sv));

	co(sv[k - 1]);
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  vector<int64_t> BC(N);
  {
    int ic = N;
    for (int ib = N - 1; ib >= 0; ib--) {
      while (ic - 1 >= 0 && C[ic - 1] > B[ib]) ic--;
      BC[ib] = N - ic;
    }
  }

  int64_t answer = 0;
  {
    int ib = N;
    int64_t total = 0;
    for (int ia = N - 1; ia >= 0; ia--) {
      while (ib - 1 >= 0 && B[ib - 1] > A[ia]) {
	ib--;
	total += BC[ib];
      }
      answer += total;
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
;
long long gcd(long long a, long long b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b){
   return a * b / gcd(a, b);
}
int main(){
  ll n,y;
  cin >> n >> y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n;j++){
      if(n-i-j<0)break;
      else if(1000*i+5000*j+10000*(n-i-j)==y){
        cout << n-i-j << " " << j << " "<< i;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1;
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

int m[50][50];
int w, h;

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

void dfs(int cw, int ch, int kind){
  REP(i, 4){
    int nw = cw + dx[i]; int nh = ch + dy[i];
    if(0 <= nw and nw < w and 0 <= nh and nh < h){
      if(m[nh][nw] == 0) { m[nh][nw] = 2 * kind; dfs(nw, nh, kind); }
      if(m[nh][nw] == -2 * kind) { m[nh][nw] = 9; dfs(nw, nh, kind); }
    }
  }
}

int main(){
  while(cin >> w >> h and w + h){
    memset(m, 0, sizeof(m));
    REP(i, h){
      string tmp; cin >> tmp;
      REP(j, w) if(tmp[j] == 'B') m[i][j] = 1; else if(tmp[j] == 'W') m[i][j] = -1;
    }
    REP(i, h) REP(j, w){
      if(m[i][j] == 1) dfs(j, i, 1);
      if(m[i][j] == -1) dfs(j, i, -1);
    }
    int bres = 0; int wres = 0;
    REP(i, h) REP(j, w) {
      if(m[i][j] == 2) bres++;
      if(m[i][j] == -2) wres++;
    }
    cout << bres << " " << wres << endl;
  }
  return 0;
}

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

int compare(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(void) {
    int n, d[100], count = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &d[i]);
    }
    qsort(d, n, 4, compare);
    for(int i = 0; i < n-1; i++) {
        if(d[i] < d[i+1]) {
            count++;
        }
    }
    printf("%d\n", count+1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<int> p(26,1000);
  rep(i,n){
    string s;
    cin>>s;
    int m=s.size();
    vector<int> q(26,0);
    rep(i,m){
      int y=s[i]-'a';
      q[y]++;
    }
    rep(i,26){
      if(q[i]<p[i]) p[i]=q[i];
    }
  }

  rep(i,26){
    if(p[i]!=1000){
      rep(j,p[i]){
        cout << (char)('a'+i);
      }
    }
  }

}

Measured memory_bytes: 256
N, M = map(int, input().split())
a_set = set()
b_set = set()
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        a_set.add(b)
    if b == N:
        b_set.add(a)

# print('a_set, b_set', a_set, b_set)
product = a_set & b_set
if len(product) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 19024
#!/usr/bin/env python3
import sys
import fractions
from functools import reduce
import random

MOD = 1000000007  # type: int

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def solve(N: int, A: "List[int]"):

    LCM = reduce(lcm,A)
    answer = 0
    for i in range(N):
        answer += LCM//A[i]
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin>>s;
    if(atoi(&s.at(0))>2019)cout<<"TBD"<<endl;
    else if(atoi(&s.at(5))>4)cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,i;
 cin>>a;
 for(i=1;i<=a;i*=2);
 cout<<i/2;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cassert>
#include<stdarg.h>
using namespace std;
typedef long long ll;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
 
/*sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);*/
 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
 
struct debug {
	~debug() { cerr << endl; }
	
	//eni(!=) cerr << boolalpha << i; ris; }        Part 1
	
	template < class c > typename \
	enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
		cerr << boolalpha << i;
		return * this;
	}
	
	//eni(==) ris << range(begin(i), end(i)); }     Part 2
	
	template < class c > typename \
	enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
		return * this << range(begin(i), end(i)); 
	}
	
	/*sim, class b dor(pair < b, c > d) {           Part 3
		ris << "(" << d.first << ", " << d.second << ")";
	}*/
	
	template < class c, class b > debug & operator << (pair < b, c > d) {
		return * this << "(" << d.first << ", " << d.second << ")";
	}
	
	/*sim dor(rge<c> d) {                           Part 4
		*this << "[";
		for (auto it = d.b; it != d.e; ++it)
			*this << ", " + 2 * (it == d.b) << *it;
		ris << "]";
	}*/
	
	template < class c > debug & operator <<(rge<c> d) {
		*this << "[";
		for (auto it = d.b; it != d.e; ++it)
			*this << ", " + 2 * (it == d.b) << *it;
		return * this << "]";
	}
	
};

 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define pb push_back
int INF = 1e9;
int arr[7] = {0, 1, 3, 2, 4, 6, 5};

int gcd(int a, int b){
	return __gcd(a, b);
}
void read(vector<ll> &a){
	for(ll &i : a) cin >> i;
}
void read(vector<int> &a){
	for(int &i : a) cin >> i;
}

void test_case(int tnum){
	string s;
	cin >> s;
	int n = s.size();
	if(s[n-1] == 's')cout << s << "es";
	else cout << s << 's';

}

 
//Can the answaer be binary searched?
//Any special cases? n=1/0;
//n^2 does it?
//Dp state?
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t = 1;
	// cin >> t;

	
	for(int i =1; i<=t;i++){
		test_case(i);
	}
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
	long double c;
	cin >> c;	
	c = c / 3;
	cout << fixed <<setprecision(12) << c * c * c << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	ll i,r,d,x;
	cin>>r>>d>>x;
	for(i=0;i<10;i++){
		x=r*x-d;
		cout<<x<<endl;
	}
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll a, val, sum = 0 ;
    cin >> a ;
    sum = a ;
    val = a * a ;
    sum += val ;
    val *= a ;
    sum += val ;
    cout << sum ;

    return 0 ;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
char grid[1001][1001];
map < int , map < int , int > > dp;
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			cin>>grid[i][j];
		}
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			if(i==0 && j==0) continue;
			if(grid[i][j]=='#') dp[i][j]=0;
			else dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
}

Measured memory_bytes: 48256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    
    long long a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    
    long long ans_p,ans_m;
    for(int k=0;k<2;k++){
        long long sum=a[0],count=0;
        
        if(k&&a[0]<=0){
            count+=abs(a[0])+1;
            sum=1;
        }
        if(!k&&a[0]>=0){
            count+=a[0]+1;
            sum=-1;
        }

        for(int i=1;i<n;i++){
            if(sum>0&&sum+a[i]>=0){
                count+=(sum+a[i])+1;
                sum=-1;
            }else if(sum<0&&sum+a[i]<=0){
                count+=abs(sum+a[i])+1;
                sum=1;
            }else{
                sum+=a[i];
            }
        }

        if(k)ans_p=count;
        else ans_m=count;
    }

    cout<<min(ans_p,ans_m)<<endl;
}


Measured memory_bytes: 1024
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [N, M, K] = nextIntArray()
    let a = nextIntArray()
    let b = nextIntArray()

    let tmp = 0
    let sumA = [0]
    for (let i = 0; i < a.length; i++) {
        tmp += a[i]
        sumA.push(tmp)
    }
    tmp = 0
    let sumB = [0]
    for (let i = 0; i < b.length; i++) {
        tmp += b[i]
        sumB.push(tmp)
    }
    let res = 0
    for(let i = 0, j = M; i <= N; i++){
        if(sumA[i] > K) break
        while(sumA[i] + sumB[j] > K ) j--
        res = Math.max(res, i+j)
    }
    console.log(res)
}
Main()


Measured memory_bytes: 67056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a,b;
    cin>>a>>b;
    if(a>=10 || b>=10) cout<<-1<<endl;
    else cout<<a*b<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main ( void ) {
	int cho;
	cin >> cho;
	if ( cho == 1 ) {
		cout << "Hello World" << endl;
		return 0;
	}
	else if ( cho == 2 ) {
		int a , b;
		cin >> a >>b;
		cout << a + b << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll k;cin>>k;

    vector<ll> v(50);
    rep(i,50)v[i]=i + k/50;
    
    rep(i,k%50){
        v[i]+=50;
        rep(j,50){
            if(i==j)continue;
            v[j]-=1;
        }
    }
    
    cout<<50<<endl;
    cout<<v<<endl;
    
    return 0;
}












Measured memory_bytes: 256
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#ifdef LOCAL
#include "prettyprint.hpp"
#else
#define debug(...)
#define debuga(arr, n)
#define debugg(grid, n) 
#endif
typedef long long int ll;
#define int ll
#define F first
#define S second
#define float double
const int inf = LLONG_MAX;
int get() { int x; cin >> x; return x; }
void getl(int* ar, int sz){ for(int i=0; i<sz; i++) cin >> ar[i];}
template <typename T> void print(T x) { cout << x << "\n";}
template <typename T> void prints(T x) { cout << x << " ";}
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int mod = 1e9+7;
const int N = 1e6+1;

int h[N], cost[N];

int32_t main(){
	fast_io();
	int n = get();
	getl(h, n);
	for (int i = 1; i < n; ++i) {
		vi l;
		if(i>=1) l.push_back(cost[i-1] + abs(h[i] - h[i-1]));
		if(i>=2) l.push_back(cost[i-2] + abs(h[i] - h[i-2]));
		cost[i] = *min_element(all(l));
	}
	print(cost[n-1]);
	return 0;
}

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

int main()
{
    // 入力
    int K,K7,pre_K7=0;
    int result=-1;
    cin >> K;

    //cout << "" << endl;
    // 計算
    rep (i,1000000){
        K7 = (pre_K7*10+7)%K;
        //cout << "K7:   " << K7 << endl;
        //cout << "K7%K: " << K7%K << endl;
        
        if  (K7%K == 0){
            result = i+1;
            cout << result << endl;
            return 0;
        } 
        pre_K7 = K7;
    }
    
    // 出力
    cout << result << endl;
    return 0;  
}


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

int n, m;
const int oo = INT_MAX - 1024;
vector<vector<int>> g;
vector<vector<int>> capacity;

int bfs(vector<int> &par){
    fill(par.begin(), par.end(), -1);
    par[0] = -2;
    queue<pair<int, int>> q;
    q.push({0, oo});
    while(!q.empty()){
        int u = q.front().first;
        int flow = q.front().second;
        q.pop();
        for(int v : g[u]){
            if(par[v] == -1 and capacity[u][v]){
                par[v] = u;
                int next_flow = min(flow, capacity[u][v]);
                if(v == n - 1) return next_flow;
                q.push({v, next_flow});
            }
        }
    }
    return 0;
}

int max_flow(){
    int flow = 0;
    vector<int> par(n);
    int new_flow = 0;
    while((new_flow = bfs(par))){
        flow += new_flow;
        int u = n - 1;
        while(u){
            int v = par[u];
            capacity[v][u] -= new_flow;
            capacity[u][v] += new_flow;
            u = v;
        }
    }
    return flow;
}

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

    cin >> n >> m;
    g.resize(n);
    capacity.resize(n);
    for(int i = 0; i < n; i++){
        capacity[i].resize(n);
    }
    for(int i = 0; i < m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        g[u].push_back(v);
        g[v].push_back(u);
        capacity[u][v] = c;
    }
    cout << max_flow() << "\n";

    return 0;
}



Measured memory_bytes: 3248
import sys
sys.setrecursionlimit(10**7)
def dfs(now):
  res=day[now]
  if vis[now]:
    if res==-1:return -1
    else:return res
  res=1
  vis[now]=1
  for to in d[now]:
    r=dfs(to)
    if r==-1:return -1
    res=max(res,r+1)
  day[now]=res
  return res
n=int(input())
v=0
si=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(i+1,n):
    si[i][j]=v
    v+=1
d=[[] for _ in range(v)]
s=[]
for i in range(n):
  a=list(map(int,input().split()))
  if i<a[0]-1:b=si[i][a[0]-1]
  else:b=si[a[0]-1][i]
  for j in a[1:]:
    j-=1
    if i<j:
      d[b]+=[si[i][j]]
      b=si[i][j]
    else:
      d[b]+=[si[j][i]]
      b=si[j][i]
vis=[0]*v
day=[-1]*v
ans=0
for i in range(v):
  di=dfs(i)
  if di==-1:
    print(-1)
    exit()
  ans=max(ans,di)
print(ans)

Measured memory_bytes: 207132
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int dp[100010][20];
int main()
{
	string S;
	cin >> S;
	dp[0][0] = 1;
	int power = 1;
	int i = 0;
	dp[0][0] = 1;
	for (int k = S.size() -  1; k >= 0; k--,i++) {
		if (S[k] == '?') {
			for (int l = 0; l <= 9; l++) {
				int num = l * power % 13;
				for (int j = 0; j < 13; j++) {
					dp[i + 1][j] += dp[i][(j - num + 13) % 13];
					dp[i + 1][j] %= mod;
				}
			}
		}
		else {
			int num = (S[k] - '0') * power % 13;
			for (int j = 0; j < 13; j++) {
				dp[i + 1][j] += dp[i][(j - num + 13) % 13];
				dp[i + 1][j] %= mod;
			}
		}
		power = power * 10 % 13;
	}
	cout << dp[S.size()][5] << endl;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <cstdio>
#include<set>


using namespace std;

int main(){

    set<int> s;

    int n;
    cin >> n;


    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        s.insert(tmp);
    }

    cout << s.size() << endl;

    return 0;

    //std::cout << "Hello World!\n";
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    vector<pair<int,int>> p;
    int n; cin >> n;
    rep(i,n){
        int a,b; cin >> a >> b;
        p.push_back(make_pair(b,a));
    }
    sort(all(p));
    ll laps = 0;
    bool is_res = true;
    for(auto c:p){
        laps+=c.second;
        if(laps>c.first){
            is_res = false;
            break;
        }
    }
    cout << (is_res?"Yes":"No") << endl;
}


Measured memory_bytes: 2420