akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int N, i, min = 1000000000, max = 0;
	int A[101];

	cin >> N;

	for ( i = 0; i < N; i++)
	{
		cin >> A[i];
		if (max < A[i])
			max = A[i];
		if (min > A[i])
			min = A[i];
	}

	cout << max - min << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
numbers = [int(i) for i in input().split()]

sorted_numbers = sorted(numbers)

diff = 0
for i in range(N):
    if numbers[i] != sorted_numbers[i]:
        diff += 1
        
if diff == 2 or diff == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
const int MAX = 2001;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    cin >> N >> K;
    COMinit();
    for ( int i = 1; i <= K; i++ ) {
        ll ans = 0;
        if ( i-2 >= 0 && i-2 <= N-K-1 ) {
            ll t = COM(K-1, i-1) * COM(N-K-1, i-2) % MOD;
            ans += t;
        }
        if ( i >= 0 && i <= N-K-1 ) {
            ll t = COM(K-1, i-1) * COM(N-K-1, i) % MOD;
            ans += t;
        }
        if ( i-1 >= 0 && i-1 <= N-K-1 ) {
            ll t = COM(K-1, i-1) * COM(N-K-1, i-1) % MOD;
            ans += t * 2;
        }
        if ( K == N && i == 1 ) {
            ans += 1;
        }
        ans %= MOD;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

typedef long long ll;
ll n,A[1000050];
int main(){
	cin >> n;
	A[1] = n; A[1] %= mod;
	ll ans = A[1];
	for(ll i = 2; i<=n; i++){
		A[i] = A[i-1];
		A[i]%=mod;
		A[i] += ((n-1)*(n-1))%mod;
		A[i]%=mod;
		if(2 <= i-2) A[i] += ans-A[i-1]-A[i-2];
		A[i] %= mod;
		A[i] += n-max((ll)2, i-1)+1; 
		A[i]%=mod;
		A[i]+=mod;
		A[i]%=mod;
		ans += A[i];
		ans %= mod;
	}
	cout << A[n];
}
/*
f(x) =
case: 1____
f(x-1)
case: YXX.. X!=1, Y!=1
(n-1)^2
case: Y111__, x-Y-1 > 0
f(x-Y-1) from Y=2 to Y=x-2, hence f(x-3) to f(1)
case: Y111.., x-1 <= Y
Y can vary from Y=2 to x-2 and from x-1 to N
hence N-x+2
*/


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	long double r, a;
	cin >> r;
	a = 2.0 * r * acos(-1.0);
	cout << fixed << setprecision(10) << a << endl;




}


Measured memory_bytes: 3808
n = int(input())
friendly = list(map(int, input().split()))
friendly.sort(reverse=True)
if len(friendly)<=2:
    print(sum(friendly[0:n-1]))
else:
    ans = friendly[0]+sum(friendly[1:(n+1)//2-1])*2+friendly[(n+1)//2-1]*((n+1)%2+1)
    print(ans)

Measured memory_bytes: 31400
#include <iostream>

int main(void) {
    int n;
    std::cin >> n;
    int cost = 100000;
    double cost_temp;

    for (int i = 0; i < n; i++) {
        cost_temp = cost * 1.05;
        cost = cost_temp;
        if (cost % 1000 != 0) {
            cost += 1000;
        }
        cost = (cost / 1000) * 1000;
    }
    std::cout << cost << std::endl;

    return 0;
}

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

int main()
{  
    int n,comm,key;
    string color;
    map<string,int>s;
    cin>>n;
    REP(i,n)
    {
        cin>>comm;
        if(comm==0)
        {
            cin>>color>>key;
            s[color]=key;
        }
        if(comm==1)
        {
            cin>>color;
            cout<<s[color]<<endl;
        }
    }
}



Measured memory_bytes: 27808
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		while (n != 0) {
			String str = scan.next();
			for (int p = 0; p < n; p++) {
				StringBuffer buf = new StringBuffer();
				int strLeng = str.length();
				for (int i = 0; i < strLeng; i++) {
					char chara = str.charAt(i);
					int number = 1;
					for (int j = i; j + 1 < str.length() && chara == str.charAt(j + 1); j++) {
						number++;
					}
					buf.append(number);
					buf.append(chara);
					i += number-1;
				}
				str = buf.toString();
				//System.out.println(str);
			}
			System.out.println(str);
			n = scan.nextInt();
		}
	}
}

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

