akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A, B, C, D;
#define op(a) (a == 1 ? '+' : '-')

bool calc(int op1, int op2, int op3)
{
	bool ret;
	int ans;

	if (op1 == 1) ans = A + B;
	else ans = A - B;

	if (op2 == 1) ans = ans + C;
	else ans = ans - C;

	if (op3 == 1) ans = ans + D;
	else ans = ans - D;

	if (ans == 7) {
		ret = true;
		cout << A << op(op1) << B << op(op2) << C << op(op3) << D << "=7\n";
	}
	else {
		ret = false;
	}

	return ret;
}

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

	A = S[0] - '0';
	B = S[1] - '0';
	C = S[2] - '0';
	D = S[3] - '0';

	rep(i, 2) rep(j, 2) rep(k, 2) if (calc(i, j, k)) return 0;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


typedef pair<ll, ll> P;

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

    vector<P> balls(N);

    rep(i, N)
    {
        cin >> balls[i].first >> balls[i].second;
    }

    sort(all(balls));

    map<P, int> diffs;

    rep(i, N)
    {
        repl(j, i + 1, N)
        {
            ll x = balls[i].first - balls[j].first;
            ll y = balls[i].second - balls[j].second;
            diffs[make_pair(x, y)]++;
        }
    }

    int maxCount = 0;

    for (auto p : diffs)
    {
        if (p.second > maxCount)
        {
            maxCount = p.second;
        }
    }

    cout << N - maxCount << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=1; i<N+1; i++){
    cin >> a.at(i);
  }
  vector<int> boxes(N+1);
  for(int i=N; i>0; i--){
    int check=0;
    for(int j=2; j<=N/i; j++){
      check+=boxes.at(i*j);
    }
    boxes.at(i)=(check%2^a.at(i));
  }
  int sum=0,no;
  for(int i=1; i<=N; i++){
    if(boxes.at(i)==1){
      sum++;
      no=i;
    }
  }
  cout << sum << endl;
  for(int i=1; i<=N; i++){
    if(boxes.at(i)==1&&i!=no){
      cout << i << ' ';
    }
    else if(boxes.at(i)==1){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 2432
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
int N,M;
char A[55][55];

int main()
{
	scanf("%d%d",&N,&M);
		for(int i=1;i<=N;i++)scanf("%s",A[i]+1);
		for(int i=1;i<=N;i++){
			for(int j=1;j<=M;j++){
				if(A[i][j]=='#'&&(A[i-1][j]=='.'||!(i-1))&&(A[i][j-1]=='.'||!(j-1))&&(A[i+1][j]=='.'||i+1>N)&&(A[i][j+1]=='.'||j+1>M))
					return puts("No"),0;
			}
		}
	puts("Yes");
	return 0;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int bf(int n,int m,vi &a){
    int ret=0;
    for(int x=1;x<=m;++x){
        bool doit=true;
        for(int j=0;j<n;++j){
            if (x < a[j]/2) {doit=false;break;}
            if ((x-a[j]/2)%a[j]!=0) {doit=false;break;}
        }
        if (doit) ++ret;
    }
    return ret;
}
int main() {
    READ(1);
    int n,m;cin>>n>>m;
    vi a(n);
    FOR(i,n) {cin>>a[i];}
 //   dbg(bf(n,m,a));
    FOR(i,n) a[i] /= 2;
    ll r=a[0];
    for(int i=1;i<n;++i){
        if (r>m) break;
        r=lcm(r,a[i]);
    }
    if (r>m){cout << 0;return 0;}
    for(int i=0;i<n;++i){
        int y=r/a[i];
        if (y%2==0){cout << 0 ; return 0;}
    }
    ll ret=m/r;
    if (ret%2==0) ret/=2;
    else ret = ret/2+1;
    cout << ret << endl;

    return 0;
}



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

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

  int X = 753;
  int len = S.length();
  int ans = 999;
  for (int i = 0; i < len - 2; i ++) {
    int num = 100 * (S[i] - '0') + 10 * (S[i+1] - '0') + 1 * (S[i+2] - '0');
    int diff = abs(X - num);
    ans = min(ans, diff);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
char ax[105];
int bx[27];

int main()
{
    int n=0,i=0,ma=100,j,mid,mid2;
    scanf("%s",ax);
    while(ax[i]!='\0'){
        i++;
    }
    n = i;
    for(i=0;i<26;i++){
        mid = 0;
        mid2 = 0;
        for(j=0;j<n;j++){
            if(ax[j]-'a'==i){
              mid = max(mid,mid2);
              mid2 = 0;
            }
            else mid2++;
        }
        mid = max(mid,mid2);
        ma = min(ma,mid);
    }
    printf("%d",ma);
    return 0;
}


Measured memory_bytes: 256
m, *S = open(0).read().split()
ans = []
for s in S:
    e = {s, s[::-1]}
    for x in range(1, len(s)):
        X = s[:x]; Y = s[x:]
        e.add(X[::-1]+Y)
        e.add(X+Y[::-1])
        e.add(X[::-1]+Y[::-1])
        e.add(Y+X)
        e.add(Y[::-1]+X)
        e.add(Y+X[::-1])
    ans.append("%d\n" % len(e))
open(1, 'w').writelines(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#define N 201000
#define int long long
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
}
using namespace std;
const int inf = 1e18;
inline void MAX(ll &a, ll b) {
  if (b > a)  a = b;
}
int A, B, C, n;
ll ans = -inf, tmp;
struct node {
  int a, b;
}nd[N];
bool cmp(const node &a, const node &b) {
  return a.a - a.b > b.a - b.b;
}
ll f[N];
priority_queue<int, vector<int>, greater<int> > q;
inline void work() {
  ll res = 0;
  for (int i = 1; i <= A; ++i) {
    q.push(nd[i].a); res += nd[i].a;
  }
  f[A] = res;
  for (int i = A + 1; i <= n; ++i) {
    int a = nd[i].a;
    if (q.top() < a)  res -= q.top(), q.pop(), q.push(a), res += a;
    f[i] = res;
  }
  while (!q.empty())  q.pop();
  res = 0;
  for (int i = n; i > n - B; --i) q.push(nd[i].b), res += nd[i].b;
  MAX(ans, res + f[n - B]);
  for (int i = n - B; i > A; --i) {
    int b = nd[i].b;
    if (q.top() < b)  res -= q.top(), q.pop(), q.push(b), res += b;
    MAX(ans, res + f[i - 1]);
  }
  printf("%lld\n", ans + tmp);
}
signed main() {
  read(A), read(B), read(C);
  n = A + B + C;
  for (int i = 1; i <= n; ++i) {
    int a, b, c; read(a), read(b), read(c);
    tmp += c;
    nd[i] = (node){a - c, b - c};
  }
  sort(nd + 1, nd + 1 + n, cmp);
  work();
  return 0;
}


Measured memory_bytes: 6172
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val counts = Array.fill(n){0}
  for (_ ← 0 until m) {
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
    counts(a - 1) += 1
    counts(b - 1) += 1
  }
  counts.foreach(println)
}


Measured memory_bytes: 25540
#include<iostream>
using namespace std;
int main(){
	int data[3];
	for(int i=0;i<3;i++)cin>>data[i];
	for(int i=0;i<3;i++){
		int k=i;
		for(int j=i+1;j<3;j++){
			if(data[k] > data[j])k=j;
		}
		int temp=data[i];
		data[i]=data[k];
		data[k]=temp;
	}
	cout<<data[0]+data[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  double ans=0;
  for(ll i=1;i<=n;i++){
    double sum=1.0/n;
    ll now=i;
    while(now<k){
      sum*=0.5;
      now*=2;
    }
    // cout<<sum<<endl;
    ans+=sum;
  }
  printf("%.15f\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

ll n;
vector<ll> a;

void solve() {
    ll res = a[0];
    repone(i, n - 1) {
        res = gcd(res, a[i]);
    }
    if (a[0] != a.back() && res == a.back()) cout << 1 << endl;
    else cout << res << endl;
}

int main() {
    cin >> n;
    a.resize(n);
    rep(i, n)cin >> a[i];
    solve();
    return 0;
}

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

        String str = "";
        int x;
        int n = scanner.nextInt();
        short[] s = new short[13];
        short[] h = new short[13];
        short[] c = new short[13];
        short[] d = new short[13];

        for(int i = 0; i < n; i++){
            str = scanner.next();
            x = scanner.nextInt();
            if(str.equals("S"))s[x-1] = 1;
            if(str.equals("H"))h[x-1] = 1;
            if(str.equals("C"))c[x-1] = 1;
            if(str.equals("D"))d[x-1] = 1;
        }
        for(int i = 0; i < 13; i++){
            if(s[i] == 0)System.out.println("S "+(i+1));
        }
        for(int i = 0; i < 13; i++){
            if(h[i] == 0)System.out.println("H "+(i+1));
        }
        for(int i = 0; i < 13; i++){
            if(c[i] == 0)System.out.println("C "+(i+1));
        }
        for(int i = 0; i < 13; i++){
            if(d[i] == 0)System.out.println("D "+(i+1));
        }


    }
}



Measured memory_bytes: 26368
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    print(A - 1, end=' ')
    print(B)
elif T == U:
    print(A, end=' ')
    print(B - 1)
else:
    print(A, end=' ')
    print(B)

Measured memory_bytes: 3060
n = gets.to_i

k6 = []
k9 = []

(1..10).each{ |i|
	if 6 ** i <= n then
		k6 << 6 ** i
	end
	
	if 9 ** i <= n then
		k9 << 9 ** i
	end
}

k6.reverse!
k9.reverse!

s = [n]
count = 0

while true
	min = s.min
	if min < 6 then
		puts count + min
		exit
	end

	next_s = []
	s.each{ |ss|
		next6 = k6.bsearch{ |x| x <= ss }
		
		if next6 != nil then
			next_s << ss - next6
		end
		
		next9 = k9.bsearch{ |x| x <= ss }
		
		if next9 != nil then
			next_s << ss - next9
		end
		
		s = next_s
	}

	count += 1
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n, m;
ll k, a[maxn], b[maxn], pre[maxn];

int main() {

	// freopen("in.in", "r", stdin);
	scanf("%d%d%lld", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		pre[i] = pre[i - 1] + a[i];
	}
	ll now = 0, res = (ll)(upper_bound(pre + 1, pre + 1 + n, k) - pre - 1);
	for (int i = 1; i <= m; i++) {
		scanf("%lld", &b[i]);
		now += b[i];
		ll d = k - now;
		if (d >= 0) res = max(res, (ll)(i + upper_bound(pre + 1, pre + 1 + n, d) - pre - 1));
	}
	printf("%lld\n", res);

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

    ll rnum = 0, gnum = 0, bnum = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') rnum++;
        if (s[i] == 'G') gnum++;
        if (s[i] == 'B') bnum++;
    }

    ll res = rnum * gnum * bnum;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i - j < 0) break;
            if (i + j >= n) break;

            if (s[i-j] == s[i]) continue;
            if (s[i+j] == s[i]) continue;
            if (s[i-j] != s[i+j]) res--;
        }
    }
    cout << res << endl;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;


    cout<<((n+999)/1000)*1000 - n<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3604
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int H = Integer.parseInt(strSplit[0]);
            int W = Integer.parseInt(strSplit[1]);
            char HW[][] = new char[H][W];
            int xNESW[] = {0, 1, 1 ,1 ,0 ,-1, -1, -1};
            int yNESW[] = {-1, -1, 0, 1, 1, 1, 0, -1};
            
            for(int i=0; i<H; i++){
                String str = br.readLine();
                for(int j=0; j<W; j++){
                    HW[i][j] = str.charAt(j);
                }
            }
            
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    char count = '#';
                    
                    if(HW[i][j] == '.'){
                        count = '0';
                        for(int k=0; k<8; k++){
                            if((i+yNESW[k]) >= 0 && (i+yNESW[k])<H && (j+xNESW[k])>=0 && (j+xNESW[k])<W && HW[i+yNESW[k]][j+xNESW[k]] == '#'){
                                count++;
                            }
                        }
                    }
                    
                    System.out.print(count);
                }
                System.out.println();
            }
            
        }catch(Exception e){
            
        }
    }
}

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

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

	int rcount = 0;
	int ans = 0;
	rep(i,n){
		if(s[i] == 'R')rcount++;
	}
	//cout << rcount << endl;
	for(int i= rcount; i <n; i++){
		if(s[i] == 'R')ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3744
# include <cstdio>
# define rep(i,n) for (int(i)=0;(i)<(n);(i)++)
int c[10][10];
int H,W,A,res;
int main ()
{
scanf ("%d%d",&H,&W);
rep (i,10)rep(j,10)scanf("%d",&c[i][j]);
rep (k,10)rep(i,10)rep(j,10)
if (c[i][j] > c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
rep(i,H)rep(j,W)
{
scanf("%d",&A);
if (A>=0) res += c[A][1];
}
printf("%d\n",res);
}

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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll t, i, sum = 0, arr[200000 + 20];
	cin >> t;
	fo(i, t) {
		cin >> arr[i];
		sum ^= arr[i];
	}

	fo(i, t) {
		arr[i] ^= sum;
		cout << arr[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 5184
#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 - 1; i >= a; i--)
typedef long long ll;


int main(){
    ll K; cin >> K;
    vector<ll> A(K);
    rep(i, 0, K) cin >> A[i];

    ll ub = 1e18, lb = 1;
    
    // 最小の値
    while(ub - lb > 1){
        ll m = (ub + lb) / 2;
        ll tmp = m;
        rep(i, 0, K){
            tmp = tmp - tmp % A[i];
        }
        if(tmp < 2) lb = m;
        else ub = m;
    }
    ll ans_s = ub;
    ub = 1e18, lb = 2;
    while(ub - lb > 1){
        ll m = (ub + lb) / 2;
        ll tmp = m;
        rep(i, 0, K){
            tmp = tmp - tmp % A[i];
        }
        if(tmp > 2) ub = m;
        else lb = m;
    }
    ll ans_b = lb;

    ll tmp = ans_s;
    rep(i, 0, K){
        tmp = tmp - tmp % A[i];
    }
    if(tmp != 2){
        cout << -1 << endl;
        return 0;
    }
    cout << ans_s << " " << ans_b << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int A, B;
	cin >> A >> B;

	rep(i, max(A , B)) {
		if (abs(A - i) == abs(B - i)) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << 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> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
vector<ll> g[200010];
ll col[200010],res[200010];

void dfs(ll v,ll c){
	col[v]=c;
	for(ll nv : g[v]){
		if(col[nv]!=-1)continue;
		dfs(nv,1-c);
	}
}

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

  memset(col,-1,sizeof(col));
  memset(res,-1,sizeof(res));
  cin>>N;
  rep(i,N-1){
  	ll a,b;
  	cin>>a>>b;a--;b--;
  	g[a].push_back(b);
  	g[b].push_back(a);
  }
  dfs(0,0);

  vector<ll> r1,r2;
  rep(i,N){
  	if((i+1)%3==1)r1.push_back(i);
  	if((i+1)%3==2)r2.push_back(i);
  }

  ll cnt0=0,cnt1=0;
  rep(i,N){
  	if(col[i]==0) cnt0++;
  	else cnt1++;
  }

  ll s1=r1.size(),s2=r2.size();
  if(s1>s2){
  	swap(s1,s2);
  	swap(r1,r2);
  }
  if(min(cnt0,cnt1)<s1){
  	ll mxc;
  	if(cnt0>cnt1) mxc=0;
  	else mxc=1;
  	rep(i,N){
  		if(col[i]==mxc&&res[i]==-1&&r1.size()){
  			res[i]=r1.back();
  			r1.pop_back();
  		}
  	}
  	rep(i,N){
  		if(col[i]==mxc&&res[i]==-1&&r2.size()){
  			res[i]=r2.back();
  			r2.pop_back();
  		}
  	}
  }else{
  	ll mxc;
  	if(cnt0>cnt1) mxc=0;
  	else mxc=1;
  	rep(i,N){
  		if(col[i]!=mxc&&res[i]==-1&&r1.size()){
  			res[i]=r1.back();
  			r1.pop_back();
  		}
  	}
  	rep(i,N){
  		if(col[i]==mxc&&res[i]==-1&&r2.size()){
  			res[i]=r2.back();
  			r2.pop_back();
  		}
  	}
  }
  ll idx=2;
  rep(i,N){
  	if(res[i]==-1){
  		res[i]=idx;
  		idx+=3;
  	}
  }
  rep(i,N)cout<<res[i]+1<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 19816
#include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

string s;
stack<bool> st;

int main()
{
    cin>>s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'S')st.push(true);
        else if(s[i] == 'T')
        {
            if(st.empty())st.push(false);
            else if(st.top() == false)st.push(false);
            else st.pop();
        }
    }
    printf("%d", st.size());
    return 0;
}


Measured memory_bytes: 644
def waru(A,B):
  if A%B==0:
    return A//B
  else:
    return (A//B)+1
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=min([A,B,C,D,E])
print(waru(N,a)+4)

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

int gcd(int x, int y) {
	if(y == 0) return x;
	return gcd(y, x % y);
}

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

	m = abs(x - a[0]);
	rep(i, n){
		m = gcd(m, abs(x - a[i]));
	}

	cout << m << endl;

}

Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn dfs(s: String, mc: u8, n: usize) {
    if s.len() == n {
        println!("{}", s);
    } else {
        for c in b'a'..mc+1 {
            // let c = cc as char;
            let mut st = s.clone();
            st.push(c as char);
            if c == mc {
                dfs(st, mc+1, n);
            } else {
                dfs(st, mc, n);
            }
        }
    }
}

fn main() {
    let n = read::<usize>();

    let s = String::new();
    dfs(s, b'a', n);

}

Measured memory_bytes: 5500
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int main(){
    int a,b,c;cin>>a>>b>>c;
    bool f=false;;
    if(a&&b){
        f=true;
    }
    if(c){
        f=true;
    }
    if(f){
        cout<<"Open"<<endl;
    }else{
        cout<<"Close"<<endl;
    }
}



Measured memory_bytes: 3092
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	x, y = rli()
	# x animals total, y legs total
	# c = num of cranes (2 legs)
	for c in range(x+1):
		t = x - c 
		if 2*c + 4*t == y:
			print("Yes")
			return
	print("No")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65260
chars = list()
n = int(input())
for i in range(n):
    chars.append(input())
C0, C1, C2, C3 = 0, 0, 0, 0
for i in chars:
    if i == 'AC': C0 = C0 + 1
    elif i == 'WA': C1 = C1 + 1
    elif i == 'TLE': C2 = C2 + 1
    else: C3 = C3 + 1
print('AC x', C0)
print('WA x', C1)
print('TLE x', C2)
print('RE x', C3)

Measured memory_bytes: 16148
#include<cstdio>
#include<cmath>
bool check(int x)
{
	if(x==2)return 1;
	for(int i=2;i<=sqrt(x);i++)
		if(x%i==0)return 0;
	return 1;
}
int n;
int main()
{
	scanf("%d",&n);
	while(n)
	{
		if(check(n))
		{
			printf("%d",n);
			return 0;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

typedef struct{
	double x, y;
}_z;

int main(){

	_z p[4];
	
	while(cin >> p[0].x >> p[0].y){
		for(int i=1; i<4; i++){
			cin >> p[i].x >> p[i].y;
		}
		
		if(p[3].x < p[0].x || p[2].x > p[1].x || p[2].y > p[1].y || p[3].y < p[0].y){
			cout << "NO" << endl;
		}
		else cout << "YES" << endl;
		
	}
	
	return 0;

}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n;
    while(cin>>n, n){
        vector<ll> a(n);
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum += a[i];
        }
        int res=0;
        for(int i=0;i<n;i++){
            if(a[i]*n <= sum) res++;
        }
        cout<<res<<endl;
    }
}



Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}*/
/*
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	return 0;
}*/

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

	int n, m;
	cin >> n >> m;
	vector<int> p(m), y(m);
	vector<vector<int>> py(n + 1, vector<int>());

	rep(i, m) {
		cin >> p[i] >> y[i];
		py[p[i]].push_back(y[i]); // 目新しい形！
	}

	rep(i, n) sort(allof(py[i + 1]));
	rep(i, m) {
		printf("%06d%06d\n", p[i], lower_bound(allof(py[p[i]]), y[i]) -
			py[p[i]].begin() + 1);
	}
}

Measured memory_bytes: 7808
n = int(input())

group = [[[] for _ in range(10)] for _ in range(10)]

for n_i in range(1, n+1):
  str_n = str(n_i)
  for i in range(1, 10):
    if int(str_n[0]) == i:
      for j in range(1, 10):
        if int(str_n[-1]) == j:
          group[i][j].append(n_i)

ans = 0
for n_i in range(1, n+1):
  str_n = str(n_i)
  f_n = int(str_n[0])
  l_n = int(str_n[-1])
  ans += len(group[l_n][f_n])
      
print(ans)

Measured memory_bytes: 52732
#include <bits/stdc++.h>
// const std::string ans[2] = {"No\n", "Yes\n"};

int main() {
    using namespace std;
    long long n,a,b;
    cin >> n >>a>>b;
    long long ans = (n / (a+b)) * a;
    ans += ((n % (a+b)) <a )?(n % (a+b)):a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10 ** 9 + 7


def main():
    n, m = map(int, readline().split())
    # a = readlines()
    As = list(map(int, readlines()))
    # diff_a = [a[i+1] - a[i] for i in range(m - 1)]
    # if 1 in diff_a:
    #     print(0)
    #     return
    broken = [False] * (n + 1)
    for a in As:
        broken[a] = True
    p1, p2 = 1, 1
    if broken[1]:
        p1 = 0

    for i in range(2, n + 1):
        if broken[i]:
            p1, p2 = 0, p1
        else:
            p1, p2 = (p1 + p2) % MOD, p1

    print(p1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11812
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    let mut tlist: Vec<(i32, i32)> = Vec::new();
    for _ in 0..n {
        let task = (sc.read(), sc.read());
        tlist.push(task);
    }

    let mut t = 0;
    tlist.sort_by_key(|k| k.1);
    for (c, d) in tlist {
        t += c;
        // println!("t: {} -> {}, d: {}", t - c, t, d);
        if t > d {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

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

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, M,wa, K, W, ans,k[5];
string s[100000];

int main() {
	cin >> N >> M;
	if (N > 2 && M > 2) {
		ans = (N - 2)*(M - 2);
	}
	if (N == 1) {
		ans = M - 2;
	}
	if (M == 1) {
		ans = N - 2;
	}
	if (N == 2 || M == 2) {
		ans = 0;
	}

	if (N == 1 && M == 1) {
		ans = 1;
	}


		cout << ans << endl;
	

	return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 3628
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

x,a=I()
print(0 if x<a else 10)


Measured memory_bytes: 10432
n = int(input())

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

def nobori():
    for i in range(n-1):
        if B[i]>B[i+1]:
            return 0
    return 1

ans ="NO"
for i in range(n):
    for j in range(i,n):
        B = A[:]
        B[i],B[j] = B[j],B[i]
        if nobori()==1:
            ans = "YES"
print(ans)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  long long c[26];
  for (int i = 0; i < 26; i++) cin >> c[i];
  long long s[D][26];
  for (int d = 0; d < D; d++) {
    for (int i = 0; i < 26; i++) {
      cin >> s[d][i];
    }
  }
  long long t[D];
  for (int d = 0; d < D; d++) {
    cin >> t[d];
    t[d]--;
  }
  long long last[26];
  fill(last, last + 26, 0);
  long long ans = 0;
  for (int d = 0; d < D; d++) {
    ans += s[d][t[d]];
    last[t[d]] = d + 1;
    for (int i = 0; i < 26; i++) {
      ans -= c[i] * (d + 1 - last[i]);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
  int n;
  while(cin>>n){
    for(int i=0; i<n; ++i){
      cin>>a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    int b=0, c=0;
    for(int i=0; i<n; ++i){
      if(i%2){
        b+=a[i];
      }
      else{
        c+=a[i];
      }
    }
    cout<<(c-b)<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int x;

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

    x = sc.nextInt();

    long low = 0, high = Integer.MAX_VALUE / 2;
    while(high - low > 1){
      long mid = (low + high) / 2;
      if(mid * (mid + 1) < 2 * x){
        low = mid;
      }
      else{
        high = mid;
      }
    }

    System.out.println(high);
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
int han[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int ans=0;
  cin >>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o') ans++;
  }
  if(ans+15-s.size()>=8) cout <<"YES\n";
  else cout <<"NO\n";
  return (0);
}


Measured memory_bytes: 256
#include<iostream>
#define N 500000
#define INF 2000000000
using namespace std;
int c;
void merge(int *A,int l,int m,int r){
  int n1=m-l,n2=r-m;
  int L[N],R[N];
  for(int i=0;i<n1;i++)L[i]=A[l+i];
  for(int i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=INF,R[n2]=INF;
  int i=0,j=0;
  for(int k=l;k<r;k++){
    if(L[i]<R[j])A[k]=L[i++];
    else A[k]=R[j++];
    c++;
  }
}
void mergesort(int *A,int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}


int main(){
  int n,S[N];
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  mergesort(S,0,n);
  for(int i=0;i<n-1;i++)cout<<S[i]<<" ";
  cout<<S[n-1]<<endl<<c<<endl;
  return 0;
}

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

int main() {
	int A, B, C, D, P;
	cin >> A >> B >> C >> D >> P;
	
	int rest = (P - C) > 0 ? P - C : 0;
	cout << min(A * P, B + D * rest) << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector< int > L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());
    ll ans = 0LL;
    rep(i, N) {
        for (int j = i + 1; j < N; ++j) {
            auto it = upper_bound(L.begin(), L.end(), L[j] - L[i]);
            int left = it - L.begin();
            it = lower_bound(L.begin(), L.end(), L[j] + L[i]);
            int right = it - L.begin();
            int res = right - left;
            if (left <= i && i <= right) {
                res -= 1;
            }
            if (left <= j && j <= right) {
                res -= 1;
            }
            ans += (ll)max(0, res);
        }
    }
    cout << ans / 3LL << endl;
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

maxCount = 0
for i in range(0, n):
    # i番目の敵をできるだけ倒す
    if a[i] > b[i]:
        maxCount += b[i]
        continue
    else:
        maxCount += a[i]
        b[i] -= a[i]
    # i+1番目の敵をできるだけ倒す
    if a[i+1] > b[i]:
        maxCount += b[i]
        a[i+1] -= b[i]
    else:
        maxCount += a[i+1]
        a[i+1] = 0

print(maxCount)


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

struct edge_t {
    int dest;
    int weight;
};

struct vertex_t {
    vector<edge_t> edges;
    vector<int> weight;

    // for dijkstra
    bool done; // confirm or not
    int cost;  // now cost
    int from;

    bool operator<(const vertex_t &another) const { // priority --> min
        return another.cost < cost;                 // order(cost)
    }

    bool operator>(const vertex_t &another) const { // priority --> min
        return another.cost > cost;                 // order(cost)
    }

    bool operator==(const vertex_t &another) const {
        return another.cost == cost; // order(cost)
    }

    vertex_t() {
        cost = INF;
        done = false;
    }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
    int i, j, k, count = 0;
    bool flag = false;
    graph[start].cost = 0;
    REP(i, size) {
        REP(j, size) {
            vertex_t cur = graph[j];
            for (edge_t edge : cur.edges) {
                if (cur.cost + edge.weight < graph[edge.dest].cost) {
                    if (i == size - 1)
                        flag = true;
                    graph[edge.dest].cost = cur.cost + edge.weight;
                }
            }
        }
    }
    if (flag) {
        return 1;
    } else {
        return 0;
    }
}

class tree_t {
public:
    bool is_leaf;
    tree_t *right;
    tree_t *left;

    tree_t() {
        is_leaf = false;
        right = NULL;
        left = NULL;
    }
};

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

int main() {

    int N;
    cin >> N;
    vector<float> v(N);

    REP(i, N) {
        cin >> v[i];
    }

    sort(v.begin(), v.end());

    float sum = v[0];

    for (i = 1; i < N; i++) {
        sum += v[i] * pow(2, i - 1);
    }

    sum /= pow(2, N - 1);

    cout << sum;
};

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int n;
    double m;
    double votessum = 0;
    cin >> n >> m;
    int p = (int) m;
    int votes[n];
    for (int i = 0; i < n; i++) {
        cin >> votes[i];
        votessum += votes[i];
    }
    for (int i = 0; i < n; i++){
        if (votes[i] >= (double) votessum*(1/(4*m))){
            p-=1;
        }
    }
    if (p<1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;


/**
 *
 * @author
 *
 *
 *
 */

public class Main {

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        int[] data = scanner.nextIntArray();

        out.println(data[0] - data[1] + 1);

        scanner.reader.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data  = nextStringArray();
            int[] a  = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data  = nextStringArray();
            Integer[] a  = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data  = nextStringArray();
            long[] a  = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}



Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int N;

    cin >> N;
    vector<int> A(N , 0);
    for (int i = 0; i < N-1; i++)
    {
        int t;
        cin >> t;

        A[t-1]++;
    }

    for(auto& x:A)
    {
        std::cout << x << std::endl;
    }

}

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>

using namespace std;

#define int long long



signed main() {
	int ans = 0;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < 3; i++) {
		if (s[i]==t[i])
		{
			ans++;
		}
	}

	cout << ans;
	
	
	return 0;
}


Measured memory_bytes: 256
a=int(input())
list=list(input().split())
result=1
for i in range(a):
  if int(list[i])%2 == 0:
    if int(list[i])%3 !=0 and int(list[i])%5 !=0:
      print('DENIED')
      result=0
      break
if result != 0:
	print('APPROVED')
    


Measured memory_bytes: 2940
def is_prime(num):
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    else:
        return True


def main():
    x = int(input())
    num = x

    while True:
        if is_prime(num):
            ans = num
            break
        num += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63024
#include <iostream>

using namespace std;

int64_t getAns(uint64_t cur)
{
    if (cur == 1)
    {
        return 1;
    }

    return (2 * getAns(cur/2) + 1);
}

int main()
{
    uint64_t h;
    cin >> h;

    cout << getAns(h) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main() {
    char S[101];
    scanf("%s",S);

    int K, sN;
    sN = strlen(S);
    scanf("%d",&K);

    int i, a=1, b=1;
    i=1;  while (i < sN && S[i] == S[i-1]) { i++; a++; }

    if (a == sN) {
        printf("%.0lf", K/2.0*sN);
        return 0;
    }

    i=sN-2;  while (i > 0 && S[i] == S[i+1]) { i--; b++; }

    unsigned long ops=0;
    for (i=1; i<sN; i++) {
        if (S[i] == S[i-1]) {
            S[i]='A';
            ops++;
        }
    }

    unsigned long sub = 0;
    if (S[i-1] == S[0]) {
        sub = (K-1)*(a/2 + b/2 - (a+b)/2);
    }
   
    printf("%lu", K*ops - sub);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<int> L(N + 1);
    L[0] = a[N-1];
    int length = 1;
    for (int i = N-2; i >= 0; i--) {
        if (L[length - 1] <= a[i]) L[length++] = a[i];
        else {
            *upper_bound(L.begin(), L.begin() + length, a[i]) = a[i];
        }
    }
    cout << length << '\n';
}


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

int main(){
	string w;
	cin>>w;
	int n=w.length();
	int a[26]={0};
	
	for(int i=0;i<n;i++){
		a[w[i]-'a']++;
	}
	
	for(int i=0;i<26;i++){
		if(a[i]%2!=0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X,A;
  cin>>X>>A;
  if(X<A){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
}


Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        if (inp[0] <= 5) Console.WriteLine(0);
        else if (inp[0] <= 12) Console.WriteLine(inp[1] / 2);
        else Console.WriteLine(inp[1]);
    }
}

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

int main() {
	string s;
  	cin>>s;
  
  	bool ddr=true;
 	
  	rep(i,s.size()){
    	if(i%2==0&&s[i]=='L'){
        	ddr=false;
        }
      
      	if(i%2==1&&s[i]=='R'){
        	ddr=false;
        }
    }
  
  if(ddr){
  	cout<<"Yes"<<endl;
  }
  
  else{
  	cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(void){
    ll n,k;
    cin>>n>>k;
    ll a;
    cin>>a;
    if(n==1){
        if(a==k)cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    ll MAX=a;
    bool ok=true;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        MAX=max(MAX,b);
        a=gcd(a,b);
        if(a==1)ok=false;
    }
    if(!ok){
        if(MAX>=k)cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        if(MAX>=k&&k%a==0)cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }
}


Measured memory_bytes: 256