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

int main(){
	int N;
	cin >> N;
	vector<ll> H(N);
	rep(i,N){
		cin >> H[i];
	}
	
	int temp = 0;
	int ans = 0;
	int val = 0;
	
	rep(i,N-1){
		if (H[i] >= H[i+1]){
			temp++;
		}else{
			temp = 0;
		}
		ans = max(ans,temp);
	}
	cout << ans << endl;
	
	
}



Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

struct BipartiteMatching {
  int n, m;
  vector<vector<int>> graph;
  vector<int> matched, match;
  vector<int> edgeview;
  vector<int> level;
  vector<int> reached[2];
  BipartiteMatching(int n, int m) : n(n), m(m), graph(n), matched(m, -1), match(n, -1) {}

  bool assignLevel() {
    bool reachable = false;
    level.assign(n, -1);
    reached[0].assign(n, 0);
    reached[1].assign(m, 0);
    queue<int> q;
    for (int i = 0; i < n; i++) {
      if (match[i] == -1) {
        level[i] = 0;
        reached[0][i] = 1;
        q.push(i);
      }
    }
    while (!q.empty()) {
      auto cur = q.front(); q.pop();
      for (auto adj : graph[cur]) {
        reached[1][adj] = 1;
        auto next = matched[adj];
        if (next == -1) {
          reachable = true;
        } else if (level[next] == -1) {
          level[next] = level[cur] + 1;
          reached[0][next] = 1;
          q.push(next);
        }
      }
    }
    return reachable;
  }

  int findpath(int nod) {
    for (int &i = edgeview[nod]; i < graph[nod].size(); i++) {
      int adj = graph[nod][i];
      int next = matched[adj];
      if (next >= 0 && level[next] != level[nod] + 1) continue;
      if (next == -1 || findpath(next)) {
        match[nod] = adj;
        matched[adj] = nod;
        return 1;
      }
    }
    return 0;
  }

  int solve() {
    int ans = 0;
    while (assignLevel()) {
      edgeview.assign(n, 0);
      for (int i = 0; i < n; i++)
        if (match[i] == -1)
          ans += findpath(i);
    }
    return ans;
  }
};

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int>> dat(n, vector<int>(m));
  BipartiteMatching bp(n, n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &dat[i][j]);
      dat[i][j]--;
      int row = dat[i][j] / m;
      bp.graph[row].push_back(i);
    }
  }
  for (int col = 0; col < m; col++) {
    bp.solve();
    for (int row = 0; row < n; row++) {
      int i = bp.match[row];
      for (int j = col; j < m; j++) {
        if (dat[i][j] / m == row) {
          if (j != col) swap(dat[i][j], dat[i][col]);
          break;
        }
      }
      bp.graph[row].erase(find(bp.graph[row].begin(), bp.graph[row].end(), i));
    }
    bp.match.assign(n, -1);
    bp.matched.assign(n, -1);
  }
  vector<vector<int>> B = dat;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d%c", B[i][j] + 1, " \n"[j + 1 == m?1:0]);
    }
  }
  vector<vector<int>> C(n, vector<int>(m));
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      C[B[i][j] / m][j] = B[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d%c", C[i][j] + 1, " \n"[j + 1 == m ? 1 : 0]);
    }
  }
  return 0;
}


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

