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

ll mod = 998244353;

class BIT{
    public:
    int size;
    vector<int> tree;
    
    void set(int n){
        size = n;
        tree = vector<int>(n+1, 0);
        return;
    }
    
    void add(int n, int a) {
        int x = n;
        while (x <= size){
            tree[x] += a;
            x += (x & -x);
        }
        return;
    }
    
    int sum(int n) {
        int x = n;
        int sum = 0;
        while (x > 0) {
            sum += tree[x];
            x -= (x & -x);
        }
        return sum;
    }
    
};

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> points(N);
    vector<int> xs(N), ys(N);
    for (int i = 0; i < N; i++) {
        cin >> xs[i] >> ys[i];
        points[i] = {xs[i], ys[i]};
    }
    sort(points.begin(), points.end());
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    for (int i = 0; i < N; i++) {
        points[i].first = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), points[i].first))+1;
        points[i].second = distance(ys.begin(), lower_bound(ys.begin(), ys.end(), points[i].second))+1;
    }
    
    BIT bit1, bit2;
    bit1.set(N+2);
    bit2.set(N+2);
    
    ll ans = 0;
    
    vector<ll> pow2(N+2, 1);
    for (int i = 1; i <= N; i++) pow2[i] = pow2[i-1]*2%mod;
    
    for (int i = 0; i < N; i++) {
        int y = points[i].second;
        int ss = bit1.sum(y), sb = i - bit1.sum(y);
        int bs = y - 1 - bit1.sum(y), bb = N - y - (i - bit1.sum(y));
        ans += (pow2[ss]-1) * (pow2[bb]-1) % mod * (pow2[sb] + pow2[bs] - 1) % mod;
        ans += (pow2[sb]-1) * (pow2[bs]-1) % mod * (pow2[ss] + pow2[bb] - 1) % mod;
        ans += (pow2[sb]-1) * (pow2[bs]-1) % mod * (pow2[ss] - 1)  % mod * (pow2[bb] - 1) % mod;
        ans += pow2[N-1];
        ans %= mod;
        bit1.add(y, 1);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include<string>
using namespace std;
typedef long long ll;
int main(){
    string s;
    ll k;
    cin >> s >> k;
    int first_i=s.size();
    int first_num = 1;
    for(int i=0;i<s.size();i++){
        if(s[i]!='1'){
            first_i = i;
            first_num = s[i]-'0';
            break;
        }
    }
    if(k < first_i+1){
        cout << 1 << endl;
    }
    else{
        cout << first_num << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> kazu(n);
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j+=i){
      kazu[j-1]++;
    }
  }
  long long ans=0;
  for(int i=0;i<n;i++)ans+=(i+1)*kazu[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 81320
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  string c,d,e;cin>>c>>d;
  int a,b;cin>>a>>b>>e;

  if(e==c)a--;else b--;
  cout<<a<<" "<<b<<endl;
  
  return 0;
}

Measured memory_bytes: 256
program prob6
    implicit none
    integer(8), parameter :: ma = 200005
    integer(8), parameter :: mo = 1000000007
    integer(8) :: n, i
    integer(8), allocatable :: c(:)
    integer(8) :: pre(ma)
    integer(8), allocatable :: dp(:)

    read(*,*) n
    allocate(c(n), dp(0:n))

    do i = 1, n
        read(*,*) c(i)
    end do

    dp(0) = 0
    dp(1) = 1
    do i = 1, ma
        pre(i) = 0
    end do
    pre(c(1)) = 1
    do i = 2, n
        if(c(i) == c(i-1)) then
            dp(i) = dp(i-1)
            pre(c(i)) = i
        else
            dp(i) = mod(dp(i-1) + dp(pre(c(i))), mo)
            pre(c(i)) = i
        end if
    end do

    write(*,*) dp(n)
    deallocate(dp, c)

    stop
contains
end program prob6

Measured memory_bytes: 7240
#include <iostream>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

int main(){
    int N, K; cin >> N >> K;
    vector<int> P(N);
    vector<long long> C(N);
    for(auto& t : P){ cin >> t; --t; }
    for(auto& t : C) cin >> t;
    long long res = -INF;
    for(int i=0;i<N;i++){
        int loop = 0;
        long long loopCost = 0;
        int pos = i;
        do {
            ++loop;
            loopCost += C[pos];
            pos = P[pos];
        } while(pos != i);
        long long partMx = 0;
        int part = K%loop;
        if(part == 0) part = loop;
        long long curCost = 0;
        for(int j=0;j<loop;j++){
            curCost += C[pos];
            if(j < K) res = max(res, curCost);
            if(j < part) partMx = max(partMx, curCost);
            pos = P[pos];
        }
        if(K >= loop && loopCost > 0) res = max(res, (K/loop-(part==loop ? 1 : 0))*loopCost + partMx);
    }
    cout << res << endl;
}

Measured memory_bytes: 3700
object Main {
  import io.StdIn._

  def getStrings = readLine().split(" ")
  def getInts = getStrings.map(_.toInt)

  def main(args: Array[String]): Unit = {
    val N = getInts(0)
    val primes = Array(3, 5, 7, 9, 11, 13, 17, 19, 23, 29, 31, 37)
    val three = for(p1 <- primes; p2 <- primes if p2 != p1; p3 <- primes if p3 != p2 && p3 != p1) yield p1 * p2 * p3
    val two = for(p1 <- primes; p2 <- primes if p2 != p1) yield p1 * p1 * p1 * p2
    println((three ++ two).toSet.count(_ <= N))
  }
}


Measured memory_bytes: 25540
import numpy as np
n, W = map(int, input().split())

w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = np.zeros((n+1, W+1))

for i in range(n):
    dp[i+1, :w[i]] = dp[i, :w[i]]
    dp[i+1, w[i]:] = np.maximum(dp[i, w[i]:], dp[i, :W-w[i]+1]+v[i])

print(int(max(dp[-1])))


Measured memory_bytes: 105856
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

struct Union_Find{
  vector<int> par,rank;
  
  void init(int n){
    par.resize(n); rank.resize(n);
    for(int i = 0 ; i < n ; i ++){
      par[i] = i;
      rank[i] = 0;
    }
  }
  
  int find(int s){
    if(par[s] == s)return s;
    return par[s] = find(par[s]);
  }

  void unite(int x,int y){
    int a = find(x),  b = find(y);
    if(a==b)return ;
    if(rank[a] < rank[b]) par[a] = b;
    else{
      par[a] = b;
      if(rank[a] == rank[b]){
	rank[b]++;
      }
    }
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }

  bool size(int x,int y){
    return par.size();
  }
};

void solve(){
  int N,Q;
  cin>>N>>Q;
  Union_Find uf;
  uf.init(N);
  rep(i,Q){
    int ord,x,y;
    cin>>ord>>x>>y;
    if(ord){
      cout<<uf.same(x,y)<<endl;
    }else{
      uf.unite(x,y);
    }
  }
}

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

Measured memory_bytes: 1344
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

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

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi, a = gi, b = gi;
    print(min(a*n, b));
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] a = new int[N + 1],f = new int[N + 1];
        for(int i = 1; i <= N; i ++) a[i] = sc.nextInt();
        for(int i = 2; i <= N; i++){
            if(i == 2)f[i] = f[i - 1] + Math.abs(a[i] - a[i - 1]);
            else f[i] = Math.min(Math.abs(a[i] - a[i - 1]) + f[i - 1],Math.abs(a[i] - a[i - 2]) + f[i - 2]);
        }
        System.out.println(f[N]);
    }
}

