akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

const int INF = 1e9;
struct edge{ int to,cap,rev;
	edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}};

int v,e;
vector<vector<edge> > G; //??°???????????£??\???????????¨???
bool used[1003]; //DFS??§??¢???????????????????????????????????°

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if( !used[e.to] && e.cap > 0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d > 0){
				e.cap -=d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int maxflow(int s, int t){
	int flow = 0;
	for(;;){
		fill(used,used + e,false);
		int f = dfs(s,t,INF);
		if(f == 0)return flow;
		flow += f;
	}
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	cin >> v >> e;
	G.resize(v);
	REP(i,e){
		int from,to,cap;
		cin >> from >> to >> cap;
		G[from].push_back(edge(to,cap,G[to].size()));
		G[to].push_back(edge(from,0,G[from].size() -1));
	}
	cout << maxflow(0,v-1) << endl;
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n, y; cin >> n >> y;
	int a = -1;
	int b = -1;
	int c = -1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(1000*(9*i+4*j+n)==y && (n-i-j)>=0){
				a = i;
				b = j;
				c = n-i-j;
			}
		}
	}
	cout << a << ' ' << b << ' ' << c << ' ' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

#define ld long double

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> gr(n);
    vector<ld> ans(n);
    for (int i = 0, x, y; i < m; i++)
    {
        cin >> x >> y;
        x--, y--;
        gr[x].push_back(y);
    }

    for (int i = n - 2; i >= 0; i--)
    {
        ld sum = 0;
        for (auto each : gr[i])
            sum += ans[each] + 1;
        sum /= gr[i].size();
        ans[i] = sum;
    }

    ld res = ans[0];

    for (int block = 0; block < n - 1; block++)
    {
        if (gr[block].size() == 1) continue;

        ans.clear();
        ans.resize(n);

        for (int i = n - 2; i >= 0; i--)
        {
            ld sum = 0, biggest = 0;
            for (auto each : gr[i])
            {
                sum += ans[each] + 1;
                biggest = max(biggest, ans[each] + 1);
            }

            if (i == block) sum = (sum - biggest) / (gr[i].size() - 1);
            else sum /= gr[i].size();

            ans[i] = sum;
        }

        res = min(res, ans[0]);
    }

    cout << fixed << setprecision(20);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

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