int main() {

    int N, Q;
    cin >> N >> Q;
    vector<int> nodes(N, 0);
    vector<int> nodes_used(N, 1);  // 使われたら0にして加算できなくする
    int a, b, p, x;
    map<int, vector<int>> connections;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        connections[a-1].push_back(b-1);
        connections[b-1].push_back(a-1);
    }
    for(int i=0;i<Q;i++){
        cin >> p >> x;
        nodes.at(p-1) += x;
    }
    vector<int> next_keys = {0};
    vector<int> next_search;
    int next_key, target;
    while (!next_keys.empty()){
        next_key = next_keys.back();
        next_keys.pop_back();
        next_search = connections[next_key];

        for(int i=0;i<next_search.size();i++){
            target = next_search.at(i);
            if(nodes_used.at(target) == 1){
                nodes.at(target) += nodes.at(next_key);
                next_keys.push_back(target);
            }

        }
        nodes_used.at(next_key) = 0;
    }
    for (int i=0;i<N;i++){
        cout << nodes.at(i);
        if(i==N-1){
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

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

using namespace std;

typedef long long ll;

int main() {
    float d,t,s;
    cin >> d >> t >> s;
    float m = d / s;
    if (m <= t){
        cout << "Yes"<<endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3700
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0

for i in range(N):
    # iの村のモンスターを処理する
    if b[i] >= a[i]:
        b[i] -= a[i]
        count += a[i]
        a[i] = 0
    else:
        a[i] -= b[i]
        count += b[i]
        b[i] = 0

    # i+1の村の処理を行う
    if b[i] > 0:
        if b[i] >= a[i+1]:
            b[i] -= a[i+1]
            count += a[i+1]
            a[i+1] = 0
        else:
            a[i+1] -= b[i]
            count += b[i]
            b[i] = 0
# モンスターの数
print(count)


Measured memory_bytes: 82020
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    string S;
    cin>>S;
    if (S[1]=='S'){
        if (S[0]=='R'||S[2]=='R') cout<<1<<endl;
        else cout<<0<<endl;
    }
    else{
        int n=1;
        if (S[0]=='R') n++;
        if (S[2]=='R') n++;
        cout<<n<<endl;
    }
    return 0;
}

Measured memory_bytes: 3564
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)
	fmt.Println(contest(x))
}

func contest(x int) string {
	if x < 1200 && x >= 1 {
		return "ABC"
	} else {
		return "ARC"
	}
}

Measured memory_bytes: 512
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-30:23:34:30
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n, x; cin >> n >> x;
  int cur = 0;
  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    int l; cin >> l;
    cur += l;
    if (cur <= x)  ++cnt;
  }

  cout << cnt + 1 << endl;

  return 0;
}

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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int main(void) {
  int n; std::cin >> n;
  std::vector<int> ds(n);
  REP(i, n) std::cin >> ds[i];

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

  std::cout << ds[n / 2] - ds[n / 2 - 1] << std::endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

long int max(long int a,long int b){
  if(a > b){
    return a;
  }else{
    return b;
  }
}

long int V[101][100001];

int main(){
  int N,W;
  scanf("%d%d",&N,&W);
  long int w[N+1],v[N+1];
  for(int i = 1;i <= N;i++){
    scanf("%ld%ld",&w[i],&v[i]);
  }
  for(int i = 0;i <= W;i++){
    V[0][i] = 0;
  }
  for(int i = 0;i <= N;i++){
    V[i][0] = 0;
  }
  
  for(int i = 1;i <= N;i++){
    for(int j = 1;j <= W;j++){
      if(w[i] <= j){
        V[i][j] = max(V[i-1][j-w[i]] + v[i],V[i-1][j]);
      }else{
        V[i][j] = V[i-1][j];
      }
    }
  }
  printf("%ld\n",V[N][W]);
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long MOD = 1e9 + 7;
    vector<long long> A(N);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum = (sum + A[i]) % MOD;
    }
    long long ans = 0;
    for(int i = 0; i < N - 1; i++){
        sum = (sum - A[i] + MOD) % MOD;
        ans = (ans + A[i] * sum % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

const int NMAX = 3e3 + 5;
const int MOD = 1e9 + 7;

int N, dp[NMAX][NMAX], ans;
char S[NMAX];

int sp[NMAX][NMAX];

static inline void Add (int &a, int b)
{
    a = (a + b) % MOD;

    return;
}

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

    cin >> N >> (S + 1);

    dp[1][1] = 1;
    sp[1][1] = 1;

    for(int i = 2; i <= N; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            if(S[i - 1] == '<')
                dp[i][j] = sp[i - 1][j - 1];
            else
                dp[i][j] = sp[i - 1][i - 1] - sp[i - 1][j - 1];

            if(dp[i][j] < 0)
                dp[i][j] += MOD;

            /*
            for(int k = 1; k < i; ++k)
            {
                int Nr = k;

                if(k >= j)
                    ++Nr;

                if((S[i - 1] == '<' && Nr < j) || (S[i - 1] == '>' && Nr > j))
                    Add(dp[i][j], dp[i - 1][k]);
            }*/
        }

        for(int j = 1; j <= i; ++j)
        {
            sp[i][j] = sp[i][j - 1];

            Add(sp[i][j], dp[i][j]);
        }
    }

    for(int j = 1; j <= N; ++j)
        Add(ans, dp[N][j]);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 69504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
string a,ans;
int main(){
	int n,s=0;cin>>n>>a;ans=a;
	for(int i=0;i<a.size();i++){
		s+=(a[i]=='(')?1:-1;
		if(s<0) ans='('+ans,s++;
	}
	while(s--) ans=ans+')';
	cout<<ans; 
}

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

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

    string s;
    unsigned long long int n;
    cin>>n;
    cin>>s;
    if(n>=s.size())
        cout<<s;
    else{
        s.erase(s.begin()+n,s.end());
        s.append("...");
        cout<<s;
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define N 200005
using namespace std;
const int M=(1<<19)+3;
const int offset=(1<<18);
const long long INF=0x3f3f3f3f3f3f3f3f;
int n,q;
int x[N];
long long xds1[M],xds2[M];long long add;
void modify(long long *xds,int pos,long long val){
	for(pos+=offset;pos;pos>>=1) xds[pos]=min(xds[pos],val-add);
}
long long query(long long *xds,int l,int r){
	if(l>r) return INF;
	long long ret=INF;
	for(l=l+offset-1,r=r+offset+1;l^r^1;l>>=1,r>>=1){
		if(l&1^1) ret=min(ret,xds[l^1]);
		if(r&1) ret=min(ret,xds[r^1]);
	}
	return ret+add;
}

int main(){
	int a,b;
	memset(xds1,0x3f,sizeof(xds1));
	memset(xds2,0x3f,sizeof(xds2));
	scanf("%d%d%d%d",&n,&q,&a,&b);
	for(int i=1;i<=q;i++) scanf("%d",&x[i]);
	modify(xds1,b,b);
	modify(xds2,b,-b);
	for(int i=1,last=a;i<=q;i++){
		long long ans=min(query(xds1,x[i]+1,n)-x[i],query(xds2,1,x[i])+x[i]);
		add+=abs(x[i]-last);
		modify(xds1,last,ans+last);
		modify(xds2,last,ans-last);
		last=x[i];
	}
	long long ans=INF;
	for(int i=1;i<=n;i++) ans=min(ans,xds1[offset+i]-i);
	cout<<ans+add<<endl;
	return 0;
}

Measured memory_bytes: 9344
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
sm = sum(a)
res = 0
div = pow(2, mod - 2, mod)
for x in a:
  res += x * (sm - x)
  res %= mod
print(res * div % mod)

Measured memory_bytes: 92080
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
	string S[N];
    REP(i,N)cin>>S[i];
    
	// 解法
	sort(S, S + N);
	// REP(i,N) printf("%lld %s \n", i, S[i].c_str());

	vector<pair<ll, string>> v;
	REP(i,N){
		if (i==0) v.pb(make_pair(-1, S[0]));
		else if (S[i-1]==S[i]) v[v.size()-1].first--;
		else v.pb(make_pair(-1, S[i]));
	} 
	// sort(v.begin(), v.end(), greater<pair<ll,string> >());
	sort(v.begin(), v.end());
	REP(i,v.size()){
        // printf("%lld %s\n", v[i].first, v[i].second.c_str());
    };
	REP(i,v.size()){
		if (v[i].first==v[0].first) printf("%s\n", v[i].second.c_str());
		else break;
    };
	//出力
}


Measured memory_bytes: 18292
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 1e3 + 4 , M = 1e4 + 3;
int h , n;
int a[N] , b[N] , memo[N][M];

int solve(int indx , int rem){
   if(rem <= 0)
      return 0;
   if(indx == n)
      return inf;
   int &ret = memo[indx][rem];
   if(~ret)
      return ret;
   ret = solve(indx , rem - a[indx]) + b[indx];
   ret = min(ret , solve(indx + 1 , rem));
   return ret;
}
int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> h >> n;
   for(int i = 0 ; i < n ; ++i)
      cin >> a[i] >> b[i];
   memset(memo , -1 , sizeof(memo));
   cout << solve(0 , h) << "\n";
}

Measured memory_bytes: 40064
#include<bits/stdc++.h>
#define MAX 502
using namespace std;

int m,n,b[MAX],r[MAX];
int match[MAX+MAX];
bool used[MAX+MAX];
vector<int> e[MAX+MAX];

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<e[v].size();i++){
    int u=e[v][i],w=match[u];
    if(w<0||(!used[w]&&dfs(w))){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int i=0;i<MAX+MAX;i++){
    if(match[i]<0){
      memset(used,0,sizeof(used));
      if(dfs(i))res++;
    }
  }
  return res;
}

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

