akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace program {
  class Program {
    static void Main()
    {
      var a = Input.ScanLongArray();
      var b = a[0] + a[1];
      Out(b%2==0 ? $"{b/2}" : "IMPOSSIBLE");
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

#define MAX_DATA_NUM 3001	// Contain last zero

typedef struct t_num_set{
	int num1;
	int num2;
}t_NUM_SET;

void swap(t_NUM_SET *t_inValue);

int main()
{
	int dataNum = 0, i = 0;
	t_NUM_SET t_inValue[MAX_DATA_NUM];
	
	for(i = 0; i < MAX_DATA_NUM; i++)
	{
		cin >> t_inValue[i].num1;
		cin >> t_inValue[i].num2;
		
		if( (0 == t_inValue[i].num1) && (0 == t_inValue[i].num2) ){
			break;
		}
		
		if(t_inValue[i].num1 > t_inValue[i].num2)
		{
			swap(&t_inValue[i]);
		}
	}
	
	dataNum = i;
	
	for(i = 0; i < dataNum; i++)
	{
		cout << t_inValue[i].num1 << " " << t_inValue[i].num2 << endl;
	}
	
	return 0;
}

void swap(t_NUM_SET *t_inValue)
{
	int tmp;
	
	tmp = t_inValue->num1;
	t_inValue->num1 = t_inValue->num2;
	t_inValue->num2 = tmp;
}


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

int main() {
  int N,M;
  int Lmax = -1;
  int Rmin = 100000;
  int count = 0;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for (int i = 0; i < M; i++) {
    cin >> L.at(i);
    cin >> R.at(i);
  }
  for(int i = 0; i < M; i++){
    if(L.at(i) >= Lmax){
      Lmax = L.at(i);
    }
    if(R.at(i) <= Rmin){
      Rmin = R.at(i);
    }
  }
  count = Rmin - Lmax + 1;
  count = max(count,0);
  cout << count << endl;
}



Measured memory_bytes: 1024
has_prev = false

while line = gets
  n = line.chomp.to_i
  break if n == 0
  teams = Hash.new(0)
  n.times do
    data = gets.chomp.split
    teams[data[0]] = data[1].to_i * 3 + data[3].to_i
  end
  
  teams = teams.sort do |(k1, v1), (k2, v2)|
    if v1 == v2
      -1
    else
      v2 <=> v1
    end
  end

  puts if has_prev

  teams.each do |key, value|
    puts "#{key},#{value}"
  end

  has_prev = true
end

Measured memory_bytes: 8608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == 'A') {
        int c_cnt = 0;
        FOR(j, 2, s.size() - 2) if(s[j] == 'C') c_cnt++;
        if(c_cnt == 1) {
            int l_cnt = 0;
            REP(i, s.size()) if('a' <= s[i] and s[i] <= 'z') l_cnt++;
            if(l_cnt == s.size() - 2) {
                cout << "AC" << endl;
                return 0;
            }
        }
    }
    cout << "WA" << endl;
    return 0;
}


Measured memory_bytes: 256
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val (T, A) = readInts()
    val H = readInts()

    var diff = Double.MAX_VALUE
    var point = -1
    H.forEachIndexed { index, h ->
        val averageDiff = Math.abs(A - (T - h * 0.006))
        if (averageDiff < diff) {
            diff = averageDiff
            point = index + 1
        }
    }

    println(point)
}

Measured memory_bytes: 38032
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const ll INF=1e12;
char maze[1000][1000];
ll d[1000][1000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    rep(i,0,H){
        rep(j,0,W){
            cin>>maze[i][j];
        }
    }
    rep(i,0,H){
        rep(j,0,W){
            if(i==0&&j==0) d[i][j]=1;
            else if(i==0){
                if(maze[i][j]!='#') d[i][j]=d[i][j-1];
            }
            else if(j==0){
                if(maze[i][j]!='#') d[i][j]=d[i-1][j];
            }
            else{
                if(maze[i][j]!='#'){
                    d[i][j]=d[i-1][j]+d[i][j-1];
                    d[i][j]%=MOD;
                }
            }
            
        }
    }
    cout <<d[H-1][W-1]<<"\n";
}


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

using i64 = int64_t;

constexpr i64 MOD = 1000000007;

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

