akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
# define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;



int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll H,W;
	cin>>H>>W;
    vector<string> S(H);
    ll w_sum[H][W]= {};
    ll h_sum[H][W]= {};
    rep(i,H){
        cin>>S[i];
    }
    ll ans = 0;
    rep(i,H) rep(j,W){
        if(S[i][j]=='#') continue;
        ll h=i,w=j,tmp_ans=0;
        if(h_sum[i][j]==0){
            while(1){
                --h;
                if(h<0) break;
                if(S[h][j]=='#') break;
                ++tmp_ans;
            }
            ll min_i =h+1;
            h=i;
            while(1){
                ++h;
                if(h==H) break;
                if(S[h][j]=='#') break;
                ++tmp_ans;
            }
            ll max_i = h-1;
            for(int k=min_i;k<=max_i;k++){
                h_sum[k][j] = tmp_ans;
            }
        }else{
            tmp_ans+=h_sum[i][j];
        }
        if(w_sum[i][j]==0){
            while(1){
                --w;
                if(w<0) break;
                if(S[i][w]=='#') break;
                ++tmp_ans;
            }
            ll min_j =w+1; 
            w=j;
            while(1){
                ++w;
                if(w==W) break;
                if(S[i][w]=='#') break;
                ++tmp_ans;
            }
            ll max_j = w-1;
            for(int k=min_j;k<=max_j;k++){
                w_sum[i][k] = tmp_ans-h_sum[i][j];
            }
        }else{
            tmp_ans+=w_sum[i][j];
        }
        ++tmp_ans;
        ans = max(ans,tmp_ans);
    }

    cout<<ans<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 67072
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long i64;
const i64 MOD = 1000000007;
void ADD(i64& a, const i64& b) { a = (a + b) % MOD; }

i64 H, W;
int N, X[30], Y[30];
int hist[1001001];

i64 precomp(i64 H, i64 W, int *Y)
{
    for (int i = 0; i < H; ++i) hist[i] = 0;
    for (int i = 0; i < N; ++i) hist[Y[i]]++;

    i64 tot = (H * W - N) % MOD;
    i64 suml = 0;
    i64 ret = 0;
    for (int i = 1; i < H; ++i) {
        ADD(suml, W - hist[i - 1]);
        i64 sumr = (MOD + tot - suml) % MOD;
        if (hist[i - 1] == 0 && hist[i] == 0) {
            ADD(ret, suml * sumr);
        }
    }
    return ret;
}
vector<pair<int, int>> summarize(int H, int *Y)
{
    vector<int> ys;
    for (int i = 0; i < N; ++i) ys.push_back(Y[i]);
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    
    vector<pair<int, int>> ret;
    if (ys[0] != 0) ret.push_back({0, ys[0] - 1});
    ret.push_back({ys[0], ys[0]});
    for (int i = 1; i < ys.size(); ++i) {
        if (ys[i - 1] < ys[i] - 1) ret.push_back({ys[i - 1] + 1, ys[i] - 1});
        ret.push_back({ys[i], ys[i]});
    }
    if (ys.back() != H - 1) ret.push_back({ys.back() + 1, H - 1});
    return ret;
}

int R, C; i64 weight[90][90];
int dis[90][90];

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

i64 bfs(int y, int x)
{
    for (int i = 0; i < R; ++i) for (int j = 0; j < C; ++j) dis[i][j] = -1;
    dis[y][x] = 0;
    queue<pair<int, int>> qu; qu.push({y, x});
    i64 ret = 0;
    while (!qu.empty()) {
        auto loc = qu.front(); qu.pop();
        int d = dis[loc.first][loc.second];
        if (make_pair(y, x) < make_pair(loc.first, loc.second)) {
            ADD(ret, d * weight[loc.first][loc.second]);
        }
        for (int i = 0; i < 4; ++i) {
            int y2 = loc.first + dy[i], x2 = loc.second + dx[i];
            if (y2 < 0 || x2 < 0 || y2 >= R || x2 >= C || weight[y2][x2] == 0 || dis[y2][x2] != -1) continue;
            dis[y2][x2] = d + 1;
            qu.push({y2, x2});
        }
    }
    return ret;
}

