akhauriyash/Code-Regression huggingface dataset:
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}



vector<ll>adj[Max+10];



ll dp[Max+10];

void dfs(ll s,ll p)
{

    dp[s]+=dp[p];


    for(auto x : adj[s])
    {
        if(x!=p)
        {
            dfs(x,s);
        }
    }
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>q;


      for(i=0; i<n-1; i++)
      {
          cin>>a>>b;

          adj[a].eb(b);

          adj[b].eb(a);
      }

      for(i=0; i<q; i++)
      {
          cin>>a>>b;

          dp[a]+=b;
      }

      dfs(1,0);

      for(i=1; i<=n; i++)
        cout<<dp[i]<<" ";

      cout<<endl;












}



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

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

    vector<int> a(n);
    for(auto &x: a) cin >> x;
    sort(a.begin(), a.end());

    vector<bool> eaten(n);
    eaten[n-1] = true;
    {
        long r = 0;
        for(int i=0; i<n-1; i++) {
            r += a[i];
            eaten[i] = a[i+1] <= 2*r;
        }
    }

    for(int i=n-2; i>=0; i--) {
        eaten[i] = eaten[i] & eaten[i+1];
    }

    long res = 0;
    for(int i=0; i<n; i++) res += eaten[i];

    cout << res << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;  
int main(){
     int A,B,C;
     cin>>A>>B>>C;
     if(B==C && A != B ){
          cout<<A;
     }
     else if( A==C && B != A ){
          cout<<B;
     }
     else if(A==B && C!=A){
          cout<<C;
     }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String O = scanner.next();
        String E = scanner.next();


        for(int i=0; i<O.length(); i++){
            System.out.print(O.charAt(i));
            if(i < E.length()){
                System.out.print(E.charAt(i));
            }
        }

        System.out.println();
    }

    static List<Integer> primeList(int n) {
        List<Integer> list = new ArrayList<>();
        boolean[] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < Math.sqrt(n); i++) {
            if (!prime[i]) continue;
            for (int j = 2; i * j <= n; j++) {
                prime[i * j] = false;
            }
        }
        for (int i = 0; i < prime.length; i++) {
            if (prime[i]) list.add(i);
        }

        return list;
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    string s;cin>>s;
    if(s=="SUN")cout<<7<<endl;
    if(s=="MON")cout<<6<<endl;
    if(s=="TUE")cout<<5<<endl;
    if(s=="WED")cout<<4<<endl;
    if(s=="THU")cout<<3<<endl;
    if(s=="FRI")cout<<2<<endl;
    if(s=="SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int t, h, w, n, i, j, k, l, x, y, d, dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
	char field[20][21], c, dir[5] = {"^>v<"};
	scanf("%d",&t);
	for(i = 0;i < t;i++){
		scanf("%d%d%*c",&h,&w);
		for(j = 0;j < h;j++){
			for(k = 0;k < w;k++){
				field[j][k] = getchar();
				for(l = 0;l < 4;l++){
					if(dir[l] == field[j][k]){
						y = j, x = k;
						d = l;
						field[j][k] = '.';
					}
				}
			}
			field[j][k] = '\0';
			getchar();
		}
		scanf("%d%*c",&n);
		for(k = 0;k < n;k++){
			c = getchar();
			if(c == 'U'){
				if(y - 1 >= 0 && field[y - 1][x] == '.')
					y--;
				d = 0;
			}
			else if(c == 'D'){
				if(y + 1 < h && field[y + 1][x] == '.')
					y++;
				d = 2;
			}
			else if(c == 'L'){
				if(x - 1 >= 0 && field[y][x - 1] == '.')
					x--;
				d = 3;
			}
			else if(c == 'R'){
				if(x + 1 < w && field[y][x + 1] == '.')
					x++;
				d = 1;
			}
			else if(c == 'S'){
				for(j = 1;y + dy[d] * j >= 0 && y + dy[d] * j < h && x + dx[d] * j >= 0 && x + dx[d] * j < w && (field[y + dy[d] * j][x + dx[d] * j] == '.' || field[y + dy[d] * j][x + dx[d] * j] == '-');j++);
				if(y + dy[d] * j >= 0 && y + dy[d] * j < h && x + dx[d] * j >= 0 && x + dx[d] * j < w && field[y + dy[d] * j][x + dx[d] * j] == '*')
					field[y + dy[d] * j][x + dx[d] * j] = '.';
			}
		}
		field[y][x] = dir[d];
		for(j = 0;j < h;j++)
			puts(field[j]);
		if(i != t - 1)
			printf("\n");
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[210], ans = 0;
  rep(i, n) cin >> a[i];

  while(true) {
    bool exist_odd = false;
    rep(i, n) {
      if( a[i] % 2 != 0 ) exist_odd = true;
    }

    if(exist_odd == true) break;

    rep(i, n) a[i] /= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	float A;
	cin >> A;

	float count_odd = 0;
	for (int i = 1; i <= A; i++) {
		if (i % 2 == 1) {
			count_odd++;
		}
	}

	float ans = count_odd / A;

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		List<Integer> arr = new ArrayList<>();

		
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			arr.add(d);
            }
			int N2 = 0;
			
			for (Integer integer : arr){
				N2 ^= integer;				
				}
				List<Integer> arr2 = new ArrayList<>();
				
				for (Integer integer : arr){
				System.out.print((integer^N2) +" ");				
				}
			
			
		}
}

