akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check


void solve(long long N, std::string S){
    REP(i, S.length()){
        ll x = S[i]-'A';
        x = (x+N) % 26;
        S.at(i) = (char)('A'+x);
    }
    cout << S << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    field = []
    for i in range(H):
        input_raw = read_func().strip().split()
        field.append(input_raw[0])
    is_all_white_raw = [True for i in range(H)]
    is_all_white_col = [True for i in range(W)]

    for i in range(H):
        for j in range(W):
            if field[i][j] == "#":
                is_all_white_raw[i] = False
                break

    for j in range(W):
        for i in range(H):
            if field[i][j] == "#":
                is_all_white_col[j] = False
                break

    for i in range(H):
        if is_all_white_raw[i] == True:
            continue
        for j in range(W):
            if is_all_white_col[j] == True:
                continue
            sys.stdout.write(field[i][j])
        print

if __name__ == '__main__':
    main()

Measured memory_bytes: 2916
#include<bits/stdc++.h>
    using namespace std;
    const int mxn = 1e5+10;
    int n;
    long long ar[mxn];
     
    int main()
    {
        cin>>n;
        for(int i = 0; i < n; i++)
            cin>>ar[i];
        long long prev = ar[n-1];
        if(prev!=2)
        {
            cout<<"-1"<<endl;
            return 0;
        }
        long long left = 2;
        long long right = 2;
        for(int i = n-1; i >= 0; i--)
        {
    		left = ((left-1)/ar[i] + 1)*ar[i];
    		right = ((right/ar[i])*ar[i]+ar[i]-1);
    		long long tmp = (right/ar[i])*ar[i];
    		
    		if(left > tmp) { cout<<"-1"<<endl; return 0;}
    	}
    	cout<<left<<" "<<right<<endl;
        return 0;
    }

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, const char * argv[]) {
	
	
	while(1) {
		
		int i,j,shuffle,num=0,flag = 0,len=0,numsum=0;
		char Cards[20001];
		
		scanf("%s",Cards);
		if(Cards[0] == '-'){
			break;
		}
		
		len = strlen(Cards);
		
		scanf("%d",&shuffle);
		
		
		for (i = 0; i < shuffle; i++) {
			
			scanf("%d",&num);
			
			for(j = 0; j < len ; j++){
				Cards[len+numsum+j] = Cards[numsum+j];
			}
			
			numsum += num;
			
		}	
		
		for(i = numsum; i < numsum + len; i++ ) {
			printf("%c",Cards[i]);
		}
			printf("\n");
	}
		
		return 0;
	
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int l,r,ans=0;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
#幅優先探索
def bfs(adj, sign):
  queue = deque([0])
  sign[0] = 0
  while queue:
    x = queue.popleft()
    for y in adj[x]:
      if sign[y] == -1:
        sign[y] = x
        queue.append(y)

if __name__ == "__main__":
  n, m = map(int, input().split())
  adj = [set() for _ in range(n)]
  for _ in range(m):
    a, b = map(int, input().split())
    adj[a-1].add(b-1)
    adj[b-1].add(a-1)
  sign = [-1]*n
  bfs(adj, sign)
  if all([x != -1 for x in sign]):
    print("Yes")
    for x in sign[1:]:
      print(x+1)
  else:
    print("No")


Measured memory_bytes: 63360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+5;
const ll mod=1e9+7;
ll F[N],I[N];
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll f(ll a,ll b)//快速乘
{
    ll k=0;
    while(b)
    {
        if(b&1) k=(k+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return k;
}

void init(){//预处理算组合数
    F[0]=1;
    ll s=1;
    for(int i=1;i<=N;i++){
        s=f(s,i);
        F[i]=s;
    }
    I[N]=power(F[N],mod-2);
    for(int i=N;i--;){
        I[i]=f(I[i+1],i+1);
    }
}

ll C(ll n, ll k){
    return f(f(F[n],I[n-k]),I[k]);
}

main(){
    init();
    ll k;
    string s;
    cin>>k>>s;
    ll len=s.size(),sum=k+len,ans=0;
    for(ll i=len;i<=sum;i++) ans=(ans+C(sum,i)*power(25,sum-i))%mod;
    cout<<ans;
}

Measured memory_bytes: 36560
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    
    cout << (b-1) / (a-1) + ( (b-1) % (a-1) > 0 ) << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll n;
  cin >> n;
  vector<ll> t(n),a(n);
  rep(i,n)cin >> t[i];
  rep(i,n)cin >> a[i];
  vector<ll> v(n,-1);
  rep(i,n)if(i == 0 || t[i] != t[i-1])v[i] = t[i];
  ll res = 1;
  for(ll i = n-1;i >= 0;i--){
    if(i == n-1 || a[i] != a[i+1]){
      if(v[i] != -1 && v[i] != a[i])res = 0;
      v[i] = a[i];
    }
  }
  rep(i,n)if(v[i] > a[i] || v[i] > t[i])res = 0;
  rep(i,n){
    if(v[i] != -1)continue;
    (res *= min(a[i],t[i]))%= MOD;
  }
  cout << res << endl;

  


  
  


  return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC90_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int cnt = 0;
            for (int i = A; i < B + 1; i++)
            {

                int a = i / 10000;
                int b = (i % 10000) / 1000;
                int c = (i % 1000) / 100;
                int d = (i % 100) / 10;
                int e = (i % 10);
                if(a == e && b == d)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;

int32_t main(){
INIT
int x;cin>>x; if(x==0){cout<<1;}else{cout<<0;}



return 0;
}





Measured memory_bytes: 3616
import collections
n = int(input())
s = [input() for _ in range(n)]
s_ = collections.Counter(s)
print("AC x",int(s_['AC']))
print("WA x",int(s_["WA"]))
print("TLE x",int(s_["TLE"]))
print("RE x",int(s_["RE"]))

Measured memory_bytes: 16580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, K;
    cin >> N >> K;
    ld p[N];
    rep(i, N){
        cin >> p[i];
    }
    ld sum[N-K+1];
    sum[0] = 0;
    rep(i, K){
        sum[0] += p[i]+1;
    }
    ld ans = sum[0];
    rep2(i, 1, N-K){
        sum[i] = sum[i-1]+p[K-1+i]-p[i-1];
        ans = max(ans, sum[i]);
    }
    cout << sp(15) << ans/2 << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<n;i++)
typedef long long int ll;
#define ALL(a) a.begin(),a.end()
int main() {
  int d,t,s;cin >> d >> t>>s;
  if((d-1)/s+1 <= t) cout << "Yes"<<endl;
  else cout <<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
vector<bool> searched;
vector<ll> b; 
vector<vector<int>> graph;
vector<ll> ans;
void dfs(ll, int);
int main(){
    int n, q;
    cin >> n >> q;
    graph.resize(n);
    b.resize(n);
    searched.resize(n);
    ans.resize(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    for(int i = 0; i < q; i++){
        ll x, y;
        scanf("%lld %lld", &x, &y);
        b[x - 1] += y;
    }
    dfs(0, 0);
    for(int i = 0; i < n; i++){
        printf("%lld ", ans[i]);
    }
}
void dfs(ll parent_pnt, int current){
    if(searched[current]) return;
    searched[current] = true;
    ans[current] = parent_pnt + b[current];
    for(int child : graph[current]){
        dfs(ans[current], child);
    }
    return;
}

Measured memory_bytes: 22784
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    int h[N][3];
    REP(i,N)
    {
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }

    ll dp[N+1][3] = {};
    //dp[i][1]: dp[i-1][0] + h[!1]
    REP(i,N+1)
    {
        REP(j,3)
        {
            dp[i][j] = 0;
        }
    }

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 0; j < 3; ++j)
        {
            int k1 = (j + 1) % 3;
            int k2 = (j + 2) % 3;
            dp[i][j] = max(dp[i-1][k1] + h[i-1][j], dp[i-1][k2] + h[i-1][j]);
        }
    }

#if DEBUG
    for(int i = 0; i <= N; ++i)
    {
        for(int j = 0; j < 3; ++j)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
#endif

    ll res = 0;
    for(int i = 0; i < 3; ++i)
    {
        res = max(res, dp[N][i]);
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int res = 0;
    rep(i, n) {
        if (sum % (4 * m) == 0) {
            if (a[i] < sum / (4 * m)) continue;
        }
        else {
            if (a[i] <= sum / (4 * m)) continue;
        }
        res++;
    }

    if (res >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200000005,INF=1<<30;
bool exi[MAX];

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll S;cin>>S;
    ll ans=0,sum=0;
    vector<int> change={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
    int j=1;
    exi[0]=1;
    ll ok=1LL<<60;
    for(int i=1;i<=25000000;i++){
        if(i==change[j]) j++;
        sum+=j;
        exi[sum]=1;
        if(sum-S>=0&&exi[sum-S]&&sum-S<=ok) ans++;
        
        if(i==9999998) ok=sum;
    }
    
    for(int i=1;i<=S/5;i++){
        if(S%i==0){
            ll k=S/i;
            if(k>=8){
                ans+=9*rui(10,k-1)-(i-1);
                ans%=mod;
            }
        }else{
            ll a=S/i;
            if(a>=8){
                ans++;
            }
        }
    }
    
    cout<<ans<<endl;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll H, W;
ll i, j, k;
int main(){
    scanf("%lld%lld", &H,&W);
    i = min(H, W);
    if(i==1){
        printf("1");
    }else{
        printf("%lld", (H * W + 1) / 2);
    }
    return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 5)


N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

parent = [-1] * N
friends = [[] for _ in range(N)]
for A, B in AB:
    unite(parent, A - 1, B - 1)
    friends[A-1].append(B-1)
    friends[B-1].append(A-1)
blocks = [[] for _ in range(N)]
for C, D in CD:
    blocks[C-1].append(D-1)
    blocks[D-1].append(C-1)

result = []
for i in range(N):
    p = find(parent, i)
    t = -parent[p] - 1
    t -= len(friends[i])
    for b in blocks[i]:
        if p == find(parent, b):
            t -= 1
    result.append(t)
print(*result)


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

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

    static class GLongestPath {
        ArrayList<Integer>[] adj;
        boolean[] vis;
        int[] dp;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            adj = new ArrayList[n];
            vis = new boolean[n];
            dp = new int[n];
            for (int i = 0; i < n; ++i) adj[i] = new ArrayList<>();
            int m = in.ni();
            for (int i = 0; i < m; ++i) {
                int a = in.ni() - 1;
                int b = in.ni() - 1;
                adj[a].add(b);
            }
            for (int i = 0; i < n; ++i) {
                if (!vis[i]) dfs(i);
            }
            int ans = 0;
            for (int i = 0; i < n; ++i) {
                ans = Math.max(ans, dp[i]);
            }
            out.println(ans - 1);
        }

        public int dfs(int node) {
            if (dp[node] != 0) return dp[node];
            int ans = 0;
            for (int g : adj[node]) {
                ans = Math.max(ans, dfs(g));
            }
            vis[node] = true;
            return dp[node] = (1 + ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 56640
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i)
    {
        for (int j = 0; j <= x; ++j)
        {
            if (i + j == x && 2 * i + 4 * j == y)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, D[100];

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> D[i];
  }

  int sum = 0;
  for(int i=0;i<N;++i){
      for(int j=i+1;j<N;++j){
          sum += D[i] * D[j];
      }
  }

  std::cout << sum << std::endl;
}


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

int main(){
  int n,a,b;
  scanf("%d%d%d", &n, &a, &b);
  int total = 0;
  for(int x = 1; x <= n; x++){
    int check = x;
    int sum = 0;
    while(check / 10 > 0 && sum <= b){
      int add = check % 10;
      sum = sum + add;
      check = check / 10;
    }
    sum = sum + check % 10;
    if(sum >= a && sum <= b){
      total = total + x;
    }
  }
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 256
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	string s,t;
	cin>>s>>t;
	int n,m;
	cin>>n>>m;
	string u;
	cin>>u;
	if(s==u){
		n--;
	}
	if(t==u){
		m--;
	}
	cout<<n<<' '<<m;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	a=int(io())
	l = list(map(int, io().split()))
	
	l.sort(reverse=True)
	m=sum(l[1:])
	pre=l[0]
	num=1
	for val in l[1:]:
		if pre > m*2:
			break
		else:
			num+=1
			pre=val
			m=m-val
		
	return num

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 14320
[n,m] = [int(i) for i in input().split()]
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
cnt = 0
flag = "No"
for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    cnt += 1

        if cnt == m ** 2:
            flag = "Yes"
        else:
            cnt = 0
print(flag)


Measured memory_bytes: 40560
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long long h, w;
	cin >> h >> w;

	if (h == 1 || w == 1) {
		cout << 1 << endl;
	}
	else {
		cout << (h * w + 1) / 2 << endl;
	}
}


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

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

  ll d, g;
  cin >> d >> g;

  vector<int> p(d), c(d);
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }

  vector<int> v(d);
  for (int i = 0; i < d; i++) {
    v[i] = i;
  }

  ll ans = -1;
  do {
    ll count = 0;
    ll r = g;  // remains
    for (int i = 0; i < d; i++) {
      int idx = v[i];

      int pi = p[idx];
      int ci = c[idx];
      int score = 100 * (idx + 1);

      if (pi * score >= r) {
        count += ceil((double)r / score);
        break;
      } else if (pi * score + ci >= r) {
        count += pi;
        break;
      } else {
        r -= (pi * score + ci);
        count += pi;
      }
    }

    if (ans == -1) {
      ans = count;
    } else {
      ans = min(ans, count);
    }
  } while (next_permutation(v.begin(), v.end()));

  cout << ans << endl;

  return 0;
}

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

#define N 100000

int n, a[N], b[N], c[N];

int main(void)
{
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }

    sort(a, a+n);
    sort(b, b+n); // やらなくていい
    sort(c, c+n);

    // b を基準にして、あてはまる a, c の数を算出する
    long cnt = 0;
    int bTmp, left, right, mid, nATmp, nCTmp;
    for (int i = 0; i < n; i++){
        bTmp = b[i];
        left = -1, right = n;     //  こうすることで常にleft, right を確認する意味はなくなり、while文の条件が活きる
        while ( right-left > 1){
            mid = (left + right) / 2;
            if (a[mid]>=bTmp){
                right = mid;
            }
            else{
                left = mid;
            }
        }
        nATmp = right;

        left = -1, right = n;
        while ( right-left > 1){
            mid = (left + right) / 2;
            if (c[mid]>bTmp){
                right = mid;
            }
            else{
                left = mid;
            }
        }
        nCTmp = n - right;
        cnt += (long) nATmp * nCTmp;
    }

    cout << cnt << endl;

    return 0;
}



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

int main(){

  int n;
  cin>>n;

  int ans=0;

  int cnt=n;

  while(cnt!=0){
    ans+=cnt%10;
    cnt/=10;
  }

  if(n%ans==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

  return 0;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  string S;
  cin >> S;
  int N = S.size();

  vector<vector<int>> dp(N + 1, vector<int>(13, 0));
  dp.at(0).at(0) = 1;

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 13; j++)
    {
      vector<int> nv;
      if (S.at(i) == '?') nv = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
      else nv = {myctoi(S.at(i))};

      for (int k = 0; k < nv.size(); k++)
      {
        int n = nv.at(k);
        int tmp = (j * 10 + n) % 13;
        dp.at(i + 1).at(tmp) += dp.at(i).at(j);
        dp.at(i + 1).at(tmp) %= MOD;
      }
    }
  }
  
  int ans = dp.at(N).at(5);
  cout << ans << endl;
}

Measured memory_bytes: 13696
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string s;
		string t;
		cin >> s;
		sort(s.begin(), s.end());
		for (int i = s.size() - 1; i >= 0; i--){
			t += s[i];
		}
		int x, y;
		x = atoi(s.c_str());
		y = atoi(t.c_str());
		cout << y - x << endl;
	}
}

Measured memory_bytes: 1232
<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$answer =0;
for ($i = 0; $i < $N; $i++) {
    while($a[$i] % 2 == 0) {
        $answer++;
        $a[$i] /= 2;
    }
}

echo $answer . PHP_EOL;


Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N 2010102
const int p=998244353;
int k,n,C[4002][4002],bin[N],anss[N];
int main()
{
	scanf("%d%d",&k,&n);
	for(int i=0;i<=4000;i++)C[i][0]=1;
	bin[0]=1;for(int i=1;i<=4000;i++)bin[i]=1ll*bin[i-1]*k%p;
	for(int i=1;i<=4000;i++)for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%p;
	for(int i=2;i<=k+1;i++)
	{
		int ans=0;
		for(int j=0;j<=i/2;j++)
		{
			int te=1ll*C[i/2][j]*C[k+n-j*2-1][n-j*2]%p;
			if(j&1)ans=(ans-te+p)%p;
			else ans=(ans+te)%p;
		}
		anss[i]=ans;
	}
	for(int i=k+2;i<=2*k;i++)anss[i]=anss[2*k+2-i];
	for(int i=2;i<=2*k;i++)printf("%d\n",anss[i]);
}


Measured memory_bytes: 66304
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			List<Integer> integers = new ArrayList<Integer>();
			for (int i = 0; i < N; i++) {
				integers.add(scanner.nextInt());
			}
			// reverse sort
			Collections.sort(integers, Comparator.reverseOrder());

			int alice = 0;
			int bob = 0;
			for (int i = 0; i < integers.size(); i++) {
				if (i % 2 == 0) {
					alice += Integer.valueOf(integers.get(i));
				} else {
					bob += Integer.valueOf(integers.get(i));
				}
			}
			System.out.println(alice - bob);
		}
	}
}