i64 repeated_squaring(i64 x, i64 n) {
    i64 res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    i64 n, a, b;
    cin >> n >> a >> b;
    vector<i64> fact(max(a,b)+1, 1);
    for(i64 i=2;i<=max(a,b);++i){
        fact[i] = fact[i-1] * i;
        fact[i] %= MOD;
    }

    i64 ans = repeated_squaring(2, n);
    ans--;
    if(ans < 0)ans += MOD;
    i64 tmp = 1;
    for(i64 i=n;i>=n-a+1;--i){
        tmp *= i;
        tmp %= MOD;
    }
    tmp *= multi_inv(fact[a], MOD);
    tmp %= MOD;
    ans -= tmp;
    if(ans < 0)ans += MOD;
    tmp = 1;
    for(i64 i=n;i>=n-b+1;--i){
        tmp *= i;
        tmp %= MOD;
    }
    tmp *= multi_inv(fact[b], MOD);
    tmp %= MOD;
    ans -= tmp;
    if(ans < 0)ans += MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;
const int maxm = 10000000;

ll solve(int n, vector<ll>& p){
  int b = n / maxm;
  int c = n % maxm;
  ll tt = p[b];
  for(int i=0;i<c;i++)tt = tt * (n - i)%mod;
  return tt;
}

void gcd(ll a,ll b, ll& d,ll& x,ll& y){  //      已经测试 FZU 1402
  if(!b) {d=a;x=1;y=0;}
  else   {	gcd(b,a%b,d,y,x);	y-=a/b*x;}
}
ll inv(ll a,ll n)  { //无逆元返回-1
  ll d,x,y;	gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  vector<ll>p = {1,682498929,491101308,76479948,723816384,67347853,27368307,625544428,199888908,888050723,927880474,281863274,661224977,623534362,970055531,261384175,195888993,66404266,547665832,109838563,933245637,724691727,368925948,268838846,136026497,112390913,135498044,217544623,419363534,500780548,668123525,128487469,30977140,522049725,309058615,386027524,189239124,148528617,940567523,917084264,429277690,996164327,358655417,568392357,780072518,462639908,275105629,909210595,99199382,703397904,733333339,97830135,608823837,256141983,141827977,696628828,637939935,811575797,848924691,131772368,724464507,272814771,326159309,456152084,903466878,92255682,769795511,373745190,606241871,825871994,957939114,435887178,852304035,663307737,375297772,217598709,624148346,671734977,624500515,748510389,203191898,423951674,629786193,672850561,814362881,823845496,116667533,256473217,627655552,245795606,586445753,172114298,193781724,778983779,83868974,315103615,965785236,492741665,377329025,847549272,698611116};
  int n, a, b;
  cin>>n>>a>>b;
  ll ret = mod - 1;
  ll tt = 2;
  int tn = n;
  ll tmp = 1;
  while(tn){
    if(tn&1)tmp=(tmp*tt)%mod;
    tn>>=1;
    tt = tt * tt %mod;
  }
  ret = (ret+tmp)%mod;
  ret = (ret + mod - solve(n, p)*inv(solve(n-a, p)*solve(a, p)%mod, mod)%mod)%mod;
  ret = (ret + mod - solve(n, p)*inv(solve(n-b, p)*solve(b, p)%mod, mod)%mod)%mod;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
int ans, a,b,c;
int main(void){
	RIII(a,b,c);
	ans+=a;
	ans = ans*10+b;
	ans = ans*10+c;
	printf("%s\n",ans%4?"NO":"YES");
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] Nnumber = new int[N];

        for (int n = 0; n < N; n++) {
        	Nnumber[n] = 1;
        }

        int K = scan.nextInt();
        int i;

        for (i = 1; i <= K; i++) {
        	int d = scan.nextInt();
        	int j;
        	for (j = 1; j <= d; j++) {
        		int A = scan.nextInt();
        		Nnumber[A-1] = 0;
        	}
        }

        int k;
        int count = 0;
        for (k = 0; k < N; k++) {
        	if (Nnumber[k] != 0) {
        		count++;
        	}
        }

		System.out.println(count);

	}
}

Measured memory_bytes: 46304
#include<stdio.h>
int main(){

  int i,m,d,count;

  while(1){
    count=0;
    scanf("%d%d",&m,&d);
    if(m==0 && d==0)break;

    for(i=1;i<=m;i++){
      if(i==2 || i==4 || i==6 || i==8 || i==9 || i==11){
	count+=31;
      }else if(i==5 || i==7 || i==10 ||i==12){
	  count+=30;
	}else if(i==3){
	  count+=29;
	}
	}
      count+=d;
      switch(count%7){

      case 0:
	puts("Wednesday");
	break;
      case 1:
	puts("Thursday");
	break;
      case 2:
	puts("Friday");
	break;
      case 3:
	puts("Saturday");
	break;
      case 4:
	puts("Sunday");
	break;
      case 5:
	puts("Monday");
	break;
      case 6:
	puts("Tuesday");
	break;
      }
    }
    return 0;
  }

