akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    vector<int> V(n);
    REP(i, n) cin >> V[i];
    sort(all(V), greater<int>());
    ll ans = V[0];
    n -= 2;
    int idx = 1;
    int cnt = 2;
    while (n--) {
    	ans += V[idx];
    	cnt--;
    	if (cnt == 0) {
    		cnt = 2;
    		idx++;
    	}
    }
    cout << ans << endl;
}

Measured memory_bytes: 4004
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
a = input()

#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])
if a.isupper()==True:
	print('A')
else:
  	print('a')

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
int n,ans,a[100001];
int gcd(int a,int b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n;
    for (int i=0;i<n;i++)
	{
        cin>>a[i];
        if (i==0) ans=a[i];
        else ans=gcd(ans,a[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
from scipy.misc import comb


def solve():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    for i in range(1, K+1):
        ans = comb(N-K+1, i, exact=True) * comb(K-1, i-1, exact=True)
        ans %= MOD
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 15160
a, b = gets.chomp.split.map(&:to_i)
a = a % 3
b = b % 3
c = (a == 0) or (b == 0)
if a == 0 or b == 0 or (a + b) % 3 == 0
  puts "Possible"
  exit
end
puts "Impossible"


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

int main(){
	int num, s, x, hap;
	cin >> num;
	x = num /500;
  	s = num % 500;
  	hap = x*1000;
  	s = s / 5;
  	hap = hap + (s*5);
  	cout << hap;
}


Measured memory_bytes: 256
from sys import stdin
def solve():
    s = int(stdin.readline())
    mod = 10**9+7
    if s < 3: return 0
    dp = [0]*(s+1)
    dp[0] = 1
    for i in range(3,s+1):
        for x in range(3,i+1):
            if x in [i-1,i-2]:
                continue
            dp[i] += dp[i-x]
    return dp[s]%mod
print(solve())

Measured memory_bytes: 73984
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
int main() {
  std::cout.tie(0); std::ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  int ans = max(0, C - (A - B));
  cout << ans << endl;
}


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

int main() {
	string s;
	cin >> s;
	int ans = 0,b = 0,e = s.size()-1;
	while (b <= e) {
		if (s[b] == s[e]) {
			b++;
			e--;
		}
		else if (s[b] == 'x') {
			b++;
			ans++;
		}
		else if (s[e] == 'x') {
			e--;
			ans++;
		}
		else {
			ans = -1;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def main():
    n, m, l = map(int, input().split())
    dist = [[float('inf')]*n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    dist2 = [[float('inf')]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if dist[i][j] <= l:
                dist2[i][j] = 1
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j])


    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if dist2[s][t] == float('inf'):
            print(-1)
            continue
        ans = dist2[s][t]
        print(ans-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 126428
package main

import (
	"fmt"
)

func main() {
	var n, t, tt, dt, x, tx, dx, y, ty, dy int
	res := true
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&tt, &tx, &ty)
		if tx > x {
			dx = tx - x
		} else {
			dx = x - tx
		}
		if ty > y {
			dy = ty - y
		} else {
			dy = y - ty
		}
		dt = tt - t
		if dt < dy+dx || ((dt)%2 != (dy+dx)%2) {
			res = false
		}
		t, x, y = tt, tx, ty
	}

	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#include<stdio.h>
 
int main()
{
  int A[100];
  int N;
  int key;
  int i, j, k;
 
  //Read N and keys
  scanf("%d", &N);
  for(i=0; i<N; i++)scanf("%d",&A[i]);
 
  //Sort
  for(i=0; i<N; i++){
    key=A[i];
    j=i-1;
 
      //if A[j]>key, change A[j] to A[j+1]
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j-=1;
    }
    A[j+1]=key;
 
      //print
    for(k=0; k<N; k++){
      printf("%d", A[k]);
      if(k<N-1)printf(" ");
    }
    printf("\n");
  } 
  return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(void) {
    vector<int> ryori;
    int N = 5;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        ryori.push_back(x);
    }

    int min = 65535;
    do {
        int result = 0;
        for (int i=0; i<N; i++) {
            result += ryori[i];
            if (result%10 != 0 && i != N-1) {
                result += 10-(result%10);
            }
            //cout << ryori[i] << " " << result << endl;
        }
        //cout << "last_result:" << result << endl;
        if (result < min) {
            min = result;
        }
    } while (next_permutation(ryori.begin(), ryori.end()));

    cout << min;

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll q;
  cin >> q;

  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  vector<ll> a(q),b(q);
  ll buf2 = 0;
  for(i=0;i<q;i++){
    cin>>a[i]>>b[i];
  }
  ll buf;
  for(i=0;i<q;i++){
    if(a[i]==b[i]){
      cout<<a[i]+b[i]-2<<endl;
    }
    else{
      buf = sqrt(a[i]*b[i]);
      
      if(buf*buf==a[i]*b[i])
        buf--;
      if(a[i]>b[i]){
        swap(a[i],b[i]);
      }
      //cout <<buf<<endl;
      //cout << max(buf-a[i],buf2) << endl;

      result=a[i]-1+max(buf-a[i],buf2)+buf;
      if(buf*(buf+1)>=a[i]*b[i]){
        result--;
      }
      cout<<result<<endl;

    }
    
  }
  return 0;
}

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

int main(){
  string a;
  int N;
  int torf=0;
  cin>>N;
  cin>>a;
  if(N%2==1)cout<<"No"<<endl;
  else{
    N/=2;
    for(int i=0;i<N;i++){
      if(a[i]!=a[N+i])torf=1;
    }
    if(torf==1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

const int PrimeMax = 999983;
int is_prime[1000001],sum[1000001];
void Eratosthenes(){
  ll N = PrimeMax;
  for(int i = 2; i <= N; i++){
    is_prime[i] = 1;
  }
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i*i <= N; i++){
    if(is_prime[i]){
      for(int j = i*2; j <= N; j+=i){
        is_prime[j] = 0;
      }
    }
  }
  ll c = 0;
  REP(i,0,N+1){
    if(is_prime[i]){
      ++c;
    }
    sum[i] = c;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  Eratosthenes();
  while(cin>>n && n){
    ll p,m,ans = 0;
    rep(i,n){
      ll f,s;
      cin >> p>>m;
      s = max(1LL,p-m);
      f = min(p+m,(ll)PrimeMax);
      ans += (sum[f]-sum[s-1])-1;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10948
while n = gets.to_i
  break if n == 0

  arr = (1..n).map { gets.to_i }

  sum = max = 0
  arr.each do |el|
    sum = [sum + el, 0].max
    max = sum if sum > max
  end
  puts arr.all? { |el| el < 0 } ? arr.max : max
end

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

#define i64 long long int

int main() {
	i64 x;
	cin>>x;
	
	i64 cur = 100;
	int t = 0;
	while(cur < x) {
		t++;
		cur += cur/100;
	}
	cout<<t<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const printTestCases = input => {
  const arr = input.split(`\n`).map(v => Number(v));
  arr.forEach((val, index) => {
    if (val !== 0) return console.log(`Case ${index + 1}: ${val}`);
  });
};

printTestCases(input);



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

#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)

using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
Graph G(100005);
vector<int> Fennec(100005);
vector<int> Sunuke(100005);
void dfs(int v,int before,int step,bool f) {
		if(f) Fennec[v]=step;
		else Sunuke[v]=step;
    for(int i=0;i<G[v].size();i++)
			if(G[v][i]!=before) dfs(G[v][i],v,step+1,f);
}

int main()
{
	int a,b;
	int N;
	int ans=0;
	sd1(N);
	for(int i=0;i<N-1;i++){
		sd2(a,b);
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,-1,0,true);
	dfs(N-1,-1,0,false);

//	for(int i=0;i<N;i++) cout<<Fennec[i]<<" ";
//	cout<<endl;
//	for(int i=0;i<N;i++) cout<<Sunuke[i]<<" ";
	for(int i=0;i<N;i++) ans+=(Fennec[i]<=Sunuke[i])?1:-1;
	printf("%s",(ans>0)?"Fennec":"Snuke");
}


Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
double dp[200][555];
int n;
main()
{
	cin>>n;
	for(int i=0;i<555;i++)dp[0][i]=1e150;
	dp[0][1]=0;
	for(int i=0;i<n;i++)
	{
		int h;
		cin>>h;
		for(int j=0;j<555;j++)dp[i+1][j]=1e150;
		for(int j=1;j<500;j++)
		{
			for(int k=1;k<500;k++)
			{
				double cost;
				if(j<=h)
				{
					if(k<=h)
					{
						cost=(2*h-j-k)/2.0;
					}
					else
					{
						cost=(h-j+k-h)/2.0-(h-j)*(k-h)/(double)(h-j+k-h);
					}
				}
				else
				{
					if(k<=h)
					{
						cost=(j-h+h-k)/2.0-(j-h)*(h-k)/(double)(j-h+h-k);
					}
					else
					{
						cost=(j+k-2*h)/2.0;
					}
				}
				dp[i+1][k]=min(dp[i+1][k],dp[i][j]+cost);
			}
		}
	}
	double ans=1e150;
	for(int i=0;i<555;i++)ans=min(ans,dp[n][i]);
	cout<<fixed<<setprecision(9)<<ans<<endl;
}



Measured memory_bytes: 3892
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }

    let mut heap = BinaryHeap::new();
    for i in 0..n {
        heap.push((a[i], a[i], 0))
    }

    for _ in 0..m {
        let (p, ai, k) = heap.pop().unwrap();
        if p == 0 {
            break;
        }
        heap.push((ai / 2usize.pow(k + 1), ai, k + 1));
    }

    let mut result = 0;
    for (p, _, _) in heap {
        result += p;
    }
    println!("{}", result);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

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

    if(n == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    s64 mod = pow(10, 9) + 7;
    s64 pow10Mod = 1;
    s64 pow9Mod = 1;
    s64 pow8Mod = 1;
    for(s64 i = 0; i < n; i++)
    {
        pow10Mod *= 10;
        pow10Mod %= mod;

        pow9Mod *= 9;
        pow9Mod %= mod;

        pow8Mod *= 8;
        pow8Mod %= mod;
    }

    s64 answer = pow10Mod;
    answer -= pow9Mod;
    if(answer < 0)
    {
        answer += mod;
    }
    answer -= pow9Mod;
    if(answer < 0)
    {
        answer += mod;
    }
    answer += pow8Mod;
    answer %= mod;

    cout << answer << endl;

    return 0;
}


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

int         ts[200005];
vector<int> G[200005];
int         v[200005];

void dfs(int n, int p = -1, int sum = 0) {
    for (int h : G[n]) {
        if (h != p)
            dfs(h, n, sum + v[n]);
    }
    v[n] += sum;
}

int main() {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        v[p] += x;
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
        cout << v[i] << " ";
}

Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 



int h,w,k;
int num;
int res[305][305];
char s[305][305];
vector<int> cnt(305);
void solve(int v1,int v2){
     vector<int> p;
     for(int i=v1;i<=v2;i++){
          for(int j=1;j<=w;j++){
               if(s[i][j]=='#')p.push_back(j);
          }
     }
     for(int i=0;i<(int)p.size();i++){
          int t1=1,t2=w;
          if(i>=1)t1=p[i-1]+1;
          if(i<(int)p.size()-1)t2=p[i];
          num++;
          for(int k=v1;k<=v2;k++){
               for(int j=t1;j<=t2;j++)res[k][j]=num;
          }
     }
}

int main()
{
     cin>>h>>w>>k;
     for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++){
               cin>>s[i][j];
               if(s[i][j]=='#')cnt[i]++;
          }
     }
     vector<int> vec;
     for(int i=1;i<=h;i++){
          if(cnt[i]>=1)vec.push_back(i);
     }
     for(int i=0;i<(int)vec.size();i++){
          int v1=1,v2=h;
          if(i>=1)v1=vec[i-1]+1;
          if(i<vec.size()-1)v2=vec[i];
          solve(v1,v2);
     }
     for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++){
               cout<<res[i][j]<<" ";
          }
          cout<<"\n";
     }

     
}




































Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

map<int, int> store;

void run_case() {
    int N, t;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> t;
        if(store.count(t)) {
            cout << "NO";
            return;
        }
        store[t]++;
    }
    cout << "YES";
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
using namespace std ;
const int MAXN = 2e6 + 5 ;
int s[ MAXN ] , pa[ MAXN ] , pb[ MAXN ] ;
int k , n ;
char ch[ MAXN ] ;
inline int Pow ( int x , int y ) {
	int ans = 1 ;
	while ( y ) {
		if ( y & 1 ) ans = ans * x % mod ;
		x = x * x % mod ;
		y >>= 1 ;
	}
	return ans ;
}
inline int C ( int x , int y ) {
	return s[ x ] * Pow ( s[ y ] , mod - 2 ) % mod * Pow ( s[ x - y ] , mod - 2 ) % mod ;
}
signed main () {
	scanf ( "%lld%s" , &k , ch + 1 ) ;
	n = strlen ( ch + 1 ) ;
	s[ 0 ] = pa[ 0 ] = pb[ 0 ] = 1 ;
	for ( int i = 1 ; i <= n + k ; i ++ ) s[ i ] = s[ i - 1 ] * i % mod ;
	for ( int i = 1 ; i <= k ; i ++ ) {
		pa[ i ] = pa[ i - 1 ] * 25 % mod ;
		pb[ i ] = pb[ i - 1 ] * 26 % mod ;
	}
	int ans = 0 ;
	for ( int i = 0 ; i <= k ; i ++ ) {
//		cout << C ( n + i - 1 , i ) << endl ;
		ans = ( ans + pb[ k - i ] * ( C ( n + i - 1 , i ) * pa[ i ] % mod ) % mod ) % mod ;
	}
	printf ( "%lld\n" , ans ) ;
	return 0 ;
}

Measured memory_bytes: 35904
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n;
vll d;

void func() {
    cin >> n;
    d.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String, Integer> map = new TreeMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.merge(s, 1, Integer::sum);
            max = Math.max(max, map.get(s));
        }
        List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
        list.sort(Map.Entry.comparingByValue());
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getValue().equals(max)) {
                sb.append(list.get(i).getKey());
                sb.append("\n");
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 79308
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,s;
  cin >> k >> s;
  int ans = 0 ;
  for ( int i=0 ; i<=k ; i++){
    for (int j=0 ; j<=k ; j++){
        int z=s-i-j ;
      if ( z<=k && z>=0 ) {
          ans++;
      }
  }
  }
           cout << ans << endl;
  return 0;
}


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

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

    vector<int> h;
    int data;
    for(int i=0;i<n;i++)
   {
    cin>>data;
    h.push_back(data);
   } 
   long long int dp[n];
   dp[0]=0;
   for(int i=1;i<n;i++)
   {
       long long int count=INT_MAX;
       for(int j=max(0,i-k);j<i ;j++)
       {
           count=min(count,(dp[j]+abs(h[i]-h[j])));
       }
       dp[i]=count;
   }
   cout<<dp[n-1];
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int qqq; cin>>qqq;
    rep(qqqqqqqqqqqqq,qqq){
        ll a,b; cin>>a>>b;
        ll ro=sqrt(a*b), ans=0;
        vector<int> candi;
        if(a==b){
            cout<<(ro-1)*2<<endl;
        }else{
            ll ans=0;
            if((a*b-1)/ro==ro){
                ans=ro*2-1;
            }else if(a*b==ro*ro) {
                ans=ro*2-2;
            }else{
                ans=ro*2;
            }
            ans--;
            b=max(a,b);
            //ll kari=(a*b-1)/b;
            //if(kari!=0){
            //    kari=(a*b-1)/kari;
            //    if(kari==b) ans--;
            //}
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3508
def main():
    n = int(input().strip())
    L = list(map(int, input().strip().split()))
    L.sort()
    max_=L[-1]
    isDivisible = [False]*(max_) # 1-Lmax
    
    for i,x in enumerate(L):
        if i!=n-1 and x==L[i+1]:
            isDivisible[x-1]=True
            continue
        j=2*x
        while j<=max_:
            isDivisible[j-1]=True
            j+=x
    ans=0
    for x in L:
        if not isDivisible[x-1]:
            ans+=1
    print(ans)
# print(ans)
    
if '__main__' == __name__:
    main()

Measured memory_bytes: 32260
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector pre(n+1, 0LL);
    for (int i = 0; i < n; i++) cin >> pre[i];


    for (int i=0; i<k; i++) {
        vector<int64> c(n+1, 0);
        for (int j = 0; j < n; j++) {
            c[max(0LL, j-pre[j])]++;
            c[min(n-1LL, j+pre[j])+1]--;
        }
        for (int j=0; j<n; j++) c[j+1] += c[j];


        bool f = true;
        for (int j=0; j<n; j++) {
            if (pre[j] != c[j]) f = false;
        }

        pre = c;
        if (f) break;
    }


    for (int j = 0; j < n; j++) {
        cout << pre[j] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5912
#include <bits/stdc++.h>
  
// Shabdan Batyrkulov
  
using namespace std;
  
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double
#define vi vector <int>
#define pii pair <int, int>
#define OK puts("OK");                                                                           
                                                                                                
const int N = (int)1e5 + 7;                                                                 
const int inf = (int)1e9 + 7;
const int MAX = (int)1e2 + 7;

int main () {
	int n; scanf ("%d", &n);
	string s, S; cin >> s;
	S = s;
	n = s.size();
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == '(') {
			if (s[i] == ')') {
				i--;
				s.erase(s.begin() + i);
				s.erase(s.begin() + i);
				i = 0;
				n = s.size();				
			}		
		}
	}
	n = s.size();
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == ')') {
			a++;
		} else {
			b++;
		}
	}
	for (int i = 0; i < a; i++) {
		printf ("(");
	}
	cout << S;
	for (int i = 0; i < b; i++) {
		printf (")");
	}
}    


Measured memory_bytes: 256
s = input() 
k = -1
l = -1
flag = False
for i in range(0,len(s)-1):
  if s[i] == s[i+1]:
    flag = True
    k = i+1
    l = i+2
    break
if not flag:
  if len(s) > 2:
    for j in range(0,len(s)-2):
      if s[j] == s[j+2]:
        flag = True
        k = j+1
        l = j+3
        break
  else:
    None
print(k,l)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000100

int dp[SIZE], dp_o[SIZE];

int main(){
  for(int i=0;i<SIZE;i++) dp[i] = dp_o[i] = i;

  for(int i=2;(ll)i*(i+1)*(i+2)<SIZE*6;i++){
    int num = (ll)i*(i+1)*(i+2)/6;

    for(int j=0;j<SIZE-num;j++){
      dp[j+num] = min(dp[j+num], dp[j] + 1);
      if(num%2)
        dp_o[j+num] = min(dp_o[j+num], dp_o[j] + 1);
    }
  }

  int n;

  while(1){
    scanf("%d", &n);
    if(!n) break;

    printf("%d %d\n", dp[n], dp_o[n]);
  }
  
  return 0;
}



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

int main()
{
    cout.precision(10);
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    double ans=0;
    for(int i=0;i<n;i++)
        ans+=1.0/a[i];
    ans=1.0/ans;
    cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  set<string> st;
  rep(i,n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n , ans = 0 , x;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> x;
        ans = (ans | (x % 2));
    }
    if(!ans)
        cout << "second\n";
    else cout << "first\n";
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"
import "sort"

func main() {
    var N, v, d int
    var list []int

    fmt.Scanf("%d", &N)

    for i := 0; i < N; i++ {
        fmt.Scanf("%d", &v)
        list = append(list, v)
    }
    sort.Sort(sort.IntSlice(list))

    for i := 1; i < N; i++ {
        d += (list[i] - list[i-1])
    }
    fmt.Println(d)
}

Measured memory_bytes: 512
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
  if i >= k:
    ans += 1 / n
  else:
    p = i
    tmp = 1 / n
    while p < k:
      p *= 2
      tmp /= 2
    ans += tmp
print(ans)


Measured memory_bytes: 2940
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    let abc: Vec<i32> = input
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect();
    if abc[0] == abc[1] && abc[1] == abc[2] {
        "No\n".to_string()
    } else if abc[0] == abc[1] {
        "Yes\n".to_string()
    } else if abc[0] == abc[2] {
        "Yes\n".to_string()
    } else if abc[1] == abc[2] {
        "Yes\n".to_string()
    } else {
        "No\n".to_string()
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

bool is_prime(ll n) {
	for(ll i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) return false;
	}
	
	return true;
}

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(ll i = 2LL; i * i <= n; ++i) {
		while( n % i == 0 ) {
			res[i]++;
			n /= i;
		}
	}
	
	if( n != 1 ) res[n] = 1;
	
	return res;
}

int main(void) {
	ll n;
	cin >> n;
	
	if( n == 1LL ) {
		cout << 0 << endl;
		return 0;
	}
	
	if( is_prime(n) ) {
		cout << 1 << endl;
		return 0;
	}
	
	map<ll, ll> mp = prime_factor(n);
	ll ans = 0LL;
	ll i = 1LL;
	bool ok = true;
	map<ll, bool> yes;
	
	for(auto& x : mp) {
		yes[x.first] = true;
	}
	
	ll now = 0LL;
	while( ok ) {
		for(auto& x : mp) {
			ll r = (ll)pow(x.first, i);
			
			if( x.second < i ) {
				yes[x.first] = false;
			} else if( n % r == 0 && x.second >= i ) {
				ans++;
				n /= r;
				x.second -= i;
				yes[x.first] = true;
			}
		}
		
		int cnt = 0;
		for(auto& b : yes) {
			if( !b.second ) cnt++;
		}
		
		if( cnt == yes.size() ) ok = false;
		
		i++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,m;
    cin>>n>>m;
    string s[n],t[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    int ans =0 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]!=t[i][j]) ans++;
        }
    }
    cout << ans << endl;


}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))

ll n;
ll a[100010];
ll solve(int sign){
    ll ans=0;
    ll sum=0;
    rep(i,0,n){
        sum+=a[i];
        if(sign==1){
            if(sum<=0){
                ans=ans+1-sum;
                sum=1;
            }
        }
        else{
            if(sum>=0){
                ans=ans+1+sum;
                sum=-1;
            }
        }
        sign*=-1;
    }

    return ans;

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        cin>>n;
        rep(i,0,n)cin>>a[i];
        cout<<min(solve(1),solve(-1));
    }
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

N, W = map(int, input().split())

weight = []
value = []

for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)

#dp = [[0]*110]*11010
dp=[[0 for _ in range(W+1)] for _ in range(N+1)]
#dp=[[0 for _ in range(110)] for _ in range(11010)]


for i in range(N):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 217620
N,M=map(int,input().split())
A=list(map(int,input().split()))
if(1 in A):
    if(4 in A):
        A.remove(4)
    if(9 in A):
        A.remove(9)
    if(6 in A):
        A.remove(6)
if(5 in A):
    if(3 in A):
        A.remove(3)
    if(2 in A):
        A.remove(2)
if(3 in A):
    if(2 in A):
        A.remove(2)
if(9 in A):
    if(6 in A):
        A.remove(6)
if(7 in A):
    if(9 in A):
        A.remove(9)
    if(6 in A):
        A.remove(6)
num=[0,2,5,5,4,5,6,3,7,6]
dp=[0]
keta=[0]
tmp=0
tmp1=0
tmp_keta=-1
tmp1_keta=-1
for i in range(1,N+1):
    tmp=-1
    tmp_keta=-1
    for j in A:
        tmp1=-1
        tmp1_keta=-1
        if(i-num[j]>=0):
            if(dp[i-num[j]]>0):
                tmp1=dp[i-num[j]]+j*(10**keta[i-num[j]])
                tmp1_keta=keta[i-num[j]]+1
            elif(dp[i-num[j]]==0):
                tmp1=j
                tmp1_keta=1

            if(tmp1>tmp):
                tmp=tmp1
                tmp_keta=tmp1_keta
                
    dp.append(tmp)
    keta.append(tmp_keta)
print(dp[N])

Measured memory_bytes: 15088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String... args) throws IOException {
        final int[] charCount = new int[26];
        final StringBuilder sb = new StringBuilder();
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            final int charactor = br.read();
            if (97 <= charactor && charactor <= 123) {
                charCount[charactor - 97]++;
            } else if (65 <= charactor && charactor <= 91) {
                charCount[charactor - 65]++;
            } else if (charactor == -1) {
                break;
            }
        }
 
        for (int i = 0; i < 26; i++) {
            sb.append(((char) (i + 97))).append(" : ").append(charCount[i]).append(i != 25 ? '\n' : "");
        }
 
        System.out.println(sb);
    }
}

