akhauriyash/Code-Regression huggingface dataset:
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.22 22:24:54
**/

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

int main() {
    int n;
    cin >> n;
    vector< int > a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    queue< int > que;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            puts("-1");
            return 0;
        } else if (b[(i - 1 + n) % n] < b[i] && b[i] > b[(i + 1) % n]) {
            que.push(i);
        }
    }
    ll ans = 0;
    while (!que.empty()) {
        int t = que.front();
        que.pop();
        
        if (b[t] % (b[(t - 1 + n) % n] + b[(t + 1) % n]) == a[t] % (b[(t - 1 + n) % n] + b[(t + 1) % n])) {
            ans += (b[t] - a[t]) / (b[(t - 1 + n) % n] + b[(t + 1) % n]);
            b[t] = a[t];
            
            
        } else {
            ans += b[t] / (b[(t - 1 + n) % n] + b[(t + 1) % n]);
            b[t] %= (b[(t - 1 + n) % n] + b[(t + 1) % n]);
        }
        if (b[t] < a[t]) {
            puts("-1");
            return 0;
        }
        if (b[(t - 2 + n) % n] < b[(t - 1 + n) % n] && b[(t - 1 + n) % n] > b[t]) {
            que.push((t - 1 + n) % n);
        }
        if (b[t] < b[(t + 1) % n] && b[(t + 1) % n] > b[(t + 2) % n]) {
            que.push((t + 1) % n);
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            puts("-1");
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5260
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll mod=1e9+7;

int main(){
    ll h,w;
    cin >> h >> w;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll num=0;
    ll cnt=0;
    vector<vector<ll>> s(h,vector<ll>(w));
    rep(i,h){
        if(i%2==0){
            for(ll j=0;j<w;j++){
                s[i][j]=num;
                cnt++;
                if(cnt==a[num]){
                    cnt=0;
                    num++;
                }
            }
        }
        else{
            for(ll j=w-1;j>=0;j--){
                s[i][j]=num;
                cnt++;
                if(cnt==a[num]){
                    cnt=0;
                    num++;
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(j) cout << " ";
            cout << s[i][j]+1;
        }
        cout << endl;
    }
    return 0;
} 

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    int n = S.length();

    vector<int> a(n, 0);

    int right = 0;
    for (int i = 0; i < n - 1; i++) {

        if (S[i] == 'R' && S[i+1] == 'R') {
            right++;
        }
        if (S[i] == 'R' && S[i+1] == 'L') {
            a[i] += right / 2 + 1;
            a[i+1] += (right + 1) / 2 + 1;
            right = 0;
        }
    }

    int left = 0;

    for (int i = n - 1; i > 0; i--) {
        if (S[i] == 'L' && S[i-1] == 'L') {
            left++;
        }
        if (S[i] == 'L' && S[i-1] == 'R') {
            a[i] += left / 2;
            a[i-1] += (left + 1) / 2;
            left = 0;
        }
    }

    rep(i, n) {
        cout << a[i] << " ";
    }

    cout << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int count = 0;
  bool flag = true;
  while (flag) {
    for (int i = 0; i < N; i++) {	
      if (A[i] % 2 == 1) {
        cout << count << endl;
        flag = false;
        break;
      } else {
        A[i] = A[i] / 2;
      }
    }
    count++;
  }
}

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

cntA = 0
cntB = 0
for i in range(N):
    if A[i]%4 == 0:
        cntA += 1
    elif A[i]%2 == 0:
        cntB += 1

print("Yes" if cntA + cntB//2  >= N//2 else "No")

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

const int maxn = 5001;
const int lbt = 1e9 + 7;

int n, k;
int a[maxn];
int dp[maxn];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = k; j >= a[i]; j--) {
			dp[j] += dp[j - a[i]];
			if (dp[j] >= lbt) dp[j] -= lbt;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = a[i]; j <= k; j++) {
			dp[j] -= dp[j - a[i]];
			if (dp[j] < 0) dp[j] += lbt;
		}
		bool f = 1;
		for (int j = max(k - a[i], 0); j < k; j++) {
			if (dp[j]) f = 0;
		}
		ans += f;
		for (int j = k; j >= a[i]; j--) {
			dp[j] += dp[j - a[i]];
			if (dp[j] >= lbt) dp[j] -= lbt;
		}
	}
	printf("%d", ans);
	return 0;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int hsd(long long n){
  
  long long x = 0;
  long long a = n;
  
  while( n > 0 ){
    x += n % 10;
    n /= 10;
  }
  
  if ( a % x == 0 ){
    return 1;
  }else{
    return 0;
  }

}
  
int main() {
  
  long long n;
  cin >> n;
  
  int s;
  
  s = hsd(n);
  
  if ( s == 1 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

int main(){
  int a, b, c;
  int keta;

  while(cin >> a){
    cin >> b;
    c=a+b;
    keta=1;
    while((c/=10)>0) keta++;
    cout << keta << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())

class Name{
  public:
    void solve(){
      ll n; cin>>n;
      ll a[n];
      for(ll i=0 ; i<n ; i++) cin>>a[i];
      ll cnt=0;
      for(ll i=0 ; i<n ; i+=2){
        if(a[i]&1) cnt++;
      }
      cout<<cnt;LOL
    }
};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  Name T;
  ll _=1; //cin>>_;
  while(_--) T.solve(); 
  return 0;
}

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

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] a = line.Trim().Split(' ');
            var ans = getAns(a);
            Console.WriteLine(ans);
        }
    }
    static double calc (string x ,Stack<double> st)
    {
        var a1 = st.Pop();
        var a2 = st.Pop();
        if (x == "+") return a1 + a2;
        else if (x == "*") return a1 * a2;
        else if (x == "-") return a2 - a1;
        else return a2 / a1;
    }
   static  double getAns ( string[] a)
    {
        var st = new Stack<double>();
        foreach (var x in a)
        {
            double b;
            if (double.TryParse(x, out b)) st.Push(b);
            else st.Push(calc(x, st));
        }
        return st.Pop();
    }
}



Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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