int main()
{
    vector<string> w(8);
    string s;
    cin >> s;
    w[1] = "SAT";
    w[2] = "FRI";
    w[3] = "THU";
    w[4] = "WED";
    w[5] = "TUE";
    w[6] = "MON";
    w[7] = "SUN";
    rep(i, 8)
    {
        if (s == w[i])
            cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll X,Y;
	cin >>  X >> Y;
	if(X<Y) cout << X;
	else if(X%Y==0) cout << -1;
	else if(X>Y) cout << X;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main(){
	var x, k, d int
	fmt.Scan(&x, &k, &d)


	if x == 0 {
		if k % 2 == 0 {
			fmt.Println(0)
			return
		}
		fmt.Println(d)
		return
	}
	x = abs(x)
	ans := x % d
	a := x / d
	if a > k {
		// 往復に辿り着く前に終る
		if x > 0  {
			fmt.Println(abs(x - k * d))
			return
		} else if  x < 0 {
			fmt.Println(abs(x +  k * d))
			return
		}
	} else if a <= k  {
		// 往復する
		if (k - a) % 2 == 0 {
			fmt.Println(abs(ans))
			return
		} else if (k-a) % 2 == 1 {
			if ans > 0 {
				ans -= d
			} else {
				ans += d
			}
			fmt.Println(abs(ans))
			return
		}
	}
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 1836
h={}
t={}
`read a;factor`.lines.map{|e|
	x=y=1
	e.gsub(/( \d+)\1*\b/){|m|
		x*=m.to_i**(a=m.count(' ')%3)
		y*=m.to_i**(-a%3)
	}
	h[x]=1.+h[x]||0
	t[x]=y
}
z=h[1]?1:0
h[1]=0
h.keys.map{|k|
	z+=[h[k],h[t[k]]||0].max
	h[k]=h[t[k]]=0
}
p z


Measured memory_bytes: 59532
import math
*A,=[int(input()) for i in range(5)]
B=[i%10 for i in A]
C=[int(math.ceil(i/10)*10) for i in A]
while True:
  x=B.index(min(B))
  if B[x]!=0:
    print(sum(C)-C[x]+A[x])
    break
  B[x]=10

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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

MOD = 1000000007

N, M = map(int, input().split())
goods = [True] * (N + 4)
dp = [0] * (N + 4)

for _ in range(M):
    x = int(input())
    goods[x] = False

dp[0] = 1
for i in range(N + 1):
    if goods[i]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD


print(dp[N])


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

using namespace std;

int main()
{
  uint64_t N, Q;
  cin >> N >> Q;

  map<uint64_t, set<uint64_t>> edges;
  for (uint64_t n = 0; n < N; ++n) {
    edges.emplace(n, set<uint64_t>());
  }

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

    edges[a - 1].insert(b - 1);
  }

  vector<uint64_t> vertex(N, 0);
  for (uint64_t q = 0; q < Q; ++q) {
    uint64_t p, x;
    cin >> p >> x;

    vertex[p - 1] += x;
  }

  vector<uint64_t> sum(N, 0);
  queue<pair<uint64_t, uint64_t>> q;
  q.emplace(0, vertex[0]);
  while (!q.empty()) {
    pair<uint64_t, uint64_t> p = q.front(); q.pop();
    sum[p.first] = p.second;
    for (uint64_t dst : edges[p.first]) {
      q.emplace(dst, p.second + vertex[dst]);
    }
  }

  for (uint64_t n = 0; n < N; ++n) {
    cout << sum[n];
    if (n + 1 < N) { cout << ' '; }
  }
  cout << endl;

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<bool>vec(N,true);
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    if(a == b){
      vec[i] = false;
    }
  }
  for(int i=0; i<N-2; i++){
    if(vec[i] == false && vec[i+1] == false && vec[i+2] == false){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

inline void print_syms(int w, bool b) { 
  for (int i = 0; i < w; i++) {
    printf(b ? "." : "#");
    b = !b;
  }
  printf("\n");
}

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  while (h && w) {
    for (int i = 0; i < h; i++) {
      print_syms(w, i % 2 ? true : false);
    }
    printf("\n");
    scanf("%d %d", &h, &w);
  }
  return 0;
}



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

using Int = __int64_t;
using vint = vector<Int>;
using vint2d = vector<vint>;
using vint3d = vector<vint2d>;

#define for_range(i, n) for (Int i = 0; i < (Int)(n); i++)

Int maxv(Int i, Int k, Int dw, vint3d &list_maxv, vint &list_v, vint &list_dw) {
  Int INF = Int(pow(10, 12));

  if (i == 0) {
    if (k == 0 && dw == 0) return 0;
    else return -INF;
  } else if (k == 0) {
    if (dw == 0) return 0;
    else return -INF;
  } else if (dw < 0) {
    return -INF;
  } else if (list_maxv[i][k][dw] != -1) {
    return list_maxv[i][k][dw];
  } else {
    Int v0 = list_v[i - 1] + maxv(i - 1, k - 1, dw - list_dw[i - 1], list_maxv, list_v, list_dw);
    Int v1 = maxv(i - 1, k, dw, list_maxv, list_v, list_dw);

    Int result = max(v0, v1);
    list_maxv[i][k][dw] = result;
    return result;
  }
}

int main() {
  Int MAXDW = 300;

  Int n, maxw;
  cin >> n >> maxw;

  vint list_dw(n);
  vint list_v(n);
  Int w0 = 0;
  for_range(i, n) {
    Int w, v;
    cin >> w >> v;
    if (i == 0) w0 = w;
    list_dw[i] = w - w0;
    list_v[i] = v;
  }

  vint3d list_maxv(n + 1, vint2d(n + 1, vint(MAXDW + 1, -1)));

  Int m = 0;

  for_range(k, n + 1) {
    for_range(dw, MAXDW + 1) {
      if (k * w0 + dw <= maxw) {
        m = max(m, maxv(n, k, dw, list_maxv, list_v, list_dw));
      }
    }
  }

  cout << m << endl;
}


Measured memory_bytes: 27812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

#define N 500005

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return mod(po(n,i_5));
}

ll n;
ll a,b,c;

ll ans=0;
void caladd(){
    rep(x,n,2*n-1){
        ll f=n;
        ll g=x-n;
        ll add=comb(f+g-1,f-1);
        add=mod(add*po(a,f));
        add=mod(add*po(b,g));
        add=mod(add*bunbo(po(a+b,f+g)));
        add=mod(add*mod(100*x));
        add=mod(add*bunbo(a+b));
        ans=mod(ans+add);
        //cout<<x<<" "<<add<<endl;
    }
}
int main(){fastio
    calc();
    
    
    cin>>n;
    cin>>a>>b>>c;
    caladd();
    swap(a,b);
    caladd();
    cout<<mod(ans)<<endl;
    
    return 0;
}


Measured memory_bytes: 8064
using System;

namespace study
{
    public class ConsoleApp1
    {
        static char[][] Grid;
        private static int h;
        private static int w;
        private static int k;

        static int Simulate(int i, int j)
        {
            int count = 0;
            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    //黒いマス
                    if (((i >> y) & 1) == 0 && ((j >> x) & 1) == 0 && Grid[y][x] == '#')
                    {
                        count++;
                    }
                }
            }

            return count;
        }

        static void Main(string[] arg)
        {
            string[] input = Console.ReadLine().Split(' ');
            h = int.Parse(input[0]);
            w = int.Parse(input[1]);
            k = int.Parse(input[2]);
            Grid = new char[h][];
            for (int i = 0; i < h; i++)
            {
                Grid[i] = Console.ReadLine().ToCharArray();
            }

            int ans = 0;
            for (int i = 0; i < (1 << h); i++)
            {
                for (int j = 0; j < (1 << w); j++)
                {
                    if (k == Simulate(i, j)) ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27364
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /*ll t;
    cin>>t;
    while (t--)
    {*/
        int i;
        char a,b;
        cin>>a>>b;
        if (a>=b)
            for (i=0;i<(int)a-48;i++)
                cout<<b;
        else
            for (i=0;i<(int)b-48;i++)
                cout<<a;
    //}
}


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

def f(n):
	return n/sum(list(map(int,list(str(n)))))

a=[]
for i in range(1,16):
	if i<=3:
		for j in range(1,10):
			a.append((j+1)*(10**(i-1))-1)
	elif i<=12:
		for j in range(1,10):
			b=[j*(10**(i-1))+(k+1)*(10**(i-2))-1 for k in range(10)]
			for k in range(9)[::-1]:
				if f(b[k])>f(b[k+1]):
					b.pop(k)
			a+=b
	else:
		for j in range(1,10):
			b=[j*(10**(i-1))+(k+1)*(10**(i-3))-1 for k in range(100)]
			for k in range(99)[::-1]:
				if f(b[k])>f(b[k+1]):
					b.pop(k)
			a+=b

for i in range(l):
	print(a[i])


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#define ll long long
#define maxn 1005

bool grid[maxn][maxn];
ll dp[maxn][maxn];
ll mod = 1e9 + 7;

int main()
{
	char temp;
	ll h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> temp;
			grid[i][j] = temp == '.';
		}
	}
	for (ll i = h - 1; i >= 0; --i) {
	    for (ll j = w - 1; j >= 0; j--) {
	        if (i == h - 1 && j == w - 1) {
	        	dp[i][j] = 1;
	        } else {
	        	if (grid[i][j]) {
	        		dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
	        	}
	        }
	    }
	}
	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 12408
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

ll fastpo(ll a, ll x){
    if(x == 0) return 1ll;
    if(x == 1) return a;
    ll y = fastpo(a, x/2);
    if(x%2 == 0){
        return y*y;
    }
    return y*y*a;
}

ll inv(ll a, ll M){
    return fastpo(a, M-2);
}

ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return -1; 
    else
    { 
        ll res = (x%m + m) % m; 
        return res;
    } 
}


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

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

void print(vector<int> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main(){
//    clock_t time_req;
//     time_req = clock();
    fastio;
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    int j = 0;
    ll ans = 0;
    for(int i=1; i<n; i++){
        if(i == 1){
            ans += a[j];
            j++;
        }
        else{
            ans += a[j];
            if(i%2 == 1){
                j++;
            }
        }
    }
    cout<<ans<<endl;
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

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

const int N = 1e5+10;
long long int v[N];

int main(){
	int n;
	long long int sum = 0;
	long long int h;

	cin >> h >> n;
	
	for(int i=0; i < n; i++) cin >> v[i];
	for(int i=0; i < n; i++) sum += v[i];
	
	if(sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
map<pair<string,string>,long>M;
int n;string s;
main()
{
	cin>>n>>s;
	for(int i=0;i<1<<n;i++)
	{
		string a="",b="";
		for(int j=0;j<n;j++)
		{
			if(i&1<<j)a+=s[j];
			else b+=s[j];
		}
		M[make_pair(a,b)]++;
	}
	long ans=0;
	for(int i=0;i<1<<n;i++)
	{
		string a="",b="";
		for(int j=0;j<n;j++)
		{
			if(i&1<<j)a+=s[n+j];
			else b+=s[n+j];
		}
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		ans+=M[make_pair(b,a)];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 87040
n,a,b = map(int,input().split())
cnt = 1
while True:
  if cnt % 2 != 0: #alice
    cnt += 1
    a += 1
    if a == b:
      print('Borys')
      break
  else:
    cnt += 1
    b -= 1
    if b == a:
      print('Alice')
      break

Measured memory_bytes: 9116
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll l = a[n-1];
    int idx = int(lower_bound(a.begin(),a.end(),l/2)-a.begin());
    cout << l << " ";
    if(idx == 0) cout << a[0] << endl;
    else if(idx == n) cout << a[n-2] << endl;
    else{
        int idx1 = idx-1, idx2 = idx;
        if(abs(a[idx1]-l/2.0) <= abs(a[idx2]*1.0 - l/2.0)) cout << a[idx1] << endl;
        else cout << a[idx2] << endl;
    }
}

Measured memory_bytes: 1152
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
  vector<vector<bool>>d(5001,vector<bool>(5001));
int main(){
  ll a,b,c,d,ans=0;cin>>a>>b;
  rep(i,a){
    cin>>c>>d;
    double e=sqrt(c*c+d*d);
    if(e<=b)ans++;
  }
  cout<<ans;
}



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

using namespace std;

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

    double s = 0;

    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a+n);

    s += a[0]/pow(2,n-1);

    for (int i = 1; i < n; ++i) s += a[i]/pow(2, n-i);

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int m;
        int nMin;
        int nMax;
        cin >> m >> nMin >> nMax;

        if (m == 0 && nMax == 0 && nMin == 0) {
            break;
        }

        vector<int> v;
        for (int i = 0; i < m; ++i) {
            int p;
            cin >> p;
            v.push_back(p);
        }

        auto maximum = make_pair(0, -1);
        for (int n = nMin; n <= nMax; ++n) {
            auto gap = v[n - 1] - v[n];
            if (maximum.second <= gap) {
                maximum = make_pair(n, gap);
            }
        }
        cout << maximum.first << endl;
    }
}

Measured memory_bytes: 3128
n = int(input())
li = list(map(int,input().split()))
#print(li)
li.sort(reverse = True)
#print(li)

sum_A = 0
sum_B = 0

for i in range(0,n,2):
	sum_A += li[i]
#print(sum_A)
for i in range(1,n,2):
	sum_B += li[i]
#print(sum_B)

print(sum_A-sum_B)

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

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

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

int main(){
	int sum = 0;
	rep(i, 5){
		int x;
		scanf("%d",&x);
		if(x<=40){
			x =40;
		}
		sum +=x;
	}
	printf("%d\n",sum/5);
	return 0;
}

Measured memory_bytes: 1188
#!/usr/bin/python

import math
import sys

def combination(a, b):
    return math.factorial(a)/(math.factorial(b) * math.factorial(a - b))

def main(argv):
    line = sys.stdin.readline().rstrip("\n")

    while line:
        n, a, b = map(lambda x: int(x), line.split(" ", 3))
        values = map(lambda x: int(x), raw_input().split(" "))

        sorted_values = sorted(values, reverse=True)
        mean = (float)(sum(sorted_values[0:a])) / a
        print mean

        counts = {}
        for v in sorted_values[0:a]:
            if not v in counts:
                counts[v] = 0
            counts[v] += 1

        count = 0
        if len(counts.keys()) == 1:
            c = 0
            for v in sorted_values:
                if v == sorted_values[0]:
                    c += 1
                else:
                    break

            for i in xrange(a, min(b, c) + 1):
                count += combination(c, i)
        else:
            c_s = 0
            c_e = 0
            for v in sorted_values:
                if v > sorted_values[a - 1]:
                    c_s += 1
                elif v == sorted_values[a - 1]:
                    c_e += 1
                elif v < sorted_values[a - 1]:
                    break

            count += combination(c_e, a - c_s)
        print count

        print " "

        line = sys.stdin.readline().rstrip("\n")

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2696
import java.util.*;

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

    int m1 = sc.nextInt();
    int d1 = sc.nextInt();
    int m2 = sc.nextInt();
    int d2 = sc.nextInt();

    if(m1+1==m2 && d2==1){
      System.out.println("1");
    }else{
      System.out.println("0");
    }
  }
}

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



int main() {

  int N;
  scanf("%d", &N);

  string S;
  cin >> S;

  int N_Operation = 0;
  int N_Red = 0;
  int N_White = 0;


  int li=0;
  int ri=N-1;
  bool found_white=false;
  bool found_red=false;

  while (li < ri){

    if (!found_white){
      if (S[li]=='W'){ found_white=true; }
      else { li++; }
    }

    if (!found_red){
      if (S[ri]=='R'){ found_red=true; }
      else { ri--; }
    }

    if (found_white && found_red){
      N_Operation++;
      li++;
      ri--;
      found_white=false;
      found_red=false;
    }

  }

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

  return 0;
}



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

# 種類の数と粉の総量
shurui_cnt, kona = map(int, input().split())
# 各種類の粉消費量
shurui_list = []
for i in range(shurui_cnt):
    shurui_list.append(int(input()))
# 作った数
total_cnt = 0

# まず全種類を一つずつ作る
for value in shurui_list:
    kona -= value
    total_cnt += 1

min_value = min(shurui_list)

# 残った粉で一番安いやつをなるだけ作る
while kona >= min_value:
    kona -= min_value
    total_cnt += 1

print(total_cnt)

Measured memory_bytes: 3060
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL a, b;
	cin >> a >> b;
	cout << (a * b) / __gcd(a, b) << endl;
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
		double T = input[0];
		double X = input[1];
		
		Console.WriteLine(T/X);
	}
}