Measured memory_bytes: 66348
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return float('inf')
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+L[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+L[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))

Measured memory_bytes: 45404
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<string> as(n), bs(m);
    for(int i=0; i<n; ++i) cin >> as[i];
    for(int i=0; i<m; ++i) cin >> bs[i];
    bool ans=false;
    for(int ay=0; ay<n-m+1; ++ay){
        for(int ax=0; ax<n-m+1; ++ax){
            bool found=true;
            for(int by=0; by<m; ++by){
                for(int bx=0; bx<m; ++bx){
                    if(as[ay+by][ax+bx]!=bs[by][bx]){
                        found=false;
                        break;
                    }
                }
            }
            if(found){
                ans=true;
                goto end;
            }
        }
    }
end:
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll a(n), b(100000, 0);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }

  priority_queue<ll> c;
  c.push(b[0]);
  c.push(b[0] + b[1]);
  c.push(b[99998] + b[99999]);
  c.push(b[99999]);
  for (ll i = 0; i < 99998; i++) {
    c.push(b[i] + b[i + 1] + b[i + 2]);
  }
  cout << c.top() << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n;
    long long d;
    int count = 0;
    long long a, b;

    cin >> n >> d;

    d *= d;

    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (a * a + b * b <= d)
        {
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 3580
n=int(input())
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
rem=(a%n)
left=n-rem
if b>=(left+a) :
    print("OK")
elif a%n ==0 or b%n==0:
    print("OK")
else :
    print("NG")

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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 1e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

int main() {
    //IO();
    ll n = read();
    if(n >= 30) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define ll long long
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
using namespace std;
// int ans=0;

// int dp(int b[],int n)
// {
//     if(n==0) return b[0];
//     else {ans+=min(abs(b[n-1]-dp(b,n-1)),abs(b[n-1]-dp(b,n-2))); cout<<ans<<endl;return ans;}
// }

int dp1(int a[], int n)
{
    int ans[n+1];
    ans[0]=0;
    ans[1]=abs(a[1]-a[0]);
    if(n==2) return(ans[1]);
    loop(i,2,n)
    {
        ans[i]=min(ans[i-1]+abs(a[i]-a[i-1]),ans[i-2]+abs(a[i]-a[i-2]));
    }
    
    return ans[n-1];
}

int32_t main()
{
   int t=1;
   //cin>>t;
   while(t--)
   {
        int n;
        cin>>n;
        int a[n+1];
        loop(i,0,n) cin>>a[i];
        cout<<dp1(a,n)<<endl;
   }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);
const ll MAX_N = 3000010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll k;
    string s;
    cin >> k >> s;
    ll n = s.size();

    init();
    
    ll ans = 0;
    exrep(i, n, n+k) {
        ans += ((modpow(25, i-n) * modpow(26, n+k-i))%mod * Comb(i-1, n-1))%mod;
        ans %= mod;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 74648
using System;
using System.Collections.Generic;

public class Grading
{
    //-1????¬??????¨????????????????????°??????????????????????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        List<string> studentPointList = new List<string>();
        string[] studentPointBuffer;
        int[] studentPoint = new int[3];
        int studentCount;

        /*---??£?¨???¨---*/

        /*??\???????????????????¨??????????????¨???????????¨????????????????????????? ??¨???-1???????????????*/
        for (studentCount = 0; ; studentCount++) {
            studentPointList.Add(Console.ReadLine());
            if (studentPointList[studentCount] == "-1 -1 -1")
                break;
        }

        /*????????????????????????????????????---------------------------------------
           ??????????¨??????????????¨????????????????????¬????????????´???????????? F???
           ??????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A ???
           ??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B???
           ??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C???
           ??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D??? ???????????????????¨?????????°??? 50 ??\???????????°????????? C???
           ??????????¨???¨??????????¨????????¨??????°??? 30 ??????????????°????????? F???
        ----------------------------------------------------------------- */

        for (int pointIndex = 0; pointIndex < studentCount; pointIndex++)
        {
            studentPointBuffer = studentPointList[pointIndex].Split();
            studentPoint[0] = int.Parse(studentPointBuffer[0]);
            studentPoint[1] = int.Parse(studentPointBuffer[1]);
            studentPoint[2] = int.Parse(studentPointBuffer[2]);
            if (studentPoint[0] != -1 && studentPoint[1] != -1)
            {
                if (studentPoint[0] + studentPoint[1] >= 80)
                {
                    Console.WriteLine("A");
                }
                else if (studentPoint[0] + studentPoint[1] >= 65)
                {
                    Console.WriteLine("B");
                }
                else if (studentPoint[0] + studentPoint[1] >= 50)
                {
                    Console.WriteLine("C");
                }
                else if (studentPoint[0] + studentPoint[1] >= 30)
                {
                    if (studentPoint[2] >= 50) { 
                        Console.WriteLine("C");
                    }
                    else
                    {
                        Console.WriteLine("D");
                    }
                }
                else
                {
                    Console.WriteLine("F");
                }
            }
            else
            {
                Console.WriteLine("F");
            }
        }
    }
}

Measured memory_bytes: 8956
<?php
$N = trim(fgets(STDIN));
$W = explode(" ", trim(fgets(STDIN)));
$sum = array_sum($W);
$S1  = 0;
$mini = $sum;
for ($i = 0; $i < $N; $i++) {
  $S1 += $W[$i];
  $mini = min($mini, abs(($sum - $S1) - $S1));
}
echo $mini."\n";
?>

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

b = ["#"] * n

li = list(input().split())

if n % 2 == 0:
    for i in range(n):
        if i == 0:
            s = (n//2)
        b[s] = li[i]

        if i != n-1:
            if i % 2 == 0:
                s = s-i-1
            else:
                s = s+i+1
else:
    for i in range(n):
        if i == 0:
            s = n//2
        b[s] = li[i]
        
        if i != n-1:
            if i % 2 == 0:
                s = s+i+1
            else:
                s = s-i-1

        
print(*b)
    

Measured memory_bytes: 25028
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	ll H, W, ch, cw, dh, dw;
	cin >> H >> W;
	cin >> ch >> cw;
	cin >> dh >> dw;
	vs S(H);
	rep(i, H) cin >> S[i];
	ll dir[] = {1, 0, -1, 0, 1};
	
	deque<pair<ll, ll>> q;
	vector<vector<ll>> dp(H, vector<ll>(W, INF));
	dp[ch - 1][cw - 1] = 0;
	q.push_back({ch - 1, cw - 1});
	ll x, y, nx, ny;

	while(!q.empty()){

		x = q.front().first;
		y = q.front().second;
		q.pop_front();
		
		rep(i, 4){
			ny = y + dir[i];
			nx = x + dir[i + 1];
			if(ny < 0 || nx < 0 || nx >= H || ny >= W) continue;
			if(S[nx][ny] == '#') continue;
			if(dp[nx][ny] > dp[x][y]) {
				dp[nx][ny] = dp[x][y];
				q.push_front({nx, ny});
			}
		}
		
		rep2(i, -2, 3){
			rep2(j, -2, 3){
				nx = x + i;
				ny = y + j;
				if(ny < 0 || nx < 0 || nx >= H || ny >= W) continue;
				if(S[nx][ny] == '#') continue;
				if(dp[nx][ny] > dp[x][y] + 1){
					dp[nx][ny] = dp[x][y] + 1;
					q.push_back({nx, ny});
				}
			}
		}
	}

	ll ans = dp[dh - 1][dw - 1];
	if(ans == INF) print(-1);
	else print(ans);	
}	

int main(){
	
	fastio;
	solve();
    
	return 0;
	
}


Measured memory_bytes: 12748
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,c=0;
  cin >> n;
  rep(i,500000){
    c+=i;
    if(c>=n){
      printf("%lld",i);
      break;
    }
  }
}

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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i = 0; i < q; i++){
    cin >> a.at(i);
  }	//input
  
  for(int i = 0; i < q; i++){
    a.at(i)--;
  }	//0-index
  
  vector<int> imos(n, 0);
  for(int i = 0; i < q; i++){
    imos.at(0)--;
    imos.at(a.at(i))++;
    if(a.at(i)+1 < n) imos.at(a.at(i)+1)--;
  }		
  for(int i = 1; i < n; i++){
     imos.at(i) += imos.at(i-1);
     //cout << imos[i] << endl;
  }	//imos method
  
  for(int i = 0; i < n; i ++){
    if(imos.at(i) <= -k){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }

}
  
  
  