Measured memory_bytes: 59792
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int a, b;
	cin >> a >> b;
	int ave = (int)ceil((double)(a + b) / 2);
	cout << ave << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int  h,w;
    int cnt=0;
    cin>>h>>w;
    vector<string> a(h),b;
    REP(i,h) {
        cin>>a[i];
        REP(j,w) {
            if(a[i][j]=='#') cnt++;
        }
    }
    b=a;

    queue<pii> q;
    cnt--;
    q.push({0,0});
    a[0][0]='.';
    while(!q.empty()) {
        int y=q.front().first;
        int x=q.front().second;
        q.pop();

        if(x<w-1 && a[y][x+1]!='.') {
            if(a[y][x+1]=='#') cnt--;
            a[y][x+1]='.';
            q.push({y,x+1});
        }
        else if(y<h-1 && a[y+1][x]!='.') {
            if(a[y+1][x]=='#') cnt--;
            a[y+1][x]='.';
            q.push({y+1,x});
        }
    }
    if(cnt==0) {
        cout<<"Possible"<<endl;
    }
    else cout<<"Impossible"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int GCD(int a,int b){
  if(a < b){
    int c = b;
    b = a;
    a = c;
  }
  int d = 1;
  while(d =! 0){
    d = a % b;
    a = b;
    b = d;
    if(d == 0){
      return a;
      break;
    }
  }
}
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int gcd = GCD(a,b);
  int num = 0;  
  for(int i = 1;;i++){
    if(gcd % i == 0){
      num++;
      if(num == k){
        cout << gcd / i << endl;
        break;
      }
    }
  }
}

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