Measured memory_bytes: 584
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 212
#define LL long long
int T,n;LL a[N];char sc[N];
struct LB{
	LL b[63];bool hv;
	inline LB(){memset(b,0,sizeof(b));hv=0;}
	inline bool Ins(LL x){for(LL i=60;i>=0;i--)if(x&(1ll<<i)){if(!b[i]){b[i]=x;return true;}x^=b[i];}return false;}
	inline bool can(LL x){for(LL i=60;i>=0;i--)if(x&(1ll<<i)){if(!b[i])return true;x^=b[i];}return false;}
	inline void cls(){memset(b,0,sizeof(b));hv=0;}
}b,c;
inline LB Merge(LB a,LB b)
{
	LB S1(a),S2(a),S;LL i,j,x,y;S.hv=a.hv&&b.hv;
	for(i=0;i<=60;i++)
	if(x=b.b[i])
	{
		y=0;
		for(j=i;j>=0;j--)
		if(x&(1ll<<j))
		{
			if(!S1.b[j]){S1.b[j]=x;S2.b[j]=y;break;}
			x^=S1.b[j];y^=S2.b[j];if(!x){S.b[i]=y;break;}
		}
	}return S;
}
inline LB Xor(LB b,LL v){c.cls();for(LL i=60;i>=0;i--)if(b.b[i]){if(b.b[i]!=v)c.Ins(b.b[i]^v);}if(b.hv)c.Ins(v);if(!b.can(v))c.hv=1;return Merge(b,c);}
int main(){
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);int i;for(i=1;i<=n;i++)scanf("%lld",&a[i]);
		scanf("%s",sc+1);b.cls();b.hv=1;
		for(i=n;i>=1;i--)if(sc[i]=='0')b.Ins(a[i]);else b=Xor(b,a[i]);
		printf("%d\n",!b.hv);
	}return 0;
}

Measured memory_bytes: 3184
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int N;
int num[13];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int D;
		scanf("%d", &D);
		num[D]++;
	}
	num[0]++;
	vector<int> va, vb;
	int cnt = 0;
	for(int i = 0; i < 13; i++){
		if(i == 0 || i == 12){
			if(num[i] >= 2){
				printf("0\n");
				return 0;
			}
		}else{
			if(num[i] >= 3){
				printf("0\n");
				return 0;
			}
		}
		if(num[i] == 1){
			va.push_back(i);
			cnt++;
		}else if(num[i] == 2){
			vb.push_back(i);
			vb.push_back(24 - i);
		}
	}
	for(int i = 0; i < vb.size(); i++) va.push_back(vb[i]);
	int res = 0;
	for(int i = 0; i < (1 << cnt); i++){
		int min_diff = 13;
		for(int j = 0; j < va.size(); j++){
			int time_j;
			if(j < cnt) time_j = (i & (1 << j) ? va[j] : ((24 - va[j]) % 24));
			else time_j = va[j];
			for(int k = 0; k < va.size(); k++){
				if(k == j) continue;
				int time_k;
				if(k < cnt) time_k = (i & (1 << k) ? va[k] : ((24 - va[k]) % 24));
				else time_k = va[k];
				int time_diff = abs(time_j - time_k);
				min_diff = min(min_diff, min(time_diff, 24 - time_diff));
			}
		}
		res = max(res, min_diff);
	}
	printf("%d\n", res);
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	if( N % 2 == 0 ) {
		cout << N << endl;
	}
	else {
		cout << 2*N << endl;
	}

	return 0;
}


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