int main()
{
    scanf("%lld%lld%d", &H, &W, &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d%d", Y + i, X + i);
    }

    i64 ret = 0;
    ADD(ret, precomp(H, W, Y));
    ADD(ret, precomp(W, H, X));

    vector<pair<int, int>> ys = summarize(H, Y), xs = summarize(W, X);
    R = ys.size(); C = xs.size();
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            weight[i][j] = (i64)(ys[i].second - ys[i].first + 1) * (xs[j].second - xs[j].first + 1);
        }
    }
    for (int i = 0; i < N; ++i) {
        int u = find(ys.begin(), ys.end(), make_pair(Y[i], Y[i])) - ys.begin();
        --weight[find(ys.begin(), ys.end(), make_pair(Y[i], Y[i])) - ys.begin()][find(xs.begin(), xs.end(), make_pair(X[i], X[i])) - xs.begin()];
    }
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            if (weight[i][j] != 0) {
                ADD(ret, weight[i][j] % MOD * bfs(i, j));
            }
        }
    }
    printf("%lld\n", ret);

    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); 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 all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int a[30];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    rep(i, s.size()) a[s[i]-'a']++;
    rep(i, 30) if (a[i] % 2) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000009;
const double pi = acos(-1);

template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

veci ret(1000010);

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

int main() {
    int N; cin >> N;
    vecvecl factors(N);

    vecl A(N);

    ll x= 1e6;
    PrimeFact<ll> PF(1e6);

    ll g = 0;
    REP(i,N) {
        ll a; cin >> a;
        A[i] = a;
        map<ll,ll> res = PF.get(a);
        for(auto p : res) ret[p.first]++;
    }

    REP(i,N) g = gcd(g,A[i]);

    bool go = true;
    REP(i,N) {
        bool ok = true;
        map<ll,ll> res = PF.get(A[i]);
        for(auto p : res) {
            //cout << a << endl;
            if(ret[p.first]-1 != 0) ok = false;
        }
        if(!ok) go = false;
    }

    if(go) cout << "pairwise coprime" << endl;
    else if(g == 1) cout << "setwise coprime"  << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 46216
n,m = map(int,input().split())
g = []
for _ in range(n):
    g.append([int(i) for i in input().split()])

c = []
for _ in range(m):
    c.append([int(i) for i in input().split()])

for i in range(n):
    ans = 0
    l = 10**16
    for j in range(m):
        tmp = abs(g[i][0] - c[j][0]) + abs(g[i][1] - c[j][1])
        
        if tmp < l:
            l = tmp
            ans = j + 1
            
    print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,ll arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to;
	ll dist;
};

vector<Edge> G[SIZE]; //グラフの隣接リスト表現
int N; //ノードの個数
int root; //根ノードの番号
int MAX_LOG_V = 17;
int POW[18];

int parent[18][SIZE];
int depth[SIZE];
ll DIST[SIZE];


//parentとdepthを再帰的に設定
void dfs(int node_id,int parent_id,int d){
	parent[0][node_id] = parent_id;
	depth[node_id] = d;
	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].to != parent_id){
			DIST[G[node_id][i].to] = DIST[node_id]+G[node_id][i].dist;
			dfs(G[node_id][i].to,node_id,d+1);
		}
	}
}

//初期化
void init(){
	//parent[0]とdepthを初期化する
	dfs(root,-1,0);
	//parentを初期化する
	for(int k = 0; k + 1 < MAX_LOG_V; k++){
		for(int node_id = 0; node_id < N; node_id++){
			if(parent[k][node_id] < 0)parent[k+1][node_id] = -1; //node_idの2^k上のノードがルートノードより上なら、2^(k+1)上も同様とする
			else{
				parent[k+1][node_id] = parent[k][parent[k][node_id]];
			}
		}
	}
}

//leftとrightのLCAを求める
int lca(int left,int right){
	//leftとrightの深さが同じになるまで親を辿る
	if(depth[left] > depth[right])swap(left,right); //rightの方が深い所にいる

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(depth[right]-depth[left] >= POW[k]){ //たとえば深さの差が39なら、32+4+2+1のように、ノードを上方に移動させる
			right = parent[k][right];
		}
	}

	if(left == right)return left;

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(parent[k][left] == parent[k][right]){
			//Do nothing
		}else{
			left = parent[k][left];
			right = parent[k][right];
		}
	}
	return parent[0][left]; //最後は、leftの親とrightの親が必ず一致している
}

ll calc_dist(int a,int b){

	return DIST[a]+DIST[b]-2*DIST[lca(a,b)];
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 17; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	int from,to;
	ll dist;

	for(int i = 0; i < N-1; i++){
		scanf("%d %d %lld",&from,&to,&dist);
		from--;
		to--;
		G[from].push_back(Edge(to,dist));
		G[to].push_back(Edge(from,dist));
	}

	root = 0;
	DIST[root] = 0;
	init();

	int num_query,K;
	int x,y;

	scanf("%d %d",&num_query,&K);
	K--;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&x,&y);
		x--,y--;
		printf("%lld\n",calc_dist(x,K)+calc_dist(K,y));
	}

	return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

const int INF = (1LL<<30);

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }

int dist[25][105][105], cost[105][105];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n, m, com, s, g;
    cin >> n >> m >> com >> s >> g;
    if(!n) break;
    REP(i, 25) REP(j, 105) REP(k, 105) dist[i][j][k] = j==k?0:INF;
    VI x(m), y(m), d(m), c(m);
    REP(i, m) {
      cin >> x[i] >> y[i] >> d[i] >> c[i];
      x[i]--, y[i]--, c[i]--;
      chmin(dist[c[i]][x[i]][y[i]], d[i]);
      chmin(dist[c[i]][y[i]][x[i]], d[i]);
    }
    VI p(com);
    REP(i, com) cin >> p[i];
    VVI q(com), r(com);
    REP(i, com) {
      q[i] = VI(p[i]-1), r[i] = VI(p[i]);
      REP(j, p[i]-1) cin >> q[i][j];
      REP(j, p[i]) cin >> r[i][j];
    }

    // 会社lで移動するときの最短距離をWFで求める
    REP(l, com) REP(k, n) REP(i, n) REP(j, n) {
      chmin(dist[l][i][j], dist[l][i][k] + dist[l][k][j]);
    }

    REP(i, 105) REP(j, 105) cost[i][j] = i==j?0:INF;
    REP(l, com) {
      REP(i, n) REP(j, n) {
        // 会社lで距離dist[l][i][j]を移動するときにかかる運賃
        int tmp = 0;
        REP(k, p[l]-1) {
          if(dist[l][i][j] < q[l][k]) {
            tmp += (dist[l][i][j] - (k==0?0:q[l][k-1])) * r[l][k];
            break;
          } else {
            tmp += (q[l][k] - (k==0?0:q[l][k-1])) * r[l][k];
          }
        }
        if(p[l] == 1) {
          tmp = dist[l][i][j] * r[l][0];
        } else if(dist[l][i][j] > q[l].back()) {
          tmp += (dist[l][i][j] - q[l].back()) * r[l].back();
        }
        chmin(cost[i][j], tmp);
      }
    }

    REP(k, n) REP(i, n) REP(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]);

    if(cost[s-1][g-1] >= INF) cout << -1 << endl;
    else cout << cost[s-1][g-1] << endl;
  }

  return 0;
}



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

using namespace std;

int main() {
    long long n,k;
    while(cin >> n >> k) {
        long long sum1=(n-k)*(1+n-k)/2;
        long long sum2=0;
        for(long long i=k+1; i<=n; i++) {
            long long su=n-i+1;
            long long sum=(su/i)*(i-k);
            long long ssum = su%i-k;
            if(ssum<0)
                sum2+=sum;
            else
                sum2=(sum2+sum+ssum);
        }
        if(k==0)
            printf("%lld\n",sum1+sum2-n);
        else
            printf("%lld\n",sum1+sum2);
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! bind_from_vec {
    ( $($variable:ident),+ = $vector: expr ) => {
        let mut v = $vector.clone().into_iter();
        $(let $variable = v.next().unwrap();)+
    };
}

macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    bind_from_vec!(a, b, x = read_to_vec::<i64>());

    println!("{}", b/x + 1 - (a+x-1)/x);
}

Measured memory_bytes: 4352
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


int main()
{
	int A[3][3] = {};

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> A[i][j];
		}
	}

	int N, K;

	cin >> N;

	std::vector<int> b;
	b.resize(N);

	int r[3][3] = {};

	for (int i2 = 0; i2 < N; ++i2) {
		cin >> b[i2];

		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (A[i][j] == b[i2]) {
					r[i][j] = 1;
				}
			}
		}
	}


	for (int i = 0; i < 3; ++i) {
		if (r[0][i] * r[1][i] * r[2][i]) {
			printf("Yes\n");
			return 0;
		}
		if (r[i][0] * r[i][1] * r[i][2]) {
			printf("Yes\n");
			return 0;
		}
	}
	if (r[0][0] * r[1][1] * r[2][2]) {
		printf("Yes\n");
		return 0;
	}
	if (r[2][0] * r[1][1] * r[0][2]) {
		printf("Yes\n");
		return 0;
	}


	printf("No\n");


	return 0;
}




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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<bool>c(8,false);
	int gm=0;
	for(int i=0,t;i<n;++i){
		cin>>t;
		if(t>=3200)++gm;
		else if(t>=2800)c.at(0)=true;
		else if(t>=2400)c.at(1)=true;
		else if(t>=2000)c.at(2)=true;
		else if(t>=1600)c.at(3)=true;
		else if(t>=1200)c.at(4)=true;
		else if(t>=800)c.at(5)=true;
		else if(t>=400)c.at(6)=true;
		else c.at(7)=true;
	}
	int cl=0;
	for(const auto&i:c)if(i)++cl;
	int mn,mx;
	if(cl==0&&gm>0)mn=1;
	else mn=cl;
	mx=cl+gm;
	cout<<mn<<" "s<<mx<<"\n"s;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