int n;
int H, W;
vector<pair<int, pair<int, int> > > cards;

vector<int> uf;
vector<int> ncard;
int getpar(int a) {
	return uf[a] < 0 ? a : (uf[a] = getpar(uf[a]));
}
bool good(int a, int b) {
	a = getpar(a);
	b = getpar(b);
	if (a == b) {
		if (ncard[a] == -uf[a]) return false;
		ncard[a]++;
		return true;
	} else {
		if (-uf[a] + -uf[b] == ncard[a] + ncard[b]) return false;
		if (-uf[a] < -uf[b]) swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
		ncard[a] += 1;
		ncard[a] += ncard[b];
		return true;
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> H >> W;
	cards.resize(n);
	for (int i = 0; i < n; i++) {
		int r, c, a;
		cin >> r >> c >> a;
		r--; c--;
		c += H;
		cards[i] = make_pair(a, make_pair(r, c));
	}
	sort(cards.begin(), cards.end());
	reverse(cards.begin(), cards.end());

	int V = H+W;
	uf.assign(V, -1);
	ncard.assign(V, 0);
	long long tot = 0;
	for (int i = 0; i < int(cards.size()); i++) {
		pair<int, pair<int, int> >& card = cards[i];
		if (good(card.second.first, card.second.second)) {
			tot += card.first;
		}
	}
	cout << tot << '\n';
}


Measured memory_bytes: 2944
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int min = Integer.MAX_VALUE;

		String[] x = new String[S.length()];
		for(int i=0; i<S.length(); i++){
			String str = String.valueOf(S.charAt(i));
			x[i] = str;
			if(i>1){
				int X = Integer.parseInt(x[i-2]+x[i-1]+x[i]);
				//System.out.println(X);
				int d = Math.abs(753-X);
				if(d<min){
					min = d;
				}
			}
		}
		System.out.println(min);
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> t;
  vector<int> x;
  vector<int> y;
  for(int i=0;i<N;i++){
    int _t,_x,_y;
    cin >> _t >> _x >> _y;
  t.push_back(_t);
  x.push_back(_x);
  y.push_back(_y);
  }
  int count=0;
  int ds;
  int dt;
  for(int i=0;i<N;i++){
    if(i==0){
      ds = x[0] + y[0];
      dt = t[0];
    }else{
    ds = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
    dt = t[i] - t[i-1];
    }
    if(ds <= dt && (ds - dt) % 2 == 0){
      count ++;
    }
//  cout << t[i] << x[i] << y[i] << endl;
  }
  if(count == N){
    cout << "Yes" << endl;
  }else{

    cout << "No" << endl;
  
  }
}

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

using namespace std;

