akhauriyash/Code-Regression huggingface dataset:
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  CIN(n,m);
  vector<V> s1(n,V(n));vector<V> s2(n,V(n));
  REP(i,n){
    SCIN(s);
    REP(j,n)
      s1[i][j] = (s[j] =='#');
  }
  REP(i,m){
    SCIN(s);
    REP(j,m)
      s2[i][j] = (s[j] =='#');
  }

  REP(i,n - m + 1){
    REP(j,n - m + 1){
      bool flag = true;
      REP(ii,m)
        REP(jj,m){
          if(s1[i+ii][j+jj] != s2[ii][jj])
            flag = false;
        }
      if(flag)EN(Yes);

    }
  }
  EN(No);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;cin>>n;
  int l,mx=0,sum=0;
  while(n>0){
    cin>>l;
  	sum+=l;
    mx=max(mx,l);
    n--;
  }
  cout<<(sum>mx*2?"Yes":"No");
    
}
  

Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    #include<string>
    #include<set>
    #include<map>
    #include<algorithm>
    #include<queue>
    #include<list>
    #include<stack>
    #include<cstdio>
    #include<fstream>
    #include<numeric>
    #include<functional>
    #include<utility>
    #include<memory>
    #include<cstring>
    #include<bits/stdc++.h>
    using namespace std; 
      
    #define CLEAN(a,b) memset(a,b,sizeof(a))
    #define mp make_pair
    #define pb push_back
    typedef long long ll;
    typedef pair<int, int> pii;
     
    ll n;
     
    int main()
    {
    	cin>>n;
    	if (n%2==0) cout<<n<<endl;
    	else cout<<n*2<<endl;
        return 0;
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var dic = new Dictionary<string, int>
            {
                {"S",0 },
                {"H",1 },
                {"C",2 },
                {"D",3 }
            };
            var Suit = new string[] { "S", "H", "C", "D" };
            var memo = new bool[4, 14];

            var n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                var suit = input[0];
                var num = int.Parse(input[1]);
                memo[dic[suit], num] = true;
            }

            for(int i = 0; i < 4; i++)
            {
                for(int j = 1; j < 14; j++)
                {
                    if (!memo[i, j])
                        Console.WriteLine("{0} {1}", Suit[i], j);
                }
            }
        }
    }
}

Measured memory_bytes: 9232
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
k = I()
ans = 0
for i in range(k):
    if int(s[i]) == 1:
        continue
    else:
        ans = i
        break
print(s[ans])


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int n;

string ans, newans;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cout << "0\n";
    cout.flush();
    cin >> ans;
    if(ans == "Vacant"){
        cout << "0\n";
        cout.flush();
        cin >> ans;
        exit(0);
    }
    int pos = 0;
    for(int i = 17; i >= 0; i--){
        if(pos + (1 << i) < n){
            cout << pos + (1 << i) << "\n";
            cout.flush();
            cin >> newans;
            if(newans == "Vacant"){
                cout << pos + (1 << i) << "\n";
                cout.flush();
                cin >> newans;
                exit(0);
            }
            if(ans == newans)
                pos += (1 << i);
        }
    }
    cout << pos + 1 << "\n";
    cout.flush();
    cin >> newans;
    exit(0);
}


Measured memory_bytes: 880
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

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

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

	vector<int> old(3,0);
	int n;
	cin >> n;

	for (int i=0;i<=n-1;i++)
	{
		vector<int> dp(3,0);
		for (int j=0;j<=2;j++)
		{
			cin >> dp[j];
		}

		for (int j=0;j<=2;j++)
		{
			int a=0;
			for (int k=0;k<=2;k++)
			{
				if (j!=k)
				{
					a=max(a,dp[j]+old[k]);
				}
			}
			dp[j]=a;
		}
		old=dp;
	}

	sort(old.begin(),old.end());
	cout << old[2] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

 public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1.
  UnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
  }
}
int UnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}

int UnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

// for verifying

