akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  var count = {
  	'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
  };
  
  input = input.split("\n");
  
  for(i = 1; i <= input[0]; i++){
    switch (input[i]) {
      case 'AC':
        count.AC ++;
        break;
      case 'WA':
        count.WA ++;
        break;
      case 'TLE':
        count.TLE ++;
        break;
      case 'RE':
        count.RE ++;
        break;
    }
  }
  
  console.log('AC x %d', count.AC);
  console.log('WA x %d', count.WA);
  console.log('TLE x %d', count.TLE);
  console.log('RE x %d', count.RE);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	
	int x, a, b; cin>>x>>a>>b;
	cout<<(abs(x - a) < abs(x - b) ? 'A' : 'B')<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    vector<int>A(n,0),B(n-1,0);
    f(i,0,n-1)cin>>B[i];
    A[0]=B[0];
    f(i,1,n)
    {
     A[i]=B[i-1];
     if(A[i-1]>B[i-1])
       {A[i-1]=B[i-1];}
    }
    f(i,0,n)sum+=A[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::collections::HashSet;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let k = v[1];
	let mut set = HashSet::new();
	for i in 0..k {
		let v:Vec<i32> = procon_read();
		let a:Vec<i32> = procon_read();
		for j in a {
			set.insert(j);
		}
	}
	println!("{}", n as usize - set.len());
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a>b)
        cout << "a > b" << endl;
    else if(a<b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
    
    return 0;
}

Measured memory_bytes: 3080
# ABC112C - Pyramid
from operator import itemgetter as gt


def main():
    N, *XYH = map(int, open(0).read().split())
    A = [(x, y, h) for x, y, h in zip(*[iter(XYH)] * 3)]
    A.sort(key=gt(2), reverse=1)
    for x in range(101):
        for y in range(101):
            i, j, k = A[0]
            h = k + abs(i - x) + abs(j - y)
            for i, j, k in A[1:]:
                if k != max(h - abs(i - x) - abs(j - y), 0):
                    break
            else:
                print(x, y, h)
                return


if __name__ == "__main__":
    main()

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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    while(X <= Y) {
        X *= 2;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	char a[1001];
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
		{
			sum++;
		}
	}
	cout<<sum;
}

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