Measured memory_bytes: 4060
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define maxn 55
#define maxm 7000
#define ll long long
using namespace std;
ll gcd(int x,int y)
{
    if(x%y==0)return y;
    else gcd(y,x%y);
}
int main()
{
    ll n,m;
    int s1[100010];
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        int flag=0;
        for(int a=1; a<=n; a++)
        {
            scanf("%lld",&s1[a]);
            if(s1[a]==1||s1[a]==m)flag=1;
        }
        sort(s1+1,s1+n+1);
        if(s1[n]<m)
        {
            printf("IMPOSSIBLE\n");
            continue;
        }
        if(flag==1)
        {
            printf("POSSIBLE\n");
            continue;
        }

        int num=s1[1];
        for(int a=2; a<=n; a++)
        {
            ll temp=gcd(s1[a],num);
            if(temp<=s1[a]&&m%temp==0)
            {
                flag=1;
                break;
            }
            num=temp;
            if(flag)break;
        }
        if(flag)printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 768
s = input()

i = s[0:2]
j = s[2:4]

yymm_flag = True
mmyy_flag = True

# YYMM
if int(j) > 12 or int(j) == 0:
  yymm_flag = False

# MMYY
if int(i) > 12 or int(i) == 0:
  mmyy_flag = False

if yymm_flag and mmyy_flag:
  print('AMBIGUOUS')

elif not yymm_flag and not mmyy_flag:
  print('NA')

elif yymm_flag:
  print('YYMM')

elif mmyy_flag:
  print('MMYY')

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

int main(void){
    string s,t,u;
    int a, b;
    cin>>s>>t>>a>>b>>u;
    if(s==u)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
s = input().split()
total = 0
minD = 0
m = []

for i in range(int(s[0])):
    m.insert(i, int(input()))
    total += int(m[i])
    if  minD > int(m[i]) or minD == 0:
        minD = m[i]

A = int(s[1])

A -= total 
ans = int(s[0])

ans += int((A / minD))


print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(t) while(t)
#define INF 0x3f3f3f3f
#define MEM(a,b) memset(a,b,sizeof(a))
#define MAXN 200010
using namespace std;

int main() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    int num=0;
    bool can=false;
    UP(i,0,n+1) {
        UP(j,0,m+1) {
            if(i*m+j*n-2*i*j==k) {
                puts("Yes");
                can=true;
                break;
            }
        }
        if(can) break;
    }
    if(!can) puts("No");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    
    int a = x/500;
    int b = (x%500)/5;
    
    long happy = a*1000 + b*5;

    System.out.println(happy);
    
  }
}