int main(){
  while(1){
    cin>>m>>n;
    if(!m&&!n)break;
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>r[i];
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	if(gcd(b[i],r[j])>1){
	  e[i].push_back(j+m);
	  e[j+m].push_back(i);
	}
    cout<<bipartite_matching()<<endl;
    for(int i=0;i<MAX+MAX;i++)e[i].clear();
  }
  return 0;
}

Measured memory_bytes: 3380
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int sum = 0;
        for(int i = 0;i < N;i++){
          int A = sc.nextInt();
          sum += A;
        }
        if(sum >= H){
        	System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 47928
#include<stdio.h>
int main()
{
  int N;
  int i,j;
  int m=0,k=0;
  int n=1;
  scanf("%d",&N);
  for(i=1; i<=N; i++){
    k=0;
    j=i;
    while(j%2==0){
      k++;
      j/=2;
    }
    if(k>m){
      m=k;  n=i;
    }
  }
  printf("%d",n);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,M,a,b;

int main(){
    cin>>N>>M;
    set<int> s,co;
    rep(i,N){
        cin>>a;
        s.insert(a);
    }
    rep(i,M){
        cin>>b;
        auto it = s.end();
        if(it != s.find(b))co.insert(b);
        s.insert(b);
    }
    cout<<co.size()<<" "<<s.size()<<endl;
    for(int tmp:co)out(tmp);
    for(int tmp:s)out(tmp);
    
    
}



Measured memory_bytes: 14428
#include<stdio.h>
long long N,G[105][105],i,j,R;
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=0;j<N;j++)
			scanf("%d",&G[i][j]);
	for(i=R=0;i<N;i++)
		for(j=i;j<N;j++)
			R+=G[i][j]<G[j][i]?G[i][j]:G[j][i];
	printf("%lld\n",R);
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

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

const int H = 101;
const int W = 101;

long long v[H][W];

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

void dfs(int x, int y, long long c, vvb &G) {
    G[y][x] = true;
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (v[sy][sx] == c && !G[sy][sx]) dfs(sx, sy, c, G);
        }
    }
}