H = [0]*N
flag=0

H[0]=T[0]
for i in range(1,N):
    if T[i]!=T[i-1]:
        H[i]=T[i]
    else:
        H[i] = -1*T[i]

H[N-1]=A[N-1]

for i in range(1,N):
    if A[N-i-1]!=A[N-i]:
        if (H[N-i-1]<0 and A[N-i-1] > -1*H[N-i-1]) or (H[N-i-1]>0 and A[N-i-1] > H[N-i-1]):
            flag=1
            break
        H[N-i-1]=A[N-i-1]
    else:
        H[N-i-1]=max(-1*A[N-i-1],H[N-i-1])
if N==1:
    if A[0]==T[0]:
        print(1)
    else:
        print(0)

elif flag==0:
    p = 10**9+7
    out = 1
    for i in range(N):
        if H[i]<0:
            out = out * (-1*H[i]) % p
    print(out)
else:
    print(0)

Measured memory_bytes: 97048
import java.util.Scanner

fun main(args: Array<String>){
  val scn = Scanner(System.`in`) //Scannerのインスタンスを作成
  val n: Long = scn.nextLong()//Int型に変換
  val x: Long = scn.nextLong()
  
  val a: MutableList<Long>  = mutableListOf()
  
  var count: Long = n
  while(0 < count--) {
    val t: Long = scn.nextLong()
    a.add(t)
  }

  var memo = Array<Array<Long>>(n.toInt(), {i -> Array<Long>(n.toInt(), { j-> 0 }) })
  
  var id: Long = n
  while(0 < id--) {
    var i: Long = n - id - 1
    var rec: Long = -1
    var jd: Long = n
    while(0 < jd--) {
      var j: Long = n - jd - 1
      var k: Long = (n + i - j) % n
      if (rec < 0 || a[k.toInt()] < rec) {
        rec = a[k.toInt()]
      }
      memo[i.toInt()][j.toInt()] = rec
    }
  }
    
  var record: Long = -1
  
  var jd: Long = n
  while(0 < jd--) {
    var j: Long = n - jd - 1
    var temp: Long = x * j
    
    var id: Long = n
    while(0 < id--) {
      var i: Long = n - id - 1
      temp = temp + memo[i.toInt()][j.toInt()]
    }
    if ( record < 0 || temp < record) {
      record = temp
    }
  }
  
  println(record)
}

Measured memory_bytes: 182592
import java.util.Scanner;

public class Main {
	public static void insertionSort(int[] array, int n) {
		int v, j;
		for (int i = 0; i < n; i++) {
			v = array[i];
			j = i - 1;
			while (j >= 0 && array[j] > v) {
				array[j + 1] = array[j];
				j--;
			}
			array[j + 1] = v;
			for (int k = 0; k < n; k++) {
				System.out.print(array[k]);
				if (k < n - 1) {
					System.out.print(" ");
				}
			}
			System.out.println();
			}
		}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		insertionSort(array, n);
	}
}



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

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

    set<int> S{};
    for (int i = 0; i < N; i++) {
        S.insert(A[i]);
    }

    if (S.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 10368
N = int(input())
D, X = [int(i) for i in input().split()]

ans = X
for _ in range(N):
    A = int(input())
    a = 0
    x = 0
    while (x * A + 1 <= D):
        a += 1
        x += 1
    ans += a
print(ans)
         

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

/***********************************/

char firstStr[3009];
char secondStr[3009];

int dp[3009][3009];
int visited[3009][3009];

int LCSlength(int i,int j)
{
    if(firstStr[i]=='\0' || secondStr[j]=='\0')
        return 0;
    if(visited[i][j])
        return dp[i][j];
    int ans = 0;

    if(firstStr[i]==secondStr[j])
        ans = 1 + LCSlength(i+1,j+1);
    else
    {
        int a = LCSlength(i+1,j);
        int b = LCSlength(i,j+1);
        ans = max(a,b);
    }
    visited[i][j] = 1;
    dp[i][j] = ans;
    return dp[i][j];
}

string str;
string mn;
int c;
void PrintLCS(int i,int j)
{
    if(firstStr[i]=='\0' || secondStr[j]=='\0')
    {

        cout<<str<<endl;
        return;
    }
    if(firstStr[i]==secondStr[j])
    {
        str+=firstStr[i];
        PrintLCS(i+1,j+1);
        // str.erase(str.end()-1);

    }
    else
    {
        if(dp[i+1][j]>=dp[i][j+1])
            PrintLCS(i+1,j);
        else if(dp[i+1][j]<dp[i][j+1])
            PrintLCS(i,j+1);
    }
}
int32_t main()
{


    /***********************************/
//#ifdef ONPC
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
    //faster();
    /*********************************/
    int test;

    scanf("%s",firstStr);
    scanf("%s",secondStr);
    int ln = LCSlength(0,0);
    c = 0;
    if(ln==0)
    {
        printf("\n");
    }
    else
    {
        PrintLCS(0,0);

    }

    return 0;
}


Measured memory_bytes: 141696
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
typedef long long ll;
#define PII pair<ll,ll>
const int maxn=2e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-10;
using namespace std;
int main()
{
	int n,i,a[maxn]={0};
	ll ans=0,sum[maxn]={0};
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),sum[a[i]]++;
	for(i=1;i<=n;i++)ans=ans+sum[i]*(sum[i]-1)/2;
	for(i=1;i<=n;i++)printf("%lld\n",ans-sum[a[i]]+1);
}