Measured memory_bytes: 35712
S = list(input())
ans = 0
i = 0

if(S[i] == 'R'):
    ans+=1
    i+=1
    if(S[i]=='R'):
        ans+=1
        i+=1
        if(S[i]=='R'):
            ans+=1
elif(S[i+1]=='R'):
    ans+=1
    i+=1
    if(S[i+1]=='R'):
        ans+=1
elif(S[i+2]=='R'):
    ans+=1
        
print(ans)

Measured memory_bytes: 9004
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


long long int wt[101],v[101];
long long int mx = 1000*100 +1;
long long int dp[101][100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   //	freopen("input.txt","r",stdin);
   //	freopen("output.txt","w",stdout);
	int n,w;
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>v[i];
	}
	for(int j=1;j<=mx;j++)
	{
		dp[n][j] = INF;
	}
	long long int ans=0,wet=INF;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<=mx;j++)
		{
			dp[i][j] = dp[i+1][j];
			if(j>=v[i])
			{
				dp[i][j] = min(dp[i][j], dp[i+1][j-v[i]]+wt[i]);
			}
			if(dp[i][j] <= w)
			{
				ans = max(ans,(long long int)j);
			}
		}	
	}
	cout<<ans<<endl;
	return 0 ;
}

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

#define N 131072