Measured memory_bytes: 17068
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, k, q;
int a[N], nw[N], tt[N];
int tot, cnt;
int ans = 0x7fffffff;
vector<int> V;
int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i = 1;i <= n;i++){
        scanf("%d",&a[i]);
		V.push_back(a[i]);
	}
    sort(V.begin() , V.end());
    V.erase(unique(V.begin() , V.end()), V.end());
    int nn = V.size();
    for(int x = 0;x < nn;x++){
        int t = V[x];
        tot = 0;
        int L = 1;
        for(int i = 1;i <= n + 1;i++){
            if (a[i] < t){
                if (i - 1 >= L){
                    int l = L, r = i-1;
                    cnt = 0;
                    for(int j = l;j <= r;j++) nw[++cnt] = a[j];
                    sort(nw + 1, nw + cnt + 1);
                    int y = cnt - k + 1;
                    for(int j = 1;j <= y;j++) tt[++ tot] = nw[j];
                }
                L = i + 1;
            }
        }
        sort(tt + 1, tt + tot + 1);
        if (tot >= q)
            ans = min(ans, tt[q] - t);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n; cin >> n;
	vector<int> a(n);
	ll sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans = INF, sub = 0;
	rep(i, 0, n-1) {
		sub += a[i];
		ans = min(ans, abs(sum - 2 * sub));
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1024
N, K = gets.split.map(&:to_i)
AS = gets.split.map(&:to_i)

def nums
  return AS if N == K

  sorted = AS.sort_by(&:abs).reverse

  return sorted.last(K) if AS.all? { |n| n < 0 } && K % 2 == 1

  nums = sorted.first(K)

  return nums if nums.select { |n| n < 0 }.count % 2 == 0

  posplus = begin
      plus = sorted[K..-1].find { |n| n > 0 }
      swap = nums.reverse.find { |n| n < 0 }
      [plus, swap]
    end

  negplus = begin
      plus = sorted[K..-1].find { |n| n < 0 }
      swap = nums.reverse.find { |n| n > 0 }
      [plus, swap]
    end

  if negplus.any?(&:nil?) && posplus.any?(&:nil?)
    # numsのままだとマイナスが確定するが、候補にゼロがあればゼロにする
    if sorted[K..-1].any?(&:zero?)
      puts "0"
      exit
    end
    return nums
  end

  swaps = if negplus.any?(&:nil?)
      posplus
    elsif posplus.any?(&:nil?)
      negplus
    elsif (posplus[0] * negplus[1]).abs >= (negplus[0] * posplus[1]).abs
      posplus
    else
      negplus
    end
  nums.length.times.each do |i|
    if nums[i] == swaps[1]
      nums[i] = swaps[0]
      break
    end
  end
  nums
end

result = 1
mod = 10 ** 9 + 7
nums.each do |n|
  result = result * n % mod
end

puts result


Measured memory_bytes: 37480
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll A, B, K; cin >> A >> B >> K;

    {
        ll X = min(A, K);
        A -= X, K -= X;
    }
    {
        ll X = min(B, K);
        B -= X, K -= X;
    }
    printf("%lld %lld\n", A, B);
    return 0;
}


Measured memory_bytes: 256
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for(int i=1;i<10;i++){
			for(int j=1;j<10;j++){
				System.out.println(i+"x"+j+"="+(i*j));
			}
		}

	}

}