Measured memory_bytes: 13396
package main

import "fmt"

func main() {
	// Code for A - Double Helix
	var b string

	fmt.Scanf("%s", &b)

	switch b[0] {
	case 'A':
		fmt.Println("T")
	case 'T':
		fmt.Println("A")
	case 'C':
		fmt.Println("G")
	case 'G':
		fmt.Println("C")
	}
}


Measured memory_bytes: 1836
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
vector<vector<int>> G;
vector<ll> c;
vector<int>f;
void dfs(int v, ll x) {
	f[v] = 1;
	c[v] += x;
	rep2(nv, G[v]) {
		if(f[nv] == 0)dfs(nv, c[v]);
	}
}
int main(void) {
	int n, q;
	cin >> n >> q;
	G.resize(n);
	c.resize(n);
	f.resize(n);
	rep(i, 0, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, 0, q) {
		int p, x;
		cin >> p >> x;
		c[p - 1] += (ll)x;
	}
	rep(i, 0, n)if(f[i] == 0)dfs(i, 0ll);
	rep(i, 0, n) {
		printf(i == n - 1 ? "%lld\n" : "%lld ", c[i]);
	}
	return 0;
}


Measured memory_bytes: 22776
N, M= map(int, input().split())
if N >= 3 and M >= 3:
    print((N - 2) * (M - 2))