// this code solves Disjoint Set: Union Find
// Tree(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp)

int main(void) {
  int n, q;
  cin >> n >> q;
  UnionFindForest UF(n);
  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    switch (com) {
      case 0:
        UF.Unite(x, y);
        break;
      case 1:
        cout << UF.IsSame(x, y) << endl;
        break;
    }
  }
}



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

int n;
vector<int> L;

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

int solve(int i, int res, int next){
    if (i == n) return res;

    return solve(i+1, gcd(res, next) , L[i+1]);
}


int main(void){
    // Your code here!
    cin >> n;
    L.resize(n);
    
    for(int i = 0; i < n; i++){
        cin >> L[i]; 
    }
    
    cout << solve(0, L[0], L[0]) << endl;
    
}


Measured memory_bytes: 640
s = input()
n = len(s)

ans = ""
i = 0
for _ in range(n):
    if i > n or ans == s: break
    if s[i:i+5] == "erase":
        i += 5
        ans += "erase"
        if s[i:i+1] == "r":
            i += 1
            ans += "r"
    elif s[i:i+5] == "dream":
        i += 5
        ans += "dream"
        if s[i:i+3] == "era": continue
        elif s[i:i+2] == "er":
            i += 2
            ans += "er"
print("YES" if ans == s else "NO")

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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int DISV[N], DISU[N];
vector<int> G[N];