struct UnionFind { /* {{{ */
  vector<int> par;

  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) { par[root(x)] = root(y); }
  bool same(int x, int y) { return root(x) == root(y); }
}; /* }}} */

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> P[i];
  }
  UnionFind uf(N + 1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }
  vector<set<int>> vs(N + 1, set<int>());
  for (int i = 1; i <= N; i++) {
    vs[uf.root(i)].insert(i);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (vs[uf.root(i)].count(P[i])) ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 10368
import fractions

N = int(input())
li = list(map(int, input().split()))

t = []
t.append(li[0])

for index, i in enumerate(li):
  if index == 0:
    continue

  k = fractions.gcd(t[index-1], li[index])
  t.append(k)

print(t[-1])

Measured memory_bytes: 16280
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int r; cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#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=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    map<char, ll> m;
    m['M'] = 0;
    m['A'] = 0;
    m['R'] = 0;
    m['C'] = 0;
    m['H'] = 0;
    REP(i, n) {
        string s;
        cin >> s;
        if ((s[0] == 'M') || (s[0] == 'A') || (s[0] == 'R') || (s[0] == 'C') || (s[0] == 'H')) {
            m[s[0]]++;
        }
    }
    string march = "MARCH";
    ll res = 0;
    FOR(i, 0, 4) {
        FOR(j, i+1, 4) {
            FOR(k, j+1, 4) {
                res += m[march[i]] * m[march[j]] * m[march[k]];
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

queue<char> cards[3];
int main(){
  for (int i = 0; i < 3; i++){
    string tmp;
    cin >> tmp;
    for (int j = 0; j < tmp.size(); j++){
      cards[i].push(tmp[j]);
    }
  }
  int turn = 0;
  while (true){
    //cout << turn << endl;
    if (cards[turn].empty()){
      cout << char('A' + turn) << endl;
      return 0;
    }
    char c = cards[turn].front();
    cards[turn].pop();

    if (c == 'a'){
      turn = 0;
    }else if(c == 'b'){
      turn = 1;
    }else{
      turn = 2;
    }
  }

  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    vector<pair<int,int>> task(n);
    for (int i = 0; i < n; i++) {
        task[i].first = get<int>();
        task[i].second = get<int>();
    }

    sort(task.begin(), task.end(),
         [](auto a, auto b) { return a.second < b.second; });

    int t = 0;
    for (int i = 0; i < n; i++) {
        t += task[i].first;
        if (t > task[i].second)
            goto No;
    }
    cout << "Yes" << endl;
    return 0;
No:
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  getline(cin,s);
  if((s.at(2)==s.at(3)) && (s.at(4)==s.at(5)))
  	cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;
	vector<P> a;
	char c=s[0];
	int cnt=1;
	int type;
	if(s[0]=='J') type=1;
	else if(s[0]=='O') type=2;
	else if(s[0]=='I') type=3;
	for(int i=1; i<s.size(); ++i){
		if(c!=s[i]){
			a.push_back(P(type,cnt));
			cnt=1;
			c=s[i];
			if(s[i]=='J') type=1;
			else if(s[i]=='O') type=2;
			else if(s[i]=='I') type=3;
		} else {
			++cnt;
		}
		if(i==s.size()-1){
			a.push_back(P(type,cnt));
		}
	}
	/*
	for(int i=0; i<a.size(); ++i){
		cout << a[i].first << " " << a[i].second << "\n";
	}
	*/
	
	int ans=0;
	for(int i=0; i+2<a.size(); ++i){
		if(a[i].first==1&&a[i+1].first==2&&a[i+2].first==3){
			//ans=max(ans,min(a[i].second,min(a[i+1].second,a[i+2].second)));
			if(a[i+1].second<=a[i].second&&a[i+1].second<=a[i+2].second) ans=max(ans,a[i+1].second);
		}
	}
	cout  << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 12340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll>a;
	vector<ll>b;
	a.push_back(0);
	b.push_back(0);
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	for(ll j=1;j<=m;j++){
		ll x;
		cin>>x;
		b.push_back(x);
	}
	for(ll i=1;i<=n;i++){
		a[i]=a[i-1]+a[i];
	}
	for(ll i=1;i<=m;i++){
		b[i]=b[i-1]+b[i];
	}
	b.push_back(INF);
	ll ans=0;
	for(ll i=0;i<=n;i++){
		ll ans2=i;
		ll sum=a[i];
		ll zan=k-a[i];
		if(zan==0){
			ans=max(ans,ans2);
			continue;
		}
		if(zan<0){
			continue;
		}
	//	cout <<zan<<endl;
	    auto itr=lower_bound(b.begin(),b.end(),zan);
//	    cout << *itr<< " "<< i<<ans<<endl;
	    if(*itr>zan){
	    	itr--;
	    }
	    ans2+=itr-b.begin();
	 //   cout <<ans2<<endl;
	    ans=max(ans,ans2);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main(){
  string s; cin >> s;
  if(((s.find('E') != string::npos) ^ (s.find('W') != string::npos)) ||
     ((s.find('N') != string::npos) ^ (s.find('S') != string::npos)))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_set<int> as;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        as.insert(a);
    }
    cout << (as.size() == n ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
 
void printv(Vl v){
    for(int i = 0; i < v.size(); i++) cout << v[i] << " \n"[i==v.size()-1];
}
 
/*--------------------------------------------------------------------------------------
 

--------------------------------------------------------------------------------------*/

// O(log (N)) の素因数分解
// エラストテネスの篩を使った素因数分解
// 前処理　O(N loglog(N))

class smart_sieve {
  ll L, R, M;
  vector<int> small;  // 小さい篩
  vector<vector<ll>> large;  // 大きい篩
  vector<ll> aux;  // aux[i] := large[i] の素因数の積

public:
  smart_sieve(ll L, ll R): L(L), R(R), M(sqrt(R)+1) {
    small.resize(M);
    iota(small.begin(), small.end(), 0);
    large.resize(R-L);
    aux.assign(R-L, 1);

    for (ll i = 2; i*i < R; ++i) {
      if (small[i] < i) continue;
      small[i] = i;
      for (ll j = i*i; j < M; j += i)
        if (small[j] == j) small[j] = i;

      for (ll j = (L+i-1)/i*i; j < R; j += i) {
        ll k = j;
        do {
          if (aux[j-L] * aux[j-L] > R) break;

          large[j-L].push_back(i);
          aux[j-L] *= i;
          k /= i;
        } while (k % i == 0);
      }
    }
  }

  vector<ll> factor(ll n) {
    assert(L <= n && n < R);
    vector<ll> res = large[n-L];
    n /= aux[n-L];
    if (n >= M) {
      res.push_back(n);
      return res;
    }
    while (n > 1) {
      res.push_back(small[n]);
      n /= small[n];
    }
    return res;
  }
};

ll b[1000005];

int main() {
	smart_sieve ss(1, 1000001); // 前処理
	
	ll n; cin >> n;
	Vl a(n);
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n){
		Vl fac = ss.factor(a[i]);
		set<ll> factor;
		for(auto it : fac) factor.insert(it);
		for(auto it : factor) b[it]++;
	}

	int f = 0;
	Rep(i, 1, 1000000){
		if(b[i] >= 2) f = 1;
		if(b[i] == n){
			co("not coprime");
			return 0;
		}
	}
	if(f == 0) co("pairwise coprime");
	if(f == 1) co("setwise coprime");

	return 0;
}


Measured memory_bytes: 93704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		A_Beginning solver = new A_Beginning();
		solver.solve(1, in, out);
		out.close();
	}

	static class A_Beginning {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int[] a = new int[4];
			for (int i = 0; i < 4; i++) {
				a[i] = in.nextInt();
			}
			int[] b = {1, 4, 7, 9};
			Arrays.sort(a);
			out.println(Arrays.equals(a, b) ? "YES" : "NO");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

ll t[200010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);
    
    ll N, T; cin >> N >> T;
    for(int i=0; i<N; ++i){
        cin >> t[i];
    }
    
    ll ans=0;
    for(int i=0; i<N-1; ++i){
        if(t[i+1]-t[i]>=T){
            ans += T;
        }else{
            int idx=0;
            while(i+idx<N){
                if(t[i+idx]-t[i]>=T) break;
                idx++;
            }
            idx--;
            ans += t[i+idx]-t[i];
            i = i+idx-1;

        }
    }
    ans += T;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  deque<int> d;
  for (int i = 0; i < n; i++) {
    int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
    if (p == 0) {
      d.push_front(a[i]);
    } else {
      d[p - 1] = a[i];
    }
  }
  cout << d.size() << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.nextInt();
        final int count = sc.nextInt();
        sc.nextLine();
        final String line = sc.nextLine();
        int[] accumulate = new int[line.length()];
        char[] charArray = line.toCharArray();

        int index = 0;
        while (index < line.length()) {
            int from = index;
            index = line.indexOf("AC", index);
            if (index != -1) {
                Arrays.fill(accumulate, from, index + 2, from == 0 ? 0 : accumulate[from - 1]);
                accumulate[index + 1] = from == 0 ? 1 : (accumulate[from - 1] + 1);
                index += 2;
            } else {
                Arrays.fill(accumulate, from, accumulate.length, from == 0 ? 0 : accumulate[from - 1]);
                break;
            }
        }
        for (int i = 0; i < count; i++) {
            final int from = sc.nextInt() - 1;
            final int to = sc.nextInt() - 1;
            int result = accumulate[to] - accumulate[from];
            System.out.println(result);
        }

    }
}


Measured memory_bytes: 68400
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

std::vector<int> sieve_of_eratosthenes(int n) {
  std::vector<int> primes(n);
  for (int i = 2; i < n; ++i) primes[i] = i;
  for (int i = 2; i * i < n; ++i)
    if (primes[i]){
      for (int j = i * i; j < n; j += i) primes[j] = 0;
    }
  return primes;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v = sieve_of_eratosthenes(2e5);
    ll x;
    cin>>x;
    FOR(i,x,2e5){
        if(v[i] != 0){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

k = int(input())
ans = 0
rev = 0
for i in range(1, k + 1):
    for j in range(i, k + 1):
        tmp = gcd(i, j)
        for l in range(j, k + 1):
            if i == j and j == l:
                ans += i
            elif i == j or j == l or l == i:
                ans += gcd(tmp, l) * 3
            else:
                ans += gcd(tmp, l) * 6
print(ans)


Measured memory_bytes: 9572
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int64_t n, t, a;
std::vector<double> h_list;

double ToTemp(int64_t h)
{
    return std::abs(t - (h * 0.006));
}

int main(void)
{
    std::cin >> n >> t >> a;

    for (int64_t i=0; i<n; ++i) {
        int64_t h;
        std::cin >> h;
        h_list.emplace_back(std::abs(a - (t - (h * 0.006))));
    }

    auto it = std::min_element(h_list.begin(), h_list.end());

    std::cout << 1 + it - h_list.begin() << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
         BufferedReader br 
           = new BufferedReader(new InputStreamReader(System.in));
           
        String str = br.readLine();
        
        String[] strArry = str.split(" ");
        int num = 0;
        int a = Integer.parseInt(strArry[0]);
        int b = Integer.parseInt(strArry[1]);
        int c = Integer.parseInt(strArry[2]);
        
        for(int i = a;i<=b;i++){
             if(c%i==0)
               num++;
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 24400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if(op=='+')
    A += B;
  else if(op=='-')
    A -= B;
  else{
    cout << "error" << endl;
  }
  cout << A << endl;
}

Measured memory_bytes: 256
import collections

n = int(input())
v = [int(i) for i in input().split()]

c1 = collections.Counter(v[0::2]).most_common()
c2 = collections.Counter(v[1::2]).most_common()
c1.append([0,0])
c2.append([0,0])
if(c1[0][0]!=c2[0][0]):
    print(n-c1[0][1]-c2[0][1])
elif(c1[1][1]>c2[1][1]):
    print(n-c1[1][1]-c2[0][1])
else:
    print(n-c1[0][1]-c2[1][1])


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	string S;
	cin >> S;
	map<char, int> m;
	for (auto s : S) m[s]++;

	bool ans = true;
	for (auto mm : m)
		if (mm.second != 1)
			ans = false;

	yn(ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int per[100001],peo[100001],m=1e9+7,n;
long long ans=1;
void init(int x)
{
    if(x%2==0) for(int i=1;i<=x;i+=2) peo[i]=i,peo[i+1]=peo[i];
    else for(int i=2;i<=x;i+=2) peo[i]=i,peo[i+1]=peo[i];
}
int main()
{
    cin>>n;
    if(n%2==0) for(int i=1;i<=n;i+=2) peo[i]=i,peo[i+1]=peo[i];
    else for(int i=2;i<=n;i+=2) peo[i]=i,peo[i+1]=peo[i];
    for(int i=1;i<=n;i++) cin>>per[i];
    sort(per+1,per+1+n);
    for(int i=1;i<=n;i++) if(peo[i]!=per[i])
        {
            cout<<"0";
            return 0; 
        }
    n/=2;
    while(n--) ans=ans*2%m;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
W, H, N = map(int, input().split())    
xya_list = [list(map(int, input().split())) for  _ in range(N)]
x_lower, x_upper, y_lower, y_upper =0, W,  0, H
for i in xya_list:
    if i[2] == 1 and i[0] > x_lower:
        x_lower = i[0]
    elif i[2] == 2 and i[0] < x_upper:
        x_upper = i[0]
    elif i[2] == 3 and i[1] > y_lower:
        y_lower = i[1]
    elif i[2] == 4 and i[1] < y_upper:
        y_upper = i[1]

area = (x_upper - x_lower) * (y_upper - y_lower)
if x_upper - x_lower > 0 and y_upper - y_lower > 0:
    print(area)
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  int ans = 0;
  rep(i, 3) {
    if(S[i] == T[i]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
	int a,b,cont[10000+50],boom[105][105];
	while(cin>>a>>b)
	{
		memset(cont,0,sizeof(cont));
		memset(boom,0,sizeof(boom));
		int n,i,j,sum=0;
		cin>>n;
		//temp=n;
		for(i=0;i<n;i++)
			cin>>cont[i];
		for(i=0;i<a;i++)
		{
			if(i%2==0)
				for(j=0;j<b;j++)
				{
					boom[i][j]=sum+1;
					cont[sum]--;
					if(cont[sum]==0)sum++;
				}
			else
				for(j=b-1;j>=0;j--)
				{
					boom[i][j]=sum+1;
					cont[sum]--;
					if(cont[sum]==0)sum++;
				}
		}
		for(i=0;i<a;i++)
		{
			for(j=0;j<b-1;j++)
				cout<<boom[i][j]<<" ";
			cout<<boom[i][j]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();

        int count = 0;
        int n = 1;
        while (true) {
            if ((t + 0.5) < a * n) {
                break;
            }
            n++;
            count += b;

        }
        System.out.println(count);
    }


}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<int> G[90005];

int main(){
  int H, W, D;
  cin >> H >> W >> D;

  vector<vector<int>> v(H*W+1);
  rep(y,H){
    rep(x,W){
      int a;
      cin >> a;
      v[a] = {y+1,x+1};
    }
  }

  G[0].push_back(0);
  REP(i,1,v.size()){
    int m = i%D;
    int x = 0;
    if(i-D>0){
      x = abs(v[i][0] - v[i-D][0]) + abs(v[i][1] - v[i-D][1]);
    }
    if(G[m].size() == 0) G[m].push_back(0);
    else G[m].push_back( G[m][G[m].size()-1] + x );
  }
  
  int Q;
  cin >> Q;
  rep(i,Q){
    int l, r;
    cin >> l >> r;
    cout << G[r%D][r/D] - G[l%D][l/D] << endl;    
  }
  
  return 0;
}

Measured memory_bytes: 10240
#include <cstdio>
using namespace std;

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a + b == 15)
		printf("+");
	else if (a*b == 15)
		printf("*");
	else
		printf("x");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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<int, int> P;

#define MAX_V 1000000
#define MAX_N 1000000
#define MAX_E 1000000
struct edge {int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

edge es[MAX_E];
int V, E;

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		depth[i] = 0;
	}
}

// 木の根を求める
int find(int x) {
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(depth[x] < depth[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}

int kruskal() {
	sort(es, es + E, comp);
	init(V);
	int res = 0;
	rep(i, 0, E) {
		edge e = es[i];
		if(!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

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

  cin >> V >> E;
  rep(i, 0, E) {
    int s, t, w;
    cin >> s >> t >> w;
    edge e = {s, t, w};
    es[i] = e;
  }
  int res = kruskal();
  cout << res << endl;
}



Measured memory_bytes: 4436
#define  _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
signed main() {
	char c;
	int n = 0, w = 0, s = 0, e = 0;
	while (scanf("%c",&c),c!='\n'&&c!=EOF) {
		if (c == 'N')n = 1;
		if (c == 'W')w = 1;
		if (c == 'S')s = 1;
		if (c == 'E')e = 1;
	}
	if ((n == 1 && s == 0) || (s == 1 && n == 0) || (w == 1 && e == 0) || (e == 1 && w == 0)) {
		cout << "No";
	}
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


vector<int> prime(int x) {
    vector<int> ans;
    vector<bool> prime(x + 1, true);
    prime[0] = prime[1] = false;
    rep(i, x + 1) {
        if (prime[i]) {
            for (int j = i + i; j < x + 1; j += i) {
                prime[j] = false;
            }
        }
    }
    
    rep(i, x + 1) {
        if (prime[i] == true) ans.push_back(i);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, K;
    cin >> N >> K;

    vll a(K + 1);
    vll pows(K + 1);
    ll p = 1000000007;
    REP(i, 1, K + 1) {
        pows[i] = modpow(K / i, N, p);
    }
    auto primes = prime(K);
    ll ans = 0;
    vll subs(K + 1);
    for (int i = K; i >= 0; i--) {
        ll sub = 0;
        REP(j, 1, K + 1) {
            if (ll(i) * ll(j) > K) break;
            sub += a[i * j];
            //sub += pows[ll(i) * ll(prime)]; //a[ll(i) * ll(prime)] + mod(pows[ll(i) * ll(prime)] - a[ll(i) * ll(prime)], p);
            sub %= p;
        }
        a[i] = mod(pows[i] - sub, p);
        ans += i * a[i];
        subs[i] = sub;
        ans %= p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5576
#include <iostream>
using namespace std;
int board[100][100],w,h,xg,yg;
bool f(int y,int x,int color){
	board[y][x] = -1;
	int dy[] = {-1,0,0,1},dx[] = {0,-1,1,0},i;
	if(y == yg - 1 && x == xg -1) return true;
	for(i = 0;i < 4;i++){
		if(y + dy[i] > -1 && y + dy[i] < h && x + dx[i] > -1 && x + dx[i] < w){
			if(board[y+dy[i]][x+dx[i]] == color){
				if(f(y+dy[i],x+dx[i],color)) return true;
			}
		}
	}
	return false;
}
int main(){
	int xs,ys,n,i,j,k,c,d,x,y;
	while(cin >> w >> h && (w != 0 && h != 0)){
		for(j = 0;j < 100;j++){
			for(i = 0;i < 100;i++){
				board[j][i] = -1;
			}
		}
		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;
		for(i = 0;i < n;i++){
			cin >> c >> d >> x >> y;
			x -= 1;
			y -= 1;
			if(d == 0){
				for(j = 0;j < 2;j++){
					for(k = 0;k < 4;k++){
						board[y+j][x+k] = c;
					}
				}
			}
			else if(d == 1){
				for(j = 0;j < 2;j++){
					for(k = 0;k < 4;k++){
						board[y+k][x+j] = c;
					}
				}
			}
		}
		if(board[ys - 1][xs - 1] != -1){
			if(f(ys - 1,xs -1,board[ys - 1][xs - 1])) cout << "OK" << endl;
			else cout << "NG" << endl;
		}
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int X = (A + D - 1) / D;
    int Y = (C + B - 1) / B;
    cout << (X >= Y ? "Yes":"No");
    return 0;
}

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

int main() {
	vector<int> v(10);
	for (int i = 0; i < 10; i++) {
		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < 3; i++) {
		cout << v.at(i) << endl;
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
int n,m,v,p,a[MAXN];
bool chk (int x) {
	int tmp=v-p;
	ll res=1ll*(x-1)*m;
	for (int i=x+1;i<=n-p+1;i++) {
		if (a[i]>a[x]+m) {return 0;}
		res+=a[x]+m-a[i];
	}
	return (res>=1ll*m*tmp);
}
int main () {
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);}
	sort(a+1,a+n+1);
	int l=1,r=n-p+2;
	while (l<r) {
		int mid=(l+r)>>1;
		if (chk(mid)) {r=mid;}
		else {l=mid+1;}
	}
	printf("%d\n",n-l+1);
	return 0;
}

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

int main () {
  string O, E;
  cin >> O >> E;
  int o = O.size();
  
  if(O.size() == E.size()) {
    for (int i = 0; i < O.size(); i++) {
    cout << O.at(i) << E.at(i);
    }
  }
  else {
    for (int i = 0; i < E.size(); i++) {
    cout << O.at(i) << E.at(i);
    }
    cout << O.at(o-1);
  }
}

Measured memory_bytes: 256