typedef struct {
  char suit;
  int num;
} card_t;

card_t A[N], C[N];

void swap(char *x, char *y, int *p, int *q) {
  char tmpc;
  int tmpi;

  tmpc = *x;
  *x = *y;
  *y = tmpc;

  tmpi = *p;
  *p = *q;
  *q = tmpi;
}

int partition(int p, int r) {
  int i, j, x;

  x = A[r].num;
  i = p - 1;
  for (j = p; j < r; j++) {
    if (A[j].num <= x) {
      i++;
      swap(&A[i].suit, &A[j].suit, &A[i].num, &A[j].num);
    }
  }
  swap(&A[i + 1].suit, &A[r].suit, &A[i + 1].num, &A[r].num);
  return i + 1;
}

void quickSort(int p, int r) {
  int q;
  
  if (p < r) {
    q = partition(p, r);
    quickSort(p, q - 1);
    quickSort(q + 1, r);
  }
}

int isStable(int n) {
  int i, j, stabFlg = 1;
  
  for (i = 0; i < n; i++) {
    if (A[i].num == A[i + 1].num) {
      for (j = 0; j < n; j++) {
	if (A[i].num == C[j].num) {
	  if (A[i].suit != C[j].suit) {
	    stabFlg = 0;
	    return stabFlg;
	  }
	  else {
	    if (A[i].num != A[i + 1].num)
	      break;
	    i++;
	  }
	}
      }
    }
  }
  return stabFlg;
}

int main(void) {
  int i, n;

  memset(A, 0, sizeof(A));
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf(" %c %d", &A[i].suit, &A[i].num);
  memcpy(C, A, sizeof(A));

  quickSort(0, n - 1);
  if (isStable(n))
    printf("Stable\n");
  else
    printf("Not stable\n");
  
  for (i = 0; i < n; i++)
    printf("%c %d\n", A[i].suit, A[i].num);

  return 0;
}

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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    int x,n;
    cin>>x>>n;
    vi a(n);
    loop(i,0,n) cin>>a[i];
    bool visited[105];
    mset(visited,0);
    loop(i,0,n){
        visited[a[i]] = 1;
    }
    int num = 0;
    rloop(i,x,0){
        if(!visited[i]){
            num = i;
            break;
        }
    }
    loop(i,x+1,102){
        if(!visited[i]){
            if(abs(num-x)>abs(i-x)){
                num = i;
                break;
            }
        }
    }
    cout<<num<<endl;

}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <exception>

