akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n = 0;
    scanf("%d",&n);
    
    int v[100] = {};
    for (int i = 0; i < n; i++) {
        scanf("%d",&v[i]);
    }

    int c[100] = {};
    for (int i = 0; i < n; i++) {
        scanf("%d",&c[i]);
    }

    int result = 0;
    

    for (int i = 0; i < n; i++) {
        if (v[i] - c[i] > 0) {
            result = result + (v[i] - c[i]);
        }
    }
    
    printf("%d\n",result);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n, m;
int d[3];
int x ,y, w, h, r;
int main(){
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if((x+r) <= w && (x-r) >= 0 && (y+r) <= h && (y-r) >= 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[1000005];
signed main() {
    int N;
    cin >> N;
    int X = N;
    for(int i = 2; i*i <= N; i++) {
        int res = 0;
        while (X%i == 0) {
            X/=i;
            res++;
        }
        cnt[i] = res;
    }
    int ans = 0;
    if(X >= 2) {
        ans++;
    }
    for(int i = 0; i <= 1000000; i++) {
        int res = 0;
        for(int j = 1; j <= cnt[i]; j++) {
            if(res+j <= cnt[i]) {
                ans++;
            }
            res += j;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11388
strN, strT = input().split()
N = int(strN)
max_t = int(strT)

min_cost = 0
for i in range(1, N+1):
    str_cost, str_time = input().split()
    cost = int(str_cost)
    t = int(str_time)
    if max_t < t:
        continue
    if min_cost == 0:
        min_cost = cost
    elif min_cost > cost:
        min_cost = cost

if min_cost == 0:
    print('TLE')
else:
    print(min_cost)


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

int main(){
  string a,b;
  string answer = "EQUAL";
  cin >> a >> b;
  if(a.size() > b.size()){
    answer = "GREATER";
  }
  else if(a.size() < b.size()){
    answer = "LESS";
  }
  else{
    for(int i = 0; i < a.size(); i++){
      if(a.at(i) > b.at(i)){
        answer = "GREATER";
        break;
      }
      else if(a.at(i) < b.at(i)){
        answer = "LESS";
        break;
      }
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5;

int main()
{
	ll x, y;
	cin >> x >> y;
	
	if (abs(x - y) <= 1)
		cout << "Brown\n";

	else
		cout << "Alice\n";	
}

Measured memory_bytes: 256
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)2e5+20
#define INF 1e12+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
typedef pair<int,pii> pI;
const int delta=(int)1e9+7;
int n,k,a[MAX_N],x,ans;
main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>x; --x; ++a[x];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<n;++i){
		if(i>=k) ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005


double max(double a, double b) {
    if (a > b) return a;
    return b;
}

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
 int a,b,c,d;
  in(a>>b>>c>>d);
  while(a>0&&c>0){
    c -= b;
    if(c<=0) {
      out("Yes");
      break;
    }
     a -= d;
    if(a<=0) out("No");
    
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef queue<pair<string, int>> Queue;
int main() {
  int n, q;
  cin >> n >> q;

  Queue Q;

  string name;
  int time;
  for (size_t i = 0; i < n; i++) {
    cin >> name >> time;
    Q.push(pair<string, int>{name, time});
  }

  int elapse = 0;
  while (!Q.empty()) {
    auto process = Q.front();
    if (process.second <= q) {
      elapse += process.second;
      cout << process.first << ' ' << elapse << endl;
      Q.pop();
    } else {
      Q.pop();
      process.second -= q;
      Q.push(process);
      elapse += q;
    }
  }
}


Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    ll n,k;cin>>n>>k;
    ll h[n];
    f(i,0,n)cin>>h[i];
    sort(h,h+n,greater<ll>());
    ll sum=0;
    f(i,k,n){
        sum+=h[i];
    }
    cout<<sum;
    return 0;
}   


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<int> v(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
		sum += v[i];
	}
	sort(v.begin(), v.end(), greater<int>());
	bool ok = true;
	for (int i = 0; i < M; ++i) {
		if (v[i] * 4 * M < sum) {
			ok = false;
			break;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> l(N);
	int i;
	for (i = 0; i < N; ++i) cin >> l[i];
	sort(l.begin(), l.end());
	int count = 0;
	int j, k, h;
	for (j = 0; j < N - 2; ++j) {
		for (k = j + 1; k < N - 1; ++k) {
			for (h = N - 1; h > k; --h) {
				if (abs(l[j] - l[k]) < l[h] && l[j] + l[k] > l[h]) {
					count += h - k;
					break;
				}
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashSet<Long> list = new HashSet<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextLong());
        }

        System.out.println(list.size() == n ? "YES" : "NO");
    }
}


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

int main(){
  int A[3];
  for(int i=0;i<3;i++){
    cin>>A[i];
  }
  sort(A,A+3);
  cout<<A[2]-A[1]+A[1]-A[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
dic={"A":0,"B":1,"C":2,"D":3,"E":4,
     "F":5,"G":6,"H":7,"I":8,"J":9,
     "K":10,"L":11,"M":12,"N":13,"O":14,
     "P":15,"Q":16,"R":17,"S":18,"T":19,
     "U":20,"V":21,"W":22,"X":23,"Y":24,"Z":25}
gyak={0:"A",1:"B",2:"C",3:"D",4:"E",
      5:"F",6:"G",7:"H",8:"I",9:"J",
      10:"K",11:"L",12:"M",13:"N",14:"O",
      15:"P",16:"Q",17:"R",18:"S",19:"T",
      20:"U",21:"V",22:"W",23:"X",24:"Y",25:"Z"}
#あとで開業なくす
N=int(input())
S=input()
M=""
for i in range(len(S)):
  M+=gyak[(dic[S[i]]+N)%26]
print(M)


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll A, B, C;
ll ret = 0;
string s;

void input() {
  IN(A);
  IN(s);
}

void solve() {
  if (A >= 3200) {
    PRINT(s);
  } else {
    PRINT("red");
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

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

int lcm(int a, int b) { return a * b / gcd(a, b); }
struct stu{
    int num;
    int hight;
};
bool cmp(stu a,stu b){
    return a.hight > b.hight;
}
signed main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<char> kirai;
    for(int i=0;i<k;i++){
        char tmp;
        cin >> tmp;
        kirai.push_back(tmp);
    }
    bool ans_b = true;
    while(ans_b){
        for(int i=0;i<k;i++){
            string nstr = to_string(n);
            if(nstr.find(kirai[i]) != string::npos){
                ans_b = true;
                break;;
            }
            ans_b = false;
        }
        n++;
    }
    cout << n - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD=1000000007;
int n;
int main()
{
	while(cin>>n,n)
	{
		vector<P> num(n);
		for(int i=0;i<n;i++)
		{
			int a,b;
			cin>>a>>b;
			num[i].first=b;
			num[i].second=a;
		}
		sort(num.begin(),num.end());
		bool b=true;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(abs(num[i].first)>=ans+num[i].second)ans+=num[i].second;
			else b=false;
		}
		if(!b)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
#include<vector>


using namespace std;
using vi=vector<int>;


void max_u(int&m, int v)
{
	if(m<v) m=v;
}


int main(void)
{
	int a, b, c, d, e, f;

	while(scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f)==6)
	{
		vi dp(f+1, -1);

		dp[0]=0;
		for(int i=0;i+a*100<=f;i++)
		{
			if(dp[i]>=0) dp[i+a*100]=dp[i];
		}
		for(int i=0;i+b*100<=f;i++)
		{
			if(dp[i]>=0) dp[i+b*100]=dp[i];
		}
		for(int i=0;i+c<=f;i++)
		{
			if(dp[i]<0) continue;
			if((dp[i]+c)*(100+e)>(i+c)*e) continue;
			max_u(dp[i+c], dp[i]+c);
		}
		for(int i=0;i+d<=f;i++)
		{
			if(dp[i]<0) continue;
			if((dp[i]+d)*(100+e)>(i+d)*e) continue;
			max_u(dp[i+d], dp[i]+d);
		}
		double r_max=0.0;
		int ans_w=a*100, ans_s=0;
		for(int i=0;i<=f;i++)
		{
			double r=(double)dp[i]/i;
			if(r_max<r)
			{
				r_max=r;
				ans_w=i;
				ans_s=dp[i];
			}
		}
		printf("%d %d\n", ans_w, ans_s);
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(true){
		int n,k;	cin>>n>>k;
		if(n==0)	return 0;
		vector<int> s(k);
		for(int i=0;i<k;i++)	cin>>s[i];
		for(int i=0;i<n;i++){
			for(int j=0;j<k;j++){
				int b;	cin>>b;
				s[j]-=b;
			}
		}
		for(int i=0;i<k;i++){
			if(s[i]<0){
				cout<<"No"<<endl;
				goto next;
			}
		}
		cout<<"Yes"<<endl;
		next:;
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int d,g; cin >> d >> g;
  vector<pii> pc(d);
  rep(i, d){
    int p,c; cin >> p >> c;
    pc[i] = mp(p,c);
  }

  int ans = 1e9;
  rep(bit, (1<<d)){
    int sum = 0;
    int cnt = 0;
    vector<bool> used(d,false);
    rep(i, d){
      if(bit & (1<<i)){
        used[i] = true;
        sum += 100*(i+1)*pc[i].first + pc[i].second;
        cnt += pc[i].first;
      }
    }
    if(sum >= g) chmin(ans, cnt);
    else{
      for(int j = d-1; j >= 0; j--){
        if(!used[j]){
          rep(k, pc[j].first){
            sum += 100*(j+1);
            cnt++;
            if(sum >= g){
              chmin(ans, cnt);
              break;
            }
          }
        }
      }
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 100003

int n,L,
	a[MXN],
	l,r,pos;

int main(){

	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
		if(a[i]+a[i+1]>=L){
			pos=i;
			break;
		}
	if(pos==0)
		printf("Impossible\n");
	else{
		printf("Possible\n");
		for(int i=1;i<=n;i++)
			if(i!=pos)
				printf("%d\n",i);
			else
				break;
		for(int i=n-1;i>=1;i--)
			if(i!=pos)
				printf("%d\n",i);
			else
				break;
		printf("%d\n",pos);
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int A,B,C;
    cin >> A >> B >> C;

    int ans = B/A;
    if(ans >= C){
        cout << C << endl;
    }
    else{
        cout << ans << endl;
    }
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

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

using tsi = tuple<string, int, int>;
int main(){
  int N;
  cin >> N;
  vector<tsi> vec(N);
  string s;
  int p;
  for(int i = 0; i < N; i++){
    cin >> s >> p;
    vec.at(i) = make_tuple(s, -1 * p, i + 1);
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < N; i++)
    cout << get<2>(vec.at(i)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}


int n;
vector<vector<int>> g;
vector<double> dp,ans;

double dfs1(int pre,int now){
    double p=0,res=0;
    for(auto to:g[now])if(to!=pre){
        p++;
        res+=dfs1(now,to);
    }
    if(p==0) return dp[now]=0;
    else return dp[now]=1.0+res/p;
}

void dfs2(int pre,int now){
    int memo=dp[now];

    double res=0;int p=0;
    for(auto to:g[now]){
        p++;
        res+=dp[to];
    }
    ans[now]=1.0+res/(double)(p);
    dp[now]=ans[now];

    for(auto to:g[now])if(to!=pre){
        double memo2=dp[now];

        if(p==1){
            dp[now]=0;
        }else{
            double pp=(double)(p);
            dp[now]-=1.0;
            dp[now]*=pp;
            dp[now]-=dp[to];
            dp[now]/=(pp-1.0);
            dp[now]+=1.0;
        }
        dfs2(now,to);
        dp[now]=memo2;
    }
    dp[now]=memo;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(8);

    cin>>n;
    g.resize(n);dp.resize(n);ans.resize(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1(-1,0);dfs2(-1,0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    bool flag = true;
    rep(i,n)
    {
        if (ary[i]%2==0)
        {
            if (ary[i]%3==0 || ary[i]%5==0)
            {
                // pass
            }
            else
            {
                flag = false;
                break;
            }
            
        }
    }
    if (flag)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    
    
    
}




Measured memory_bytes: 256
#include <stdio.h>          // printf(), fgets()
#include <ctype.h>          // isdigit()

#define N 62
const char NUL = '\0';

int
main(int argc, char **argv)
{
	char a[N];
	char b[N];
	char c[N];
	char d[N];
	int la, lb, lc;
	int x;
	char line[128];
	const char *pb, *pc;
	const char *s;
	int i;

	while (fgets(line, sizeof(line), stdin) != NULL)
	{
		s = line;
		for (la = 0; *s != '+'; ++la, ++s)
			;

		for (i = 0; i < la; ++i)
		{
			if (isdigit(line[la - 1 - i]))
				a[i] = line[la - 1 - i] - '0';
		}

		s++;
		pb = s;
		for (lb = 0; *s != '='; ++lb, ++s)
			;

		for (i = 0; i < lb; ++i)
		{
			if (isdigit(pb[lb - 1 - i]))
				b[i] = pb[lb - 1 - i] - '0';
		}

		s++;
		pc = s;
		for (lc = 0; *s != '\n' && *s != NUL; ++lc, ++s)
			;

		for (i = 0; i < lc; ++i)
		{
			if (isdigit(pc[lc - 1 - i]))
				c[i] = pc[lc - 1 - i] - '0';
		}

		if ((line[0] == 'X' && la >= 2) || (*pb == 'X' && lb >= 2) || (*pc == 'X' && lc >= 2))
			x = 1;
		else
			x = 0;

		for (; x <= 9; ++x)
		{
			for (i = 0; i < la; ++i)
			{
				if (line[la - 1 - i] == 'X')
					a[i] = x;
			}

			for (i = 0; i < lb; ++i)
			{
				if (pb[lb - 1 - i] == 'X')
					b[i] = x;
			}

			for (i = 0; i < lc; ++i)
			{
				if (pc[lc - 1 - i] == 'X')
					c[i] = x;
			}

			int cy = 0;
			for (i = 0; i < la || i < lb; ++i)
			{
				d[i] = cy;
				if (i < la)
					d[i] += a[i];

				if (i < lb)
					d[i] += b[i];

				cy = d[i] / 10;
				d[i] %= 10;
			}

			if (cy != 0)
				d[i] = cy;

			for (i = 0; i < lc; ++i)
			{
				if (c[i] != d[i])
					break;
			}

			if (i >= lc)
				break;
		}

		if (x <= 9)
			printf("%d\n", x);
		else
			printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 528
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll k;cin>>k;
    ll ans=-1;
    vector<ll>a(k+1);
    a[0]=7%k;
    rep(i,k+1){
        if(a[i]%k==0){
            ans=i+1;
            break;
        }
        if(i<k)a[i+1]=(a[i]*10+7)%k;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int solve(){
	int n;
	cin >> n;
	vi as(n);
	trav(x, as) cin >> x;


	auto works = [&](int c){
		int m = c==1 ? 0 : 10 + n/(c-1);
		vi cur(m, 0);
		set<int> nz;
		int prv = -1;
		rep(i,0,n){
			if(prv < as[i]) ;
			else if(c==1) return false;
			else if(as[i] > m) ;
			else {
				int j = as[i]-1;
				while(!nz.empty()){
					auto it = nz.end();
					--it;
					if(*it <= j) break;
					else {
						cur[*it] = 0;
						nz.erase(it);
					}
				}
				while(true){
					if(j < 0) return false;
					if(++cur[j] == c){
						cur[j] = 0;
						nz.erase(j);
						--j;
					} else {
						nz.insert(j);
						break;
					}
				}
			}
			prv = as[i];
		}
		return true;
	};

	int lo = 0, hi = n;
	while(lo+1 < hi){
		int mi = (lo+hi)/2;
		if(works(mi)) hi = mi;
		else lo = mi;
	}
	return hi;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	cout << solve() << endl;
}

Measured memory_bytes: 1880
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define max1 200001


int main(){	
	
	int n,m;
	cin>>n>>m;
	int h[n+1];
	for(int i=1;i<=n;i++)
		cin>>h[i];
	vector<vector<int> > adjl(n+1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adjl[a].push_back(h[b]);
		adjl[b].push_back(h[a]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(adjl[i].empty()){
			ans++;
			continue;
		}
		sort(adjl[i].begin(),adjl[i].end());
		ans+=(h[i]>adjl[i][adjl[i].size()-1]);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 8784
a,b,c,d=map(int,input().split())
if abs(a-c)<=d:
    print("Yes")
elif a<=b<=c and b-a<=d and c-b<=d:
    print("Yes")
elif a>=b>=c and a-b<=d and b-c<=d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  ll n ;
  cin >> n;
  queue<ll> A ; rep2(i,1,9) A.push(i) ;
  ll kai=0 ;
  ll ans= 0;
  while(kai<n){
    ll base= A.front() ;//先頭の値の取得の時にカウント
     ans=base ;       //先にあんすを保存
    kai ++ ;            //操作回数に関わらずキューの順で取得
    if(base%10!=0) A.push(base*10+(base%10)-1) ;
    A.push(base*10+(base%10)) ;
    if(base%10!=9) A.push(base*10+(base%10)+1) ;
    A.pop() ;            //操作は一回きりなので用済みを先頭から削除
  }
    cout << ans<< endl ; 
     return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vector<bool> isMale(n, false);
  std::cout << 0 << std::endl;
  string s; std::cin >> s;
  if (s == "Male")
    for (int i = 0; i < n; i+=2) isMale[i] = true;
  else if (s == "Female")
    for (int i = 1; i < n; i+=2) isMale[i] = true;
  else
    return 0;
  int l = 0, r = n;
  rep(i, 19) {
    int mid = (l + r) / 2;
    std::cout << mid << std::endl;
    std::cin >> s;
    if (s == "Male") {
      if (isMale[mid]) l = mid;
      else r = mid;
    } else if (s == "Female") {
      if (!isMale[mid]) l = mid;
      else r = mid;
    } else
      return 0;
  }
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second

#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long
ll M=1e9+7;
ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a%M;
    }
    ll k=power(a,b/2)%M;
    if(b%2){
        return (k%M*k%M*a%M)%M;
    }
    return (k%M*k%M)%M;
}

int main(){
 ll n,k;
 cin>>n>>k;
 ll ans[k+1];
 ll total=0;
 for(ll i=k;i>=2;i--){
     ans[i]=power(k/i,n);
     for(ll j=i*2;j<=k;j+=i){
         ans[i]=(ans[i]-ans[j]+M)%M;
     }
     total=(total+(i%M*ans[i]%M)%M)%M;
 }
 ll x=0;
 for(int i=2;i<=k;i++){
     x=(x%M+ans[i]%M)%M;
 }
 x=(power(k,n)-x+4*M)%M;
 total=(total%M+x%M)%M;
 cout<<total;
} 


Measured memory_bytes: 4424
def p_a():
    A, B = map(int, input().split())
    print(A * B if A < 10 and B < 10 else -1)


def p_b():
    N = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if N == i * j:
                print("Yes")
                exit()
    print("No")


import math


def p_c():
    N = int(input())
    m = int(math.sqrt(N))

    for i in reversed(range(1, m + 1)):
        if N % i == 0:
            print(i + N // i - 2)
            break


def p_d():
    pass


def p_e():
    pass


def p_f():
    pass


if __name__ == '__main__':
    p_c()


Measured memory_bytes: 40556
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        StringBuilder sb = new StringBuilder();

        if (A >= K) {
            sb.append(A-K);
            sb.append(" ");
            sb.append(B);
            System.out.println(sb.toString());
        } else if (B >= K - A) {
            sb.append(0);
            sb.append(" ");
            sb.append(B- K + A);
            System.out.println(sb.toString());
        } else {
            System.out.println("0 0");
        }
    }
}


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

int main(){
  int a;
  int ans = 0;
  cin >> a;
  for (int i=0; i < 3; i++) {
    if (a % 10 == 1)
      ans++;
    a = a / 10;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define ll long long
const int mod=1e9+7;
const int N=2e5+100;

ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n){
       if(n&1) sum=sum*x%mod;
       x=x*x%mod;
       n>>=1;
    }
    return sum;
}
int main()
{
    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++){
        sum+=s[i]-'0';
    }
    //cout<<sum<<endl;
    cout<<(sum%9==0?"Yes":"No");
    return 0;
}



Measured memory_bytes: 3728
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#define ll long long
#define M
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int main() {
	int n = read();
	if(n == 3 || n == 7 || n == 5) cout << "YES";
	else cout << "NO";



	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];
int n;
int sibling(int);

void print(int u){
  int i,z, degree=0;
  if(T[u].l!=NIL)degree++;
  if(T[u].r!=NIL)degree++;
  z=sibling(u);
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p,z,degree, D[u],H[u]);

  if(T[u].p==-1) printf("root");
  else if(T[u].l==-1&&T[u].r==NIL) printf("leaf");
  else printf("internal node");
  printf("\n");

}
void calcDepth(int u, int p){
  if(u==NIL)return;
  D[u] = p;
  if(T[u].r!=NIL) calcDepth(T[u].r,p+1);
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
}

int HEIGHT(int u){
  int k,h1=0,h2=0;
  if(T[u].r!=NIL)h1=HEIGHT(T[u].r)+1;
  if(T[u].l!=NIL)h2=HEIGHT(T[u].l)+1;
  if(h1>h2)H[u]=h1;
  else H[u]=h2;
  return H[u];
  


}
int main(){
  int i, j, k;
  int id, sib, child,left,right;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
   for(i=0; i<n; i++){
    scanf("%d %d %d",&child, &left, &right);
    if(left!=NIL)T[left].p=child;
    if(right!=NIL)T[right].p=child;
    T[child].l = left;
    T[child].r = right;
  }


//根を求める (find the root)                                                                                 
for(i=0; i<n; i++){
  if(T[i].p == -1) root = i;
 }

//それぞれのノードの深さを求める (find depth of each node)                                                   
calcDepth(root, 0);
HEIGHT(root);
//出力 (output)                                                                                              
for(i=0; i<n; i++) print(i);

return 0;
}

int sibling(int u){
  int i,j;
  if(T[u].p==NIL)return NIL;
  /*for(i=0;;i++){
    if(u!=i&&D[u]==D[i])return D[j];
    return -1;
    }*/
  if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
  return T[T[u].p].l;
 if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
return T[T[u].p].r;
return -1;
}




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

int main(){
  int sd = 700;
  int cnt = 0;
  string s;
  cin >> s;
  for (size_t i = 0; i < 3; i++) {
    if (s[i] == 'o') {
      cnt += 1;
    }
  }
  cout << sd + 100 * cnt << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

//r[k][i] 2^k経ったときにiから→に行ける箇所
lli r[63][100100];

void func(long long N, std::vector<long long> x, long long L, long long Q, std::vector<long long> a, std::vector<long long> b){

    x.push_back(INF);
    REP(i,0,N){
        auto itr = upper_bound(x.begin(),x.end(),x[i]+L);
        itr--;
        lli nexIndex = itr-x.begin();
        r[0][i] = nexIndex;
        LOG2(i,r[0][i]);
    }

    REP(k,1,62){
        REP(i,0,N){
            r[k][i] = r[k-1][r[k-1][i]];
            LOG3(k,i,r[k][i]);
        }
    }

    REP(i,0,Q){
        lli aa = a[i];
        lli bb = b[i];

        lli small = 0,large = 1e9;
        while(small+1<large){
            lli middle = small+large;
            middle/=2;

            lli now = aa;
            for(lli i=0;i<62;i++){
                if(middle&(1LL<<i))now = r[i][now];
            }

            if(now<bb)small=middle;
            else large = middle;
        }
        cout<<large<<endl;
    }



}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    long long L;
    scanf("%lld",&L);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--,b[i]--;
        if(a[i]>b[i])swap(a[i],b[i]);
    }
    func(N, std::move(x), L, Q, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 54060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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


int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    int ans = 0;
    // (i, j) からいける場所の最短経路の最長距離を求める
    REP(i, H){
        REP(j, W){
            if(S[i][j] == '#') continue;

            vector<vector<int>> dist(H, vector<int>(W, 1e+3));
            dist[i][j] = 0;

            queue<pair<int,int>> q;
            q.push({i, j});

            while(!q.empty()){
                auto tmp = q.front();
                q.pop();
                int x = tmp.first;
                int y = tmp.second;
                vector<pair<int,int>> next = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
                for(auto n: next){
                    int ni = x+n.first;
                    int nj = y+n.second;
                    if(0 <= ni and ni < H and 0 <= nj and nj < W and S[ni][nj] == '.'){
                        if(dist[ni][nj] > dist[x][y]+1){
                            dist[ni][nj] = dist[x][y]+1;
                            q.push({ni, nj});
                        }
                    }
                }
            }
            REP(k, H){
                REP(l, W){
                    if(dist[k][l] != 1e+3) ans = max(ans, dist[k][l]);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	long int a[10000];

	long int i, j,n,z,s;

	scanf("%ld",&n);

	for (i = 0; i < n; i++){
		scanf("%ld", &a[i]);
	}

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

			if (a[i]>a[j]){
				z = a[i];
				a[i] = a[j];
				a[j] = z;
			}

		}
	}
	s = a[0];
	for (i = 1; i < n; i++){
		s = s + a[i];
	}
	printf("%ld %ld %ld\n",a[0],a[n-1],s);

	return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
 
using i64=int64_t;

class quick_find_weighted{
	public:
	int size=0;
	vector<int> belong;
	vector<set<int>> groups;
	quick_find_weighted(int size_):size(size_),belong(size_),groups(size_){
		for(int i=0; i<size; ++i){
			belong[i]=i;
			groups[i].insert(i);
		}
	}
	void unite(int x,int y){
		int gx=belong[x],gy=belong[y];
		if(gx==gy) return;
		if(groups[gx].size()<groups[gy].size()) swap(gx,gy);
		for(int z:groups[gy]) belong[z]=gx;
		groups[gx].insert(groups[gy].begin(),groups[gy].end());
		groups[gy].clear();
	}
	int find(int x)const{
		return belong[x];
	}
    bool is_same_group(int x,int y)const{
        return find(x)==find(y);   
    }
	void erase(int x){
		int gx=belong[x];
		if(gx==-1) return;
		belong[x]=-1;
		groups[gx].erase(x);
	}
};
 
void solve(){
    int n,q;
    cin >> n >> q;
    quick_find_weighted ds(n);
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) ds.unite(x,y);
        else cout << int(ds.is_same_group(x,y)) << endl;
    }
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vec_rep(itr,v) for(auto itr = v.begin(); itr != v.end(); ++itr)

int main(void){
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p;vector<int> q; vector<int> r;
    int input;
    rep(i,A){cin >> input;p.emplace_back(input);}
    rep(i,B){cin >> input;q.emplace_back(input);}
    rep(i,C){cin >> input;r.emplace_back(input);}
    ll ans = 0; 
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());
    int p_count = X-1;
    int q_count = Y-1;
    int r_count = 0;
    int same_count = 0;
    while((p_count >= 0 || q_count >= 0)&&r_count < C){
        bool p_to_r = true;
        if(p_count < 0)p_to_r = false;
        else if(q_count < 0)p_to_r = true;
        else if(p[p_count] > q[q_count])p_to_r = false;
        else if(p[p_count] == q[q_count]){
            same_count++;
            p_count--;q_count--;
            if(p_count >=0 ||q_count >=0)continue;
        }
        if(same_count > 0){
            p_count += same_count;q_count+= same_count;
            same_count = 0;
        }
        if(p_to_r){
            if(p[p_count] < r[r_count]){
                ans+=r[r_count];
                p_count--;r_count++;
            }
            else break;
        }
        else{
            if(q[q_count] < r[r_count]){
                ans+=r[r_count];
                q_count--;r_count++;
            }
            else break;
        }
    }
    rep(i,p_count+1)ans+=p[i];
    rep(i,q_count+1)ans+=q[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);

int main(){
    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int p = s - x - y;
            if(p>=0&&p<=k) ans++;
        }
    }
    cout << ans << endl;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n;
    cin >> n;

    printf("%.8f\n", 2.0 * PI * n);

    return 0;
}
/** atcoder **/


Measured memory_bytes: 3748
//=================================
// Created on: 2018/09/22 00:40:43
//=================================
#include <bits/stdc++.h>
using ll = long long;
int main()
{
    int N, K, Q;
    std::cin >> N >> K >> Q;
    std::vector<ll> A(N);
    std::map<ll, std::vector<int>> mp;
    for (int i = 0; i < N; i++) { std::cin >> A[i], mp[A[i]].push_back(i); }
    auto B = A;
    std::sort(B.begin(), B.end());
    std::vector<bool> ok(N, true);
    ll ans = 1LL << 60;
    for (int i = 0; i < N; i++) {
        const ll L = (i == 0 ? -1 : B[i - 1]);
        for (const auto e : mp[L]) { ok[e] = false; }
        std::vector<ll> v;
        std::vector<ll> buf;
        buf.reserve(N);
        for (int pos = 0; pos < N; pos++) {
            if (ok[pos]) {
                buf.push_back(A[pos]);
            } else {
                if (buf.size() > K - 1) {
                    std::sort(buf.begin(), buf.end());
                    for (int i = 0; i < buf.size() - K + 1; i++) { v.push_back(buf[i]); }
                }
                buf.clear();
            }
        }
        if (buf.size() > K - 1) {
            std::sort(buf.begin(), buf.end());
            for (int i = 0; i < buf.size() - K + 1; i++) { v.push_back(buf[i]); }
        }

        if (v.size() < Q) { continue; }
        std::sort(v.begin(), v.end());
        ans = std::min(ans, v[Q - 1] - B[i]);
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {  
    char a;
    cin >> a;
    if (a >= 'A' && a <= 'Z')
        cout << 'A';
    else
        cout << 'a';
}       

Measured memory_bytes: 3624
#pragma warning (disable:4996)
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	float n, k;
	cin >> n>>k;
	int a[100005];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cout << ceil((n - 1) / (k - 1))<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    //    static String INPUT = "5\n3 2 2 4 1\n1 2 2 2 1";
    static String INPUT = "";

    public static void main(String[] args) {
        InputStream is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());

        Scanner scanner = new Scanner(is);

        final int n = scanner.nextInt();
        List<Position> positionList = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            positionList.add(
                    new Position(
                            scanner.nextInt(),
                            scanner.nextInt(),
                            scanner.nextInt()
                    )
            );
        }

        System.out.println(solve(positionList) ? "Yes" : "No");
    }

    static class Position {
        int t;
        int x;
        int y;

        public Position(int t, int x, int y) {
            this.t = t;
            this.x = x;
            this.y = y;
        }
    }

    static boolean solve(List<Position> positionList) {
        Position currentPosition = new Position(0, 0, 0);
        for (int i = 0; i < positionList.size(); i++) {
            Position nextPosition = positionList.get(i);
            if (!possibleMove(currentPosition.t, nextPosition.t, currentPosition.x, nextPosition.x, currentPosition.y, nextPosition.y)) {
                return false;
            }
            currentPosition = nextPosition;
        }
        return true;
    }

    static boolean possibleMove(int t1, int t2, int x1, int x2, int y1, int y2) {
        int tDiff = t2 - t1;
        int absX = Math.abs(x1 - x2);
        int absY = Math.abs(y1 - y2);

        if (absX + absY <= tDiff) {
            if (tDiff % 2 == (absX + absY) % 2) {
                return true;
            }
        }
        return false;
    }

}


Measured memory_bytes: 92368