elif N == 2 or M == 2:
    print(0)
elif N == 1 and M != 1:
    print(M - 2)
elif N != 1 and M == 1:
    print(N - 2)
else:
    print(1)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
#define  MOD 1000000007
int main(){
    int h,w,i,j;
    cin>>h>>w;
    int dp[h][w];
    char a[h][w];
    for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>a[i][j],dp[i][j]=0;
    dp[0][0]=1;
    for(i=0;i<h;i++)for(j=0;j<w;j++)if((i+j)&&a[i][j]!='#')dp[i][j]=((i>0?dp[i-1][j]:0)+(j>0?dp[i][j-1]:0))%MOD;
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  vector <int> v;
  int tmp;
  cin >> n;
  cin.ignore();
  for(int i = 0; i < n; i++){
    cin >> tmp;
    v.push_back(tmp);
  }

  sort(v.begin(), v.end()); // 平均化は小さい方から？

  double ans = (double) v[0];
  for(int i = 1; i < n; i++){
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		if((r*100+g*10+b)%4==0)System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {
            int n = int.Parse(Console.ReadLine());
            int[] ta = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] hlist = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int t = ta[0];
            int a = ta[1];

            float nearest = Math.Abs(100000 - a);
            int answer = 0;

            for(int i = 0; i < n; i++)
            {
                float temp = t - (hlist[i] * 0.006f);
                if(nearest > Math.Abs(temp - a))
                {
                    nearest = Math.Abs(temp - a);

                    answer = i + 1;
                    if (Math.Abs(temp - a) == 0)
                    {
                        break;
                    }
                }


            }

            Console.WriteLine(answer);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13340
#include <bits/stdc++.h>
    
using namespace std;
int k;
string s,se;
int main( ) {
    cin>>k;
    cin>>s;
    if(k<s.length()){
        se = se.assign(s, 0, k);
        cout<<se<<"...";
    }
    else{
        cout<<s;
    }
    
    return 0;
}

Measured memory_bytes: 3632
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e5+9;
int n;
pll a[sz];
int ans;
ll cs[sz];

int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i].f;
		a[i].s=i;
	}
	sort(a,a+n);
	cs[0]=a[0].f;
	for(int i=1;i<n;++i){
		cs[i]=cs[i-1]+a[i].f;
	}
	ans=1;
	for(int i=n-2;i>=0;--i){
		if(a[i+1].f<=2*cs[i]) ans++;
		else break;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {return a>b?a:b;}
	int MIN(int a,int b) {return a<b?a:b;}
	int ABS(int a) {return a<0?-a:a;}
	int GCD(int a,int b) {return !b?a:GCD(b,a%b);}
	int LCM(int a,int b) {return a/GCD(a,b)*b;}
	int QSM(int a,int b,int p) {int ret=1;while (b) (b&1)&&(ret=ret*a%p),a=a*a%p,b>>=1;return ret;}
	int ROUND(double a) {return a+0.5;}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
const int maxN=2005;int n,x,y,dis[maxN][maxN],s[maxN][maxN],ans[maxN],t[maxN*maxN];
int main() {
	cin>>n>>x>>y,dis[x][y]=1;
	//for (int i=1;i<n;i++) dis[i][i+1]=1; 
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++) dis[i][j]=1;
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++) {
			//if (i<=x&&j>=y) s[i][j]=x-i+1+j-y;
			//else s[i][j]=j-i;
			s[i][j]=min(j-i,ABS(x-i)+1+ABS(j-y));
		}
	//for (int i=1;i<n;i++) {
	//	for (int j=i+1;j<=n;j++) printf("s[%d][%d]=%d ",i,j,s[i][j]);
	//	puts("");
	//}
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++) t[s[i][j]]++;
	for (int k=1;k<n;k++) cout<<t[k]<<'\n';
}