Measured memory_bytes: 4864
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	cin>>m;
	vector<ll> vis(n+1,0);
	vis[1]=1;
	int counter=0;
	ll boxcount[n+1]={0};
	for(int i=1;i<=n;i++)
	boxcount[i]++;
	while(m--)
	{
	    cin>>a>>b;
	    if(!vis[a])
	    {boxcount[a]--;boxcount[b]++;continue;}
	    vis[b]=1;
	    boxcount[b]++;
	    boxcount[a]--;
	    if(boxcount[a]<=0)
	    {
	        vis[a]=0;
	    }
	}
	cout<<count(1,vis);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;


int N , Q ;

void replaceSum(){
	
	int sum = 0;
	cin >> N ;
	vector<int> freq(100001 , 0);
	for(int i=0 , inp ; i < N ; i++){
		
		cin >> inp ;
		freq[inp]++;
		sum += inp ;
	}
	
	cin >> Q ;
	
	for(int Query=0, B ,C ; Query < Q ; Query++){
		
		cin >> B >> C ;
		sum -= freq[B] * B ;
		sum += freq[B] * C ;
		freq[C] +=  freq[B];
		freq[B] = 0 ;
		
		cout << sum << endl ;
	}
	
}







int32_t main() {
	
	ios_base::sync_with_stdio(false) ,cin.tie(nullptr);
	replaceSum();
	
	return 0;
}


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

// -------------------
// ここから先は変更しない
// -------------------
int main() {
  char c;
  cin >> c;
  string a = "vowel",b = "consonant";
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << a << endl;
  }else{
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    int64_t b_n = vec[0];
    int s = 0;
    int64_t splited = 1;
    for (int64_t i=1; i<N; i++) {
        int64_t n = vec[i];
        if (s == 0) {
            if (n > b_n) {
                s = 1;
            } else if (n < b_n) {
                s = -1;
            }
        } else if (s == 1) {
            if (n >= b_n) {
            } else {
                splited += 1;
                s = 0;
            }
        } else {
            if (n <= b_n) {
            } else {
                splited += 1;
                s = 0;
            }
        }

        b_n = n;
    }

    cout << splited << endl;
    return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  rep(i, k){
    int d;
    cin >> d;
    rep(i, d){
      int tmp;
      cin >> tmp;
      tmp--;
      mp[tmp]++;
    }
  }

  ll res = 0;
  rep(i, n){
    if(mp[i] == 0) res++;
  }
  cout << res <<endl;
}


Measured memory_bytes: 3668
#include <stdio.h>

int main()
{
 int H, W, i, j;

 while(1)
 {
     scanf("%d %d\n", &H, &W);

     if(H == 0 && W == 0)break;

     for(i = 0; i < H; i++)
     {
         for(j = 0; j < W; j++)
         {
             printf("#");
         }
         printf("\n");
     }
     printf("\n");
 }
 return 0;
}

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