void DFS(int v, int p, int dis[N]) {
	for (int u : G[v]) if (u != p) {
		dis[u] = dis[v] + 1;
		DFS(u, v, dis);
	}
}

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, V, U; cin >> n >> V >> U;
	for (int i = 1; i < n; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	DFS(V, 0, DISV);
	DFS(U, 0, DISU);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (DISV[i] > DISU[i]) continue;
		ans = max(ans, DISU[i] - 1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12544
N=int(input())
A,B = list(map(int,input().split()))

P = list(map(int,input().split()))
one=0
two=0
thre=0
for i in range(N):
    if P[i]<=A:
        one+=1
    elif P[i]<=B:
        two+=1
    else:
        thre+=1
print(min(one,two,thre))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n;cin >> n;
	int k;cin >> k;
	
	REP(i,k)
	{
		ll x,y;cin >> x >> y;
		ll ret = min(min(x,n+1-x),min(y,n+1-y))%3;
		if(ret == 0)ret = 3;
		cout << ret << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3080
a = raw_input()
n, w, s, e = -1, -1, -1, -1

for i in a:
	if i == "S":
		s = 1
	if i == "W":
		w = 1
	if i == "E":
		e = 1
	if i == "N":
		n = 1

if w * e > 0 and n * s > 0:
	print "Yes"
else:
	print "No"

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W,H; cin >> W >> H;
    vector<PLL> pq;
    REP(i,W){
        LL p; cin >> p;
        pq.eb(p,0);
    }
    REP(i,H){
        LL q; cin >> q;
        pq.eb(q,1);
    }
    sort(pq.begin(),pq.end());

    int a = W + 1;
    int b = H + 1;
    LL ans = 0;
    for(auto x : pq){
        dump(x.first)
        if(x.second == 1){
            if(a == 0) continue;
            ans += x.first * a;
            dump(ans)
            b--;
        }
        else{
            if(b == 0) continue;
            ans += x.first * b;
            dump(ans)
            a--;
        }
    }
    cout << ans << endl;

}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int h, w;
int a[85][85];
int dp[85][85][12810];

int main(){
	cin >> h >> w;
	RC(i, h){
		RC(j, w){
			cin >> a[i][j];
		}
	}
	RC(i, h){
		RC(j, w){
			Int b;
			cin >> b;
			a[i][j] -= b;
		}
	}
	dp[0][0][6400 + a[0][0]] = 1;
	dp[0][0][6400 - a[0][0]] = 1;
	RC(i, h){
		RC(j, w){
			if(i != 0){
				RC(k, 12810){
					if(dp[i - 1][j][k]){
						if(k - a[i][j] > 0) dp[i][j][k - a[i][j]] = 1;
						if(k + a[i][j] > 0) dp[i][j][k + a[i][j]] = 1;
					}
				}
			}
			if(j != 0){
				RC(k, 12800){
					if(dp[i][j - 1][k]){
						if(k - a[i][j] > 0) dp[i][j][k - a[i][j]] = 1;
						if(k + a[i][j] > 0) dp[i][j][k + a[i][j]] = 1;
					}
				}
			}
		}
	}
	ARC(k, 6400, 12800){
		if(dp[h - 1][w - 1][k]){
			cout << k - 6400 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 340992
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>

int main() {
        fio;
        int n,m;
        cin>>n>>m;
        if(n==m)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
        

 }



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

int main() {
	int N;
	long long K;
	int A[200100];
	cin >> N >> K;

	int nextTown = 1;
	vector<bool> visited(N + 1);
	vector<int> visitedOrder(N + 1);

	int period = 0;
	int margin = 0;
	bool periodic = false;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		visited[i] = false;
	}

	if (N < K) {
		for (int i = 0; i < N; i++) {
			if (visited[nextTown]) {
				periodic = true;
				period = i - visitedOrder[nextTown];
				margin = visitedOrder[nextTown];
				break;
			}
			visited[nextTown] = true;
			visitedOrder[nextTown] = i;
			nextTown = A[nextTown];
		}
	}
	else {
		for (int i = 0; i < K; i++) {
			nextTown = A[nextTown];
		}
	}

	if (periodic) {
		int surplus = (K - margin) % period;
		int count = 0;
		nextTown = 1;
		while (count < surplus + margin) {
			nextTown = A[nextTown];
			count++;
		}
	}

	cout << nextTown;
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,m;
cin >> n >> m;
vi a(m),b(m);
rep(i,m) cin >> a[i] >> b[i];
vi c(n);
for(int i = 1;i < n+1;i++){
    rep(j,m){
        if (a[j] == i || b[j] == i)
        {
            c[i-1]++;
        }
        
    }
}
rep(i,n) cout << c[i] << endl;
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
inline int read(){char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 1e3 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int n,m,fx,fy,ex,ey,vis[N][N],way[4][2] = {{1,0},{-1,0},{0,1},{0,-1}},ans[N][N];
char str[N][N];
struct node
{
    int x,y,step;
};
deque<node> q;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    cin >> n >> m >> fx >> fy >> ex >> ey;
    for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)
            cin >> str[i][j],ans[i][j] = -1;
    q.push_back({fx,fy,0});
    while(!q.empty())
    {
        node t = q.front();
        int x = t.x,y = t.y,step = t.step;
        q.pop_front();
        if(vis[x][y]) continue;
        ans[x][y] = step,vis[x][y] = 1;
        for(int i = 0;i < 4;i++)
        {
            int xx = x+way[i][0],yy = y+way[i][1];
            if(xx > 0 && xx <= n && yy > 0 && yy <= m && !vis[xx][yy] && str[xx][yy] == '.')
                q.push_front({xx,yy,step});
//            cout << xx << " " << yy << " " << step << endl;
        }
        for(int i = -2;i <= 2;i++)
        {
            for(int j = -2;j <= 2;j++)
            {
                int xx = x+i,yy = y+j,flag = 0;
                if(xx > 0 && xx <= n && yy > 0 && yy <= m && !vis[xx][yy] && str[xx][yy] == '.')
                    q.push_back({xx,yy,step+1});
            }
        }
    }
    cout << ans[ex][ey] << endl;
}


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

const ll mod = 1000000007;
int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(int a = 1; a < N; a++){
        for(int b = 1; a*b < N; b++){
            int c = N - a*b;
            if(c > 0){
               // cout <<a << b << c << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    next = {'Sunny':'Cloudy',
            'Cloudy':'Rainy',
            'Rainy':'Sunny'}
    print(next[input()])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	S := sc.Next()
	for i := 0; i < len(S)-1; i++ {
		if S[i] == S[i+1] {
			fmt.Println("Bad")
			os.Exit(0)
		}
	}
	fmt.Println("Good")
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func min64(x, y float64) float64 {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == k + 1) {
            k++;
        }
    }
    int ans;
    if (k == 0) {
        ans = -1;
    } else {
        ans = n - k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
char a;
int32_t main(){
CODE_START;
cin>>a;
cout<<char(a+1);
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x = 1000;
  rep(i,n-1) {
    int s = a[i];
    int t = a[i+1];
    if (s < t) {
      ll k = x/s;
      x %= s;
      x += k*t;
    }
  }
  cout << x << endl;
  return 0;
}

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

int main(){
    ll h, n;
    cin >> h >> n;

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

    if(h > sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
int recursin(int);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>=b*2-1){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(char a,char b){
	return a>b;
}
int main()
{
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    long long ans;
    ans = 0;


    for (int i = 1; i <= N - 1; ++i){
    long long res = 1;
    for (auto p : prime_factorize(i)) res *= p.second + 1;
    ans += res;
    }

    cout << ans << endl;
}
  

Measured memory_bytes: 3628
L,R=list(map(int, input().split()))
M=2019
if R-L==1:
  print(((R%M)*(L%M))%M)
  exit()
if L//M!=R//M:
  print(0)
  exit()
L=L%M
R=R%M
ans=M
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans=min(ans,(i*j)%M)
print(ans)


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t), greater<char> ());

    if(s<t)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n; ll z, w; cin >> n >> z >> w;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    if (n == 1) {
        cout << abs(a[0] - w) << endl;
    } else {
        ll m1 = abs(a[n-1] - w);
        ll m2 = abs(a[n-1] - a[n-2]);
        cout << max(m1, m2) << endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll L, R;
  cin >> L >> R;
  ll m = 2019;
  ll l, r = 0;
  l = L % 2019;
  r = R % 2019;
  if (l > r||R-L>=2019)
  {
    cout << 0 << endl;
    return 0;
  }
  else
  {
    for (ll i = l; i < r; i++)
    {
      for (ll j = i + 1; j < r + 1; j++)
      {
        m = min(m, i * j % 2019);
      }
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
as = []
ans1 = []
ans2 = []
H.times do |i|
    as[i] = gets.chomp
    ans1[i] = as[i].dup
    ans2[i] = as[i].dup
end

H.times do |i|
    if i%2 == 0
        ans1[i] = '#'*(W-1) + '.'
    else
        ans2[i] = '.' + '#'*(W-1)
    end
    ans1[i][0] = '#'
    ans2[i][-1] = '#'
end

puts ans1
puts
puts ans2

# result = Array.new(H){'.'*W}
# H.times do |i|
#     W.times do |j|
#         result[i][j] = '#' if ans1[i][j] == '#' && ans2[i][j] == '#'
#     end
# end
# puts result

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define matrix vector < vector<double> >

using namespace std;

const double eps = 1e-9;
const double PI = acos(-1.0);
const int inf = int (1e9+7);
const ll INF = (ll) 8e18+7;
const int mod = int (1e4+7);     
const int N = int (3e5+7);    

int n, h, w;
ll ans[12];
map < pair <int, int> , int> ma;

void check(int x, int y) {
	int sum = 0;
	for(int i = x; i < x + 3; i ++) {
		for(int j = y; j < y + 3; j ++) {
			if(i < 1 || i > h || j < 1 || j > w) return;
			sum += ma[mp(i, j)];
		}
	}
	ans[sum] --, ans[sum + 1] ++;
}

void upd(int x, int y) {
	for(int i = x; i >= x - 2; i --) {
		for(int j = y; j >= y - 2; j --) {
			check(i, j);
		}
	}
}

int main () { 
   	//freopen("input.txt", "r", stdin);
   	//freopen("output.txt", "w", stdout);  
   	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> h >> w >> n;
	ans[0] = (h - 2) * 1ll * (w - 2);
	for(int i = 0; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		if(ma[mp(x, y)] == 1) continue;
		upd(x, y);
		ma[mp(x, y)] = 1;
	}
	for(int i = 0; i < 10; i ++)
		cout << ans[i] << endl;
	return 0;
} 

Measured memory_bytes: 156544
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>

using namespace std;


int main(void) {

	// a = 97 (int)

	int st1set[26] = { 0 };
	int st2set[26] = { 0 };

	string S;
	int N;
	int comCnt = 0;
	int max = 0;


	cin >> N;
	
	S.resize(N);

	cin >> S;

	for (int i = 0; i < N; i++) {
		st1set[S[i] - 97] = 1;
		for (int j = i + 1; j < N; j++) {
			st2set[S[j] - 97] = 1;
		}

		for (int k = 0; k < 26; k++) {
			if (st1set[k] && st2set[k])
				comCnt++;
		}

		if (max < comCnt) {
			max = comCnt;
		}

		for (int k = 0; k < 26; k++) {
			st2set[k] = 0;
		}
		comCnt = 0;
	}

	cout << max << endl;
	
	return 0;
}



Measured memory_bytes: 256
from collections import deque

N, *AB = map(int, open(0).read().split())

E = [set() for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a].add((b, i))
    E[b].add((a, i))

K = max(len(e) for e in E)
A = [0] * (N - 1)
Q = deque([(-1, 1)])
while Q:
    p, v = Q.popleft()
    C = (c for c in range(1, K + 1) if c != p)
    for u, i in E[v]:
        E[u].remove((v, i))
        c = next(C)
        Q.append((c, u))
        A[i] = c

print(K)
for a in A:
    print(a)


Measured memory_bytes: 53540
#include<stdio.h>
int main(){
  int i,n,S[100000],q,T[50000],key,count=0,flag,right,left,mid;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    key = T[i];
    left=0;
    right=n;
    flag=0;
      
      while(left < right){
        mid = (left + right) / 2;
        
        if(S[mid] == key){
          flag=1;
          break;
        }
        else if(key < S[mid]) right = mid;
        else left = mid+1;
      }
    if(flag == 1) count++;
  }

  printf("%d\n",count);
    
  return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<string> s;
    s.resize(n);
    
    for (auto&& e : s) {
        cin >> e;
    }
    
    vector<string> m;
    m.resize(n);
    
    int cnt = 0;
    for (int a = 0; a < n; ++a) {
        for (int i = 0; i < n; ++i) {
            m[i] = s[(i + a) % n];
        }
        
        bool ng = false;
        for (int i = 1; i < n && !ng; ++i) {
            for (int j = 0; j < n && i > j && !ng; ++j) {
                if (m[i][j] != m[j][i]) {
                    ng = true;
                }
            }
        }
            
        if (!ng) {
            cnt += n;
        }
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let nm = read_vec::<i64>();
    let ans  = go(nm[0],nm[1]);
    println!("{}",ans);
}
fn go(n:i64 , m:i64) -> i64{
    if m <= 1{
        return 0;
    }
    if n * 2 >= m {
        return m/2;
    }
    let ans  = n + (m - n * 2) / 4;
    ans
}

Measured memory_bytes: 4352
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int n;
  while (cin >> n, n){
    list<pair<int, int>> l{{-1, inf}};
    rep(i, n){
      string c;
      cin >> c;
      if (c == "W"){
        int a, b;
        cin >> a >> b;
        auto it = l.begin();
        while (b > 0){
          if (it->first == -1){
            if (b >= it->second){
              it->first = a;
              b -= it->second;
            }
            else {
              l.insert(next(it), {-1, it->second - b});
              *it = {a, b};
              b = 0;
            }
          }
          ++it;
        }
      }
      else if (c == "D"){
        int a;
        cin >> a;
        auto it = l.begin();
        while (it != l.end()){
          if (it->first == a) it->first = -1;
          ++it;
        }
        it = l.begin();
        while (next(it) != l.end()){
          if (it->first == -1 && next(it)->first == -1){
            it->second += next(it)->second;
            l.erase(next(it));
          }
          ++it;
        }
      }
      else if (c == "R"){
        int a;
        cin >> a;
        auto it = l.begin();
        while (a >= it->second){
          a -= it->second;
          ++it;
        }
        cout << it->first << endl;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3328
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double , double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction

#define  EPS 1e-9
#define  MAX 100007
int a[MAX];
int main()
{
    int T,n;
    scanf("%d",&n);
    n*=2;
    FOR(i,0,n-1)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<n-1;i+=2)
    {
        sum+=min(a[i],a[i+1]);
    }
    printf("%d",sum);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
static const int MAX = 100000;
int arr[MAX], n;


int partition(int p, int r) {
    int x, i, j;
    x = arr[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (arr[j] <= x) {
            i++;
            swap(arr[j], arr[i]);
        }
    }
    swap(arr[i+1], arr[r]);
    return i+1;
}

int main()
{
    int q;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    q = partition(0, n-1);

    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", arr[i]);
        if (i == q) printf("]");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
//#include <istream>
//#include <sstream>
using namespace std;

int main()
{
	int A;
	int ma;
	int mi;
	int B;
	int C;
	cin >> A;
	cin >> B;
	cin >> C;
	mi = min(A, B);
	ma = max(A, B);	
  
	if (mi<=C&&C<=ma)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int A = int.Parse(input[0]);
    int B = int.Parse(input[1]);
    int C = int.Parse(input[2]);
    Console.WriteLine(C <= A + B ? "Yes" : "No");
  }
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        --a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
    }
    for(int i = 0; i < n-1; ++i){
        cin >> c[i];
    }
    int bef = n, ans = 0;
    for(int i = 0; i < n; ++i){
        int now = a[i];
        ans += b[now];
        if(now == bef + 1) ans += c[bef];
        bef = now;
    }
    cout << ans << "\n";
    return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef long double ld;

const ll INF = 2e18 + 7;

ll d;
map<ll, ll> dp;
vector<pair<ll, ll>> ps;

ll solve(ll n) {
    if (dp.count(n)) return dp[n];
    if (n == 0) return dp[n] = 0;
    dp[n] = INF;
    if (dp[n] / d >= n) dp[n] = n * d;
    for (auto go : ps) {
        dp[n] = min(dp[n], solve(n / go.x) + go.y + llabs(n / go.x * go.x - n) * d);
        dp[n] = min(dp[n], solve((n + go.x - 1) / go.x) + go.y + llabs((n + go.x - 1) / go.x * go.x - n) * d);
    }
    return dp[n];
}

void solve() {
    ll n, a, b, c;
    cin >> n >> a >> b >> c >> d;
    dp.clear();
    ps = {{2, a}, {3, b}, {5, c}};
    cout << solve(n) << '\n';
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}


Measured memory_bytes: 4412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        while (n > 0) {
            if (n % 10 == 9) {
                System.out.println("Yes");
                return;
            } else {
                n /= 10;
            }
        }
        System.out.println("No");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 19668
// AOJ 0328: Metal Recycling
// 2017.10.14

#include <stdio.h>

char buf[30], *p;
int f[200020];

int getInt()
{
	int n = 0;
	if (*p == ' ') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, max;

	fgets(p=buf, 10, stdin); n = getInt();
	max = 0; while (n-- > 0) {
		fgets(p=buf, 30, stdin);
		i = getInt() + getInt();
		if (i > max) max = i;
		f[i]++;
	}
	for (i = 0; i <= max; i++) {
		if (f[i] >= 1) {
			f[i+1] += f[i] >> 1, f[i] &= 1;
			if (i == max) max++;
		}
	}
	for (i = 0; i <= max; i++) if (f[i]) printf("%d 0\n", i);
	return 0;
}

Measured memory_bytes: 2424