using namespace std;

int table[100][100];
int memo[100][100];

int w, h;
int xs, ys, xg, yg;
int n;

void solve(int xs, int ys, int c)
{
	if( memo[xs][ys] ) {
		return;
	}

	if( !( 0 < xs && xs < w+1 && 0 < ys && ys < h+1 && table[xs][ys] == c ) ) {
		memo[xs][ys] = 1;
		return;
	}
	
	if( xs == xg && ys == yg ) {
		memo[xs][ys] = 1;
		throw string("OK");
	}

	memo[xs][ys] = 1;	

	solve(xs+1, ys, c);
	solve(xs, ys+1, c);	
	solve(xs-1, ys, c);
	solve(xs, ys-1, c);

	return;
}

int main(int argc, char* argv[])
{
	while(1) {

		for( int i = 0; i < 100; i++ ) {
			for( int j = 0; j < 100; j++ ) {
				table[i][j] = 0;
				memo[i][j] = 0;
			}
		}		

		cin >> w >> h;

		if( w == 0 && h == 0 )
			break;
			
		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;

		for( int i = 0; i < n; i++ ) {

			int c; cin >> c;
			int d; cin >> d;
			int x, y; cin >> x >> y;

			table[x][y] = c;
			table[x][y+1] = c;
			table[x+1][y] = c;
			table[x+1][y+1] = c;

			if( d == 0 ) {

				table[x+2][y] = c;
				table[x+2][y+1] = c;
				table[x+3][y] = c;
				table[x+3][y+1] = c;																

			} else {

				table[x][y+2] = c;
				table[x+1][y+2] = c;
				table[x][y+3] = c;
				table[x+1][y+3] = c;								
			}
		}

		try {
			if( table[xs][ys] )
				solve(xs, ys, table[xs][ys]);
			cout << "NG" << endl;
		} catch(string& msg) {
			cout << msg << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 3184
def SCC_Tarjan(g):
    def dfs(v):
        nonlocal idx
        pre[v] = low[v] = idx
        idx += 1
        S.append(v)
        #onS[v] = 1
        for c in g[v]:
            if pre[c] == -1: 
                dfs(c)
                low[v] = min(low[v], low[c])
            #elif onS[c]:
            else:
                low[v] = min(low[v], pre[c])

        if low[v] == pre[v]:
            cc = []
            while True:
                w = S.pop()
                #onS[w] = 0
                pre[w] = n
                cc.append(w)
                if w==v: break
            scc.append(cc)


    n = len(g)
    pre = [-1]*n # 負なら未処理、[0,n) ならpre-order, n ならvisited
    low = [0]*n
    onS = [0]*n
    idx = 0
    S = []
    scc = []
    for i in range(n):
        if pre[i] == -1:
            dfs(i)
    
    #print(g)    
    #print("idx",pre)
    #print("low",low)
    #print(scc)
        
    return scc

###########################################################################                        
###########################################################################                        

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10**6)
#n,*w = [int(i) for i in read().split()]

n,m = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int, readline().split())
    g[a].append(b)

gp = SCC_Tarjan(g)
print(len(gp))
for lst in gp[::-1]:
    print(*([len(lst)]+lst))


Measured memory_bytes: 232608
#include <stdio.h>

#define WIDTH 12
#define HEIGHT 12

void del( int, int );

char field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int x, y, island;

	while ( ungetc( getchar(), stdin ) != EOF ) {
		for ( y = 0; y < HEIGHT; y++ )
			for ( x = 0; x < WIDTH; x++ )
				scanf( "%c ", field[ x ] + y );

		island = 0;
		for ( x = 0; x < WIDTH; x++ )
			for ( y = 0; y < HEIGHT; y++ )
				if ( field[ x ][ y ] == '1' ) {
					del( x, y );
					island++;
				}

		printf( "%d\n", island );
	}

	return 0;
}