int main(){
  
  int X,Y,A,B,C,Z;
  cin>>X>>Y>>A>>B>>C;
  Z=X+Y;
  long long ans=0;
  long long p[A],q[B],r[C];
  for(int i=0;i<A;i++) cin>>p[i];
  for(int i=0;i<B;i++) cin>>q[i];
  for(int i=0;i<C;i++) cin>>r[i];
  sort(p,p+A);
  reverse(p,p+A);
  sort(q,q+B);
  reverse(q,q+B);
  sort(r,r+C);
  reverse(r,r+C);
  pair<int,int> P[Z];
  for(int i=0;i<X;i++){
  	P[i].first=p[i];
    P[i].second=0;
    ans+=p[i];
  }
  for(int i=0;i<Y;i++){
  	P[i+X].first=q[i];
    P[i+X].second=1;
    ans+=q[i];
  }
  
  sort(P,P+Z);
  int j=0;
  for(int i=0;i<Z;i++){
  	if(P[i].first<r[j]){
      ans-=P[i].first;
      ans+=r[j];
      j++;
    }
    if(j==C) break;
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, W;
    cin >> n >> W;
    vector<int> Weights(n), Values(n);
    for (int i = 0; i < n; i++){
        cin >> Weights[i] >> Values[i];
    }
    int sumValues = accumulate(Values.begin(), Values.end(), 0);
    vector<ll> dp(sumValues + 1, INT32_MAX);
    //DP[item][Val] -> store min weight such that total value is Val

    dp[0] = 0;
    //dp[0][Values[0]] = Weights[0];

    for (int item = 0; item < n; ++item){
        int weight = Weights[item];
        int value = Values[item];
        for (int i = sumValues; i >= value; i--){
            dp[i] = min(dp[i], dp[i - value] + weight);
        }
    }

    int ans = 0;
    for (int i = 1; i <= sumValues; i++){
        if (dp[i] <= W) ans = i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

const int MAX_N = 1300000;
bool prime[MAX_N+1];

void sieve()
{
  fill(prime, prime+MAX_N+1, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; i++)
    if(prime[i])
      for(int j = i*2; j <= MAX_N; j += i)
        prime[j] = false;
}

int main()
{
  sieve();
  while(1){
    int N;
    cin >> N;
    if(N == 0) break;
    if(prime[N]){
      cout << "0" << endl;
      continue;
    }
    int x = N - 1;
    int y = N + 1;
    while(!prime[x])
      x--;
    while(!prime[y])
      y++;
    cout << y - x << endl;
  }
}

Measured memory_bytes: 2428
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
struct Card {
	char alpha,
		number;
};
void printCard(Card card[],int N,string stable)
{
	for (int i = 0; i < N; i++)
	{
		if (i == 0)
		{
			cout << card[i].alpha << card[i].number << flush;
		}else if (i == N - 1)
		{
			cout << " " << card[i].alpha << card[i].number << endl;
		}else
		{
			cout << " " << card[i].alpha << card[i].number << flush;
		}
	}

	cout<< stable<<endl;
}
void stableSort()
{
	
	const int MAX = 36;
	Card forBubble[MAX];
	Card forSelection[MAX];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> forBubble[i].alpha >> forBubble[i].number;
	}

	for (int i = 0; i < N; i++)
	{
		forSelection[i].alpha = forBubble[i].alpha;
		forSelection[i].number = forBubble[i].number;
	}
	//bubble
	for (int i = N - 1; i >= 0;i--)
	{
		for (int j = 0; j < i; j++)
		{
			if (forBubble[j].number > forBubble[j + 1].number)
			{
				Card temp = forBubble[j];
				forBubble[j] = forBubble[j + 1];
				forBubble[j + 1] = temp;
			}
		}
	}

	//selection
	for (int i = 0; i < N; i++)
	{
		int k = i;
		for (int j = i + 1; j < N; j++)
		{
			if (forSelection[k].number > forSelection[j].number)
			{
				k = j;
			}
		}

		if (i != k)
		{
			Card temp = forSelection[i];
			forSelection[i] = forSelection[k];
			forSelection[k] = temp;
		}
	}

	string stable = "Stable";

	printCard(forBubble, N,stable);
	//equls
	for (int i = 0; i < N; i++)
	{
		if (forBubble[i].alpha == forSelection[i].alpha && forBubble[i].number == forSelection[i].number)continue;

		stable = "Not stable";
	}

	printCard(forSelection, N, stable);

	

}

int main()
{
	//maximumProfit();
	//insertionSort();
	//bubbleSort();
	//selectionSort();
	stableSort();
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;

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

int X, Y;

bool map[50][50];
bool passed[50][50][50][50];

struct P
{
    int tx, ty;
    int kx, ky;
    int cost;

    P(int _tx, int _ty, int _kx, int _ky, int _cost) : tx(_tx), ty(_ty), kx(_kx), ky(_ky), cost(_cost) {};
};

bool check(int x, int y)
{
    return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
}

int main()
{
    int tx, ty, kx, ky, ans;
    while(cin >> X >> Y, X|Y)
    {
        ans = -1;
        memset(passed, 0, sizeof passed);
        queue<P> que;

        cin >> tx >> ty >> kx >> ky;
        tx--, ty--, kx--, ky--;

        for(int i = 0; i < Y; i++)
            for(int j = 0; j < X; j++)
                cin >> map[i][j];

        passed[tx][ty][kx][ky] = true;

        for(que.push(P(tx, ty, kx, ky, 0)); !que.empty(); que.pop())
        {
            P p = que.front();

            if(p.cost >= 100)
                break;

            if(p.tx == p.kx && p.ty == p.ky)
            {
                ans = p.cost;
                break;
            }

            for(int i = 0; i < 4; i++)
            {
                int mtx = p.tx + dx[0][i], mty = p.ty + dy[0][i];
                int mkx = p.kx + dx[1][i], mky = p.ky + dy[1][i];

                if(check(mtx, mty))
                    mtx = p.tx, mty = p.ty;
                if(check(mkx, mky))
                    mkx = p.kx, mky = p.ky;
                if(passed[mtx][mty][mkx][mky])
                    continue;

                passed[mtx][mty][mkx][mky] = true;
                que.push(P(mtx, mty, mkx, mky, p.cost + 1));
            }
        }

        if(ans == -1)
            puts("NA");
        else
            cout << ans << endl;
    }
}

Measured memory_bytes: 7536
#include<bits/stdc++.h>
#define MOD (1e9 + 7)
#define fi(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i >= b; i--)
#define vfi(v,i) for(auto i = v.begin(); i != v.end(); i++)
#define vfd(v,i) for(auto i = v.rbegin(); i != v.rend(); i++)
#define vi vector<int>
#define pb push_back

using namespace std;
typedef long long ll;

const int M = 301;
//declaring array globally with maximum size, as otherwise we'll have segmentation error
double dp[M+1][M+1][M+1];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k1 = 0, k2 = 0, k3 = 0, x, n;
	cin>>n;
	fi(i,0,n){
		cin>>x;
		if(x == 1)
			k1++;
		else if(x == 2)
			k2++;
		else
			k3++;
	}

	fi(k, 0, n+1){
		fi(j,0,n-k+1){
			fi(i,0,n-j-k+1){

				/* since the maximum sum can atmost be n, we loop till sum n is reached. We work it in the reverse order; this is 
					because, generally in dp, we may need to access terms like dp[i-1][j+1], but here, we need to look forward ie 
					dp[i+1][j-1][k], so we must start with k and nest inwards  
				*/

				/*
					Math proof:
					
					Let s = a+b+c

					dp[i][j][k]=((n−s)/n)∗(1+dp[i][j][k])+(i/n)∗(1+dp[i-1][j][k])+(j/n)∗(1+dp[i+1][j-1][k])+(k/n)∗(1+dp[i][j+1][k-1]) 
					Rearranging, dp[i][j][k]=(n/s)+(i/s)∗dp[i-1][j][k]+(j/s)∗dp[i+1][j-1][k]+(k/s)∗dp[i][j+1][k-1]

				*/

				if(i == 0 && j == 0 && k == 0 ) {
					continue;
				}

				dp[i][j][k] = 0;
				int s = i+j+k;

				if(i){
					double pi = (1.0 * i)/s;
					dp[i][j][k] += pi*dp[i-1][j][k]; 
				}

				if(j){
					double pj = (1.0 * j)/s;
					dp[i][j][k] += pj*dp[i+1][j-1][k];
				}

				if(k){
					double pk = (1.0 * k)/s;
					dp[i][j][k] += pk*dp[i][j+1][k-1];
				}

				double empty = (1.0 * n)/s;
				dp[i][j][k] += empty;
			}
		}
	}

	cout<<setprecision(14)<<fixed<<dp[k1][k2][k3]<<'\n';

	return 0;
}	

Measured memory_bytes: 215296
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
map<string,int> cnt;
int main()
{
	int n;cin>>n;
	int maxi = 0;
	for(int i=1;i<=n;i++){
		string s;cin>>s;
		cnt[s]++;
		maxi = max(maxi,cnt[s]);
	}
	for(auto x:cnt){
		if(x.second==maxi){
			cout << x.first << endl;
		}
	}
}


Measured memory_bytes: 27008
#include<stdio.h>
int main(void)
{
	int n,k;
	int i,hei;
	long long int max;
	max=0;
	hei=0;
	while(scanf("%d",&n)!=EOF){
		for(i=0;i<n;i++){
			scanf("%d",&k);
			max+=k;
		}
		hei=max/n;
		printf("%d\n",hei);
	}
	return 0;
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class ABC167C
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int n = int.Parse(str1[0]);
            int m = int.Parse(str1[1]);
            int x = int.Parse(str1[2]);
            int[] c = new int[n];
            int[,] a = new int[n,m];
            int minc = 10000000;
            for(int i = 0; i < n; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                c[i] = int.Parse(str2[0]);
                for(int j = 0; j < m; j++)
                {
                    a[i,j] = int.Parse(str2[j+1]);
                }
            }
            for(int bit = 0; bit < (1<<n); bit++)
            {
                int totalc = 0;
                int[] totala = new int[m];
                int flag = 1;
                for(int i = 0; i < n; i++)
                {
                    if((bit & (1<<i)) > 0)
                    {
                        totalc += c[i];
                        for(int j = 0; j < m; j++)
                        {
                            totala[j] += a[i,j];
                        }
                    }
                }
                for(int i = 0; i < m; i++)
                {
                    if(totala[i]<x)
                    {
                        flag = 0;
                    }
                }
                if(flag==1 && totalc < minc)
                {
                    minc = totalc;
                }
            }
            if(minc == 10000000)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(minc);
            }
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ull i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull A,B,K;		cin>>A>>B>>K;
	if(A>=K)	A-=K;
  	else if(A+B<=K){
      A=0;
      B=0;
    }
  else{
    B=B-K+A;
  	A=0;
  }
	cout<<A<<" "<<B<<endl;
	
    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    map<int, int> mp;
    rep(i, n) ++mp[a[i]];
    
    ll ans = 0;
    for (auto e : mp) ans += 1LL * e.S * (e.S - 1);
    
    rep(i, n) {
        cout << (ans - 1LL * mp[a[i]] * (mp[a[i]] - 1) + max(0LL, 1LL * (mp[a[i]] - 1) * (mp[a[i]] - 2))) / 2 << endl;
    }
}


Measured memory_bytes: 10012
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[200010];
set<int> s;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",a+i);
    }
    for(int i=0;i<n;i++)
    {
        if(s.count(a[i]))
        {
            printf("NO");
            return 0;
        }
        s.insert(a[i]);
    }
    printf("YES");
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if (judge(s, 0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	public static boolean judge(String s, int i) {
		if (i == s.length()) {
			return true;
		}
		
		boolean f = false;
		
		if (s.length() >= i + 7 && s.substring(i, i + 7).equals("dreamer")) {
			f |= judge(s, i + 7);
		} 
		if (s.length() >= i + 5 && s.substring(i, i + 5).equals("dream")) {
			f |= judge(s, i + 5);
		} 
		if (s.length() >= i + 6 && s.substring(i, i + 6).equals("eraser")) {
			f |= judge(s, i + 6);
		} 
		if (s.length() >= i + 5 && s.substring(i, i + 5).equals("erase")) {
			f |= judge(s, i + 5);
		} 
		
		return f;
	}
}

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

int main() {
 
  string S,T ;
  cin >>S>>T ;
  int ans;
  ans = 0;
  if(S.at(0)==T.at(0)){
    ans ++;
  }
   if(S.at(1)==T.at(1)){
    ans ++;
  }
   if(S.at(2)==T.at(2)){
    ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/wjex/cp/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


void solve(){
	int a , b , c , k; 
	re(a,b,c,k);
	int i = 0 ; 
	if(a>=k) cout << k << endl ;
	else{
		int sm = a; 
		k-=a;
		if(k) k-=b;
		if(k)sm-=k;
		cout << sm << endl;
	}
}
	

signed main() {
	unsyncIO();
	int tt =1 ;
	//cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main()
{
    int n, count = 0, i, j, x;
    cin >> n;
    int arr[n];
    for(i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=n-1; j>i; j--)
        {
            if(arr[i] > arr[j])
            {
                x = arr[i];
                arr[i] = arr[j];
                arr[j] = x;
                count++;
            }
        }
    }
    if(count <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int a,b,c;
    int tmpA,tmpB,tmpC;
    int ans = 0;
    cin >> a >> b >> c;
    if(!(a%2 == 0 && b%2 == 0 && c%2 == 0)){
        cout << 0;
    }else {
        while (!(a == b && b == c) && (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)) {
            ans++;
            tmpA = a;
            tmpB = b;
            tmpC = c;
            a = tmpB / 2 + tmpC / 2;
            b = tmpC / 2 + tmpA / 2;
            c = tmpA / 2 + tmpB / 2;
        }
        if (a == b && b == c) cout << -1;
        else cout << ans;
    }


    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll n;cin>>n;
            ll arr[n];
            for(ll i=0;i<n;i++)cin>>arr[i];
            ll mx =arr[0],ans=0;
            for(ll i=1;i<n;i++)
            {
                mx = max(mx,arr[i]);
                ans += mx-arr[i];
            }
            cout<<ans<<endl;
        }
    }

Measured memory_bytes: 5128
def resolve():
    import copy
    n = int(input())
    x = input()
    ones = x.count("1")
    dones = ones - 1
    iones = ones + 1

    def counter(n):
        ans = 0
        while n > 0:
            n = n % bin(n).count("1")
            ans  += 1
        return(ans)

    modd = 0

    modi = 0
    for i in reversed(range(n)):
        if x[i] == "1":
            if dones != 0:
                modd += pow(2,n-i-1,dones)
            modi += pow(2,n-i-1,iones)

    for i in range(n):
        ans = 0
        if x[i] == "0":
            w = (modi + pow(2,n-i-1, iones))%iones
            ans += 1
            print(ans + counter(w))

        else:
            if dones == 0:
                print(0)
                continue
            else:
                w = (modd-pow(2,n-i-1, dones) + dones)%dones
                ans += 1
                print(ans + counter(w))
resolve()

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;
    double n, m, d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(20);

    double p;
    if(d <= 1e-9) p = 1.0/n;
    else p = (2.0 * (n - d))/ (n * n);

    cout << (m - 1.0) * p << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.flt", "r", stdin );
	int z;

	while (cin >> z && z ){
		int x, y;
		long long z3 = (long long)(z*z*z);
		long long res = 0LL;
		for (x = 1; x < z; ++x ){
			for (y = 1; y < z; ++y ){
				long long z0 = (long long)(x*x*x + y*y*y);
				if (z0 <= z3 ){
					res = max (res, z0);
				} // end if
			} // end for
		} // end for
		cout << (z3 - res ) << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 868
let pair_of_list list = match list with
    first :: second :: [] -> (first, second)
  | _ -> failwith "Elements are less than two";;

let comparizon (a, b) =
  if a < b then "a < b"
  else if a > b then "a > b"
  else "a == b";;

read_line()
|> Str.split (Str.regexp " ")
|> List.map int_of_string
|> pair_of_list
|> comparizon
|> print_endline



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = 0;
    if (a >= c) {
        ans = ((d > b) ? b : d) - a;
    } else {
        ans = ((d > b) ? b : d) - c;
    }
    cout << ((ans > 0) ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    ll delta=b-a;
    rep(i,n){
        ll up=i,down=n-1-i;
        if(up*c-down*d<=delta&&delta<=up*d-down*c){
            cout << "YES" << endl;
        	return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++)
    {
        string s1 = to_string(i);
        string s2 = s1;
        reverse(s2.begin(), s2.end());
        if (s1 == s2) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {


		String[] S=toStringArray(nextString());

		long ans =0;
		int a=-1;
		int z=0;
		for(int i=0;i<S.length;i++){
			if(a==-1&&"A".equals(S[i])){
				a=i;
			}
			if("Z".equals(S[i])){
				z=i;
			}
		}

		System.out.println(z-a+1);
	}




	public static String[] toStringArray(String s){
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for(int i=0;i<tmp.length;i++){
			tmp[i]=String.valueOf(c[i]);
		}
		return tmp;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 35760
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

l=LIST()

l.sort()
print(sum(l[:2]))


Measured memory_bytes: 3064
subroutine heapsort(n,array)
    implicit none
    integer,intent(in) :: n
    integer,intent(inout) :: array(1:n)
    
    integer ::i,k,j,l
    integer :: t
    
    if(n.le.0)then
       write(6,*)"Error, at heapsort"; stop
    endif
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
  end subroutine heapsort

program main
    integer N, diff
    integer, allocatable :: a(:)

    read(*,*) N
    allocate(a(N))
    read(*,*) a(:)

    call heapsort(N,a)

    diff=0
    do i=1,N
        if(mod(i,2)/=0)then
            diff = diff + a(N-i+1)
        else
            diff = diff - a(N-i+1)
        endif
    enddo

    write(*,*) diff
    
end program

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
  ll x,k,d;cin >> x >> k >> d;
  x = abs(x);
  ll a = x/d;
  ll ans = x % d;
  if(k < a) cout << x - k*d << endl;
  else {
    if(k%2 == 0) {
      if(a%2 == 0) cout << ans << endl;
      else cout << d - ans << endl;
    }else {
      if(a%2 == 1) cout << ans << endl;
      else cout << d - ans << endl;
    }
  }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
typedef long long LL;
const LL P = 1e9+7;
const int N = 2e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k,a[N],l[N],r[N],tr[N],con[N];

void add(int x,int val){for(;x<=n+1;x+=x&-x)tr[x]+=val;}
int get(int x){int res=0;for(;x;x-=x&-x)res+=tr[x];return res;}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n)scanf("%d",a+i),++a[i]; 
	r[0] = 0, l[n+1] = n;
	memset(tr,0,sizeof tr);
	rep(i,1,n){
		add(a[i],1);
		if(i>k) add(a[i-k],-1);
		r[i] = get(n+1)==get(a[i]) ? r[i-1] : i;
	}
	memset(tr,0,sizeof tr);
	rrep(i,n,1){
		add(a[i],1);
		if(i+k<=n)add(a[i+k],-1);
		l[i] = get(a[i]-1)==0 ? l[i+1] : i;
	}
	rrep(i,n,1) con[i] = a[i]<a[i+1] ? con[i+1]+1 : 1;
	int ans = n-k+1, j, cnt=0;
	rep(i,1,n+1-k)
		if(con[i]>=k){
			++cnt;
		}else{
			for(j=i+1;j<=n+1-k&&l[j]==l[i]&&r[j+k-1]==r[i+k-1];++j);
			ans -= j-i-1, i=j-1;
		}
	if(cnt>1) ans -= cnt-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
// using ll = long long;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    map<ll, ll> d;
    rep(i, n) {
        ll a;
        cin >> a;
        ll b = a - 1;
        ll c = a + 1;
        if (d[a])
            d[a]++;
        else
            d[a] = 1;

        if (d[b])
            d[b]++;
        else
            d[b] = 1;

        if (d[c])
            d[c]++;
        else
            d[c] = 1;
    }

    ll maxVal = 0;
    for (auto const& x : d) {
        maxVal = max(x.second, maxVal); 
    }

    cout << maxVal << endl;
}

Measured memory_bytes: 9372
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 1000000007LL;
vector<P> ball;
int main() {
	int N;
	cin >> N;
	int Rmin = 1 << 30, Rmax = -(1 << 30);
	int Bmin = 1 << 30, Bmax = -(1 << 30);
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		Rmin = min(Rmin, x);
		Rmax = max(Rmax, x);
		Bmin = min(Bmin, y);
		Bmax = max(Bmax, y);
		ball.emplace_back(x, y);
	}
	LL ans = (LL)(Rmax - Rmin)*(Bmax - Bmin);
	sort(ball.begin(), ball.end());
	int Min = 1 << 30, Max = -(1 << 30);
	int b = 1 << 30;
	for (int i = 0; i + 1 < N; i++) {
		Min = min(Min, ball[i].second);
		Max = max(Max, ball[i].second);
		b = min(b, max(Max, ball[N - 1].first) - min(Min, ball[i + 1].first));
	}
	ans = min(ans, (LL)(max(Rmax, Bmax) - min(Rmin, Bmin))*b);
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    while (1) {
        for (int i = 0; i < n; i++) {
            if (a[i] & 1) {
                cout << ans << endl;
                return 0;
            }
            a[i] /= 2;
            if (i == n - 1) ans++;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll H,W;
queue<pl> que;
ll GridBFS(pl start,pl goal,vector<vector<char>> &info,vvl &now){
    que.emplace(start);
    now[start.fi][start.se]=0;
    while(que.size()){
        ll y=que.front().fi,x=que.front().se;
        que.pop();
        rep(k,4){
            ll ny=y+dy[k],nx=x+dx[k];
            if(0<=ny and ny<H and 0<=nx and nx<W){
                if(info[ny][nx]=='#')continue;
                if(now[ny][nx]>now[y][x]+1){
                    now[ny][nx]=now[y][x]+1;
                    que.emplace(ny,nx);
                }
            }
        }
    }
    return now[goal.fi][goal.se];
}
int main(){
    cin>>H>>W;
    vector<vector<char>> info(H,vector<char>(W));
    ll counth=0;
    rep(i,H)rep(j,W){
        cin>>info[i][j];
        if(info[i][j]=='.')counth++;
    }
    pl start={0,0},goal={H-1,W-1};
    vvl now(H,vl(W,INF));
    ll k=GridBFS(start,goal,info,now);
    if(k==INF)cout<<-1<<endl;
    else cout<<counth-k-1<<endl;
    return 0;
}

Measured memory_bytes: 256
m = 2019
s = 0
i = 1
l=[0]*m

for c in reversed(input()):
    s = (s + int(c)* i)%m
    l[s] +=1
    i = (i*10)%m
    
print(l[0] + sum(v*(v-1)//2 for v in l))

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

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

	int w, h;
	int x, y, r;
	int mini;

	cin >> w >> h >> x >> y >> r;

	mini = min(x, w - x);
	mini = min(mini, y);
	mini = min(mini, h - y);
	if (mini >= r){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 3148
use proconio::*;

fn run() {
    input! {
        n: usize,
        d: i64,
        p: [(i64, i64); n],
    }
    let ans = p.into_iter().filter(|p| p.0.pow(2) + p.1.pow(2) <= d.pow(2)).count();
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

string a[8];
void dfs(int y, int x) {
  if( y < 0 || 8 <= y || x < 0 || 8 <= x || a[y][x] == '0')return;
  a[y][x] = '0';
  for(int i = -3; i < 4; i++)
    for(int j = -3; j < 4; j++)
      if(i == 0 || j == 0)dfs (y + i, x + j);
}
int main(){
  string s; int n, x, y, i, j = 1;
  cin >> n;
  while(n--) {
    for( i = 0; i < 8; i++) cin >> a[i];
    cin >> x; cin >> y;
    dfs(y - 1, x - 1);
    printf("Data %d:\n", j++);
    for(i = 0; i < 8; i++)
      cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  vector<vi> c(3,vi(3));
  rep(i,3) rep(j,3) cin >> c[i][j];
  rep(i,3){
    int num = *min_element(all(c[i]));
    rep(j,3){
      c[i][j] -= num;
    }
  }
  rep(i,3){
    int num = 0;
    rep(j,3) chmax(num,c[j][i]);
    rep(j,3){
      c[j][i] -= num;
    }
  }
  rep(i,3){
    rep(j,3){
      if(c[i][j] < 0){
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int n=0;
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0&&b%i==0){
		    n++;
		}
		if(n==k){
			cout<<i<<endl;
			return 0;
		}
	}
   return 0;
}


Measured memory_bytes: 256
import math
def main():
  h,w = list(map(int,input().split()))
  a = [input() for i in range(h)]
  ans=0
  i=0
  while i<h:
    if '#' not in a[i] :
      a.pop(i)
      h=h-1
      i-=1
    i+=1
  i=0
  while i<w:
    for j in range(0,h):
      if a[j][i]=='#':
        break
      elif j==h-1:
        for k in range(0,h):
          a[k]=a[k][:i]+a[k][i+1:]
        w-=1
        i-=1
    i+=1
  for i in range(0,h):
    print(a[i])
main()

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

int main(){
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.length()/2;i++){
    if(s[i]!=s[s.length()-i-1])cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
  int e[21];
  int ans=0;
  int a[111];
  memset(a,0,sizeof(a));
  for(int i=0;i<12;i++){
    cin >> e[i];
    a[e[i]-1]++;
  }
  
  for(int i=0;i<100;i++){
    if(a[i]>=4){
      ans+=a[i]/4;
    }
  }
  if(ans == 3){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

int main(void)
{
    int M1, M2, D1, D2;

    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if(M1 != M2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)

s1 = [1]
s2 = []
while s1:
    a = s1.pop()
    s2 += [a]
    for b in win_lose[a]:
        s1 += [b]
memo = [0] * (N + 1)
for x in s2[::-1]:
    if win_lose[x] == set():
        memo[x] = 0
    else:
        memo[x] = max(a + b for a, b in zip(
            sorted(memo[y] for y in win_lose[x])[::-1], range(1, N + 1)))
print(memo[1])


Measured memory_bytes: 53180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  s[3]='8';
  print(s);
  return 0;
}

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

int main(){
    int n;  cin>>n;
    string s[n];    for(int i=0;i<n;i++)cin>>s[i];
    int m;  cin>>m;
    string t[m];    for(int i=0;i<m;i++)cin>>t[i];
    
    int res[n]={0};
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(s[i]==s[j])res[i]++;
        }

        for(int k=0;k<m;k++){
            if(s[i]==t[k])res[i]--;
        }
    }

    //for(int i=0;i<n;i++)cout<<ans[i]<<endl;
    int ans=0;
    for(int i=0;i<n;i++){
        if(res[i]>ans)ans=res[i];
    }

    cout<<ans<<endl;

    return 0;
}


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

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

  valarray<int> p(n);
  for (auto&& e : p) cin >> e;

  queue<int> q;
  int s = 0;

  for (int i = 0; i < n; i++) {
    if (q.size() < size_t(k)) {
      q.push(p[i]);
      s += p[i];
    }
    if (q.size() == size_t(k)) {
      p[i] = s;
      s -= q.front();
      q.pop();
    }
  }

  cout << setprecision(8) << double(p.max() + k) / 2 << endl;
}


Measured memory_bytes: 1792
K = int(input())

mod_ans = 7%K
mod_10 = 10%K
mod_7_10 = 7%K
if 7%K == 0:
    print(1)
else:
    for i in range(int(K**(1/1))):
        mod_7_10 = (mod_7_10 * mod_10)%K
        mod_ans = (mod_ans + mod_7_10)%K
#        print(i+2, mod_ans)
        if mod_ans == 0:
            print(i+2)
            break
    else:
        print(-1)

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

int n, i;
int h [100001];
int A [100001];
int B [100001];
int C [100001];
int a [100001];
int b [100001];
int c [100001];

int main ()
    {
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        scanf ("%d%d%d",&a[i],&b[i],&c[i]);
    for (i=1; i<=n; i++)
        {
        A[i]=max(B[i-1],C[i-1])+a[i];
        B[i]=max(A[i-1],C[i-1])+b[i];
        C[i]=max(A[i-1],B[i-1])+c[i];
        }
    printf ("%d\n",max(max(A[n],B[n]),C[n]));
    return 0;
    }


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N, D;
  cin >> N >> D;
  vector<int> t(N);
  for(int i=0; i<N; i++){
    cin >> t[i];
  }
  ll ans=0;
  for(int i=0; i<N-1; i++){
    if(t[i]+D <= t[i+1]){
      ans += D;
    }else{
      ans += t[i+1]-t[i];
    }
  }
  ans += D;
  cout << ans << endl;
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	double X[10], Y[10];
	cin >> N;
	vector<int> P;
	int F = 1;
	rep(i, 0, N)
	{
		cin >> X[i] >> Y[i];
	}
	rep(i, 0, N)
	{
		P.push_back(i);
		F *= (i + 1);
	}

	double ans = 0.0;
	do
	{
		rep(i, 0, N - 1)
		{
			double dx = X[P[i]] - X[P[i + 1]];
			double dy = Y[P[i]] - Y[P[i + 1]];
			ans += sqrt(dx*dx + dy * dy);
		}
	} while (next_permutation(all(P)));

	cout << fixed << setprecision(10) << ans / F << endl;

	return 0;
}

Measured memory_bytes: 256
program sample
  implicit none
  integer N, L, M, k, i, j, e
  read(*,*) N, L
  M = 0
  do i =1, N
  M = M + L + i - 1
  end do
  if ( abs(L + N - 1) >= abs(L )) then
   k = abs(L + N - 1)
  else
   k  = abs (L)
  endif
  do j = 1, N
   if (  abs( L + j - 1) < k) then
    k = abs( L + j - 1)
    e = j
   endif
  end do
  write(*,*) M - L - e + 1
  stop
end program sample 

Measured memory_bytes: 256