int main() {
    int N,cntA=0,cntB=0;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++)
        cin>>a.at(i);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int j=0;j<N;j++){
        if(j%2==0)
            cntA+=a.at(j);
        else cntB+=a.at(j);
    }
    cout<<cntA-cntB<<endl;

}

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

int main()
{
  int N,K;
  cin>>N>>K;
  int vec[N];
  int count=1,tmp;
  for(int i=0;i<N;i++) cin>>vec[i];//input
  tmp = N-K;
  while(tmp>0)
  {
    tmp -= (K-1);
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,k;
  cin>>n>>k;
  
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  
  ll mans=100100100100;
  for(int bit=0;bit<(1<<(n-1));bit++){
    ll ans=0;
    int cnt=0;
    rep(i,n-1){
      if(bit&(1<<i)) cnt++;
    }
    if(cnt!=k-1) continue;
    
    ll mh=A[0];
    for(int i=0;i<n-1;i++){
      if(bit&(1<<i)){
        if(A[i+1]<=mh){
          ans+=mh+1-A[i+1];
          mh=mh+1;
        }
      }
      mh=max(mh,A[i+1]);
    }
    mans=min(mans,ans);
  }
  
  cout<<mans<<endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = 0; i < K; i++) {
        if (i % 2) {
            A += B / 2;
            B -= B / 2 + (B % 2);
        }
        else {
            B += A / 2;
            A -= A / 2 + (A % 2);
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(){
  char c[4];
  int i,j=0;
  scanf("%s",c);
  for(i=0;i<2;i++){
  	if(c[i] == c[i+1] && c[i+1] == c[i+2]){
    	j=1;
    }
  }
  printf("%s\n",(j==1)?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())

upper = ((N-1)*(N-2))//2
if (upper < K):
    print('-1')
    exit()

ans = []
# star graph (1-N, 2-N, 3-N, ...)
for i in range(N-1):
    ans.append((i+1,N))
add = upper - K
count = 0
for i in range(N-1):
    if count < add:
        for j in range(i):
            if count < add:
                ans.append((i+1, j+1))
                count += 1
            else:
                break
    else:
        break

print(len(ans))
for edge in ans:
    print("{} {}".format(edge[0], edge[1]))


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int ans=0;
    for(int i=n;i>=2;--i){
        int len=0;
        while(i>=2&&a[i]<=a[i-1]){
            len++;
            i--;
        }
        ans=max(ans,len);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, D; cin >> N >> D;
    vector<int> d(N); for (auto &i : d) cin >> i;
    vector<int> A(N), B(N);
    A[0] = D;
    for (int i = 1; i < N; i++) {
        A[i] = min(A[i-1], abs(A[i-1] - d[i-1]));
    }
    B[N-1] = 1;
    for (int i = N-2; i >= 0; i--) {
        if (B[i+1] <= d[i+1] / 2) B[i] = B[i+1];
        else B[i] = B[i+1] + d[i+1];
    }
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int q; cin >> q; q--;
        cout << (A[q] >= B[q] ? "YES" : "NO") << '\n';
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main () {
	int H,W;
	cin >> H >> W;
	int grid[H][W];
	std::vector<int> skipX;
	std::vector<int> skipY;
	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			char tmp;
			cin >> tmp;
			if(tmp == '#'){
				grid[y][x] = 1;
			}else{
				grid[y][x] = 0;
			}
		}
	}
	for (int y = 0; y < H; ++y)
	{
		bool tmp = false;
		for (int x = 0; x < W; ++x)
		{
			if(grid[y][x] == 1)tmp = true;
		}
		if(!tmp)skipY.push_back(y);
	}
	for (int x = 0; x < W; ++x)
	{
		bool tmp = false;
		for (int y = 0; y < H; ++y)
		{
			if(grid[y][x] == 1)tmp = true;
		}
		if(!tmp)skipX.push_back(x);
	}
	for (int i = 0; i < (int)skipX.size(); ++i)
	{
		//cout << skipX[i] << endl;
	}
	for (int i = 0; i < (int)skipY.size(); ++i)
	{
		//cout << skipX[i] << endl;
	}
	for (int y = 0; y < H; ++y)
	{
		auto it = find(skipY.begin(), skipY.end(),y);
		if(it == skipY.end()){
			for (int x = 0; x < W; ++x)
			{
				it = find(skipX.begin(), skipX.end(),x);
				if(it == skipX.end()){
					if(grid[y][x] == 1){
						cout<<'#';
					}else{
						cout<<'.';
					}
				}else{
					//cout << "X" << x << "is deleted" << endl;
				}
			}
			cout << endl;
		}else{
			//cout << "Y" << y << "is deleted" << endl;
		}

	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  itn n,a[1200000],b[1000000]={};
  itn q[10000000];
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  for(int i=n-1;i>=0;i--){
    if(a[i]!=a[i+1])
    q[i]=b[i]+q[i+1];
    else q[i]=q[i+1];
  }
  for(int i=1;i<=n;i++){
    cout<<b[i]<<"\n";
  }
}

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

int main(){
    int N; cin >> N;
    vector<int> w(N, 0);
    rep(i, N) cin >> w.at(i);

    int sum = 0;
    int half = 0;
    rep(i, N){
        sum += w.at(i);
    }

    int min_ans = 100000;
    rep(i, N-1){
        half += w.at(i);
        min_ans = min(min_ans, abs(sum-2*half));
    }

    cout << min_ans << endl;

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi cnt(n, 0);

    mint ans = 1;
    rep(i, n) {
        if (a[i] == 0) {
            ans *= 3 - cnt[0];
            cnt[0]++;
        } else {
            ans *= cnt[a[i] - 1] - cnt[a[i]];
            cnt[a[i]]++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    cout << (a + b + 1) / 2 << endl;

    return 0;
}



Measured memory_bytes: 256
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 Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    List<Tuple<int, int>>[] es;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] ar = new int[9];
        for (int i = 0; i < N; i++)
        {
            int a = Math.Min(8, cin.nextInt() / 400);
            ar[a]++;
        }

        int max = 0;
        int min = 0;
        for (int i = 0; i < 8; i++)
        {
            if (ar[i] >= 1) max = ++min;
        }

        max += ar[8];
        if (min == 0) min = 1;

        Console.WriteLine(min + " " + max);
    }
}


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: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)

int main(){
    int a,b;
    cin >> a >> b;

    rep(i,10000){
        int x = i*0.08;
        int y = i*0.1;
        if(x==a&&y==b){
            cout << i << endl;
            return 0;
        }
    }
    puts("-1");

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
  FIO
  long long n,a,b;
  cin>>n>>a>>b;
  cout<<(n/(a+b)*a)+min(a,n%(a+b));
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    printf("%d ",min(a,b));
    if(n-(a+b)>0){
        printf("0\n");
    }
    else{
        printf("%d\n",a+b-n);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/

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

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

int main(){
    string s;
    bool dp[505][505];

    cin >> s;

    int n = s.size();
    REP(i, n) REP(j, n) dp[i][j] = false;

    for(int len = 3; len <= n; len += 3){
        REP(l, n){
            int r = l + len - 1;
            if(r > n) break;

            for(int c = l+1; c < r; c += 3){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l != c-1 && !dp[l+1][c-1]) continue;
                    if(c != r-1 && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }

    if(dp[0][n-1]) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	
	char s[h][w+1];
	
	for(int i=0; i<h; i++) cin >> s[i];
int a;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			a=0;
			if(s[i][j]=='#') continue;
			
			if(i-1>=0){
				if(j-1>=0){
					if(s[i-1][j-1]=='#') a+=1;
				}
				if(s[i-1][j]=='#') a+=1;
				if(j+1<w) if(s[i-1][j+1]=='#') a+=1;
			}
			
			if(j-1>=0){
				if(s[i][j-1]=='#') a+=1;
			}
			if(j+1<w) if(s[i][j+1]=='#') a+=1;
			
			if(i+1<h){
				if(j-1>=0){
					if(s[i+1][j-1]=='#') a+=1;
				}
				if(s[i+1][j]=='#') a+=1;
				if(j+1<w) if(s[i+1][j+1]=='#') a+=1;
			}
			
			s[i][j] = '0' +a;
		}
	}
	
	for(int i=0; i<h; i++) cout << s[i] << endl;
	return 0;
}
		


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,i,j,k;
	for(k=0;k<300;k++){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0){
			break;
		}else{
			for(i=0;i<a;i++){
				if(i==0||i==a-1){
					for(j=0;j<b;j++){
						printf("#");
					}
				}else{
					for(j=0;j<b;j++){
						if(j==0||j==b-1){
							printf("#");
						}else{
							printf(".");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2588
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int m; cin >> m; ll dig = 0, sum = 0;
  for(int i=0; i<m; i++) {
    ll c, d; cin >> c >> d; dig += d; sum += c*d;
  }
  cout << (dig-1) + ((sum-1)/9) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int abs(int n)
{
    if(n>=0)
        return n;
    else
        return -n;
}
int main()
{
    int a,b;
    int k;
    while(~scanf("%d%d",&a,&b))
    {
        k=(a+b)/2;
        if(abs(a-k)==abs(b-k))
            printf("%d\n",k);
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 128
object Main extends App {
  var a = readInt
  var b = readLine.split(" ").map(_.toInt)
  var c = b.sorted
  var sum = 0
  for(i <- 0 until a) {
    if(b(i)!=c(i)) {
      sum = sum + 1
    }
  }
  print(if(sum > 2){"NO"} else {"YES"})
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'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'};

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

int main(){
    int n, c; cin >> n >> c;
    vector<vector<int> > d(c+1, vector<int>(c+1));
    REP(i, 0, c){
        REP(l, 0, c){cin >> d[i+1][l+1];}
    }
    vector<vector<int> > lis(n+1, vector<int>(n+1));
    REP(i, 0, n){
        REP(l, 0, n){cin >> lis[i+1][l+1];}
    }
    vector<vector<int> > color(3, vector<int>(c+1, 0));
    REP(i, 1, n+1){
        REP(l, 1, n+1){
            color[(i+l)%3][lis[i][l]]++;
        }
    }
    ll ans = 1e17;
    REP(i, 1, c+1){
        REP(l, 1, c+1){
            if(i == l){continue;}
            REP(j, 1, c+1){
                if(i == j || j == l){continue;}
                ll mid = 0;
                REP(k, 1, c+1){
                    mid += (color[0][k] * d[k][i]) + (color[1][k] * d[k][l]) + (color[2][k] * d[k][j]);
                }
                ans = min(ans, mid);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,i,j,k,ok,ng,l,q;
ll x[500005],y[500005],z[500005],w[500005];
char s[500005],t[500005];
bool flag,dame;

int main(){
    cin >> n;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	while(num < n){
		for(i=n;i>=1;i--){
			ok = false;
			if(x[i] == i){
				y[num++] = i;
				for(k=i;k<=n;k++){
					x[k] = x[k+1];
				}
				ok = true;
				break;
			}
		}
		if(!ok){
			p(-1);
			return 0;
		}
	}
	for(i=num-1;i>=0;i--){
		p(y[i]);
	}
	//p(ans);
	return 0;
}

Measured memory_bytes: 28032
from collections import defaultdict
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = defaultdict(list)
  par =  [None]*N
  cnt = [0]*(N+1)
  for a,b in zip(*[iter(L)]*2):
    dic[a] += [b]
    cnt[b] += 1

  for i in range(1,N+1):
    if cnt[i]==0:
      q = [i]
      par[i-1] = '0'
      break
  
  while q:
    m = q.pop()
    for c in dic[m]:
      cnt[c] -= 1
      if cnt[c]==0:
        par[c-1] = str(m)
        q += [c]

  ans = '\n'.join(par)
  print(ans)
  
if __name__== '__main__':
  main()


Measured memory_bytes: 37220
#include<bits/stdc++.h>
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
using namespace std;

typedef pair <int, int> ii;
vector <ii> mv;
int n, m, a[N], b[N], dp[N], bit[N], p[N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod;
}

void update(int i, int val){
    while (i < N){
        add(bit[i], val);
        i += i&(-i);
    }
}

int get(int i){
    int ans = 0;
    while (i > 0){
        add(ans, bit[i]);
        i -= i&(-i);
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(a+1, a+1+n);
    sort(b+1, b+1+m);

    int cnt = 1;
    for (int i = 1; i <= n; i++){
        while (cnt <= m && b[cnt] < a[i]) cnt++;
        if (cnt == 1 || cnt > m) continue;
        mv.push_back(ii(a[i] - b[cnt-1], b[cnt] - a[i]));
    }

    sort(mv.begin(), mv.end(), [](ii x, ii y){
         return ((x.first < y.first) || (x.first == y.first && x.second > y.second));
         });
    n = 0;
    for (int i = 0; i < mv.size(); i++){
        if (i == 0 || mv[i] != mv[i-1]) {
            mv[n++] = mv[i];
        }
    }
    mv.resize(n);
    n = mv.size();

    for (int i = 0; i < n; i++) p[i] = i;
    sort(p, p+n, [](int x, int y){
        return (mv[x].second < mv[y].second) || (mv[x].second == mv[y].second && x > y);
        });

    for (int i = 0; i < n; i++) a[p[i]] = i+2;
    update(1, 1); ans = 1;
    for (int i = 0; i < n; i++){
        dp[i] = get(a[i]);
        add(ans, dp[i]);
        update(a[i], dp[i]);
    }
    cout << ans;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#include <cstring>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return 0;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    ll x1= powc(10,n), x2=( 2*powc(9,n))%MAX, x3= powc(8,n);
    cout<<(x1-x2+x3+MAX)%MAX;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w, h, x, y; cin >> w >> h >> x >> y;
  cout << (ld)w*h/2 << ' ';
  if(x == (ld)w/2 && y == (ld)h/2) {
    cout << 1 << endk;
  } else {
    cout << 0 << endk;
  }
  return 0;
}


Measured memory_bytes: 3804
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C = map(int, readline().split())
    K = int(readline())
    count = 0
    while A>=B:
        B*=2
        count += 1
    while B>=C:
        C*=2
        count += 1
    if count<=K:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



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

int main() {
	int64_t N, x, a[100], count = 0, sum = 0;
	cin >> N >> x;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + N);
	if (sum < x) cout << N - 1 << endl;
	else if (sum == x) cout << N << endl;
	else {
		for (int i = 0; i < N; i++) {
			if (x < a[i]) break;
			x -= a[i];
			count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        WriteLine(15 - S.Length + S.Sum(x => x == 'o' ? 1 : 0) >= 8 ? "YES" : "NO");
    }
}



Measured memory_bytes: 11220
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N,M;
int32_t A[300][300];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	for (int32_t i = 0; i < N; ++i)	for (int32_t j = 0; j < M; ++j)
	{
		in >> A[i][j];
	}
	int32_t max_n = 1;
	for (; max_n <= N; ++max_n)
	{
		int32_t num[300] = {};
		int32_t index[300] = {};
		for (int32_t i = 0; i < N; ++i) {
			num[A[i][index[i]]]++;
		}
		bool ok = false;
		while (!ok)
		{
			ok = true;
			for (int32_t i = 0; i < N; ++i) {
				auto m = A[i][index[i]];
				if (num[m] > max_n) {
					ok = false;
					++index[i];
					if (index[i] >= M) {
						goto fail;
					}
					num[A[i][index[i]]]++;
				}
			}
		}

		break;
	fail:;
	}
	out << max_n << endl;
	return 0;
}
#endif



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

int main(){
  int n,m,x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }    
  }

  int ans = 1000000000;
  for (int bit = 0; bit < (1<<n); bit++)
  {
    vector<int> summ(m);
    int costs = 0;
    for (int i = 0; i < n; i++)
    {
      if((1<<i)&bit){
        costs+=c[i];
        for (int j = 0; j < m; j++)
        {
          summ[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int i = 0; i < m; i++)
    {
      if(summ[i]<x) ok = false;
    }
    if(ok) ans = min(ans,costs);
  }
  if(ans==1000000000) cout << -1 << endl;
  else cout << ans << endl;
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	int d[105];
	rep(i, n) cin >> d[i];

	set<int> se;

	rep(i, n){
		se.insert(d[i]);
	}

	cout << se.size();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

LL n, k, b[40], dp[2], INF = 1e18;

int main() {
	cin >> n >> k;
	inc(i, n) {
		LL a;
		cin >> a;
		inc(j, 40) { b[j] += bit(a, j); }
	}
	
	dp[0] = 0;
	dp[1] = -INF;
	dec(i, 40) {
		LL dp0 = exchange(dp[0], -INF);
		LL dp1 = exchange(dp[1], -INF);
		LL B = bit(k, i);
		LL s[2] = { b[i] * (1LL << i), (n - b[i]) * (1LL << i) };
		
		setmax(dp[0], dp0 + s[B]);
		setmax(dp[B], dp0 + s[0]);
		setmax(dp[1], dp1 + s[0]);
		setmax(dp[1], dp1 + s[1]);
	}
	
	cout << max(dp[0], dp[1]) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000

void merge(int[], int, int, int);
void mergeSort(int[] ,int,int);

int L[MAX/2+2],R[MAX/2+2],count;
int main(){
  
  int n,i,S[MAX];
  count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&S[i]);
    if(S[i] >= INFTY){
      return 1;
    }
  }

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    if( i ) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);


  return 0;
}

void merge(int A[],int left,int mid,int right){

  int i,j,k,n1,n2;
  n1 = mid -left;
  n2 = right - mid;

  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++)  R[i] = A[mid + i];
  L[n1] = R[n2]= INFTY;
  i = j = 0;
  for(k=left;k<right;k++){ count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
    j = j + 1;
    }
  }
}
void mergeSort(int A[], int left, int right){
    int mid;

    if(left+1<right){
 
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
	
    }
  }

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    int cnt = 0;
    REP(i,n) {
        int x; cin >> x;
        if (x != i + 1) cnt++;
    }
    if (cnt <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int N;
string s;

int main(){

cin>>N>>s;

int x=0,Max=0;
for(int i=0; i<s.size(); i++){
    if(s[i]=='I') x++;
    if(s[i]=='D') x--;
    Max=max(Max,x);
}

cout<<Max<<endl;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

vector<ll> par(200001);
vector<ll> ank(200001);

ll find(ll x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x , ll y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	else if (ank[x] < ank[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (ank[x] == ank[y]) ank[x]++;
	}
}

bool same(ll x, ll y) {
	return find(x) == find(y);
}

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;


	cin >> n >> m;
	vector<ll> ans(n);
	
	for(i=0;i<n;i++) {
		par[i] = i;
		ank[i] = 0;
	}

	for(i=0;i<m;i++) {
		cin >> a >> b;
		a--;
		b--;
		unite(a , b);
	}
	for(i=0;i<n;i++) {
		x = find(i);
		ans[x]++;
	}
	y = 0;
	for(i=0;i<n;i++) {
		y = max(y , ans[i]);
	}
	cout << y << endl;
	return 0;
}


Measured memory_bytes: 5620
using System;
using System.IO;
namespace aoj{
	class program{
	
	static void Main() {
		string find=Console.ReadLine();
		string str=Console.In.ReadToEnd();
		FindStr fs=new FindStr(find,str);
		Console.WriteLine("{0}",fs.find());
	
	}
}

class FindStr{
	string src;
	string[] dst;
	public FindStr(string s, string d){
		src=s;
		d=d.Substring(0,
		d.LastIndexOf("END_OF_TEXT",StringComparison.OrdinalIgnoreCase));
		char[] sep = new char[] {' ','\n'};
		dst = d.Split(sep,
	    StringSplitOptions.RemoveEmptyEntries);
	}
	public int find(){
		int count =0;
		for(int i=0;i<dst.Length;i++){
		if(src.Equals(dst[i],StringComparison.OrdinalIgnoreCase))			
			count++;
		}
		return count;
	}

}
}

Measured memory_bytes: 5644
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, l;
    int tmp=0, t=INT_MAX, mem, ans;
    
    scanf("%d%d", &n, &l);
    
    for (int i=1; i<=n; i++) {
        tmp=abs(l+i-1);
        if (tmp<t) {
            t=tmp;
            mem=i;
        }
    }
    
    //printf("%d, %d, ", t, mem);
    ans=n*(2*l-1+n)/2-(l+mem-1);
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1696
N = int(input())
c = input()
from collections import  deque
cc = deque(c)
ans = 0
while len(cc)>1:
    #print(cc)
    c1 = cc.popleft()
    c2 = cc.pop()
    #print(cc,c1,c2,ans)
    if c1 == "R":
        cc.append(c2)
        continue
    else:
        if c2 == "R":
            ans += 1
            continue
        else:
            cc.appendleft(c1)
print(ans)

Measured memory_bytes: 81300
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, m = ns()

    table_TF = [False for _ in range(n)]
    table_TF[0] = True

    table_cnt = [1 for _ in range(n)]

    for _ in range(m):
        x, y = ns()
        x -= 1
        y -= 1

        table_cnt[x] -= 1
        table_cnt[y] += 1
        if table_TF[x]:
            table_TF[y] = True
        if table_cnt[x] == 0:
            table_TF[x] = False

    ans = 0
    for tf in table_TF:
        if tf:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  string S;
  cin >> S;
  
  //main
  
  if(S[0] == 'S'){
    cout << "Cloudy" << endl;
  }else if(S[0] == 'C'){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

  // output
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{
	vector<string> v;
	string s;
	int n,i,m=0;
	cin>>n;
	map<string,int>::iterator it;
	for(i=0;i<n;i++){
		cin>>s;
		mp[s]++;
		m=max(mp[s],m);
	}
	for(it=mp.begin();it!=mp.end();it++){
		if(it->second==m){
			cout<<it->first<<endl;
		}
	}

	return 0;
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/(b))
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int D, T, S;
    cin >> D >> T >> S;
    double time = double(D)/double(S);
    if(time > T){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3664