int main(){
	string s,t;
	int n;
	int flag;
	cin >> s>>t;
	n = s.length();
	
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			flag = 1;
			if(s[(i+j)%n]==t[j]){
				flag = 1;
			}else{
				flag = 0;
				break;
			}
		}			
		if(flag==1)break;
	}
	if(flag==1){
		cout << "Yes" <<endl;
	}else{
		cout << "No" <<endl;
	}
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vector<vi> a(N,vi(N,-1));
    int x,y,z;
    Rep(i,N){
        Scd(x);
        Rep(j,x){
            Scd2(y,z);
            y--;
            a[i][y] = z;
        }
    }

    int ans = 0;
    int cnt = 0;
    bool ok = false;
    Rep(bi,(1<<N)){
        ok = true;
        cnt = 0;
        Rep(i,N){
            if( bi&(1<<i) ){
                cnt++;
                Rep(j,N){
                    if( a[i][j] == -1 ) continue;
                    if( (bi&(1<<j)) != (a[i][j]<<j) ) ok = false;
                }
            }
        }
        if( ok ){
            ans = max(ans,cnt);
        }
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
         Scanner S =  new Scanner(System.in);
         int N = Integer.parseInt(S.next());
         int M = Integer.parseInt(S.next());
         int total = 0;
         for(int i=0;i<M;i++){
             total += Integer.parseInt(S.next());
         }

         if(N >= total){
             System.out.println(N-total);
         } else {
             System.out.println(-1);
         }

    }
}


Measured memory_bytes: 41596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

pii a[N];