int main() {
	int n; cin >> n;
	int monster[n + 1];
	int hero[n];
	for (int i = 0; i < n + 1; i++) {
	    cin >> monster[i];
	}
	for (int i = 0; i < n; i++) cin >> hero[i];
	long long res = 0;
	for (int i = 0; i < n; i++) {
	    if (hero[i] <= monster[i]) {
	        res += hero[i];
	        hero[i] = 0;
	    }
	    else {
	        res += monster[i];
	        hero[i] -= monster[i];
	        if (monster[i + 1] >= hero[i]) {
	            res += hero[i];
	            monster[i + 1] -= hero[i]; 
	        }
	        else {
	            res += monster[i + 1];
	            monster[i + 1] = 0;
	        }
	    }
	}
	cout << res;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
*A, = map(int, input().split())
A = [0] + A
bit = list(bin(k)[2:][::-1])
m = len(bit)
DP = [[None for j in range(m)] for i in range(n + 1)]
for i in range(n + 1):
    DP[i][0] = A[i]
for j in range(1, m):
    for i in range(n + 1):
        DP[i][j] = DP[DP[i][j - 1]][j - 1]
i = 1
for j, b in enumerate(bit):
    if b == '1':
        i = DP[i][j]
print(i)


Measured memory_bytes: 206688
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)
		for(int j=1;j<=s.size()-i;j++){
			int f=1;
			string ss=s.substr(i,j);
			for(int i=0;i<ss.size();i++)
				if(ss[i]!='A' && ss[i]!='G' && ss[i]!='C' && ss[i]!='T')
					f=0;
			if(f)
				ans=max((int)ss.size(),ans);
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define ll long long int

#include <bits/stdc++.h>

using namespace std;
const int N = 200;
int arr[N];

int main() {

    int n;
    cin >> n;
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        if (arr[i] % 2 && (i + 1) % 2)cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  set<char> S;
  for(int i = 0; i < s.size(); i++){
    if(S.count(s.at(i))){
      cout << "no" <<endl;
      return 0;
    }
    else S.insert(s.at(i));
  }
  
  cout << "yes" <<endl;
}
  
  
  

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int b[101];
int p[101][12];

int main() {
    int N;
    cin >> N;
    rep(i, N) {
        rep(j, 10) {
            int tmp;
            cin >> tmp;
            b[i] = (b[i]<<1)+tmp;
        }
    }
    rep(i, N) {
        rep(j, 11) {
            cin >> p[i][j];
        }
    }
    ll ans = -1e18;
    for (int bit=1; bit<(1<<10); ++bit) {
        ll tmp=0;
        rep(i, N) {
            int c = __builtin_popcount(bit&b[i]);
            tmp += (ll)p[i][c];
        }
        ans=max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

K = []
for i, a in enumerate(A):
    k = 0
    while a%2==0:
        a//=2
        k+=1
    K.append(k)
    A[i] = a

if len(set(K))>1:
    print(0)
    exit()

def gcd(a,b):
    if a>b: a,b = b,a
    while a: a,b=b%a, a
    return b

def lcm(a,b):
    return a*b//gcd(a,b)

l = 1
for a in A:
    l = lcm(l,a)

l *= 2**K[0]
print((M+l)//(l*2))

Measured memory_bytes: 14484
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        System.out.println(t/a*b);
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, ans = 0;
    cin >> x;
    for(int b = 1; b <= sqrt(x); b++) {
        for(int p = 2; p < 10; p++) {
            int num = pow(b, p);
            if((num <= x)&&(ans <= num)) ans = num;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 998244353LL
#define MAXN 300002
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
vector< pii > v;
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
        ll n;
        cin>>n;
        vector<ll>v;
        
          for(ll i=0;i<n;i++)
          {
            ll x;
            cin>>x;
            v.pb(x);
          }
          stack<ll> ans;
          while(sz(v))
          {
         
            ll i;
            for(i=sz(v)-1;i>=0;i--)
            {
             // cout<<i<<endl;
              if(v[i]==i+1)
              {
                ans.push(i+1);
                v.erase(v.begin()+i);
                break;
              }

            }
      
           if(i==-1)
           {
            cout<<-1;
            return 0;
           }
          }
          //cout<<2<<endl;
          while(!ans.empty())
          {
            cout<<ans.top()<<"\n";
            ans.pop();
          }
       return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

ll f(ll x, ll b, ll K) {
    if (x % b <= K-1)
        return K * (x/b) + x%b + 1;
    else 
        return K *  (x/b + 1);
}

int main() {
    ll N, K, ans = 0, b;    cin >> N >> K;
    for (b = 1; b <= N; b++)
        ans += max((ll)0, b-K) * (N/b) + max((ll)0, N%b - K +1);
    cout << ans - ((K==0) ? N : 0) << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<pair<int, int>> bat(m);
    for (int i=0; i<m; i++) {
        cin >> bat.at(i).first >> bat.at(i).second;
    }
    sort(bat.begin(), bat.end(), greater<pair<int, int>>());
    int rm = n;
    int cnt = 0;
    for (auto p : bat) {
        if (p.second <= rm) {
            cnt++;
            rm = p.first;
        }
    }
    cout << cnt << endl;
    return 0;
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,temp;
map<int,int> dt;
int main(){
    cin >> N;
    rep(i,N) cin >> temp, dt[temp]++;
    int ans = 0;
    for(auto itr = dt.begin(); itr != dt.end(); ++itr){
        int def = itr->second - itr->first;
        if(def >= 0) ans += def;
        else ans += itr->second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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

LL solve(vector<LL> L, LL N){
  LL ans = 0;
  rep(i,N)
    rep(j,N)
      rep(k,N){
        if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i] && (L[i]!=L[j])&&(L[j]!=L[k])&&(L[k]!=L[i])){
          ans++;
        }else{
          bool flag = 0;
        }
      }

  return ans/6;
}
int main() {
  using dt=LL;
  dt N; scanf("%ld" ,&N);
  vector<dt> L(N,0);
  dt V;
  rep(i,N){
    scanf("%ld", &V);
    L[i]=V;
  }
  dt ans = solve(L,N);
  printf("%ld\n",ans);
  return 0;
}



Measured memory_bytes: 3788
#!/usr/bin/env python3
from functools import reduce

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while 0 < b:
        a, b = b, a % b
    return a


def solve(n, a):
    ans = reduce(gcd, a)

    return ans


def main():
    n = input()
    n = int(n)
    a = list(map(int, input().split()))

    print(solve(n, a))


if __name__ == '__main__':
    main()



Measured memory_bytes: 14600
# ABC057C - Digits in Multiplication
def factorize(x: int) -> list:
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret = [i, x // i]
    return ret


def main():
    n = int(input())
    a, b = factorize(n)
    print(max(len(str(a)), len(str(b))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	string s;
	cin>>s;
	n  = s.size();
	if( n % 2 == 0 ){
		for(int i=0;i<n/2;i++){
			if( s[2*i] != 'h' || s[2*i+1] != 'i' ){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	else{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
  while(true){
    int h, w;
    std::cin >> h;
    std::cin >> w;

    if(h == 0 && w == 0) break;

    std::string str = "";
    for(int i = 0; i < w; i++){
      str += "#";
    }
    for(int i = 0; i < h; i++){
      std::cout << str << std::endl;
    }
    std::cout << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3148
#include <iostream>

using namespace std;

using ll = long long;

ll gcd(int a, int b) {
    return b?gcd(b, a%b):a;
}

int main() {
    int n;
    cin >> n;
    ll a, ans;
    for(int i=0;i<n;++i) {
        cin >> a;
        if(i) ans = gcd(ans, a);
        else ans = a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;

long long fac[maxn];
long long inv[maxn];
long long facinv[maxn];
long long dp[maxn][maxn];
long long pwfacinv[maxn][maxn];

int main()
{
	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	fac[0] = fac[1] = inv[1] = facinv[0] = facinv[1] = 1;
	for (int i = 2; i <= N; ++i)
	{
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
	dp[A - 1][0] = 1;
	for (int i = A; i <= B; ++i)
	{
		pwfacinv[i][0] = 1;
		for (int j = 1; j <= N; ++j)
			pwfacinv[i][j] = pwfacinv[i][j - 1] * facinv[i] % mod;
		for (int j = 0; j <= N; ++j)
		{
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			for (int k = C; k <= D && j + i * k <= N; ++k)
			{
				dp[i][j + i * k] = (dp[i][j + i * k] + dp[i - 1][j] * pwfacinv[i][k] % mod * facinv[k] % mod) % mod;
			}
		}
	}
	printf("%lld\n", dp[B][N] * fac[N] % mod);
	return 0;
}


Measured memory_bytes: 16000
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 998244353;

int add(int a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
    return a;
}

int dp[NAX];
int stop[NAX];

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;

        vector<pair<int, int>> v(n);

        for (auto &x : v)
            cin >> x.f >> x.s;

        sort(all(v));

        dp[n] = 1;

        for (int i = n - 1; i >= 0; i--)
        {
            stop[i] = i + 1;
            while (stop[i] < n && (v[i].f + v[i].s - 1) >= (v[stop[i]].f))
                stop[i] = stop[stop[i]];
            dp[i] = add(dp[i + 1], dp[stop[i]]);
        }
        cout << dp[0] << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 3456
import numpy as np
n, k = map(int, input().split())
a = np.zeros(n + 1)
a[0] = 1
for i in range(k):
    d = int(input())
    a[np.array(list(map(int, input().split())))] += 1
print(np.count_nonzero(a == 0))


Measured memory_bytes: 27208
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int n, m;
  static long ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    m = Integer.parseInt(in[1]);

    br.close();

    out.println(n*m);

    out.flush();
  }
}


Measured memory_bytes: 32532
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <cstdlib>
using namespace std;




int main() {

    string S;

    cin >> S ;

    int bad=0;

    for(int i=0;i<S.length()-1;i++){
        if(S[i]==S[i+1]){
            bad=1;
        }
    }

    if(bad){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String,Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] tmp = sc.next().toCharArray();
           Arrays.sort(tmp);
           String key = String.valueOf(tmp);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 47060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int d,g;
    cin>>d>>g;
    vector<int>p(d);
    vector<int>c(d);
    rep(i,d)cin>>p[i]>>c[i];
    int min_c=1e9;
    for(int bit=0;bit<(1<<d);++bit){
        int get_score=0,cnt=0,max=-1;
        rep(i,d){
            if(bit&(1<<i)){
                get_score+=100*(i+1)*p[i]+c[i];
                cnt+=p[i];
            }
            else{
                max=i;
            }
        }
        if(get_score<g){
            int p_cnt=0;
            int x=(g-get_score-1+100*(max+1))/(100*(max+1));
            if(x>p[max])cnt=1e9;
            else cnt+=x;
        }
        min_c=min(min_c,cnt);
    }
    cout<<min_c<<endl;
 
    return 0;
}


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, sum = 0;
	
	cin >> N;
	
	vector<pair<int, int>> tasks(N);
	
	for(int i=0; i<N; i++)
		cin >> tasks[i].second >> tasks[i].first;
	
	sort(tasks.begin(), tasks.end());
	
	for(int i=0; i<N; i++){
		sum += tasks[i].second;
		if(sum > tasks[i].first){
			cout << "No";
			return 0;
		}
	}
	
	cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            string result = "";

            string s = Console.ReadLine();

			switch(s){
                case "A":
                    result = "T";
                    break;
                case "C":
                    result = "G";
                    break;
                case "G":
                    result = "C";
                    break;
                case "T":
                    result = "A";
                    break;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 17228
H, W = map(int, input().split())

#%%
ho = H // 2 + H % 2
he = H // 2
wo = W - (W // 2)
we = W // 2
ans = ho * wo + he * we
if H == 1 or W == 1:
    print(1)
else:
    print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {
        int n; cin >> n;
        vector<int> v(n);
        for (auto& i: v) cin >> i;

        auto can= [](int a, int b, int c) {
                if (a!= b&& b!= c&& a!= c) {
                        if (a+ b> c&& c+ a> b&& b+ c> a) return 1;
                        else return 0;
                } return 0;
        };

        int an= 0;
        for (int i = 0; i< n; i++) {
                for (int j = i+ 1; j< n; j++) {
                        for (int k= j+ 1; k< n; k++) {
                                if (can(v[i], v[j], v[k])) an++;
                        }
                }
        }
        cout << an<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

using namespace std;

typedef long long ll ;
#define X first
#define Y second

int main() {
	int n;
	cin >> n;
	ll a[n], b[n], ans = 0;
	pair<ll, ll> c[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i].X = a[i] + b[i];
		c[i].Y = i;
	}
	sort(c, c + n);
	for(int i = n - 1; i >= 0; i -= 2)
		ans += a[c[i].Y];
	for(int i = n - 2; i >= 0; i -= 2)
		ans -= b[c[i].Y];
	cout << ans ;
}



Measured memory_bytes: 3456
//いっしょ

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    int ans=inf;
    rep(j,-100,101){
        int c = 0;
        rep(i,0,n){
            c+=abs(a[i]-j)*abs(a[i]-j);
        }
        ans=min(ans,c);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i = 0 , taroPo = 0 , hanakoPo = 0 ;
		while(i != n){
			i++;
			String taro = scan.next();
			String hanako = scan.next();
			
			if(taro.compareTo(hanako) < 0) hanakoPo += 3;
			else if(taro.compareTo(hanako) > 0) taroPo += 3;
			else { 
				taroPo ++;
				hanakoPo ++;
			}
		}
		
		System.out.println(taroPo + " " + hanakoPo);
		
	}

}

Measured memory_bytes: 20812
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    ll n; cin >> n;
    ll lo = inf, hi = 0, mx = 0;
    vpll v(n, {0LL, 0LL});
    F0R(i, n) {
        cin >> v[i].f >> v[i].s;
        lo = min(lo, v[i].s);
        hi = max(hi, v[i].f);
        mx = max(mx, v[i].s - v[i].f + 1);
    }
    sort(begin(v), end(v)); 

    ll l = v[0].s;
    multiset<ll> ms;
    for(ll i = 1; i < n; i++) {
        ms.insert(v[i].s);
    }

    ll best = 0LL;
    for(ll i = 1; i < n; i++) {
        best = max(best, max(0LL, l - v[i - 1].f + 1LL) + max(0LL, *ms.begin() - v.back().f + 1LL));
        l = min(l, v[i].s);
        ms.erase(ms.find(v[i].s));
    }

    cout << max(best, mx + max(lo - hi + 1, 0LL)) << endl;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void)
{
    int a;
    scanf("%d", &a);
    int b[3];
    for( int i = 0; i < 3; i++){
        b[i] = a % 10;
        a = a / 10;
    }
    
    if(b[0] == b[2]){
        printf("Yes");
    }else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll a, b;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    a = 1;
    cin >> N;
    while(N--) {
        ll q, x;
        cin >> q >> x;
        if(q == 1) {
            a *= x;
            b *= x;
        }
        if(q == 2) {
            b += x;
        }
        if(q == 3) {
            b -= x;
        }
    }
    cout << -b << " " << a << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  if(S[K-1]=='A') S[K-1] = 'a';
  if(S[K-1]=='B') S[K-1] = 'b';
  if(S[K-1]=='C') S[K-1] = 'c';

  cout << S << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes";
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No";
            return 0;
        }
        
    }
}









Measured memory_bytes: 3576
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int n;
	int x[110];
	int y[110];
	int h[110];
	int i,j,k;
	int takasa;
	int ansx,ansy,ansh;
	int flag=0;
	
	//データの読み込み
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&x[i],&y[i],&h[i]);
	}
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	for(i=0;i<101;i++){
		for(j=0;j<101;j++){
			for(k=0;k<n;k++){
				if(h[k]!=0){
					takasa=abs(x[k]-i)+abs(y[k]-j)+h[k];
					break;
				}
			}
			flag=1;
			for(k=0;k<n;k++){
				if(h[k]!=0){
					if(takasa!=abs(x[k]-i)+abs(y[k]-j)+h[k]){
						flag=0;
					}
				}else{
					if(abs(x[k]-i)+abs(y[k]-j)<takasa){
						flag=0;
					}
				}
			}
			if(flag==1){
				ansx=i;
				ansy=j;
				ansh=takasa;
			}
		}
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d %d %d",ansx,ansy,ansh);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if (N == 1) {
        if (A == B) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    ll tmp = B - A;
    ll ans = max(tmp * (N - 2) + 1, 0ll);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  rep(i,n)cin>>l[i];
  
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int body =0;
  rep(i,k){
    body += l[i];
  }
  
  cout<<body;
        


}


Measured memory_bytes: 3540
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
import java.util.Scanner;

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

        String ans = "";

        if(a == 7) {
            if(b == 5 && c == 5) {
                ans = "YES";
            } else {
                ans = "NO";
            }
        } else if(b == 7) {
            if(a == 5 && c == 5) {
                ans = "YES";
            } else {
                ans = "NO";
            }
        } else if(c == 7) {
            if(a == 5 && b == 5) {
                ans = "YES";
            } else {
                ans = "NO";
            }
        } else {
            ans = "NO";
        }

        System.out.println(ans);

        in.close();
    }
}


Measured memory_bytes: 8788
while 1:
    counter=0
    try:
        n,m=map(int,input().split())
        if n==0:break
        count=[i+1 for i in range(n)]
        while len(count)>1:
            for j in count:
                counter += 1
                if counter==m:
                    if j==count[-1]:
                        count.remove(j)
                        counter=0
                    else:
                        count.remove(j)
                        counter = 1
        print(*count)
    except:break


Measured memory_bytes: 5608
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  usize n;
  std::cin >> n;
  std::vector<std::string> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  usize ans = 0;
  usize a = 0, b = 0, ba = 0;
  for (const auto &e : s) {
    for (const auto i : rep(1, e.size())) {
      if (e[i - 1] == 'A' && e[i] == 'B') {
        ++ans;
      }
    }
    if (e.front() == 'B') {
      ++b;
    }
    if (e.back() == 'A') {
      ++a;
    }
    if (e.front() == 'B' && e.back() == 'A') {
      ++ba;
    }
  }
  ans += std::min(a, b);
  if (a != 0 && a == b && a == ba) {
    --ans;
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll Mod = 1e9 + 7;
int n;
char  a[55], b[55];
ll ans = 1;

int main()
{
    // FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        scanf("%d %s %s", &n, a + 1, b + 1);
        if (a[1] == b[1]) ans = 3;
        else ans = 6;
        for (int i = 2; i <= n; i++) {
            if (a[i] == a[i - 1]) continue;
            else if (a[i] == b[i] && a[i - 1] == b[i - 1]) ans = (ans * 2) % Mod;
            else if (a[i] == b[i]) continue;
            else if (a[i - 1] == b[i - 1]) ans = (ans * 2) % Mod;
            else ans = (ans * 3) % Mod;
        }
        printf("%lld\n", ans);
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e3+5;
const double EPS = 1e-6;
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
    int a;
    scanf("%d",&a);
    int shi=a/10;
    int ge=a%10;
    if(shi==9||ge==9) printf("Yes\n");
    else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int in;
	cin>>in;
	int a=in/1000,b=in/100%10,c=in/10%10,d=in%10;
	rep(i,1<<3){
		int e=a+b+c+d;
		e=(a + ((i&(1<<2))?b:-b) + ((i&(1<<1))?c:-c) + ((i&1)?d:-d));
		if(e==7){
			cout<<a<<((i&(1<<2))?'+':'-')<<b<<((i&(1<<1))?'+':'-')<<c<<((i&1)?'+':'-')<<d<<"=7"<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2104
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String T= sc.next();
        T = T.replace("P?","PD");
        T = T.replace("?D","PD");
        T = T.replace("?","D");
        System.out.println(T);
    }
}


Measured memory_bytes: 41712
// ABC_120_B
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

	vector<int> v;

	int mini = min(a, b);
	for(int i = 1; i <= mini; ++i){
		if(a % i == 0 && b % i == 0) {
			v.push_back(i);
	  }
		else continue;
	}

	sort(v.rbegin(), v.rend());
	//for(auto item : v) cout << item << " ";
  cout << v[k-1] << "\n";

  return 0;
}      

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
using namespace std;
int main(){
    int r,g,b;
    cin >> r >> g >> b;
    if((2*g+b)%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  cout<<a*b/2<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,x,y,z=2,sum=0;
	char a[50],b[50];
	cin>>a;
	cin>>b;
	x=strlen(a);
	y=strlen(b);
	for(i=0;i<x+y;i++)
	{
		if(z%2==0)
		{
			if(sum<x)
			{
				cout<<a[sum];
			}
			else
			{
				cout<<a[sum-x];
			}
		}
		else
		{
			if(sum<y)
			{
				cout<<b[sum];
			}
			else
			{
				cout<<b[sum-y];
				sum++;
			}
			sum++;
		}
		z++;
	}
	cout<<endl;
 	return 0;
}


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

int main(void) {
    string ans;
    string str;
    cin >> str;

    for(auto &i : str) {
        if(i != 'B') {
            ans.push_back(i);
        }
        else if(!ans.empty()){
            ans.pop_back();
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

const int w=1e6+7;

vector<int> ip(mx,0);

bool isprime(int x){
  if(x==2 || x==3){ return true; }
  if(x<2 || x%2==0){ return false; }
  
  int sqrtx = ceil(sqrt(x));
  for(int i=3; i<=sqrtx; i+=2){ if(x%i==0){ return false; } }
  return true;
}

void ipset(int x){                                        //x miman prime set
  for(int i=2; i<x; i++){ ip[i]=(int)isprime(i);}
}


int main(){
  ipset(mx);
  int n; cin>>n;
  int cnt=2;
  while(n>0){
    if(ip[cnt]==1&& cnt%10==1){
      cout << cnt << " ";
      n--;
    }
    cnt++;
  }
  cout<<endl; return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi Hand = { 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1 };
	//			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
	string S;
	cin >> S;
	while (S != "#") {
		int cur = -1;
		int ans = -1;
		REP(i, SZ(S)) {
			if (cur != Hand[S[i] - 'a']) {
				ans++;
				cur = Hand[S[i] - 'a'];
			}
		}
		cout << ans << endl;
		cin >> S;
	}
	return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, s1, s2, s3;
  cin >> A;
  s1=A/100;
  s2=(A-s1*100)/10;
  s3=(A-s1*100-s2*10);
  
    cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
    char s[1100];
    int p[4]={},ans;
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='N')p[0]++;
        else if(s[i]=='W')p[1]++;
        else if(s[i]=='S')p[2]++;
        else p[3]++;
    }
    if(p[0]==0&&p[2]==0&&p[1]*p[3]>0)ans=1;
    else if(p[1]==0&&p[3]==0&&p[0]*p[2]>0)ans=1;
    else if(p[0]*p[1]*p[2]*p[3]>0)ans=1;
    else ans=0;
    if(ans==1)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128