int main() {
    int N;
    while (cin >> N, N) {
        memset(v, 0, sizeof(v));
        vi L, T, R, B;
        set<int> Ys, Xs;
        REP(i, N) {
            int l, t, r, b;
            cin >> l >> t >> r >> b;
            L.push_back(l);
            T.push_back(t);
            R.push_back(r);
            B.push_back(b);
            Ys.insert(t);
            Ys.insert(b);
            Xs.insert(l);
            Xs.insert(r);
        }
        Ys.insert(-1);
        Ys.insert(1e6 + 10);
        Xs.insert(-1);
        Xs.insert(1e6 + 10);
        vi Y(ALL(Ys));
        vi X(ALL(Xs));
        set<long long> S;
        REP(i, N) {
            int xl = lower_bound(ALL(X), L[i]) - X.begin();
            int xr = lower_bound(ALL(X), R[i]) - X.begin();
            int yt = lower_bound(ALL(Y), T[i]) - Y.begin();
            int yb = lower_bound(ALL(Y), B[i]) - Y.begin();
            FOR(x, xl, xr) {
                FOR(y, yb, yt) {
                    long long bit = (1LL << i);
                    v[y][x] |= bit;
                }
            }
        }

        int cnt = 0;
        vvb G(H, vb(W));
        REP(y, H) REP(x, W) {
            if (!G[y][x]) {
                cnt++;
                dfs(x, y, v[y][x], G);
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3984
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


#define EACHC(t,i,c) for(t::const_iterator i=(c).begin(); i!=(c).end(); ++i)
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  EACHC(Edges,e, g[v]) {
    if (color[e->dst] == 2) continue;
    if (color[e->dst] == 1) return false;
    if (!visit(g, e->dst, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
bool topologicalSort(const Graph &g, vector<int> &order) {
  int n = g.size();
  vector<int> color(n);
  REP(u, n) if (!color[u] && !visit(g, u, order, color))
    return false;
  reverse(ALL(order));
  return true;
}

int main() {
	int n;
	cin>>n;
	int m;
	cin>>m;
	Graph g(n);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(a,b,1));
	}
	vi order;
	bool f=topologicalSort(g,order);
	assert(f);
	REP(i,order.size()){
		cout<<order[i]+1<<endl;
	}
	REP(i,n-1){
		bool flag=false;
		REP(j,g[order[i]].size()){
			if(g[order[i]][j].dst==order[i+1]){
				flag=true;
				break;
			}
		}
		if(!flag){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}

Measured memory_bytes: 3328
#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.at(i);
  }

  vector<int> ans(N);

  for(int i=0; i<N; i++){
    ans.at(A.at(i) - 1) = i + 1;
  }

  for(int i=0; i<N; i++){
    cout << ans.at(i); 
    if(i < N - 1){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
char  a[27]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char x;
cin>>x;
for(int i=0;i<26;i++)
{
if (x==a[i])
{
    cout<<a[i+1];
}

}
    return 0;
}

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        
       int d = a / b;
    int    r = a%b;
       double f = (double)a / (double)b;
        
        System.out.printf(d +" " +  r +" "+ "%f", f);
        
        
    }
}


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

int main() {
  string n;
  cin >> n;
  
  for( int i = 0; i < 3; i++ ){
    if( n.at(i) == '1' ){
      n.at(i) = '9';
    }else{
      n.at(i) = '1';
    }
  }
    cout << n << endl;
}

Measured memory_bytes: 256
//  Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 305
#define MOD 998244353
using namespace std;
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
typedef long long i64;

i64 N, sum;
i64 a[MAX];
i64 memo[MAX][90005];

i64 dp( i64 x , i64 s )
{
    if( x > N )
    {
        if( s >= ( sum + 1 ) / 2 )
            return 1;
        return 0;
    }
    if( memo[x][s] != -1 )
        return memo[x][s];
    
    i64 ans = 0;
    ans += 2 * dp( x + 1 , s );
    ans += dp( x + 1 , s + a[x] );
    ans %= MOD;
    return memo[x][s] = ans;
}

i64 dp2( i64 x , i64 s )
{
    if( x > N )
    {
        if( s == sum / 2 )
            return 1;
        return 0;
    }
    if( memo[x][s] != -1 )
        return memo[x][s];
    i64 ans = dp2( x + 1 , s ) + dp2( x + 1 , s + a[x] );
    ans %= MOD;
    return memo[x][s] = ans;
}

int main()
{
    optimiza_io 
    memset( memo , -1 , sizeof memo );
    cin >> N;
    i64 ansi = 1;
    for( i64 i = 1; i <= N; i ++ )
    {
        cin >> a[i];
        sum += a[i];
        ansi *= 3;
        ansi %= MOD;
    }
    i64 tmp = 3 * dp( 1 , 0 );
    if( sum % 2 == 0 )
    {
        memset( memo , -1 , sizeof memo );
        tmp -= 3 * dp2( 1 , 0 );
        tmp %= MOD;
        tmp += MOD;
        tmp %= MOD;
    }
    
    cout << ( ( ( ansi - tmp ) % MOD ) + MOD ) % MOD << "\n";
    return 0;
}

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

using namespace std;

int main(){
  long int N,i,j;
  cin >> N;
  int a[N],s[N];
  for(i=0;i<N;i++){
    cin >> a[i];
    s[i]=a[i];
  }
  sort(s,s+N);
  
  int max1,max2;
  max1=s[N-1];
  max2=s[N-2];
  
  for(i=0;i<N;i++){
    if(a[i]!=max1){
      cout << max1 << endl;
    }
    else{
      cout << max2 << endl;
    }
  }
}

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

int main(){
	unsigned long long int n;
	cin >> n;
	unsigned long long int res = 0;
	unsigned long long int divider = 10;
	
	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}
	while(divider <= n){
		res += (n/divider);
		divider *= 5;
	}
	
	cout << res << endl;
	
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    
    int cou = 0;
    for(int i=0; i<3; i++){
    if(ss[0]==ss[1]){
        cou++;    
    }
    if(ss[1]==ss[2]){
        cou++;
    }
    if(ss[0]==ss[2]){
        cou++;    
    }
}
    if(cou>0){
    System.out.println("No");
     }else{
    System.out.println("Yes");   
        }
    }
}


Measured memory_bytes: 35516
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int C = cin.nextInt();
        int D = cin.nextInt();
        int result = A < B ? A : B;
        result += C < D ? C : D;
        Console.WriteLine(result.ToString());
    }
}
public class Point
{
    public int Color;
    public int X;
    public int Y;
    public Point(int color, int x, int y)
    {
        Color = color;
        X = x;
        Y = y;
    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

using namespace std;

typedef long long ll;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        ll n, a, b;
        cin >> n >> a >> b;
        cout << (n / (a + b)) * a + min(a, n % (a + b)) << "\n";
        return 0;
}


Measured memory_bytes: 764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i, a) {
        cin >> p[i];
    }
    rep(i, b) {
        cin >> q[i];
    }
    rep(i, c) {
        cin >> r[i];
    }
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    rep(i, a-x) {
        p.pop_back();
    }
    rep(i, b-y) {
        q.pop_back();
    }



    int i = 1, j = 1, k = 0;
    while(1) {
        auto itrp = p.end()-i;
        auto itrq = q.end()-j;
        if(*itrq >= *itrp && *itrp < r[i+j+k-2]) {
            *itrp = r[i+j+k-2];
            if(i != x) {
                ++i;
            } else {
                ++k;
            }
        } else if(*itrq <= *itrp && *itrq < r[i+j+k-2]) {
            *itrq = r[i+j+k-2];
            if(j != y) {
                ++j;
            } else {
                ++k;
            }
        } else {
            break;
        }
        if(i+j+k-2 == r.size()) break;
    }

    ll ans=0;
    for(ll x:p) {
        ans += x;
        //cout << x << endl;
    }
    
    for(ll y:q) {
        ans += y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

const int MAXN = 1e5+3;
const int MOD = 1e9+7;

int N;
int H[MAXN];
int ans;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    fori(i,N) cin >> H[i];

    int c = 0;
    ford(i,N-1) {
        if (i == N-1 || H[i] < H[i+1]) {
            ans = max(ans, c);
            c = 0;
        } else {
            c++;
        }
    }

    ans = max(ans, c);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<vector>
#include<complex>
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

enum { OUT, ON, IN };
int contains(const G& g, const P& p) {
  bool in = false;
  for (int i = 0; i < g.size(); ++i) {
  	P a,b;
    a = curr(g,i) - p, b = next(g,i) - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

int main(){
	int n; cin>>n;
	double x1,y1,x2,y2,x3,y3,xk,yk,xs,ys;
	while(n--){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>xk>>yk>>xs>>ys;
		P pk(xk,yk),ps(xs,ys),p1(x1,y1),p2(x2,y2),p3(x3,y3);
		G t;t.push_back(p1),t.push_back(p2),t.push_back(p3);
		bool f1=contains(t,pk),f2=contains(t,ps);
		cout<<(f1&&!f2||!f1&&f2?"OK":"NG")<<endl;
	}
	return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

static vector<mint> mfact(1, 1); // n! (mod MOD)
mint nPr(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  if (r == 0) return 1;
  int pn = mfact.size();
  if (pn < n + 1) {
    mfact.resize(n + 1);
    for (int i = pn; i <= n; i++) mfact[i] = mfact[i - 1] * i;
  }
  return mfact[n] * mfact[n - r].inv();
}
mint nCr(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  if (r == 0) return 1;
  int pn = mfact.size();
  if (pn < n + 1) {
    mfact.resize(n + 1);
    for (int i = pn; i <= n; i++) mfact[i] = mfact[i - 1] * i;
  }
  return mfact[n] * mfact[r].inv() * mfact[n - r].inv();
}

void solve() {
  int n, m;
  cin >> n >> m;
  mint ans = 1;
  map<ll, int> prime;
  for (ll i = 2; i * i <= m; i++) {
    while (m % i == 0) {
      prime[i]++;
      m /= i;
    }
  }
  if (m != 1) prime[m] = 1;
  for (auto p : prime) {
    ans *= nCr(n + p.second - 1, n - 1);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    ll x, m = 100;
    cin >> x;
    int i;
    for (i = 1; ; ++i) {
        m += m / 100;
        if (m >= x)
            break;
    }
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int countup(int n){
    int count = 1;
    while(true) {
        if(n >= count) {
            n -= count;
            count++;
        }
        else {
            break;
        }
    }
    return count-1;
}

int main()
{   
    long long N;
    cin >> N;

    int memo[1000000+10] = {0};
    bool flag1 = true;
    long long N_c = N;
    int ans = 0;
    while(flag1) {
        for (long long i = 2; i <= (int)sqrt(N)+1; ++i) {
            if(N_c%i == 0){
                memo[i]++;
                N_c /= i;
                break;
            }
            // 素数がこれ以上見つからない
            if(i >= (int)sqrt(N)) {
                flag1 = false;
            }
        }
    }
    // 1じゃない場合はNそのものが素数の場合
    if (N_c != 1) {
        ans++;
    }
    for (long long i = 2; i <= (int)sqrt(N)+1; ++i) {
        ans += countup(memo[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7520
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int a[100005],b[100005],c[100005];
  int dp_a[100005],dp_b[100005],dp_c[100005];
  int ans;
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  dp_a[1] = a[1];
  dp_b[1] = b[1];
  dp_c[1] = c[1];
  for(int i=2; i<=n; i++){
    dp_a[i] = max(dp_b[i-1],dp_c[i-1]) + a[i];
    dp_b[i] = max(dp_a[i-1],dp_c[i-1]) + b[i];
    dp_c[i] = max(dp_a[i-1],dp_b[i-1]) + c[i];
  }
  ans = max(dp_a[n],dp_b[n]);
  cout << max( ans ,dp_c[n] ) << endl;
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
	int n,b;ll a;scanf("%d %lld %d",&n,&a,&b);
	vector<int> x(n);ll ans=0;
	rep(i,n)scanf("%d",&x[i]);
	rep(i,n-1){
		int diff=x[i+1]-x[i];
		ans+=((a*diff<b)?a*diff:b);
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        vec[a]++;
        vec[b]++;
    }
    bool f=true;
    REP(i,n){
        if(vec[i]%2){
            f=false;
        }
    }
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int n; (n = in());) {
		int d {};
		vector<int> p(n);
		for (int c, i {}; (c = gcu()) != '\n'; ++i %= n)
			switch (c) {
			case 'M':
				p[i]++;
				break;
			case 'S':
				d += p[i] + 1;
				p[i] = 0;
				break;
			default:
				p[i] += d + 1;
				d = 0;
			}
		sort(begin(p), end(p));
		outl(p, ' ', d);
	}
}


Measured memory_bytes: 2620
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>
#include <climits>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int N, M;
int u, v;
int S, T;

int main() {
	cin >> N >> M;
	vector<vector<int>> G(N + 1);
	for (int i = 0; i < M; i++) {
		cin >> u >> v;
		G[u].push_back(v);
	}
	cin >> S >> T;
	vector<vector<bool>> visit(3, vector<bool>(N + 1));
	for (int i = 0; i < 3; i++)for (int j = 0; j <= N; j++)visit[i][j] = false;
	vector<vector<int>> cost(3, vector<int>(N + 1));
	for (int i = 0; i < 3; i++)for (int j = 0; j <= N; j++)cost[i][j] = -3;
	cost[0][S] = 0;

	queue<tuple<int, int>> q;

	int d = 0;
	q.push(tie(d, S));

	while (q.size() != 0) {
		tie(d, u) = q.front();
		q.pop();
		visit[d][u] = true;
		int nxd = (d + 1) % 3;
		for (int e : G[u])
			if (!visit[nxd][e]) {
				int nx = cost[d][u] + 1;
				if (cost[nxd][e] == -3 || nx < cost[nxd][e]) { cost[nxd][e] = nx; q.push(tie(nxd, e)); }

			}
	}
	cout << cost[0][T] / 3 << endl;
}


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

int main(){
  int s;
  cin >> s;
  int i=1;
  if(s==1 || s==2 || s==4){
    cout << 4 << endl;
    return 0;
  }
  while(true){
    if(s==4){
      cout << i+3 << endl;
      return 0;
    }
    if(s%2==0){
      s /= 2;
      i ++;
    }else{
      s = 3*s +1;
      i ++;
    }
  }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	VEC(int, m, b, 0);
	VEC2(int, n, m, a, 0);
	REP(i, m) cin >> b[i];
	REP(i, n) REP(j, m) cin >> a[i][j];
	int ans = 0;
	REP(i, n)
	{
		int sum = 0;
		REP(j, m) sum += a[i][j] * b[j];
		if( sum + c > 0 ) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
	int a[210000],n;
	int tmp[210000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		tmp[i]=a[i];
	}
	printf("\n");
	qsort(a, n, sizeof(int), compare_int);
	for(int i=0;i<n;i++){
		if(a[n-1]==tmp[i]){
			printf("%d\n",a[n-2]);
		}else{
			printf("%d\n",a[n-1]);
		}
	}
}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <long long>l,r,s;
long long n,k,ans=1000000000;

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a==0){
			k--;
			if(k==0){
				cout<<0<<endl;
				return 0;
			}
		}else if(a>0){
			r.push_back(a);
		}else{
			s.push_back(a);
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		l.push_back(s[i]*-1);
	}
	for(int i=0;i<=k;i++){
		if(l.size()>=i&&r.size()>=k-i){
			if(i==0){
				ans=min(r[k-1],ans);
			}else if(i==k){
				ans=min(l[i-1],ans);
			}else{
				ans=min(ans,l[i-1]+r[k-i-1]+min(l[i-1],r[k-i-1]));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2548
//2017.12.10
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {
	int n, ans=0,a1,a2,a3;
	cin >> n;
	//vector <int> A(n);
	//string str;
	//for (int i = 0; i < n; i++) {
		//cin >> A[i];
	//}
	a1=n-(n/10)*10;
	n = n/10;
	a2=n-(n/10)*10;
	n = n/10;
	a3=n;

	if(a1==1) ans+=1;
	if(a2==1) ans +=1;
	if(a3==1) ans +=1;
	
	//sort(A.begin(), A.end());

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        k: usize, x: usize
    };

    let res = if 500 * k >= x { "Yes" } else { "No" };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2240