Measured memory_bytes: 33152
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

int main() {
    int n, d;
    cin >> n >> d;
    vector<P> x(n);
    rep(i, n) cin >> x[i].first >> x[i].second;
    two_sat ts(n);
    rep(i, n) REP(j, i + 1, n) {
        if(abs(x[i].first - x[j].first) < d)
            ts.add_clause(i, false, j, false);
        if(abs(x[i].first - x[j].second) < d)
            ts.add_clause(i, false, j, true);
        if(abs(x[i].second - x[j].first) < d)
            ts.add_clause(i, true, j, false);
        if(abs(x[i].second - x[j].second) < d)
            ts.add_clause(i, true, j, true);
    }
    if(ts.satisfiable()) {
        cout << "Yes" << endl;
        vector<bool> ans = ts.answer();
        rep(i, n) {
            if(ans[i]) {
                cout << x[i].first << endl;
            } else {
                cout << x[i].second << endl;
            }
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
def com(n,k):
    if k==0:
        return 1
    s=n
    p=10**9+7
    inv=[0,1]
    for c in range(2,k+1):
        inv.append((-(p//c)*inv[p%c])%p)
        s=(((s*(n+1-c))%p)*inv[c])%p
    return s


x,y=map(int,input().split())
if (x+y)%3!=0 or 2*y<x or 2*x<y:
    print(0)
else:
    r=min(2*y-x,2*x-y)//3
    print(com((x+y)//3,r))

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

long long n, c, w, v, f[100010];
int main() {
    cin >> n >> c;
    for(int i = 0; i < n; i++) {
        cin >> w >> v;
        for(int j = c; j >= w; j--)
            f[j] = max(f[j], f[j - w] + v);
    }
    cout << f[c];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k; cin>>k;
  string s; cin>>s;
  int n=s.length();
  for(int i=0;i<min(k,n);i++)
    cout<<s[i];
  // for(int i=k;i<n;i++)
  if(n>k)
  cout<<"...";
  return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B= inputArray[1];


			//答えの出力
			var ans = A*B;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28172
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	while (N) {
		vector<pair<pair<int,int>,int>>score(N + 1);
		for (int i = 1; i <= N; i++) {
			score[i].second -= i;
		}
		vector<vector<int>>WA(N + 1, vector<int>(M + 1));
		for (int i = 0; i < K; i++) {
			int a, b, c;
			string s;
			cin >> a >> b >> c >> s;
			if (s[0] == 'C') {
				score[a].first.first++;
				score[a].first.second -= c;
				score[a].first.second -= WA[a][b] * 1200;
			}
			else {
				WA[a][b]++;
			}
		}
		stable_sort(score.begin(), score.end());
		reverse(score.begin(), score.end());
		for (auto i : score) {
			if (i.second) {
				cout << -i.second << " " << i.first.first << " " << -i.first.second << endl;
			}
		}
		cin >> N >> M >> K;
	}
	return 0;
}

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

static const int N = 100;

int main()
{
    int n,p[N+1],m[N+1][N+1],i,l,j,k;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> p[i-1] >> p[i];
    }

    for(i=1;i<=n;i++) m[i][i]=0;
    for(l=2;l<=n;l++)
    {
        for(i=1;i<=n-l+1;i++)
        {
        j = i+l-1;
        m[i][j] = (i << 21);
        for(k=i;k<=j-1;k++)
        {
            m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i -1] * p[k] * p[j]);
        }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


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

typedef long long int ll;

int main(){

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

}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
total_weight = sum(W)
half_weight = total_weight / 2 
temp_total = 0
for i in range(N):
    temp_total += W[i]
    if temp_total > half_weight:
        last_add = i
        break
    
print(int(2 * (min(abs(temp_total - half_weight),abs(temp_total - half_weight - W[last_add])))))
    

Measured memory_bytes: 3060
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        A,B,K = list(map(
            int, input().split()))
    else:
        pass

    A = A - K
    B = B if A > 0 else B + A 
    print(max(A,0),max(B,0))



if __name__ =='__main__':
    main()

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
             
            Map<String, Long> data = new HashMap<>();
            int cnt = 0;
            for (int i=1; i <= n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                String e = st.nextToken();
                Long total = data.getOrDefault(e, 0L);
                if (total == null) continue;
                
                Long p = Long.parseLong(st.nextToken());
                Long q = Long.parseLong(st.nextToken());
                total += p * q;
                if (total >= 1_000_000L) {
                    System.out.println(e);
                    total = null;
                    cnt++;
                }
                data.put(e, total);
            }
            if (cnt == 0) {
                System.out.println("NA");
            }
        }
    }
}

Measured memory_bytes: 26016
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    string n;
    cin >> n;

    for (int i = 0; i < n.size(); ++i) {
        string str = n.substr(i, 1);
        if (str == "9") {
            cout << "1";
        } else {
            cout << "9";
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import math 
N = int(input())

used = []

def primes(n):
  primefac = dict()
  d = 2
  while d * d <= n:
    iter_ = 0
    while n % d == 0:
      iter_ += 1
      n //= d
    primefac[d] = iter_
    d += 1
  if n > 1:
    primefac[n] = 1
  return primefac 

p = primes(N)

count = 0
for (k, v) in p.items():
  count += math.floor(-0.5 + math.sqrt(0.25 + 2 * v))

print(count)


Measured memory_bytes: 92780
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector< vector<int> > ice(90, vector<int>(90));

int m, n;

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

int dfs(int i, int j, int count) {
	if (i < 0 || n <= i || j < 0 || m <= j || ice[i][j] == 0) return 0;
	ice[i][j] = 0;
	int ret = count;
	for (int k=0; k<4; ++k) {
		ret = max(ret, dfs(i + dy[k], j + dx[k], count + 1));
	}
	ice[i][j] = 1;
	return ret;
}

int main() {
	while (cin >> m >> n && m && n) {
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				cin >> ice[i][j];
			}
		}
		int ans = 0;
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				ans = max(ans, dfs(i, j, 1));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
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++)
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    int sLen = s.length();
    for (int i = 0; i < min(K, sLen); i++){
        if (s[i] != '1'){
            cout << s[i] << endl;
            break;
        }
        else if (i == K-1){
            cout << 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define max 1000000007

int inv_mod(long long a)
{
    long long b, x, u, q, abs_m, tmp;

    b = max;
    x = 1;
    u = 0;
    while (b > 0)
    {
        q = a / b;
        tmp = u;
        u = x - q * u;
        x = tmp;
        tmp = b;
        b = a - q * b;
        a = tmp;
    }
    while (x < 0)
        x = x + max;

    return x;
}

int main()
{

    int n;
    int m;

    scanf("%d", &n); //読み取り
    scanf("%d", &m); //読み取り

    long long kumiawase[500001];
    kumiawase[0] = 1;
    for (int i = 0; i < n; i++)
    {
        kumiawase[i + 1] = (m - n + i + 1) * kumiawase[i] % max;
        //printf("%lld ", kumiawase[i + 1]);
    } //aのパターン数

    int pulamai = -1;
    long long amari_block;
    long long beforehaiti = 1;
    long long addr;
    long long sum = kumiawase[n];
    for (int block_size = 1; block_size <= n; block_size++)
    {
        amari_block = n - block_size; //あまりのコマブロック

        beforehaiti = ((amari_block + 1) * beforehaiti %max)* inv_mod(block_size)%max; //ネックはここ割り算の処理に逆元を使う
        sum = sum + pulamai * beforehaiti * kumiawase[n - block_size] % max;

        while (sum < 0)
        {
            sum += max;
        }
        pulamai = pulamai * (-1);
    }
    long long ans = 0;
    ans = (sum % max) * (kumiawase[n] % max) % max;

    printf("%lld\n", ans);
}

Measured memory_bytes: 5964
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// 素直に桁数を計算:O(logN)
const int Digit(int n)
{
    int digit = 0;
    while (n > 0)
    {
        ++digit;
        n /= 10;
    }
    return digit;
}

int main()
{
    int N; cin >> N;
    int ans = 0;
    // 素直に1~Nの全ての数について桁数を計算:O(NlogN)
    for (int i = 1; i <= N; ++i)
    {
        if (Digit(i) % 2 == 1) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
Sa = list(map(str, str(input())))
Sb = list(map(str, str(input())))
Sc = list(map(str, str(input())))


tmp = ""
result = ""
for i in range(len(Sa)+len(Sb)+len(Sc)) :
  if i == 0 :
    tmp = Sa[0]
    Sa = Sa[1:]
  else:
    if tmp == "a" :
      if not Sa :
        result = "A"
        break
      tmp = Sa[0]
      Sa = Sa[1:]
    elif tmp == "b" :
      if not Sb :
        result = "B"
        break
      tmp = Sb[0]
      Sb = Sb[1:]
    else:
      if not Sc :
        result = "C"
        break
      tmp = Sc[0]
      Sc = Sc[1:]
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
long long int N;
cin >>N;  double M[N]; double s;
for(long long int i=0;i<N;i++){
cin >> M[i];
}
sort(M,M+N);
for(long long int i=0;i<N-1;i++){
  M[i+1]=(M[i]+M[i+1])/2;
}

printf("%.5f",M[N-1]);

}

Measured memory_bytes: 256