Measured memory_bytes: 23892
dxdy = [(0, 1), (0, -1), (1, 0), (-1, 0)]
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if (i + j) % 2:
            if s[i][j] == '.':
                s[i][j] = '#'
            else:
                s[i][j] = '.'
d = [[True] * w for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if not d[i][j]:
            continue
        d[i][j] = False
        st = [(i, j)]
        b, wh = 0, 0
        while st:
            y, x = st.pop()
            if (x + y) % 2:
                b += 1
            else:
                wh += 1
            for dx, dy in dxdy:
                if 0 <= x + dx < w and 0 <= y + dy < h and d[y + dy][x + dx] and s[y][x] == s[y + dy][x + dx]:
                    st.append((y + dy, x + dx))
                    d[y + dy][x + dx] = False
        ans += b * wh
print(ans)


Measured memory_bytes: 55636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] c = new String[h];
        for (int i = 0; i < h; i++) {
            c[i] = sc.next();
        }

        for (int i = 0; i < h; i++) {
            System.out.println(c[i]);
            System.out.println(c[i]);
        }
    }

}


Measured memory_bytes: 23252
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

int main(){
    int n,m;
    int temp,temp1;
    cin>>n>>m;
    vector<int> array(n,0);
    for(int i=0;i<m*2;i++){
        cin>>temp;
        array[temp-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<array[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if (n == 0) {
				break;
			}
			int turn = 0;
			int[] pebbles = new int[n];
			int inBowl = p;
			int winner = -1;
			while(true) {
				if (inBowl > 0) {
					inBowl--;
					pebbles[turn]++;
					if (inBowl == 0 && pebbles[turn] == p) {
						winner = turn;
						break;
					}
				}else{
					inBowl += pebbles[turn];
					pebbles[turn] = 0;
				}
				turn = (turn + 1) % n;
			}
			System.out.println(winner);
		}
	}

}

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

int	main()
{
	int	N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>>	cnt_vec(N + 1, vector<int>(N + 1, 0));
	vector<int>	cnt_R_vec(N + 1, 0);
	int	L, R;
	for (int i = 0; i < M; ++i) {
		cin >> L >> R;
		cnt_vec.at(R).at(L) += 1;
		cnt_R_vec.at(R) += 1;
	}
	vector<vector<int>>	cumsum_vec(N + 1, vector<int>(N + 1, 0));
	vector<int>	cumsum_R(N + 1, 0);
	for (int i = 0; i < N; ++i)
		cumsum_R.at(i + 1) = cumsum_R.at(i) + cnt_R_vec.at(i + 1);
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < N; ++j) {
			cumsum_vec.at(i).at(j + 1) = cumsum_vec.at(i).at(j);
			cumsum_vec.at(i).at(j + 1) += cnt_vec.at(i).at(j + 1);
		}
	}
	for (int j = 1; j <= N; ++j) {
		for (int i = 0; i < N; ++i) {
			cumsum_vec.at(i + 1).at(j) += cumsum_vec.at(i).at(j);
		}
	}
	int	p, q;
	for (int i = 0; i < Q; ++i) {
		cin >> p >> q;
		cout << cumsum_R.at(q) - cumsum_vec.at(q).at(p - 1) << endl;
	}
}