void del( int x, int y ) {
	int i;

	field[ x ][ y ] = '0';

	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ] == '1' )
			del( nx, ny );
	}
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    int x, k = 9;
    cin>>x;
    for(int i=400;i<=2000;i+=200)
    {
        if(i > x)
            break;
        --k;
    }
    cout<<k;

    return 0;
}

Measured memory_bytes: 3644
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	inf = 10000000071000000
	sc = bufio.NewScanner(os.Stdin)
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


func main() {
	s := gostring()
	k := goint()
	ans := make([]byte,len(s))
	for i,_ := range s {
		ascii := int(s[i])
		diff := 123 - ascii
		if diff <= k && s[i] != 'a'{
			ans[i] = byte(97)
			k -= diff
		} else {
			ans[i] = s[i]
		}
	}
	n := ((int(ans[len(ans)-1]) - 97 + k) % 26) + 97
	ans[len(ans)-1] = byte(n)
	fmt.Println(string(ans))
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){   
    string s,t;
    cin>>s>>t;
    int a = s.size();
    int b = t.size();
    int arr[a+1][b+1] = { };
    int keep[a+1][b+1] = { };
    for(int i = 1;i<=a;i++){
        for(int j = 1;j<=b;j++){
            int cost = 0;
            if(s[i-1]==t[j-1]){
                cost = 1;
            }
            if(arr[i-1][j]>arr[i][j-1]){
                arr[i][j] = arr[i-1][j];
                keep[i][j] = 1;
            }
            else{
                arr[i][j] = arr[i][j-1];
                keep[i][j] = 2;
            }
            if(arr[i-1][j-1]+cost>arr[i][j]){
                arr[i][j] = arr[i-1][j-1]+cost;
                keep[i][j] = 3;
            }

        }
    }
    /*
    for(int i = 1;i<=a;i++){
        for(int j = 1;j<=b;j++){
            cout<<arr[i][j]<<" ";

        }
        cout<<endl;
    }
    cout<<endl;
    for(int i = 1;i<=a;i++){
        for(int j = 1;j<=b;j++){
            cout<<keep[i][j]<<" ";

        }
        cout<<endl;
    }
    
*/

    string ans = "";
    int i = a;
    int j = b;
    while(i>=0 && j>=0){
        if(keep[i][j]==3){
            ans = s[i-1] + ans;
            i--;j--;        
        }
        else if (keep[i][j]==2){
            j--;
        }
        else{
            i--;
        }        
    }
    cout<<ans;
    
}

















Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  string S;
  int test=0;
  
  for(int i=0; i<N; i++){
  	S = "";
    cin >> S;
    if(S == "Y") test++;
  }
  
  if(test > 0) cout << "Four" << endl;
  else cout << "Three" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double a[3],b[3],dis,m;
    cin >>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
    dis = (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]);
    if(dis>(a[2]+b[2])*(a[2]+b[2])) cout <<"0"<<endl;
    else if(dis<(a[2]-b[2])*(a[2]-b[2])){
      if(a[2]>b[2]) cout <<"2"<<endl;
      else cout <<"-2"<<endl;
    }
    else cout <<"1"<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

/***** type *****/
using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
using ml = boost::multiprecision::cpp_int;

/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
#define nya 10                                   // nya size
/***** for each macro *****/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = Size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

