akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){

	int x;
	cin >> x;

	int maxx = 0;
	for (int i = 1; i< 1000; i++) {
		for (int j = 2; j < 11; j++) {
			if (pow(i, j) <= x) {
				maxx = max(maxx, (int)(pow(i, j)));
			}
			else  { break; }
		}
	}
	cout << maxx << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


ll n = 1e5+10,m = 2e5+10;
ll INF = INT_MAX;
vector<ll> place(n,INF), is_move(n,0);

template<class T>
bool dfs(vector<vector<Pll>> &graph, T now, T mi = 0, T ma = 0){
    bool ok = true;
    is_move[now] = 1;
    for(auto i : graph[now]){
        ll to = i.first, dis = i.second;
        if(!is_move[to]){
            place[to] = place[now] + dis;
            ma = max(ma,place[to]);
            mi = min(mi,place[to]);
            ok &= dfs(graph, to, mi, ma);
        }
        else{
            if(place[to] != place[now] + dis)ok = false;
        }
    }
    return ok & ((ma-mi) < 1e9);
}

int main(){
    cin >> n >> m;
    vector<ll> l(m), r(m), d(m);
    vector<vector<Pll>> graph(n);
    rep(i,m){
        cin >> l[i] >> r[i] >> d[i];
        l[i]--;r[i]--;
        graph[l[i]].emplace_back(Pll(r[i],d[i]));
        graph[r[i]].emplace_back(Pll(l[i],-d[i]));
    }
    bool res = true;
    rep(i,n){
        if(!is_move[i]){
            place[i] = 0;
            res &= dfs(graph,ll(i));
        }
    }
    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 24704
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  using llp = pair<ll, ll>;

  ll N, M;
  cin >> N >> M;
  vector<llp> A;
  for (ll i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    A.emplace_back(x, y);
  }

  sort(begin(A), end(A), greater<>());

  auto compare = [](llp x, llp y) { return x.second < y.second; };

  priority_queue<llp, vector<llp>, decltype(compare)> pq(compare);

  ll ans = 0;
  for (ll i = M - 1; i >= 0; i--) {
    // 候補の追加
    for (auto it = A.rbegin(); it != A.rend(); it++) {
      if (i + it->first > M) {
        break;
      }
      pq.push(*it);
      A.pop_back();
    }

    // 候補から取り出し
    if (pq.empty()) continue;
    auto item = pq.top();
    pq.pop();
    ans += item.second;
  }


  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    bool ans = (a>=1 && a<=9 && b>=1 && b<=9);
    cout << (ans ? a*b : -1) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A1277
Title Minimal Backgammon
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
#define MAXSTEP 100
#define MAXTURN 100
double Prob[MAXSTEP+1][MAXTURN+1];
int Lose[MAXSTEP+1];
int Back[MAXSTEP+1];
int N,T,L,B;
//
void print_all()
{
        int i,j;
        for(i=0;i<=N;i++)
        {
                for(j=0;j<=T;j++)
                        printf("%lf ",Prob[i][j]);
                printf("\n");
        }
}
main()
{
        int i,j,k,x,step;
        double prob_sum;

        while(EOF!=scanf("%d %d %d %d",&N,&T,&L,&B) && (N||T||L||B))
        {
                for(i=0;i<MAXSTEP+1;i++)
                {
                        for(j=0;j<MAXTURN+1;j++)
                                Prob[i][j]=0.0;
                        Lose[i]=0;
                        Back[i]=0;
                }
                for(i=0;i<L;i++)
                {
                        scanf("%d",&x);
                        Lose[x]=-1;
                }
                for(i=0;i<B;i++)
                {
                        scanf("%d",&x);
                        Back[x]=-1;
                }
                Prob[0][0]=1.0;
                for(i=0;i<T;i++)
                {
                        for(j=0;j<=N-1;j++)
                                for(k=1;k<=6;k++)
                                {
                                        if(j+k>N)
                                                step=N-(j+k-N);
                                        else
                                                step=j+k;
                                                         
                                        if(Lose[step])
                                        {
                                                ;
                                                Prob[step][i+2]+= (1.0/6.0*Prob[j][i]);
                                                //printf("L=%d %d %lf\n",step,i+2,1.0/6.0*Prob[j][i]);
                                        }

                                        else if(Back[step])
                                        {
                                                Prob[0][i+1]+= (1.0/6.0*Prob[j][i]);
                                                ;
                                        }
                                        else
                                        {
                                                Prob[step][i+1] += (1.0/6.0*Prob[j][i]);
                                                //printf("sip=%d %d %lf\n",step,i+1,1.0/6.0*Prob[j][i]);
                                        }
                                }
                }
                prob_sum=0.0;
                //print_all();
                for(i=0;i<=T;i++)
                        prob_sum+=Prob[N][i];
                printf("%lf\n",prob_sum);

                }
return(0);
}

Measured memory_bytes: 716
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1e9+7

int main(){
	int N;
	int sum = 0;
	int M = -1;
	cin >> N;
	int i = 0;
	while(i < N){
		int tmp;
		cin >> tmp;
		sum = sum + tmp;
		if(M < tmp){
			M = tmp;
		}
		i++;
	}
	if(sum-M <= M){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,k;cin >>n>>k;
    vector<int>a(n);
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        sum+=a[i];
    }
    unordered_map<ll,int>mp;
    for (ll i = 1; i*i<=sum; ++i) {
        if(sum%i==0){
            mp[i]++;
            mp[sum/i]++;
        }
    }
    auto add=[&](ll x){
        vector<int>r;
        for (int i = 0; i < n; ++i) {
            if(a[i]%x){
                r.push_back(a[i]%x);
            }
        }
        if(r.empty())return true;
//        if(r.size()%2==1)return false;
        sort(all(r));
        sum=0;
        int cnt=0;
        for (int i = 0; i < r.size(); ++i) {
            sum+=r[i];
        }
        if(sum%x!=0){
            return false;
        }
        reverse(all(r));
        int w=0;
        for (int i = 0; i < r.size(); ++i) {
            w += r[i];
            w += (x - r[i]);
            cnt+= (x - r[i]);
            if (w ==sum)break;
        }
        if(cnt>k)return false;
        return true;
    };
    ll ans=0;
    for(auto p:mp){
        if(add(p.first))ans=max(ans,p.first);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3580
a, b, m = gets.split.map &:to_i
as = gets.split.map &:to_i
bs = gets.split.map &:to_i
mins = [as.min + bs.min]
m.times do
  x, y, c = gets.split.map &:to_i
  mins << as[x-1] + bs[y-1] - c
end
puts mins.min

Measured memory_bytes: 18844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const int MAX_X=50, 
          MAX_Y=50;
const ll INF = 10e9;

int N;
int a[200010];
int target;

void rep(int n) {
    for(int i=n; i<=N; i++){
        if(a[i] == target){
            target++;
            rep(i+1);
            break;
        }
    }
}

int main() {
    cin >> N;
    REP(i, N) cin >> a[i+1];
    target = 1;
    rep(1);
    if(target == 1) {
        cout << -1 << endl;
    } else {
        int ans = N-target+1;
        cout << ans << endl;
    } 
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		int[] data = new int[n];
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}

    	int count = 0;
    	for (int i = 0; i < n; i++) {
    		int mini = i;
    		for (int j = i; j < n; j++) {
    			if (data[j] < data[mini]) {
    				mini = j;
    			}
    		}
    		if (mini != i) {
    			int temp = data[i];
    			data[i] = data[mini];
    			data[mini] = temp;
    			count++;
    		}
    	}

    	printData(data);
    	System.out.println(count);

        sc.close();
	}

	private static void printData(int[] data) {
		StringBuffer printData = new StringBuffer();
		for (int i = 0; i < data.length; i++) {
			printData.append(data[i]);
			printData.append(" ");
		}
		printData.delete(printData.length() - 1, printData.length());
		System.out.println(printData);
	}
}

Measured memory_bytes: 18124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

string s;
string c="CODEFESTIVAL2016";

string a;
string b;

int res;

int main()
{
	cin >> s;
	res = 0;
	for (int i=0; i<s.size(); i++){
		a = s[i];
		b = c[i];
		if (a!=b){
			res++;
		}

	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  int count = 0, max_count = 0;

  int h_prev;
  cin >> h_prev;
  for (int n=1; n<N; ++n) {
    int h;
    cin >> h;
    if (h <= h_prev) {
      ++count;
      max_count = max(count, max_count);
    } else {
      count = 0;
    }
    h_prev = h;
  }

  cout << max_count << endl;

  return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n,k = MI()
li = sorted(LI())
print(sum(li[:k]))

Measured memory_bytes: 9192
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255

using namespace std;


int main()
{
	string s;
	cin >> s;
	string output;
	for (int i = 0; i < s.size(); i++)
	{
		output += 'x';
	}
	cout << output << endl;
	return 0;
}

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

int main()
{
    int n;
    double x[1000] = {}, y[1000] = {}, a = 0, b = 0, c = 0, d = 0;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> y[i];
    }
    for (int i = 0; i < n; i++)
    {
        a += abs(x[i] - y[i]);
        b += (abs(x[i] - y[i])) * (abs(x[i] - y[i]));
        c += (abs(x[i] - y[i])) * (abs(x[i] - y[i])) * (abs(x[i] - y[i]));
        if (d < abs(x[i] - y[i]))
        {
            d = abs(x[i] - y[i]);
        }
    }
    cout << setprecision(10)
         << a << endl
         << sqrt(b) << endl
         << cbrt(c) << endl
         << d;
}



Measured memory_bytes: 3420
def edmonds_karp(s, t, C):
    import copy
    import collections

    r = copy.deepcopy(c)
    maxf = 0

    while True:
        q, found = collections.deque(), False
        q.append(([S], 10 ** 15))
        while len(q) > 0 and not found:
            p, minf = q.popleft()
            for to, flow in r[p[-1]].items():
                if flow == 0:
                    continue
                elif to == T:
                    p, minf = p + [to], min(flow, minf)
                    found = True
                    break
                elif not to in p:
                    q.append((p + [to], min(flow, minf)))

        if not found:
            break

        for i in range(len(p) - 1):
            r[p[i]][p[i + 1]] -= minf
            if p[i] in r[p[i + 1]]:
                r[p[i + 1]][p[i]] += minf
            else:
                r[p[i + 1]][p[i]] = minf
        maxf += minf

    return maxf


N = int(input())
A = list(map(int, input().split()))

gain = sum([max(a, 0) for a in A])

S, T = 0, N + 1
c = [{} for i in range(N + 2)]
for i in range(N):
    ix = i + 1
    if A[i] <= 0:
        c[S][ix] = -A[i]
    else:
        c[ix][T] = A[i]

    for j in range(2 * ix, N + 1, ix):
        c[ix][j] = 10 ** 15

print(gain - edmonds_karp(S, T, c))


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,0,h-1)cin >> s[i];
    int dp[h][w] = {INF};
    rep(i,0,h-1)rep(j,0,w-1){
        if(i == 0 && j == 0){dp[i][j] = 0;continue;}
        if(i == 0){dp[i][j] = s[i][j] == s[i][j-1] ? dp[i][j-1] : dp[i][j-1] + 1;continue;}
        if(j == 0){dp[i][j] = s[i][j] == s[i-1][j] ? dp[i-1][j] : dp[i-1][j] + 1;continue;}
        dp[i][j] = min(s[i][j] == s[i-1][j] ? dp[i-1][j] : dp[i-1][j] + 1,dp[i][j] = s[i][j] == s[i][j-1] ? dp[i][j-1] : dp[i][j-1] + 1);
    }
    int ans = (dp[h-1][w-1]+1)/2;//max(dp[h-1][w-1]-1,0);
    // rep(i,0,h-1){
    //     rep(j,0,w-1)cout << dp[i][j];
    //     cout << endl;
    // }
    if(s[0][0] == '#' && s[h-1][w-1] == '#')ans++;
    // if(s[0][0] == '.' && s[h-1][w-1] == '#')ans++;
    // if(s[0][0] == '.' && s[h-1][w-1] == '#')ans+=2;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007

using namespace std;

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

    // code comes here
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    
    ll p[a],q[b],r[c];
    for(ll i=0;i<a;i++)
    {
        cin>>p[i];
    }
    for(ll i=0;i<b;i++)
    {
        cin>>q[i];
    }
    for(ll i=0;i<c;i++)
    {
        cin>>r[i];
    }

    sort(p,p+a,greater<ll>());
    sort(q,q+b,greater<ll>());
    
    vector<ll> res;
    for(ll i=0;i<x;i++)
    {
        res.push_back(p[i]);
    }
    for(ll i=0;i<y;i++)
    {
        res.push_back(q[i]);
    }
    
    for(ll i=0;i<c;i++)
    {
        res.push_back(r[i]);
    }
    
    sort(res.begin(),res.end(),greater<ll>());
    
    ll sum=0;
    for(ll i=0;i<x+y;i++)
    {
        sum+=res[i];
    }

    cout<<sum<<endl;
    return 0;
}





Measured memory_bytes: 8560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;cin >> N >> K;
    if (K == 1) cout << 0 << endl;
    else cout << abs(N - (K - 1) - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef tuple<double, int, int, int> T2;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

double dijkstra(int s, int g, vector<vector<T>> &G){
    vector<vector<vector<double>>> dist(40, vector<vector<double>>(40, vector<double>(40, INF)));
    priority_queue<T2, vector<T2>, greater<T2>> que;
    dist[s][35][0] = 0;
    que.push(T2(0, s, 35, 0));

    while(!que.empty()){
        double cdist;
        int cv, pv, pvel;
        tie(cdist, cv, pv, pvel) = que.top();
        que.pop();
        
        for(auto x : G[cv]){
            int nv, ndist, nlim;
            tie(nv, ndist, nlim) = x;

            if(nv == pv) continue;

            for(int i=-1; i<=1; i++){
                int nvel = pvel + i;
                if(nvel <= 0) continue;
                if(nlim < nvel) continue;
                
                if(dist[cv][pv][pvel] + 1. * ndist / nvel < dist[nv][cv][nvel]){
                    dist[nv][cv][nvel] = dist[cv][pv][pvel] + 1. * ndist / nvel;
                    que.push(T2(dist[nv][cv][nvel], nv, cv, nvel));
                }
            }
        }
    }

    double ans = INF;
    for(int i=0; i<=30; i++){
        ans = min(ans, dist[g][i][1]);
    }

    return ans;
}

int main(){
    while(1){
        int n, m; cin>>n>>m;
        if(n == 0) return 0;
        int s, g; cin>>s>>g;
        s--, g--;
        vector<vector<T>> G(n);
        for(int i=0; i<m; i++){
            int x, y, d, c; cin>>x>>y>>d>>c;
            x--, y--;
            G[x].push_back(T(y, d, c));
            G[y].push_back(T(x, d, c));
        }

        double ans = dijkstra(s, g, G);
        if(ans == INF){
            cout << "unreachable" << endl;
        }
        else{
            cout << fixed << setprecision(8) << ans << endl;
        }
    }
}


Measured memory_bytes: 4152
#include <stdio.h>

int main() {
  char str[31], ctr = 0;
  scanf("%[^\n]", str);

  for(int i = 0; str[i] != '\0'; i++) {
    if(str[i] == ' ' && str[i-1] == str[i+1]) {
      ctr++;
    }
  }
  if(ctr == 2) {
    puts("YES");
  }
  else {
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 1568
#include <stdio.h>
#include <string.h>

int main(void){
    char s[10],t[10],u[10];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);

    if(strcmp(s,u)==0)
        printf("%d %d\n",a-1,b);
    else
        printf("%d %d\n",a,b-1);
    return 0;
}

Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: i64 = input();
    let a: i64 = input();
    let b: i64 = input();
    println!(
        "{}",
        if a >= b {
            "delicious"
        } else if a + x >= b {
            "safe"
        } else {
            "dangerous"
        }
    );
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
int main(){
    char a[20], b[20];
    cin>>a>>b;
    int len = strlen(b);
    len -= 1;
    b[len] = '\0';
    if(strcmp(a, b)==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
int cnt = 0;
vector<int> G;
void insertion_sort(int A[], int n, int g) {
    int v;
    for (int i = 1; i < n; i++) {
        v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int A[], int n) {
    for (int h = 1;;) {
        if (h > n) {
            break;
        }
        G.push_back(h);
        h = 3 * h + 1;
    }
    int m = G.size();
    rep(i, m) { insertion_sort(A, n, G[m - i - 1]); }
    cout << m << "\n";
    rep(i, m) { cout << G[m - i - 1] << (i < m - 1 ? " " : "\n"); }
}

void Main() {
    int n;
    cin >> n;
    int A[1000000];
    rep(i, n) cin >> A[i];
    shell_sort(A, n);
    cout << cnt << "\n";
    rep(i, n) cout << A[i] << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 7052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int main() {
    int n;
    cin >> n;
    set<string> st;
    REP(i,n){
        string s;
        cin >> s;
        st.insert(s);
    }
    if (st.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;


    return 0;
}

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

int main(){
  vector<ll> L(87);
  int n;
  cin >> n;
  L[0]=2;
  L[1]=1;
  for(int i=0;i<n-1;i++){
    L[i+2]=L[i+1]+L[i];
  }
  cout << L[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int count = 0;
  int g_flg = 0;
  int w_flg = 0;
  int y_flg = 0;
  int p_flg = 0;
  for (int i = 0; i < N; i++){
    string tmp1;
    cin >> tmp1;    
    if (tmp1 == "G" and g_flg == 0){
      count += 1;
      g_flg = 1;
    }
    else if (tmp1 == "W" and w_flg == 0){
      count += 1;
      w_flg = 1;
    }
    else if (tmp1 == "Y" and y_flg == 0){
      count += 1;
      y_flg = 1;
    }
    else if (tmp1 == "P" and p_flg == 0){
      count += 1;
      p_flg = 1;
    }
    else{
      continue;
    }
  }
  if (count == 3){
    cout << "Three" << endl;
  }
  else if (count == 4){
    cout << "Four" << endl;
  }
  else{
    cout << "error!" << endl;
  }
}

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

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

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

using namespace std;

typedef long long ll;

const int MAXN = 51;

int n, a;
ll x[MAXN];

// na i-toj poz, uzeo sam ih j, suma mi je k
ll dp[MAXN][MAXN][MAXN*MAXN];

int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n >> a;
  REP(i, n) cin >> x[i];

  dp[0][0][0] = 1;
  dp[0][1][x[0]] = 1;
  FOR(i, 1, n) {
    REP(j, n) {
      REP(k, 2500) {
        dp[i][j][k] += dp[i-1][j][k];
        dp[i][j+1][k+x[i]] += dp[i-1][j][k];
      }
    }
  }

  ll ans = 0;
  FOR(i, 1, n + 1) {
    ans += dp[n-1][i][i*a];
  }

  cout << ans << endl;

  return 0;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  char A[3][3];
  rep(i, 0, 3){
    rep(j, 0, 3){
      cin >> A[i, j];
    }
  }

  cout << A[0][0] << A[1][1] << A[2][2] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
int dp[1000];

int main(){
  int n;
  string s;
  int ans=0;
  cin >> n >> s;
  int tmp, n100, n10, n1;
  int j, k, l;
  char x;
  
  for(int i=0;i<1000;i++){
    tmp=i;
    n1=tmp%10;
    tmp=tmp/10;
    n10=tmp%10;
    tmp=tmp/10;
    n100=tmp;
    //cout << n100 << n10 << n1;
    //x = s[2];
    //cout << atoi(&x) << endl;
    for(j=0;j<n;j++){
      x=s[j];
      if(n100==atoi(&x))break;
    }
    for(k=j+1;k<n;k++){
      x=s[k];
      if(n10==atoi(&x))break;
    }
    for(l=k+1;l<n;l++){
      x=s[l];
      if(n1==atoi(&x)){
        dp[i]=1;
      }
    }
  }
 
  for(int i=0;i<1000;i++){
    if(dp[i]==1){
      //cout << i << endl;
      ans++;
    }
  }
  cout << ans;
  return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int n;
int m;
uint x;
vector<int> c;
bool bef = 0;
bool aft = 1;
const int size = 255 + 1;
vector<vector<uint>> vec(2, vector<uint>(size, -1));

inline uint mse(uint a, uint b) {
	uint diff = (a > b) ? (a - b) : (b - a);
	return diff * diff;
}

uint calcBefMin(int i) {
	uint min_val = -1;
	for (auto v : c) {
		int key = i - v;
		if (key < 0 or key > 255) {
			continue;
		}
		min_val = min(min_val, vec[bef][key]);
	}
	return min_val;
}

inline uint myplus(uint a, uint b) {
	uint m = -1;
	if (b <= m - a) { // check overflow
		return a + b;
	}
	return -1;

}

void solve() {
	c.resize(m);
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	int c_max = *std::max_element(begin(c), end(c));
	int c_min = *std::min_element(begin(c), end(c));
	for (int i = 0; i <= 255; i++) {
		vec[bef][i] = -1;
	}
	vec[bef][128] = 0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		int bef_key;
		// do
		for (bef_key = 1; bef_key <= 254; bef_key++) {
			vec[aft][bef_key] = myplus(calcBefMin(bef_key), mse(bef_key, x));
		}
		// do for 255
		bef_key = 255;
		uint min_val = -1;
		for (int key = bef_key - c_max; key <= 255; key++) {
			min_val = min(min_val, vec[bef][key]);
		}
		vec[aft][bef_key] = myplus(min_val, mse(bef_key, x));
		// do for 0
		bef_key = 0;
		min_val = -1;
		for (int key = bef_key - c_min; key >= 0; key--) {
			min_val = min(min_val, vec[bef][key]);
		}
		vec[aft][bef_key] = myplus(min_val, mse(bef_key, x));
		// for next
		bef = !bef;
		aft = !aft;
	}
	cout << *std::min_element(begin(vec[bef]), end(vec[bef])) << endl; // bef is correct, because swaped
}

int main() {


	while (true) {
		cin >> n >> m;
		if (n == 0 and m == 0) {
			break;
		}
		solve();
	}

	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
struct edge{int from,to,cost;};
int n,m;
vector<edge> vec;
int d[1010];
bool used[1010];
void bf(int s){
	fill(d+1,d+n+1,INF);
	d[s]=0;
	rep(i,n){
		bool update=false;
		for(edge e:vec){
			if(d[e.from]==INF)continue;
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update)break;
	}
}
void check(){
	rep(i,n+1){
		for(edge e:vec){
			if(d[e.from]==INF)continue;
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				used[e.to]=true;
			}
			if(used[e.from])used[e.to]=true;
		}
	}
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		vec.push_back({a,b,-c});
	}
	bf(1);
	int ans=-d[n];
	check();
	if(!used[n])cout<<ans<<endl;
	else puts("inf");
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	long long N, X, D = 1;

	vector<long long> x, v, d;
	cin >> N >> X;
	x.resize(N);
	v.resize(N);

	for (int i = 0; i < N; ++i){
		cin >> x[i];
	}
	sort(x.begin(), x.end(), less<int>());

	for (int i = 0; i < N; ++i){
		v[i] = abs(X - x[i]);
	}

	long long min = 1e10;

	for (int i = 0; i < N; ++i){
		if (min > v[i])
			min = v[i];
	}
	
	for (D = min; D != 1; --D){
		if (min % D != 0)
			continue;
		int j;
		for (j = 0; j < N - 1; ++j){
			if (v[j] % D != 0)
				break;
		}
		if (j == N - 1)
			break;
	}
	cout << D << endl;

	return 0;
}

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

int dp[8][8][64];
char grid[8][8];
int H, W;
int cnt = 0;

int dfs(int x, int y, int c) {
  // cout << x << " " << y << " " << c << endl;
  if ( dp[x][y][c] >= 0 ) return dp[x][y][c];
  if ( x == W-1 && y == H-1 ) {
    
    if ( c == cnt-1 ) return 1;
    else return 0;
  }

  int ret = 0;
  if ( x < W-1 ) ret |= dfs(x+1, y, c+(grid[y][x+1] == '#'));
  if ( y < H-1 ) ret |= dfs(x, y+1, c+(grid[y+1][x] == '#'));

  return dp[x][y][c] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  cin >> H >> W;
  REP(i, H) REP(j, W) {
    cin >> grid[i][j];
    if ( grid[i][j] == '#' ) cnt++;
  }

  fill_n(**dp, 8*8*64, -1);

  int ans = dfs(0, 0, 0);
  if ( ans > 0 ) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  return 0;
}


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

const int N = 1e5 + 2;

int L[N], R[N], ans = 1;
int a[N], n;

int main()
{
	cin >> n;
	for(int i =1; i<=n; i++)
	{
		cin >> a[i];
		L[i] = __gcd(L[i-1], a[i]);
	}
	for(int i = n; i>=1;i--)
	{
		R[i] = __gcd(R[i+1], a[i]);
	}
	for(int i = 1; i<=n; i++)
	{
		ans = max(ans, __gcd(L[i-1], R[i+1]));
	}
	cout<<ans;
}




Measured memory_bytes: 1408
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int N, K, count = 0, x = 0, y = 0;
	cin >> N >> K;
	int *a = (int*)malloc(sizeof(int)*N);
	int *num = (int*)malloc(sizeof(int)*(N+1));
	for (int i = 0;i < N + 1;i++)num[i] = 0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		num[a[i]]++;
	}
	sort(num, num + N + 1);
	for (int i = 0;i <= N;i++) {
		if (num[i] > 0 ){
			count++;
		}

	}
	
	if (count <= K) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (int i = 0;i < N + 1;i++) {
			if (num[i] > 0) {
				x += num[i];
				y++;
				if (y == count - K)break;
			}
		}
	}
	cout << x << endl;
	return 0;

}

Measured memory_bytes: 1792
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    println!(
        "{}",
        *[a*c, a*d, b*c, b*d].iter().max().unwrap()
    );
}


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

using namespace std;

int main (){
        long long n, m, k, x, N, ans=0;
        map <long long, long long> his;

        cin >> n >> m;
        N=n;
        while (n--){
                cin >> k;
                while (k--){
                        cin >> x;
                        his[x]++;
                }
        }

        for (long long j = 1; j<=m; j++){
                (his[j]==N) ? ans++ : ans=ans;
        }

        cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	string S;
	cin>>S;
	int ssize=S.size();
	int zeroone=0;
	for(int i=0; i<ssize; i++)
	{
		if(i%2==0)
		{
			if(S[i]!= '0')
			{
				zeroone++;
			}
		}
		else
		{
			if(S[i]!= '1')
			{
				zeroone++;
			}
		}
	}
	int onezero=0;
	for(int i=0; i<ssize; i++)
	{
		if(i%2==0)
		{
			if(S[i]!='1')
			{
				onezero++;
			}
		}
		else
		{
			if(S[i]!='0')
			{
				onezero++;
			}
		}
	}
	int ans=min(zeroone,onezero);
	cout<<ans<<endl;
}

Measured memory_bytes: 512
s = input()
if s[0] != 'A':
  print("WA")
elif s[2:-1].count("C") != 1:
  print("WA")
else:
  a = s[2:-1].find("C")+2
  if (s[1:a]+s[a+1:]).islower():
    print("AC")
  else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>

//4b?£?*3f???*10r??¨?±?*v???
int main(int argc, char const* argv[])
{
	int n;
	int b, f, r, v;
	int d[4][3][10] = {0};
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> b>> f>> r>> v ;
		d[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				std::cout <<' '<< d[i][j][k];
			}
			std::cout << std::endl;
		}
		if (i<3) std::cout << "####################" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int calc(const vector<int> &a, int k){
  const int n = a.size();
  int c = 0;
  REP(i,n - k + 1){
    int s = 1;
    REP(j,k) s *= a[i + j];
    c = max(c, s);
  }
  return c;
}

int main(){
  while(true){
    const int n = getInt();
    const int k = getInt();

    if(n + k == 0) break;

    vector<int> a(n);
    REP(i,n) a[i] = getInt();
    const int c = calc(a, k);

    int cc = 0;
    REP(i,n) for(int j = i + 1; j < n; j++){
      swap(a[i], a[j]);
      cc = max(cc, calc(a, k));
      swap(a[i], a[j]);
    }

    if(cc >= c) printf("%d\n", cc - c);
    else puts("NO GAME");
  }

  return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++)
    {
        if(i%d==0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  if (s.substr(2, 1) == s.substr(3, 1) && s.substr(4, 1) == s.substr(5, 1))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 

ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);

int main()
{
	ll m,n;
	cin>>m>>n;
	cout<<m*n/__gcd(m,n)<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string A;
ll nxt[200010][30];
std::map<ll, ll> mp;
ll dp[200010];

int main() {
  std::cin >> A;

  ll N = A.size();

  repd( i, N ) {
    mp[A[i]-'a'] = i;

    rep( c, 26 ) {
      if( mp.count(c) )
        nxt[i][c] = mp[c];
      else
        nxt[i][c] = N;
    }
  }

  rep( i, N+1 )
    dp[i] = INF;

  dp[N] = 1;
  dp[N+1] = 0;

  repd( i, N ) rep( c, 26 ) {
    chmin( dp[i], dp[nxt[i][c]+1]+1 );
  }

  std::string ans;

  for( ll i = 0; i < N; ++i ) {
    rep( c, 26 ) if( dp[i] == dp[nxt[i][c]+1]+1 ) {
      ans += c+'a';
      i = nxt[i][c];
      break;
    }
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 52188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int sum = a+b;

		    if(sum%2==0){
		    	System.out.println(sum/2);
		    }else{
		    	System.out.println("IMPOSSIBLE");
		    }
		  }
		}


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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2));

    //fill(s.begin(),s.end(),'x');

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> s.at(i).at(j);
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int cnt = 0;
            if(s.at(i).at(j) == '.'){
                for(int y = -1; y <= 1; y++){
                    for(int x = -1; x <= 1; x++){
                        if(s.at(i+y).at(j+x) == '#'){
                            cnt++;
                        }
                    }
                }
                s.at(i).at(j) = cnt + '0';
            }
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cout << s.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
int i[11111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  string s;
  cin >>a>>b>>c;
  if(b>c) swap(b,c);
  if(b+a>=c) cout <<0<<'\n';
  else{
    cout <<c-a-b<<'\n';
  }
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2040;
long long a[maxn], b[maxn], x;
int main(){
	int n; cin >> n >> x;
	for(int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	for(int i = 0; i < n; i++) ans += a[i];
	for(int i = 0; i < n; i++) b[i] = a[i];
	for(int i = 1; i < n; i++){
		for(int j = 0; j < n; j++) b[j] = min(b[j], a[(j - i + n) % n]);
		long long sum = 0;
		for(int j = 0; j < n; j++) sum += b[j];
		ans = min(ans, sum + i * x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	int n;
	cin>>n;
	double result=0;
	for(int i=0;i<n;i++){
		double x;
		cin>>x;
		result+=1.0/x;
	}
	result=1.0/result;
	cout<<fixed<<setprecision(5)<<result;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] N_K = Console.ReadLine().Split(' ');
        int K = Convert.ToInt32(N_K[1]);

        var list2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Array.Sort(list2);

        int sum = 0;
        for (int i = 0; i < K; i++)
        {
            sum += list2[i];
        }
        Console.WriteLine(sum);
    }
}

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int hoge = -1, idx = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (hoge < abs(a[i])) {
            hoge = abs(a[i]);
            idx = i;
        }
    }
    vector<P> ans;
    for (int i = 0; i < n; i++) {
        if (i == idx) continue;
        a[i] += a[idx];
        ans.emplace_back(idx + 1, i + 1);
    }

    if (a[idx] >= 0) {
        for (int i = 1; i < n; i++) {
            a[i] += a[i - 1];
            ans.emplace_back(i, i + 1);
        }
    } else {
        for (int i = n - 1; i > 0; i--) {
            a[i - 1] += a[i];
            ans.emplace_back(i + 1, i);
        }        
    }

    cout << ans.size() << endl;
    for (P& p : ans) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 100005
#define MAXM 100005
#define MAXV 1000000009

ll n, A[MAXN], a, b, c;

int main()
{
    cin >> n;
    REP(i, 0, n){
        cin >> A[i];
        if(A[i] % 4 == 0){
            a++;
        }
        else if(A[i] % 2 == 0){
            b++;
        }
        else{
            c++;
        }
    }
    if(n % 2 == 0){
        if(a >= c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else {
        if(a + 1 >= c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }



    return 0;
}
/*
*/





Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n];
  for(int i=0;i<n;i++)
  {
    dp[i]=INT_MAX;
    if(i==0) dp[i]=0;
    else if(k>i){
      for(int j=1;j<=i;j++){
      	int a= arr[i]>arr[i-j]?arr[i]-arr[i-j]:arr[i-j]-arr[i];
    	a+=dp[i-j];
    	dp[i]=min(a,dp[i]);
    	}
    }
    else{
      for(int j=1;j<=k;j++){
        int a= arr[i]>arr[i-j]?arr[i]-arr[i-j]:arr[i-j]-arr[i];
          a+=dp[i-j];
          dp[i]=min(a,dp[i]);
      }
    }
  }
  cout<<dp[n-1];
  return 0;
}

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

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	BigInteger bi;

	while(sc.hasNext()){
	    int cnt = 0;
	    for(int i = sc.nextInt(); i >= 1; --i){
		bi = new BigInteger(sc.next());
		if(bi.isProbablePrime(100)) ++cnt;
	    }
	    System.out.printf("%d\n", cnt);
	}
    }

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

Measured memory_bytes: 13000
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

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

    a_sum = sum(a)
    b_sum = sum(b)

    if a_sum < b_sum:
        print(-1)
        sys.exit()

    a_minus_b = [a[i] - b[i] for i in range(n)]

    a_minus_b.sort()
    minus_count = 0
    minus_sum = 0

    for i in range(n):
        if a_minus_b[i] < 0:
            minus_count += 1
            minus_sum += -(a_minus_b[i])
        else:
            break

    plus_count = 0
    plus_sum = 0

    for i in range(n-1, -1, -1):
        plus_sum += a_minus_b[i]
        plus_count += 1
        if plus_sum >= minus_sum:
            break

    if minus_count == 0:
        print(0)
    else:
        print(plus_count+minus_count)



if __name__ == '__main__':
    main()

Measured memory_bytes: 77104