void solve()
{
	int n, m, i, l, r;
	cin >> m >> n;
	fo(i,1,n+1)
		cin >> a[i].F >> a[i].S;
	l = 1;
	r = m;
	fo(i,1,n+1)
	{
		l = max(l, a[i].F);
		r = min(r, a[i].S);
	}
	cout << max(r-l+1,0) << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000009
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
const int maxn=1e6+10;
const int N=2e5+10;
using namespace std;
int id(int l,int r){return l+r|l!=r;}
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t;
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    if(n%3==0||m%3==0)return 0*puts("0");
    ll ret=1e18;
    ret=min(ret,(ll)m);
    ret=min(ret,(ll)n);
    rep(i,1,n-1)
    {
        ll a1=(ll)(n-i)*(m/2);
        ll a2=(ll)(n-i)*m-a1;
        ll ma=max({a1,a2,(ll)i*m});
        ll mi=min({a1,a2,(ll)i*m});
        ret=min(ret,ma-mi);
    }
    rep(i,1,m-1)
    {
        ll a1=(ll)(m-i)*(n/2);
        ll a2=(ll)(m-i)*n-a1;
        ll ma=max({a1,a2,(ll)i*n});
        ll mi=min({a1,a2,(ll)i*n});
        ret=min(ret,ma-mi);
    }
    printf("%lld\n",ret);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
vector<int> g[100010];
ll a[100010], b[100010];
void dfs(int x, int p){
	for(auto y:g[x]){
		if(y==p) continue;
		dfs(y, x);
		a[x]+=a[y];
		b[x]+=b[y];
	}
}
ll a1[100010];
void dfs2(int x, int p, ll &ans, bool &dame){
	if(a1[x]<b[x]) dame=1;
	ans+=a1[x]-b[x];
	for(auto y:g[x]){
		if(y==p) continue;
		a1[y]+=a1[x]-b[x];
		dfs2(y, x, ans, dame);
	}
}
int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int u, v;
		cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++) cin>>b[i];
	dfs(0, -1);
	ll l=-1, r=1e18;
	while(r-l>1){
		ll m=(l+r)/2;
		for(int i=0; i<n; i++) a1[i]=a[i];
		for(auto y:g[0]){
			a1[y]+=m;
		}
		ll ans=m;
		bool dame=0;
		dfs2(0, -1, ans, dame);
		if(!dame) r=m;
		else l=m;
	}
	for(int i=0; i<n; i++) a1[i]=a[i];
	for(auto y:g[0]){
		a1[y]+=r;
	}
	ll ans=r;
	bool dame=0;
	dfs2(0, -1, ans, dame);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 18136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, ans;
  cin >> n;
  ans = n / 111;
  if(n % 111 == 0)
    cout << n;
  else
    cout << (ans+1) * 111;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define ForE(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;
string s,t;

main()
{
        cin>>s;
        rep(i,s.size())
        {
                cout<<'x';
        }
        cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

ll dp[100005][4];
void solve(){
  string s;
  cin>>s;
  memset(dp,0,sizeof(dp));
  int n=s.size();
  dp[0][0]=1;
  rep(i,n){
    rep(j,4){
      if(j<3){//まだ選べる
        if(s[i]==char('A'+j))dp[i+1][j+1]=+dp[i][j];//?でなくて選ぶとき
        else if(s[i]=='?')dp[i+1][j+1]+=dp[i][j];//?で選ぶとき
        dp[i+1][j+1]%=mod;      
        if(s[i]=='?'){
          dp[i+1][j]+=3*dp[i][j];//?で選ばないとき
          dp[i+1][j]%=mod;
        }
        else {
          dp[i+1][j]+=dp[i][j];//それ以外で選ばないとき
          dp[i+1][j]%=mod;
        }
      }
      else {//もう選べない
        if(s[i]=='?'){
          dp[i+1][j]+=3*dp[i][j];//これ以上選べない
          dp[i+1][j]%=mod;
        }
        else {
          dp[i+1][j]+=dp[i][j];//これ以上選べない
          dp[i+1][j]%=mod;
        }
      }
    }
  }
  cout<<dp[n][3];
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  int i = 1;
  while(cnt < n){
    cnt += i;
    i++;
  }
  int p = cnt - n;
  for(int j = 0; j < i-1; j++){
    if(j + 1 != p) cout << j + 1 << endl;
  }
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#define rep(i, start, end) for (int i = start; i < end; ++i)
using namespace std;
typedef long long ll;

int n, m;
vector<int> a;
ll ans;

int main() {
   cin >> n >> m;
   rep(i, 0, n) {
      int x;
      cin >> x;
      a.push_back(x);
   }

   sort(a.begin(), a.end());

   rep(i, 0, m) {
       int x = a.back() / 2;
       a.pop_back();
       auto l = upper_bound(a.begin(), a.end(), x);
       a.insert(l, x);
   }

   rep(i, 0, n) {
       ans += a.back();
       a.pop_back();
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;



int main()
{

     string s,t;
     ll i,c=0;

     cin>>s>>t;

     for(i=0;i<3;i++)
     {
         if(s[i]==t[i])c++;
     }

     cout<<c<<endl;

    return 0;
}



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

int main(void){
  int bingo[3][3];
  bool check[3][3];
  int A;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>A;
      bingo[i][j]=A;
      check[i][j]=false;
    }
  }
  int N;
  cin>>N;
  int b;
  for(int i=0;i<N;i++){
    cin>>b;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(bingo[j][k]==b){
          check[j][k]=true;
        }
      }
    }
  }
  bool retval=false;
  if(check[0][0] && check[0][1] && check[0][2])retval=true;
  if(check[1][0] && check[1][1] && check[1][2])retval=true;
  if(check[2][0] && check[2][1] && check[2][2])retval=true;
  if(check[0][0] && check[1][0] && check[2][0])retval=true;
  if(check[0][1] && check[1][1] && check[2][1])retval=true;
  if(check[0][2] && check[1][2] && check[2][2])retval=true;
  if(check[0][0] && check[1][1] && check[2][2])retval=true;
  if(check[2][0] && check[1][1] && check[0][2])retval=true;
  if(retval){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

vector<int> v;

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<2*n;i++)
	{
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	long long ans=0;
	for(int i=0;i<2*n;i+=2)
	{
		ans+=v[i];
	}
	printf("%lld",ans);
}

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


//97 98 99
//65 66 67

int main() {
    string A, B, C; cin >> A >> B >> C;
    int ca=1, cb=0, cc=0;
    vector<string> S{A, B, C};
    vector<int> CT{ca, cb, cc};
    char ch;
    for(int i = 0; i < 1000; i++){
        if(i == 0) ch = S[0][0];
        //cout << ch << " " << ch-97 << "   " << CT[ch-97] << endl;
        int idx = (int)ch-97;
        if(CT[idx] == S[idx].size()) {cout << (char)(ch - 32) << endl; return 0;}
        ch = S[idx][CT[idx]];
        CT[idx]++;
    }
}

Measured memory_bytes: 256
def main():
  N = int(input())
  S = input()

  ans = 0

  # PINの方のパターンが少ないので、PINが文字列から再現できるか全探索する
  for i in range(1000):
    pin = str(i).zfill(3)
    cur = 0

    for char in S:
      if(pin[cur] == char):
        cur += 1

        if(cur == 3):
          ans += 1
          break;

  print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

class vec{
public:
	int x,y;
	vec(int x_=0,int y_=0):x(x_),y(y_){}
	void make(int x_,int y_){
		x = x_; y = y_;
	}
	vec operator + (vec A){
		vec ans(this->x+A.x,this->y+A.y);
		return ans;
	}
	vec operator - (vec A){
		vec ans(this->x-A.x,this->y-A.y);
		return ans;
	}
	int operator * (vec A){
		return this->x*A.x+this->y*A.y;
	}
	bool operator == (vec A){
		return (this->x==A.x && this->y==A.y);
	}
	double r(){
		return sqrt((double)x*x+(double)y*y);
	}
	double sita(){
		double ans = atan2(y,x);
		return (ans<0.000?ans+2.0*M_PI:ans);
	}
};
double sin_sita(vec v1,vec v2){ // v2 basis
	return double(v2.x*v1.y-v2.y*v1.x)/v1.r()/v2.r();
}
double cos_sita(vec v1,vec v2){ // v2 basis
	return double(v2.x*v1.x+v2.y*v1.y)/v1.r()/v2.r();
}
bool Ientersected(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy){
	ll ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
	ll tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
	ll tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
	ll td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
	return tc * td <= 0 && ta * tb <= 0;
}

int main(){
	int q,x0,y0,x1,y1,x2,y2,x3,y3;
	cin >> q;
	double EPS = 1e-13;
	FOR(i,0,q){
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		if(max(x0,x1) < min(x2,x3) || max(x2,x3) < min(x0,x1)){
			cout << 0 << endl;
			continue;
		}
		if(max(y0,y1) < min(y2,y3) || max(y2,y3) < min(y0,y1)){
			cout << 0 << endl;
			continue;
		}
		if(Ientersected(x0,y0,x1,y1,x2,y2,x3,y3)){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}

}


Measured memory_bytes: 3088
a,b,c = map(int,input().split())
MOD = 10**9+7

def comb(n,r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= MOD
        fac *= i+1
        fac %= MOD
    return res*pow(fac,MOD-2,MOD)%MOD 

p = pow(2,a,MOD)
q = comb(a,b)
r = comb(a,c)
ans = (p-q-r-1)%MOD
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define reg register
#define maxn 1000005
#define M 1000000007
using namespace std;
inline int read()
{
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int siz,n,k,a[maxn],b[maxn],sum[maxn],c[maxn],d[maxn];
long long ans;
int lowbit(int x){return x&-x;} 
int query(int x)
{
    int res = 0;
    for(int i = x; i; i -= lowbit(i)) res += sum[i];
    return res;
}
void update(int x)
{
    for(int i = x;i <=siz; i+=lowbit(i))sum[i]++;
}
int main()
{
    n = read(); k =read();
    for (int i = 1; i <= n; i++) a[i] = read(), b[i] = a[i];
    sort(b + 1,b + n + 1);
    siz = unique(b + 1, b + n + 1) - b - 1;
    for(int i = n; i >= 1;i--)
    {
        int x = lower_bound(b + 1, b + siz + 1, a[i]) - b ;
        c[i] = query(x - 1);
        update(x);
    }
    for(int i = 1;i <= n; i++)
    {
        int x = lower_bound(b + 1, b + siz + 1, a[i]) - b ;
        d[i] = query(x - 1);
    }
    for(int i = 1;i <= n; i++)
    {   
        ans = (ans + 1ll * c[i] * k) % M;
        ans = (ans + 1ll * k  * (k-1) / 2 % M * d[i] % M)%M;
    } 
    printf("%lld",ans);
}

Measured memory_bytes: 8448
n, t = map(int, input().split())
a = list(map(int, input().split()))


#最小値が更新された時にそれまでの利益の最大値を候補としてリストに追加
a.append(0)
mini = 10e10
maxval = 0
maxvals = []
for x in a:
    if mini > x:
        mini = x
        maxvals.append(maxval)
        maxval = 0
    else:
        maxval = max(maxval, x - mini)

print(maxvals.count(max(maxvals)))
#3 2
#100 50 200

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
struct obs{
	int h;
	vector<int> el;
};
int cnt;obs ob[100010];
int main()
{
	
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>ob[i].h;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		ob[x-1].el.push_back(y-1);
		ob[y-1].el.push_back(x-1);
	}
	for(int i=0;i<n;i++)
	{     
		set<int>s(ob[i].el.begin(),ob[i].el.end());
		ob[i].el.assign(s.begin(),s.end());
	}
	for(int i=0;i<n;i++)
	{
		int frag=1;
		for(vector<int>::iterator it=ob[i].el.begin();it!=ob[i].el.end();it++)
			if(ob[i].h<=ob[*it].h)
				frag=0;
		if(frag==1)
		{
			cnt++;
				
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  if(n==1){
  cout << 0 << endl;
  }
  else{
  cout << 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>

int main()
{
    int N, H[101];
    int ans = 1;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> H[i];
    }
    for (int j = 1; j < N; j++) {
        for (int k = 0; k < j; k++) {
            if (H[k] > H[j]) {
                break;
            }
            if (k == j - 1) {
                ans++;
            }
        }
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	ll a, b;
	cin >> n >> a >> b;
	ll c = a - b;
	vi v(n);
	REP(i, n)
	{
		cin >> v[i];
	}
	ll mi = 0;
	ll ma = (ll)1e9;
	while (mi != ma) {
		ll mid = mi + (ma - mi) / 2;
		cnt = 0;
		REP(i, n)
		{
			if (v[i] - b * mid > 0) {
				cnt += ((v[i] - b * mid) + (c - 1)) / c;
			}
		}
		if (cnt <= mid) {
			ma = mid;
		} else {
			mi = mid + 1;
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1024