/***** lambda *****/
auto Adjust = [] // add vector or sub vector
(auto b, auto e, auto x)
{ for (auto it = b; it != e; ++it)* it += x; };
auto Bit = [] // long long bit shift
(auto n) { return (1LL << n); };
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoLL = [] // char to long long
(auto c) { return (ll)(c - '0'); };
auto Divc = [] // long double div ceiling
(auto a, auto b) { return ceil((ld)a / (ld)b); };
auto Nya = [] // long long nya size
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = []   // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };
auto VVT = []   // vector<vector<T>> resize 
(auto& vvt, auto ysize, auto xsize)
{ vvt.resize(ysize); each(i, vy, vvt) vy.resize(xsize); };
auto VVVT = []   // vector<vector<vector<T>>> resize 
(auto& vvvt, auto zsize, auto ysize, auto xsize)
{ vvvt.resize(zsize); each(z, vz, vvvt) VVT(vz, ysize, xsize); };
auto InVVT = []  // input vector<vector<T>> (T != struct)
(auto& vvt) { each(y, vy, vvt) each(x, e, vy) cin >> e; };
auto InVVVT = [] // input vector<vector<vector<T>>> (T != struct)
(auto& vvvt) { each(z, vz, vvvt) InVVT(vz); };


int main(void)
{
	ll A, B; cin >> A >> B; A--; B--;
	vt<bool> v(3);

	v[A] = true;
	v[B] = true;

	rep(i, 0, 3)
	{
		if (!v[i]) cout << i + 1;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  int N,M,K;cin >> N >> M >> K;
  bool isok = false;
  repeat(a,N+1){
    repeat(b,M+1){
      isok |= (N-a)*b+a*(M-b)==K;
    }
  }
  cout << (isok? "Yes":"No") << endl;
  return 0;
}


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

using namespace std;
long long x[10000010], y[10000010];
#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 pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n;
   cin >> n;
   cout << (n - 2) * 180 << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 1000000;

long long cnt;
int l;
int A[MAX];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
    for(int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;

        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int n){
    for(int h = 1; ; ){
        if(h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for(int i = G.size()-1; i >= 0; i--){
        insertionSort(A, n, G[i]);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for(int i = G.size()-1; i >= 0; i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }

    printf("\n");
    printf("%d\n", cnt);
    for(int i = 0; i < n; i++) printf("%d\n", A[i]);  
}


Measured memory_bytes: 7156
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    X, Y, A, B, C = mis()
    p = sorted(lmis(), reverse=True)[:X]
    q = sorted(lmis(), reverse=True)[:Y]
    r = lmis()
    print(sum(sorted(p+q+r, reverse=True)[:X+Y]))

main()


Measured memory_bytes: 22504
#include <stdio.h>
#include <math.h>
int main(void) {
	int n;
	int x[100];
	int y[100];
	double max = 0.0;
	double sum=0.0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x[i]);
	for(int i=0;i<n;i++)scanf("%d",&y[i]);
	for(int i=0;i<n;i++)sum += fabs((double)(x[i]-y[i]));
	printf("%lf\n",sum);
	sum = 0;
	for(int i=0;i<n;i++)sum += pow(fabs((double)(x[i]-y[i])),2);
	printf("%lf\n",sqrt(sum));
	sum = 0;
	for(int i=0;i<n;i++)sum += pow(fabs((double)(x[i]-y[i])),3);
	printf("%lf\n",cbrt(sum));
	sum = 0;
	for(int i=0;i<n;i++)if(max<fabs(x[i]-y[i]))max = fabs((double)(x[i]-y[i]));
	printf("%lf",max);
	
	return 0;
}


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

ans = 0 

ans += H//2*W

if H % 2 == 0:
  print(ans)
  
elif H == 1 or W == 1:
  print(1)
  
else:
  if W % 2 == 0:
    ans += W//2
    print(ans)
    
  else:
    ans += W//2+1
    print(ans)
  

Measured memory_bytes: 3060
#include<iostream>
#define llu long long unsigned
using namespace std;

llu int a, b, x;

llu int f(llu n, llu x){
    if(n == -1) return 0;
    return (n/x)+1;
}

int main(){
    cin >> a >> b >> x;

    cout << (f(b, x) - f(a-1, x));

    return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

s = input()

ans = []
for i in range(len(s)-2):
    ans.append(abs(753-(int(s[i:i+3]))))
print(min(ans))









Measured memory_bytes: 9144