Measured memory_bytes: 9180
#include <iostream>
using namespace std;
int main(void){
  int t,h,m,s;
  cin >> t;
  s=t%60;
  t/=60;
  m=t%60;
  t/=60;
  h=t%60;
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

using namespace std;

//int binSearch(vector<int> &v,int cy,int dx,int R){
//	int ub=v.size()-1;
//	int lb=-1;
//	while(ub-lb>1){
//		int mid=ub+lb;
//		mid/=2;
//		if(R-dx>=(cy-v[mid])*(cy-v[mid])){
//			ub=mid;
//		}
//		else{
//			lb=mid;
//		}
//	}
//	return ub;
//}

int main(){
	int an,bn,r;
	int flyX[100001];
	int flyY[100001];
	int px,py;
	vector<int> energy[10001];
	int sum;
	while(cin>>an>>bn>>r&&!(an==0&&bn==0&&r==0)){
		for(int i = 0; i < 10001; i++){
			energy[i].clear();
		}
		for(int i = 0; i < an; i++){
			cin>>flyX[i]>>flyY[i];
		}
		int infoMinX=10000000;
		int infoMaxX=-1;
		
		for(int i = 0; i < bn; i++){
			cin>>px>>py;
			energy[px].push_back(py);
		}
		for(int i = 0; i < 10001; i++){
			sort(energy[i].begin(),energy[i].end());
		}
		sum=0;
		for(int i = 0; i < an; i++){
			int minx=max(0,flyX[i]-4*r);
			int maxx=min(9999,flyX[i]+4*r);
			for(int j = minx; j <= maxx; j++){
				if(energy[j].empty())
					continue;
				int ovlimit=(int)(sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]+EPS);
				double lolimit2=(-sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]);
				int lolimit=(int)(lolimit2+EPS);
				if(!EQ(lolimit2,(int)lolimit2)){
					lolimit++;
				}
				sum+=(upper_bound(energy[j].begin(),energy[j].end(),ovlimit)
					-lower_bound(energy[j].begin(),energy[j].end(),lolimit));
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

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

using namespace std;

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

  vector< pair<int , int> > chan(N);
  int t[N], c[N];

  for(int i = 0; i < N; i++){
    cin >> chan[i].first >> t[i] >> c[i] ;
    chan[i].second = i;
    /*
      chan[i].first    = s
      char[i].second   = index(c & t)
    */
  }

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

  // 連続チャンネル放送の物をくっつける
  vector<pair<int,int> > sequence(31);
  for(int i = 0; i < 31; i++) sequence[i] = make_pair(0,0);
  vector<pair<int,int> > chan2;

  for(int i = 0; i < N; i++){
    int chanNum = c[chan[i].second]; //このチャンネルのが連続しているか
    if(sequence[chanNum].second == chan[i].first){
      sequence[chanNum].second = t[chan[i].second];

    }else{
      if(sequence[chanNum].first != 0) chan2.push_back(sequence[chanNum]);
      //cout << sequence[chanNum].first << "     " << sequence[chanNum].second << endl;
      sequence[chanNum].first = chan[i].first;
      sequence[chanNum].second = t[chan[i].second];
    }
  }

  for(int i = 1; i <= C; i++){
    if(sequence[i].first != 0 && sequence[i].second != 0){
      chan2.push_back(sequence[i]);
    }
  }
  vector<int> cTime(200100,0);
  //imos
  for(int i = 0; i < chan2.size(); i++){
    //cout << chan2[i].first << ' ' << chan2[i].second << endl;
    cTime[2*chan2[i].first] += 1;
    cTime[2*chan2[i].second+2] += -1;
  }

  for(int i = 1; i <= 200010; i++) cTime[i+1] += cTime[i];
  /*for(int i = 1; i <= 50; i++){
    cout << cTime[i] << ' ';
    if(i % 10 == 0) cout << endl;
  }
  //*/
  int ans = 0;
  for(int i = 0; i <= 200010; i++)  ans = max(ans,cTime[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3444
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] A = new Integer[N];
		int sum=0;
		int all_plus=0;
		int all_minus=0;
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			sum+=Math.abs(A[i]);
		}
		Arrays.sort(A);

		if (N==2) {
			System.out.println(A[1]-A[0]);
			System.out.print(A[1]);
			System.out.print(" ");
			System.out.println(A[0]);
		} else {
			Queue<Integer> plus = new ArrayDeque<Integer>();
			Queue<Integer> minus = new ArrayDeque<Integer>();
			List<Integer> list = new LinkedList<Integer>();
			for (int i=0;i<N;i++) {
				if (A[i]>0) {
					plus.add(A[i]);
					all_plus=1;
				} else {
					list.add(A[i]);
					all_minus=1;
				}
			}
			Collections.reverse(list);
			List<Integer> list_2 = new ArrayList<Integer>(list);
			for (int i=0;i<list.size();i++) {
				minus.add(list_2.get(i));
			}
			if (all_plus==0) {
				sum+=2*minus.peek();
			} else if (all_minus==0) {
				sum-=2*plus.peek();
			}
			System.out.println(sum);

			if (plus.isEmpty()) {
				int tmp=minus.remove();
				int tmp_2=minus.remove();
				System.out.print(tmp);
				System.out.print(" ");
				System.out.println(tmp_2);
				plus.add(tmp-tmp_2);
			}
			if (minus.isEmpty()) {
				int tmp=plus.remove();
				int tmp_2=plus.remove();
				System.out.print(tmp);
				System.out.print(" ");
				System.out.println(tmp_2);
				minus.add(tmp-tmp_2);
			}

			while (plus.size()>1) {
				int tmp=plus.remove();
				int tmp_2=minus.remove();
				System.out.print(tmp_2);
				System.out.print(" ");
				System.out.println(tmp);
				minus.add(tmp_2-tmp);
			}

			while (!minus.isEmpty()) {
				int tmp=plus.remove();
				int tmp_2=minus.remove();
				System.out.print(tmp);
				System.out.print(" ");
				System.out.println(tmp_2);
				plus.add(tmp-tmp_2);
			}
		}
	}
}

Measured memory_bytes: 78444
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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

int main() {
    ll x;
    cin >> x;
    ll tmpa, tmpb;
    FOR(a, 0, 200){
        FOR(b, -200, 200){
            if(pow(a,5)-pow(b,5) == x){
                tmpa = a;
                tmpb = b;
                break;
            }
        }
    }
    cout << tmpa << ' ' << tmpb << endl;
}


Measured memory_bytes: 4080
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for (int i=0; i<4; i++) {
      if (s.charAt(i) == '+') ans++;
      if (s.charAt(i) == '-') ans--;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]

t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = P[i]
    dt, dx, dy = (t - t0), (x - x0), (y - y0)
    dd = abs(dx) + abs(dy)
    if not (dd <= dt and dd % 2 == dt % 2):
        print('No')
        break
    t0, x0, y0 = t, x, y
else:
    print('Yes')


Measured memory_bytes: 17352