int main() {
	string s;
	cin >> s;
	int count = 0;
	TRAVEL:
	for (int i = 0; i < (int)s.size() - 1; i++)
	{
		if (s[i] != s[i + 1])
		{
			s.erase(i, 2);
			count += 2;
			goto TRAVEL;
		}
	}
	cout << count;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
 int A,B,C;
 cin>>A>>B>>C;
 cout<< C << " " << A << " " << B <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n, m, w, w2;
vector<int>cnt, z;
int s[100010], sum[100010];
int main() {
	cin >> n >> m;
	w = n;
	rep(i, n + 1) {
		char a; cin >> a;
		s[i] = a - '0';
		if (s[i] == 0) z.push_back(i);
		sum[i + 1] += s[i];
	}
	while (w != 0) {
		int c = low(all(z), w - m) - z.begin();
		int d = z[c];
		if (w - m <= d && d < w) {
			cnt.push_back(w - d);
			w -= w - d;
		}
		else {
			cout << -1 << endl;
			return 0;
		}

	}
	reverse(all(cnt));
	for (int i : cnt) cout << i << " ";
	cend;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct rb{
    ll x;
    ll l;
    bool operator<(const rb &another) const
    {
        return x+l < another.l + another.x;
    };
};


int main(void){
    ll n; cin >> n;
    vector <ll> xs;
    vector <ll> ls;
    vector <rb> rbs;
    REP(i, n){
        ll x; cin >> x; xs.push_back(x);
        ll l; cin >> l; ls.push_back(l);
        rbs.push_back({x, l});
    }
    sort(rbs.begin(), rbs.end());
    ll ans = 0;
    ll kagen = 1e8*(-1);
    REP(i, n){
        rb r = rbs[i];
        ll mae = r.x - r.l;
        if (mae < kagen){
            continue;
        }
        ll ato = r.x + r.l;
        kagen = ato;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4704
from collections import deque
H, W = map(int, input().split())
k=[0]*200000
for i in range(W):
    ta,tb = map(int, input().split())
    if ta == 1:
        k[tb-1]+=1
    if tb == H:
        k[ta-1]+=1
s = 0
for i in range(len(k)):
    if k[i]>=2:s=1
if s ==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
long long int arr[10000001],brr[10000001];
long long int p[1000000];
void calpr(int n){
    int i,j;
    for(i=1;i<=n;i++){
        //if(p[i]==0){
            for(j=i;j<=n;j+=i){
                p[j]++;
            }
        
    }
}
void calarr(int a){
    int i,j,k;
    long long int x,y,z,n;
    for(i=2;i<=a;i++){
        n=i;
        x=0,y=1;
        while(n%2==0){
            n/=2;
            x++;
        }
        y*=(x+1);
        x=0;
        for(j=3;j<10000;j+=2){
            if(p[j]==0){
                while(n%j==0){
                    n/=j;
                    x++;
                }
                y*=(x+1);
                x=0;
            }
        }
        if(n!=1)
        y*=2;
        arr[i]=y*i;
    }
}
int main(){
    long long int i,j,n,x=0;
   // calpr();
    //calarr();
    /*for(i=2;i<25;i++){
        cout<<p[i];
    }
    cout<<"\n";*/
    scanf("%lld",&n);
  calpr(n);
   // calarr(n);
    for(i=2;i<=n;i++){
        x+=i*p[i];
    }
    x++;
    printf("%lld\n",x);
    
}


Measured memory_bytes: 81932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    int n, x, t; cin >> n >> x >> t;
    int times = ceil(1.0 * t * n / x);
    int ans = times / t * t;
    if (times % t) ans += t;
    cout << ans; 

    return 0;
}



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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 100005
#define mxnn 2000005
vector<int>g[mxn];
int dp[mxn][2];
void dfs(int a,int p){
int x = 1,z = 1;
for(int i = 0;i<g[a].size();i++){
    int y = g[a][i];
    if(y == p) continue;
    dfs(y,a);
    x = (x*(dp[y][0]+dp[y][1]))%mod;
    z = (z*dp[y][0])%mod;
}
dp[a][0] = x;
dp[a][1] = z;
}
int32_t main(){
sp;
int n;
cin >>n;
for(int i = 0;i<n-1;i++){
    int u,v;
    cin >>u >>v;
    g[u].pb(v);
    g[v].pb(u);
}
dfs(1,0);
cout<<(dp[1][0]+dp[1][1])%mod;
return 0;
}


Measured memory_bytes: 14208
#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() {
    string w;
  	int cnt = 0;
    cin >> w;
    rep(i, w.length()) {
    	cnt = count(w.begin(), w.end(), w[i]);
      	if(cnt % 2 != 0){
        	cout << "No" << endl;
          	return 0;
        }
    }
  	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			int[] as = new int[M];
			int[] bs = new int[M];
			
			for(int i = 0; i < M; i++) {
				final int a = sc.nextInt();
				final int b = sc.nextInt();
				
				as[i] = a;
				bs[i] = 0;
				for(int j = 0; j < b; j++) { 
					bs[i] |= (1 << (sc.nextInt() - 1));
				}
			}
			
			final long INF = Long.MAX_VALUE / 2 - 1;
			long[] moneys = new long[1 << N];
			Arrays.fill(moneys, INF);
			moneys[0] = 0;
			for(int key = 0; key < M; key++) {
				for(int bit = 0; bit < (1 << N); bit++) {
					if(moneys[bit] >= INF) { continue; }
					
					final int next_bit = bit | bs[key];
					moneys[next_bit] = Math.min(moneys[next_bit], moneys[bit] + as[key]);
				}
			}
			
			System.out.println(moneys[(1 << N) - 1] >= INF ? -1 : moneys[(1 << N) - 1]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22472
#include <stdio.h>
#define N_MAX 20

int vs[N_MAX + 1];

int main(void)
{
    int n, a, v;

    scanf("%d", &n);

    while(~scanf("%d %d", &a, &v))
        vs[a] = v;

    for(v = -1; n >= 1; n--)
        if(vs[n] >= v)
            a = n, v = vs[n];

    printf("%d %d\n", a, v);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

int belong( std::vector<int> g, int a, int b )
{
	int cnt = 0;
	for( int i = 0; g[ i ] != 0; i++ ) {
		if( g[ i ] == a or g[ i ] == b ) {
			cnt += 1;
		}
	}
	return cnt;
}

int main()
{
	std::vector<int> g[] = {
		{ 1, 3, 5, 7, 8, 10, 12, 0 },
		{ 4, 6, 9, 11, 0 },
		{ 2, 0 },
	};

	int a, b;
	std::cin >> a >> b;

	bool isbel = false;
	for( int i = 0; i < 3; i++ ) {
		if( belong( g[ i ], a, b ) == 2 ) {
			isbel = true;
			break;
		}
	}

	std::cout << ( isbel ? "Yes" : "No" ) << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ICoins {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            double[] p = new double[N];
            for (int c = 0; c < N; c++) {
                p[c] = in.nextDouble();
            }
            double[] pNumHeads = new double[N + 1];
            pNumHeads[0] = 1;
            for (int c = 0; c < N; c++) {
                for (int h = N; h > 0; h--) {
                    pNumHeads[h] = p[c] * pNumHeads[h - 1] + (1 - p[c]) * pNumHeads[h];
                }
                pNumHeads[0] = (1 - p[c]) * pNumHeads[0];
            }
            double res = 0;
            for (int i = (N + 1) / 2; i <= N; i++) {
                res += pNumHeads[i];
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 35976
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    X = int(buflist[1])
    buf = input()
    buflist = buf.split()
    L = list(map(int, buflist))
    bound = [0]
    for i in range(N):
        bound.append(bound[-1] + L[i])
    for i, x in enumerate(bound):
        if x > X:
            print(i)
            return
    print(N+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> G[1005];
int owner[1005];
bool visited[1005];
bool can[1005];
int tarohana=0;
bool clear=true;
void dfs(int s,int own)
{
    visited[s]=true;
    for(int i=0;i<int(G[s].size());i++)
    {
        int to=G[s][i];
        if(own==1)
        {
            if(!visited[to] && owner[to]==0)
            {
                owner[to]=-1;
            }
            else
            {
                if(owner[to]==1)
                {
                    clear=false;
                    return;
                }
            }            
        }
        else
        {
            if(!visited[to] && owner[to]==0)
            {
                owner[to]=1;
                tarohana++;
            }
            else
            {
                if(owner[to]==-1)
                {
                    clear=false;
                    return;
                }
            }      
        }      
    }
    for(int i=0;i<int(G[s].size());i++)
    {
        int to=G[s][i];
        if(!visited[to])
        {
            dfs(to,owner[to]);
        }
    }
}

int main(void)
{
    int N,M,conquer=0;
    while(cin >> N >> M && N)
    {
        for(int i=0;i<1005;i++) G[i].clear();
        vector<int> conquerlist;
        conquer=0;
        memset(visited,false,sizeof(visited));
        memset(owner,0,sizeof(owner));
        memset(can,false,sizeof(can));
        for(int i=0;i<M;i++)
        {
            int u,v;
            cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        for(int i=1;i<=N;i++)
        {
            memset(visited,false,sizeof(visited));
            memset(owner,0,sizeof(owner));
            tarohana=1;
            owner[i]=1;
            dfs(i,1);
            bool clear=true;
            bool ok=true;
            for(int i=1;i<=N;i++)
            {if(!visited[i]) ok=false;}
            if(clear && ok && tarohana%2==0) can[tarohana/2]=true;
        }
        for(int i=1;i<=N;i++) if(can[i]) conquer++,conquerlist.push_back(i);
        cout << conquer << endl;
        for(int i=0;i<conquer;i++)
        {
            cout << conquerlist[i] << endl;
        }
        //cout << endl;
    }
}


Measured memory_bytes: 3168
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int H,W,A,B;
    int **map;
    scanf("%d %d %d %d",&H,&W,&A,&B);
    map=(int **)malloc(sizeof(int *)*H);
    for(int i=0;i<H;i++) map[i]=(int *)malloc(sizeof(int)*W); 
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) map[i][j]=1;
    }   
    for(int i=0;i<B;i++){
        for(int j=0;j<A;j++) map[i][j]=0;
    }
    for(int i=B;i<H;i++){
        for(int j=A;j<W;j++) map[i][j]=0;
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) printf("%d",map[i][j]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 5628
def is_stable(oline, line):
    for i in range(N):
        for j in range(i+1, N):
            for a in range(N):
                for b in range(a+1, N):
                    if (oline[i][1] == oline[j][1]) & (oline[i] == line[b]) & (oline[j] == line[a]):
                        return False
    return True

N = int(input())
line = input().split()
oline = line.copy()
#BubbleSort
for i in range(N):
    for j in range(N-1, i, -1):
        if int(line[j][1]) < int(line[j-1][1]):
            tmp = line[j]
            line[j] = line[j-1]
            line[j-1] = tmp
print(' '.join(line))
print(('Not stable', 'Stable')[is_stable(oline, line)])

#SelectionSort
line = oline.copy()
for i in range(N):
    minj = i
    for j in range(i+1, N):
        if int(line[minj][1]) > int(line[j][1]):
            minj = j
    tmp = line[i]
    line[i] = line[minj]
    line[minj] = tmp
print(' '.join(line))

print(('Not stable', 'Stable')[is_stable(oline, line)])

Measured memory_bytes: 7828
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;
//const int p = 31;

int n;

int main()
{
    //ifstream cin ("gen.in");
    //ofstream cout ("sysadmin.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    cin >> n;
    cout << (int) ceil((double) n / 2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define MM(arr,x) memset(arr,x,sizeof(x))
using namespace std;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x1=a*c;
	ll x2=a*d;
	ll x3=b*c;
	ll x4=b*d;
	cout<<max(x1,max(x2,max(x3,x4)));
	return 0;
} 

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,n,k,t=0,a[55];
	cin >> n >> k ;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=n-k;i<n;i++){
		t+=a[i];
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int da[101][5500];

int main() {
    int i,j,k=0,h,n,s,mx=-100000001,d[101];
	cin >> n;
	for (i=0;i<n;i++) {
		for (j=0; j<n; j++) cin >> d[j];
		for (k=0,h=0;h<n;h++) for (s=0,j=h;j<n;j++,k++) { s+=d[j]; da[i][k]=s; }
		}
	for (i=0;i<k;i++) for (j=0;j<n;j++) for (s=0,h=j;h<n;h++) { s+=da[h][i]; if (s>mx) mx=s;}
	cout << mx << endl;
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

struct LongestCommonSubsequence {
    static const int max_length = 1001;
    std::vector<std::vector<int>> dp;
    std::vector<std::vector<int>> pre;
    std::string s, t;

    LongestCommonSubsequence(std::string left, std::string right) {
        s = "+" + left;
        t = "*" + right;
        dp.assign(max_length, std::vector<int>(max_length, 0));
        pre.assign(max_length, std::vector<int>(max_length, 0));
    }

    void lcs() {

        for (int si = 1; si < s.size(); si++) {
            for (int ti = 1; ti < t.size(); ti++) {
                if (s[si] == t[ti]) {
                    dp[si][ti] = dp[si - 1][ti - 1] + 1;
                    pre[si][ti] = 1;
                }
                else if (dp[si - 1][ti] > dp[si][ti - 1]) {
                    dp[si][ti] = dp[si - 1][ti];
                    pre[si][ti] = 2;
                }
                else {
                    dp[si][ti] = dp[si][ti - 1];
                    pre[si][ti] = 3;
                }
            }
        }
    }

    std::string solve() {
        std::string ans = "";

        int si = s.size() - 1;
        int ti = t.size() - 1;
        while (si >= 1 && ti >= 1) {
            if (pre[si][ti] == 1) {
                ans += s[si];
                si--, ti--;
            }
            else if (pre[si][ti] == 2) {
                si--;
            }
            else {
                ti--;
            }
        }

        reverse(ans.begin(), ans.end());
        return ans;
    }
};

int main() {
    ll q;
    cin >> q;
    rep(i, q) {
        string s, t;
        cin >> s >> t;
        LongestCommonSubsequence seq(s, t);
        seq.lcs();
        cout << seq.solve().size() << endl;
    }
    return 0;
}


Measured memory_bytes: 10816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < D; j++ ) {
            cin >> X[i][j];
        }
    }
    set<ll> s;
    for ( int i = 1; i < 200; i++ ) {
        s.insert(i*i);
    }

    ll ans = 0;
    for ( int i1 = 0; i1 < N; i1++ ) {
        for ( int i2 = i1+1; i2 < N; i2++ ) {
            ll d = 0;
            for ( int j = 0; j < D; j++ ) {
                ll a = (X[i1][j] - X[i2][j]);
                d += a*a;
            }
            if ( s.find(d) != s.end() ) {
                ans++;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

vector<int> man;
int a;
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,q;
	cin >> n >> k >> q;
	man.resize(n+1,k);
	int sum = 0;
	rep(i,q){
		cin >> a;
		sum++;
		man[a]++;
	}
	reps(i,n){
		if(man[i] <= sum) cout << "No\n";
		else cout << "Yes\n";
	}
	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	map<int, int> cnt;
	REP(i,n) cnt[a[i]]++;
	int ans = 0;
	for(auto i = begin(cnt); i != end(cnt); i++){
		if(i->second < i->first) ans += i->second;
		else ans += i->second - i->first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <math.h>

int main(void){
	int n;
	double xa, ya, ra, xb, yb, rb;
	double dis;
	int ans;
	int i;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		dis = sqrt(pow((xb - xa), 2) + pow((yb - ya), 2));
		if(ra + rb < dis) ans = 0;
		else if(ra + rb >= dis){
			if(ra > rb && dis < (ra - rb)){
				ans = 2;
			}else if(rb > ra && dis < (rb - ra)){
				ans = -2;
			}else{
				ans = 1;
			}
		}

		printf("%d\n", ans);

	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  REP(i,n) cin >> v[i];
  int abmin = min(n,k);
  ll ans = 0;
  REP(a,abmin+1){
    REP(b,abmin+1-a){
      vector<int> hand;
      REP(i,a) hand.push_back(v[i]);
      for(int i=n-1; i>=n-b; i--) hand.push_back(v[i]);
      if(hand.size()==0) continue;
      sort(ALL(hand));
      int pos = 0;
      int dis = k - (a+b);
      REP(i,dis){
        if(hand[pos]>=0) break;
        pos++;
      }
      ll sum = 0;
      FOR(i,pos,hand.size()) sum += (ll)hand[i];
      ans = max(ans, sum);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int flag = 0;
	if(a == b && b != c) flag = 1;
	if(a == c && a != b) flag = 1;
	if(b == c && a != b) flag = 1;
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }

    cout << n*(n-1)/2 - k << endl;

    for(ll i = 1; i <=n; ++i){
        for(ll j = i+1; j <=n; ++j){
            if(i != 1 && k > 0){
                k--;
                continue;
            }

            cout << i << " " << j << endl;
        }
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL t,a,b,c,d;
inline LL work(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(b>a||b>d)return puts("No"),0;
	LL gcd=__gcd(b,d);
	a%=gcd;
	LL t=c-b+1;
	LL x=a-gcd;
	if(x<t)x+=gcd*((t-x-1)/gcd+1);
	puts(x>=0?"Yes":"No");
}
int main(){
	scanf("%lld",&t);
	while(t--)work();
}

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

n = (x - 1) // 11 * 2
p = 2 if (x - 1) % 11 > 5 else 1

print(n + p)

# def hoge(x): return (x-1)//11 * 2 + (2 if (x-1)%11 > 5 else 1)

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

int main(){
    long A,B,C,K;

    cin >> A >> B >> C >> K;

    long ans;

    if(A>=K){
        //cout << "case a" << endl;
        ans = K;
    }else if( A+B>=K ){
        //cout << "case b" << endl;
        ans = A;
    }else{
        //cout << "case c" << endl;
        ans = A-(K-A-B);
    }

    cout << ans << endl;

    return 0;
}

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

bool prime[60000];

void func(){
    fill(prime,prime+60000,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<60000;i++){
        if(prime[i]){
            for(int j=i*2;j<60000;j+=i){
                prime[j]=0;
            }
        }
    }
}

int main() {
    func();
    int n,i=0;
    while(cin>>n){
        for(i=n-1;prime[i]!=1;i--){}
        cout << i << ' ';
        for(i=n+1;prime[i]!=1;i++){}
        cout << i << endl;
    }
	return 0;
}

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

int main()
{
  int hand[5];

  for(;cin>>hand[0],hand[0];)
    {
      int ans[5]={3,3,3,3,3};
      bool check[4]={false,false,false,false};
        check[hand[0]]=true;
      for(int i=1;i<5;i++)
	{
	  cin>>hand[i];
	  check[hand[i]]=true;
	}
      //      for(int i=1;i<4;i++)
      //	cout<<check[i]<<endl;
      for(int i=0;i<5;i++)
	{
	  if(hand[i]==1)
	    {
	      if(check[2])
		ans[i]=1;
	      if(check[3])
		ans[i]=2;
	    }
	 else if(hand[i]==2)
	    {
	      if(check[3])
		ans[i]=1;
	      if(check[1])
		ans[i]=2;
	    }
	 else if(hand[i]==3)
	    {
	      if(check[1])
		ans[i]=1;
	      if(check[2])
		ans[i]=2;
	    }	  
	}

      for(int i=1;i<4;i++)
	{
	  if(!check[i])
	    {
	      for(int j=0;j<5;j++)
		cout<<ans[j]<<endl;
	      break;
	    }
	  if(i==3)
	    {
	      for(int j=0;j<5;j++)
		cout<<"3"<<endl;
	    }
	}
    }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A[1 << 18];
pair<int, int> zeta[1 << 18];

pair<int, int> update_best(pair<int, int> &a, pair<int, int> &b)
{
	if (a.first < b.first) return update_best(b, a);
	return make_pair(a.first, max(a.second, b.first));
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < (1 << N); ++i) scanf("%d", A + i);

	for (int i = 0; i < (1 << N); ++i) zeta[i] = make_pair(A[i], 0);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < (1 << N); ++j) {
			int k = j | (1 << i);
			if (k != j) zeta[k] = update_best(zeta[j], zeta[k]);
		}
	}

	int ret = 0;
	for (int i = 1; i < (1 << N); ++i) {
		ret = max(ret, zeta[i].first + zeta[i].second);
		printf("%d\n", ret);
	}

	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll H, N;
  cin >> H >> N;
  ll A[N];
  ll sum = 0;
  for(int i=0;i<N;++i) {
    cin >>A[i];
    sum += A[i];
  }
  if(H > sum) cout << "No";
  if(H <= sum) cout << "Yes";
}


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

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

	int N, M;
	string A[50];
	string B[50];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N-M+1; i++) {
		for (int j = 0; j < N-M+1; j++) {
			int s = 1;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (A[i + k][j + l] != B[k][l]) {
						s = 0;
					}
				}
			}
			if (s == 1) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

amountx = x2 - x1
amounty = y2 - y1

x4 = x1 - amounty
y4 = y1 + amountx
x3 = x2 - amounty
y3 = y2 + amountx

print(x3, y3, x4, y4)


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

l = []
r = []
for i in range(n):
    lt, rt = map(int,input().split())
    l.append(lt)
    r.append(rt)

l.append(0)
r.append(0)

l.sort()
r.sort()
l.reverse()

ans = 0
i = 0
while r[i]<l[i]:
    ans += 2*(l[i] - r[i])
    i+=1

print(ans)


Measured memory_bytes: 11512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;
long long int mode=0;
string s,t;
bool hikaku(string str1,string str2){
    for(int i=0;i<str1.length();i++){
        if(str1[i]=='?'||str1[i]==str2[i]){

        }else{
            return false;
        }
    }
    return true;
}

int main() {
	cout << fixed << setprecision(18);
    cin>>s>>t;
    for(int i=s.length()-t.length();i>=0;i--){
        //cout<<s.substr(i,t.length())<<endl;;
        if(mode==0&&hikaku(s.substr(i,t.length()),t)){
            for(int j=0;j<t.length();j++){
                s[i+j]=t[j];
            }
            mode=1;
        }
    }
    for(int i=s.length();i>=0;i--){
        if(s[i]=='?'){
            s[i]='a';
        }
    }
    if(mode==0){cout<<"UNRESTORABLE";}
    else{cout<<s;}


} 


Measured memory_bytes: 256