Measured memory_bytes: 2944
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//s配列に格納した単語を、辞書順にソートする
//getline(cin, s);
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  int n;
  int flag = 0;
  cin >> n;
  vector<int>d(n);
  rep(i,n)cin>>d.at(i);
  int m;
  cin >> m;
  vector<int>t(m);
  rep(i,m) cin >> t.at(i);
  
  map<int,int>mp;
  
  for(int i=0;i<n;i++){
    mp[d.at(i)]++;
  }
  for(int i=0;i<m;i++){
    if(mp[t.at(i)] >= 1){
      mp[t.at(i)]--;
    }
    else{
      flag = 1;
    }
  }
  if(flag==1) cout<<"NO"<<endl;
  else 		  cout<<"YES"<<endl;
}

Measured memory_bytes: 14348
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
ll ar[1000000];
int main()
{
    ll n;

  cin>>n;
  for(ll i=0;i<n;i++)
    cin>>ar[i];
    ll ans=0;
    ll  ma=ar[0];
   for(ll i=1;i<n;i++)
      {
          ma=max(ma,ar[i]);
          if((ar[i])-ma<0)
          {
              ans+=abs(ma-ar[i]);
          }
      }
      cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5140
N,W = map(int,input().split())
item = [list(map(int,input().split())) for i in range(N)]
w = item[0][0]

dp = [[[0 for k in range(3*N+1)] for j in range(N+1)] for i in range(N+1)]

for i in range(1,N+1):
    for j in range(1,i+1):
        for k in range(3*j+1):
            if item[i-1][0]-w <= k:
                dp[i][j][k] = max(dp[i-1][j-1][k-(item[i-1][0]-w)]+item[i-1][1],dp[i-1][j][k])
            else:
                dp[i][j][k] = dp[i-1][j][k]
                
ans = 0
for j in range(N+1):
    for k in range(3*N+1):
        if j*w+k <= W:
            ans = max(ans,dp[N][j][k])
            
print(ans)

Measured memory_bytes: 68572
//WA

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d%d", &n ,&k);
  long d = n/k; long ans = 0;
  ans += d*d*d;
  if (k%2 == 0) {
    d = n/(k/2) - d;
    ans += d*d*d;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    vector<bool> X(H,false);
    vector<bool> Y(W,false);
    for (int i = 0; i < H; i++) {
        cin >> a[i];
        for(int j = 0; j < W; j++) {
            if(a[i][j] == '#') {
                X[i] = true;
                Y[j] = true;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(X[i]) {
                if(Y[j]) {
                    cout << a[i][j];
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define rep(i,j,k) for(i=j;i<=k;++i)
#define down(i,j,k) for(i=j;i>=k;--i)
struct E{
	int to,nxt;
}ed[N];
int timing,n,sum,i,j,top,K,u,v;
int c[N],fa[N],dep[N],L[N],id[N],R[N],head[N],anc[N][20];
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void dfs(int x){
	int i;
	timing++; L[x]=timing; anc[x][0]=fa[x];
	rep(i,1,19) anc[x][i]=anc[anc[x][i-1]][i-1];
	for(i=head[x];i;i=ed[i].nxt){
		dep[ed[i].to]=dep[x]+1;
		dfs(ed[i].to);
	}
	R[x]=timing;
}
int jump(int x,int k){
	int i;
	down(i,19,0)
	if(k>=(1<<i)){
			x=anc[x][i];
			k-=(1<<i);
	}
	return x;
}
void add(int u,int v){
	top++; ed[top]=(E){v,head[u]}; head[u]=top;
}
bool cmp(int a,int b){
	return dep[a]>dep[b];
}
int getsum(int x){
	if(!x) return 0;
	int tmp=0;
	for(;x;x-=(x&(-x))) tmp+=c[x];
	return tmp;
}
void add_c(int x,int v){
	for(;x<=n+1;x+=(x&(-x))) c[x]+=v;
}
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout); 
	read(n); read(K);
	rep(i,1,n) {
		read(fa[i]);
		if(i>1) add(fa[i],i);
	}
	if(fa[1]!=1) sum=1;
	fa[1]=0; dep[0]=-1;
	dfs(1);
	rep(i,1,n) id[i]=i;
	sort(id+1,id+1+n,cmp);
	rep(i,1,n){
		u=id[i];
		if(dep[u]<=K) break;
		if(getsum(L[u])) continue ;
		v=jump(u,K-1);
		add_c(L[v],1); add_c(R[v]+1,-1);
		sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 14592
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  if (m > 4)
  {
    printf("TBD\n");
    return 0;
  }
  printf("Heisei\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    int len = s.length();
    bool tate = false;
    int cnt = 0;
    vector<int> ta;
    vector<int> yo;
    REP(i,len){
        if(s[i] == 'F'){
            cnt++;
        }else{
            if(tate){
                tate = false;
                ta.push_back(cnt);
            }
            else{
                tate = true;
                yo.push_back(cnt);
            }
            cnt = 0;
        }
    }
    if(tate){
        ta.push_back(cnt);
    }
    else{
        yo.push_back(cnt);
    }

    bool ans = true;
    int x_pos = 0;
    int y_pos = 0;
    x_pos += yo[0];
    yo.erase(yo.begin());
    sort(ta.begin(), ta.end(), greater<int>());
    sort(yo.begin(), yo.end(), greater<int>());

    REP(i,ta.size()){
       int z = ta[i];
       if(y - y_pos > 0) y_pos += z;
       else y_pos -= z; 
    }
    if(y != y_pos) ans = false;

    REP(i,yo.size()){
       int z = yo[i];
       if(x - x_pos > 0) x_pos += z;
       else x_pos -= z; 
    }
    if(x != x_pos) ans = false;

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

	int N= sc.nextInt();
	int X[]=new int[N];
    
	for(int i=0;i<N;i++){
		X[i]=sc.nextInt();
	}
    int Y[]=X.clone();
    Arrays.sort(Y);
        
    for(int i=0; i<N; i++){
        if(X[i]<=Y[(N/2)-1]){
            System.out.println(Y[N/2]);
        }else{
            System.out.println(Y[(N/2)-1]);
        }    
    }
       
    }

}


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

#define ll long long int
#define ld long double
#define clr(arr) memset(arr,0,sizeof(arr))
#define nn '\n'

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

    int t = 1;
    //cin>>t;
    while(t--)
    {
        int r,g,b;
        cin>>r>>g>>b;
        int k;
        cin>>k;
        while(g<=r && k>0)
        {
            g *= 2;
            k--;
        }
        while(b<=g && k>0)
        {
            b *= 2;
            k--;
        }
        if(g>r && b>g) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    }

    return 0;
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(s==u)
	{
		cout<<a-1<<' '<<b<<endl;
	}
	else
		cout<<a<<' '<<b-1<<endl;


}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字の入力
		String a = sc.next();
                for (int i=0; i<a.length()-1; i++){
                     for (int j=i+1; j<a.length();j++){
                          if (a.charAt(i) == a.charAt(j) ){
                               System.out.println("no");
                               return;
                          }
                     }
                }
		// 出力
		System.out.println("yes");
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int num[9];

int mentu(int i){
	int ret;
	while(i < 9 && !num[i])i++;
	if (i == 9) {
		for (int j = 0; j < 9; j++){
			if (num[j]) return 0;
		}
		return 1;
	}
	if (num[i] >= 3){
		num[i] -= 3;
		ret = mentu(i);
		num[i] += 3;
		if (ret) return 1;
	}
	if(i < 7 && num[i] && num[i + 1] && num[i + 2]){
		num[i]--;
		num[i + 1]--;
		num[i + 2]--;
		ret = mentu(i);
		num[i]++;
		num[i + 1]++;
		num[i + 2]++;
		if (ret) return 1;
	}
	mentu(i + 1);
}

int main(){
	int flag[9],f;
	string s;
	while (cin >> s){
		f = 0;
		for (int i = 0; i < 9; i++) {
			num[i] = 0;
			flag[i] = 0;
		}
		for (int i = 0; i < 13; i++){
			num[s[i] - '1']++;
		}
		for (int i = 0; i < 9; i++){
			if (num[i] == 4) continue;
			num[i]++;
			for (int j = 0; j < 9; j++){
				if (num[j] >= 2){
					num[j] -= 2;
					if (mentu(0)) flag[i] = 1;
					num[j] += 2;
				}
			}
			num[i]--;
		}
		for (int i = 0; i < 9; i++){
			if (flag[i]) {
				if (!f) {
					cout << i + 1;
					f = 1;
				}
				else cout << " " << i + 1;
			}
		}
		if (!f) cout << 0;
		cout << endl;
	}
}

Measured memory_bytes: 1180
N = int(input())
na = len(str(N))
if na == 1:
    print(N)
if na == 2:
    print(9)
if na == 3:
    print(9+N-99)
if na == 4:
    print(909)
if na == 5:
    print(909+N-9999)
if na == 6:
    print(90909)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), pos, neg;
    ll zero = 0;
    for(int i=0;i<n;++i) {
        cin >> a[i];
        if(a[i] > 0) pos.push_back(a[i]);
        else if(a[i] < 0) neg.push_back(a[i]);
        else ++zero;
    }
    sort(a.begin(), a.end());
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    if(k <= pos.size() * neg.size()) {
        ll ng = -LINF, ok = 0;
        while(ok-ng > 1LL) {
            ll mid = (ok + ng) / 2;

            ll kk = 0;
            for(int i=0;i<pos.size();++i) {
                ll d = ll(upper_bound(neg.begin(), neg.end(), (mid-pos[i]+1)/pos[i]) - neg.begin());
                kk += d;
            }

            if(kk >= k) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << ok << endl;
    } else if(k <= pos.size() * neg.size() + zero * (n-zero) + zero * (zero-1) / 2) {
        cout << 0 << endl;
    } else {
        for(int i=0;i<neg.size();++i) neg[i] *= -1;
        sort(neg.begin(), neg.end());
        ll ng = 0, ok = LINF;
        while(ok-ng > 1LL) {
            ll mid = (ok + ng) / 2;

            ll kk = pos.size() * neg.size() + zero * (n-zero) + zero * (zero-1) / 2;
            for(int i=0;i<pos.size();++i) {
                ll d = ll(upper_bound(pos.begin()+i+1, pos.end(), mid/pos[i]) - pos.begin()) - (i+1);
                kk += d;
            }
            for(int i=0;i<neg.size();++i) {
                ll d = ll(upper_bound(neg.begin()+i+1, neg.end(), mid/neg[i]) - neg.begin()) - (i+1);
                kk += d;
            }

            if(kk >= k) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << ok << endl;
    }
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set 
#define mod 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
#define int long long
#define Max 3000

int dp[Max+1][Max+1];

string getLcs(string &s, string &t, int len) {
    string lcs;
    int i = 0, j = 0;
    while(len > 0) {
        if(s[i] == t[j]) {
            lcs += s[i];
            i++;
            j++;
            len--;
        } else {
            if(dp[i][j+1] > dp[i+1][j]) {
                j++;
            } else {
                i++;
            }
        }
    }
    return lcs;
}

int lenLcs(string &s, string &t, int i, int j) {
    if(i >= s.size() or j >= t.size()) {
        return 0;
    }

    if(dp[i][j] != -1) {
        return dp[i][j];
    }

    if(s[i] == t[j]) {
        return dp[i][j] =  1 + lenLcs(s, t, i+1, j+1);
    } else {
        return dp[i][j] = max(lenLcs(s, t, i+1, j), lenLcs(s, t, i, j+1));
    }
}

string solve(string s, string t) {
    memset(dp, -1, sizeof dp);
    int len = lenLcs(s, t, 0, 0);
    return getLcs(s, t, len);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t; cin >> s >> t;
    cout << solve(s, t);
    return 0;
}

Measured memory_bytes: 74332
#include<cstdio>
int wp[2005], bp[2005];
int c[4005];
long long f[2005][2005];

void change(int p,int v,int n){
    while(p<=n){
        c[p] += v;
        p += (p&-p);
    }
}

int ask(int p){
    int res = 0;
    while(p!=0){
        res += c[p];
        p -= (p&-p);
    }
    return res;
}

long long min(long long a,long long b){ return a>b?b:a; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= 2*n; i++){
        char s[2]; int u;
        scanf("%s%d",s,&u);
        if(s[0]=='W') wp[u] = i;
        else bp[u] = i;
    }
    for(int i = 1; i <= n; i++) change(wp[i],1,2*n);
    //printf("ok\n");
    for(int i = 0; i <= n; i++){
        if(i!=0) change(wp[i],-1,2*n);
        for(int j = 1; j <= n; j++) change(bp[j],1,2*n);
        for(int j = 0; j <= n; j++){
            if(i==0 && j==0) f[i][j] = 0;
            else{
                f[i][j] = 1e18;
                if(j!=0) change(bp[j],-1,2*n);
                if(i!=0){
                    long long cost = ask(wp[i]-1);
                    f[i][j] = min(f[i][j],f[i-1][j]+cost);
                }
                if(j!=0){
                    long long cost = ask(bp[j]-1);
                    f[i][j] = min(f[i][j],f[i][j-1]+cost);
                }
                //printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
            }
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}


Measured memory_bytes: 33100