akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll query(string &s)
{
	cout<<"? "<<s<<'\n';
	fflush(stdout);
	ll x; cin>>x;
	return x;
}

vector<ii> edges;

void out()
{
	cout<<"! ";
	for(int i=0;i<edges.size();i++)
	{
		cout<<"(";
		cout<<edges[i].fi<<","<<edges[i].se<<")";
		if(i+1<edges.size()) cout<<' ';
	}
	cout<<'\n';
	fflush(stdout);
}

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int main()
{
	vector<ii> possible;
	srand(199);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			possible.pb(mp(i,j));
		}
	}
	random_shuffle(possible.begin(),possible.end());
	DSU dsu(n);
	for(int i=0;i<possible.size();i++)
	{
		if(dsu.sameset(possible[i].fi,possible[i].se)) continue;
		string s(n,'0');
		s[possible[i].fi]=s[possible[i].se]='1';
		if(query(s)==1)
		{
			dsu.merge(possible[i].fi,possible[i].se);
			edges.pb(possible[i]);
		}
		if(int(edges.size())>=n-1)
		{
			out();
			return 0;
		}
	}
		
}


Measured memory_bytes: 1488
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,A;cin>>N>>A;
    int X[60];
    for(int i=0;i<N;i++){
        int x;cin>>x;
        x-=A;
        X[i]=x; 
    }
    map<int,ll> mp[60];
    mp[0][X[0]]++;
    for(int i=1;i<N;i++){
        for(auto itr=mp[i-1].begin();itr!=mp[i-1].end();itr++){
            mp[i][itr->first]=mp[i-1][itr->first];
        }
        for(auto itr=mp[i-1].begin();itr!=mp[i-1].end();itr++){
            mp[i][itr->first+X[i]]+=mp[i-1][itr->first];
        }
        mp[i][X[i]]++;
    }
    cout<<mp[N-1][0]<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;

std::vector <int> a;

int main()
{	
	int N,s,s1,s2,t,ave;
	cin >> N;
	a.resize(N);
	s = 0;
	s1 = 0;
	s2 = 0;
	t = 100000;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		s += a[i];
	}
	for (int i = 0; i < N; ++i) {
		s1 += a[i];
		s2 = s - s1;
		if (abs(s1 - s2) < t)t = abs(s1 - s2);
	}
	cout << t << "\n";


}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int                     integer;
#define int                     long long
typedef pair<int, int>          pii;
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define rep(i, a, b)            for(int i = a; i < (b); i++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<(x)<<endl
#define p2(x,y)                 out<<(x)<<' '<<(y)<<endl
#define p3(x,y,z)               out<<(x)<<' '<<(y)<<' '<<(z)<<endl
#define p4(x,y,z,w)             out<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<endl
#define p1d(a,n)                for(int ix=0;ix<n-1;ix++) out<<a[ix]<<' '; out<<a[n-1]<<'\n';
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define pl(x)                   out<<(x)
#define pll(x)                  out<<(x)<<' '
#define range(v)                v.begin(),v.end()
#define all(x)                  begin(x), end(x)
#define sz(x)                   (int)(x).size()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

ll iceildiv(const ll a, const ll b){ if(a==0){return 0;} return (1 + ((a - 1)/b));}
bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a, T b, const int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    string st; s(st);
    int n = sz(st);
    if(st[n - 1] == 's'){
        st += "es";
    }else{
        st += 's';
    }
    p(st);
    return;
}

class APluralForm {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    APluralForm solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam


int main()
{
  ll d,n,s;
  cin >> d >> s >> n;

  string ans = "Yes";
  if (d > s* n ) ans = "No";

  cout << fixed << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
N,K = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

b = Array.new(N+1, 0)
a.map { |a| b[a-1] += 1 }
b.sort!.delete(0)

if b.size <= K
  puts 0
else
  puts b.reverse.drop(K).inject(:+)
end


Measured memory_bytes: 21248
h,w = map(int,input().split())
o = [input() for i in range(h)]
n = [[0] * (w) for i in range(2*h)]
for i in range(2*h):
  for j in range(w):
    n[i][j] = o[i//2][j]
  print(''.join(n[i]))

Measured memory_bytes: 3188
from math import ceil


def check(hs, ws):
    rtn = []
    for i in range(3):
        for j in range(i + 1, 3):
            rtn.append(abs(hs[i] * ws[i] - hs[j] * ws[j]))
    return max(rtn)


h, w = map(int, input().split())

ans = []


hh = [ceil(h / 3), h // 3, h - ceil(h / 3) - h // 3]
ww = [w, w, w]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

h, w = w, h
hh = [ceil(h / 3), h // 3, h - ceil(h / 3) - h // 3]
ww = [w, w, w]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

hh[0] = h // 3
ww[0] = w
hh[1:3] = [h - hh[0], h - hh[0]]
ww[1:3] = [w // 2, ceil(w / 2)]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

hh[0] = ceil(h / 3)
ww[0] = w
hh[1:3] = [h - hh[0], h - hh[0]]
ww[1:3] = [w // 2, ceil(w / 2)]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

h, w = w, h
hh[0] = h // 3
ww[0] = w
hh[1:3] = [h - hh[0], h - hh[0]]
ww[1:3] = [w // 2, ceil(w / 2)]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

hh[0] = ceil(h / 3)
ww[0] = w
hh[1:3] = [h - hh[0], h - hh[0]]
ww[1:3] = [w // 2, ceil(w / 2)]
if hh.count(0) == 0 and ww.count(0) == 0:
    ans.append(check(hh, ww))

print(min(ans))


Measured memory_bytes: 3192
N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]+1):
    for n2 in range(num[1]+1):
        for n3 in range(num[2]+1):
            for n4 in range(num[3]+1):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = sum(w[0][:n1])+sum(w[1][:n2])+sum(w[2][:n3])+sum(w[3][:n4])
                    ans = max(ans,vc)
print(ans)
        

Measured memory_bytes: 3064
N,W=map(int,input().split())
waight=[0]
value=[0]
for _ in range(N):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
SUM_v=sum(value)
dp=[[float("inf")]*(SUM_v+1) for _ in range(N+1)]
dp[0][0]=0
ans=0
for i in range(N):
    for sum_v in range(SUM_v+1):
        dp[i+1][sum_v]=min(dp[i][sum_v],dp[i][max(0,sum_v-value[i+1])]+waight[i+1])
        if dp[i+1][sum_v]<=W:
            ans=max(ans,sum_v)
print(ans)

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    string u = "";
    REP(i, n){
        u += s[i];
        u += t[i];
    }
    cout << u << endl;
    return 0;
}


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

int B[100005];
int N;
long long sum;
int minus_;

int main() {
  cin >> N;
  int a;
  rep(i, N) {
    cin >> a;
    B[i] = abs(a);
    if(a < 0) {
      minus_++;
    }
  }
  sort(B, B+N);
  if(minus_ % 2 == 0) {
    sum = accumulate(B, B+N, 0ll);
  } else {
    sum = accumulate(B+1, B+N, 0ll) - B[0];
  }
  cout << sum << endl;
  return 0;
}



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

using namespace std;

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

  vector<int> w(n), v(n);
  int sum_v = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
    sum_v += v[i];
  }

  // dp[i+1][j] :=
  // i番目までのお菓子から価値の総和がjとなるようにいくつかを選んだとき,
  //             重さの総和の最小値
  const int INF = 1000000009;
  vector<vector<int>> dp(n + 1, vector<int>(sum_v + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int value = 0; value <= sum_v; value++) {
      // i番目のお菓子をナップサックに入れない
      dp[i + 1][value] = min(dp[i + 1][value], dp[i][value]);
      if (value - v[i] >= 0) {
        // i番目のお菓子をナップサックに入れる
        dp[i + 1][value] = min(dp[i + 1][value], dp[i][value - v[i]] + w[i]);
      }
    }
  }
  int ans = 0;
  for (int value = 0; value <= sum_v; value++) {
    if (dp[n][value] <= lim_w) {
      ans = max(ans, value);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 40192
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		a: usize,
	}

	if (n % 500) <= a {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



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

int calc(int x) {
  int sum = 0;
  while (x > 0) {
  	sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    int tmp = calc(i);
  	if (tmp >= A && tmp <= B) sum += i; 
  }
  cout << sum << endl;
}

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

int main() {
	int i;
	int length;
	char input[128];
	int ans = 0;

	while(scanf("%s", input) != EOF) {
		length = strlen(input);

		for(i = 0; i < length / 2 + 1; i++) {
			if(input[i] != input[length - 1 - i])
				break;
		}

		if(i == length / 2 + 1)
			ans++;
	}

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

	return 0;
}

Measured memory_bytes: 540
use std::collections::BinaryHeap;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let mut a: usize = 0;
    let mut b: usize = 0;
    let v: Vec<usize> = input_vector();
    let mut heap = BinaryHeap::new();
    for z in 0..n {
        heap.push(v[z]);
    }
    loop {
        match heap.pop() {
            Some(s) => a += s,
            None => break,
        };
        match heap.pop() {
            Some(s) => b += s,
            None => break,
        };
    }
    println!("{}", a - b);
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){
int a,b;
int c[101];
scanf("%d\n",&a);
for(b=0;a>b;b++){
scanf("%d",&c[b]);
}
b=b-1;
while(b>=0){
if(b!=0){
printf("%d ",c[b]);
b=b-1;
}
else{
printf("%d",c[b]);
b=b-1;
}
}
printf("\n");
return 0;
}



Measured memory_bytes: 2060
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n-1];
        for (int i = 0; i < n-1; i++) {
            b[i] = sc.nextInt();
        }
        
        int count = b[0] + b[n-2];
        for (int i = 0; i < n - 2; i++) {
            count += Math.min(b[i], b[i+1]);
        }
        System.out.println(count);
        
    }
}

Measured memory_bytes: 35928
#include <iostream>

using namespace std;

int main()
{
  int N;
  int m = 0, s = 0, n;
  cin >> N;
  while (N--) {
    cin >> n;
    s += n;
    if (n > m) m = n;
  }
  cout << ((m < s - m) ? "Yes" : "No");
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);

$ss = array();
for ($i=0; $i < $n; $i++) {
  fscanf(STDIN, "%s", $s);
  if (isset($ss[$s])) {
    $ss[$s]++;
  } else {
    $ss[$s] = 0;
  }
}

arsort($ss);

$before = 0;
$answers = array();
foreach ($ss as $k => $v) {
  if ($v >= $before) {
    $answers[] = $k;
  } else {
    break;
  }
  $before = $v;
}

asort($answers);

foreach ($answers as $answer) {
  echo $answer . "\n";
}


Measured memory_bytes: 35316
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    
    if(A<=C && C<=B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int g[16][16],n,x,y,now;

void func2(void);

void func1(void){
  if(x>=n)x=0;
  if(x<0)x=n-1;
  if(y>=n)y=0;

  if(g[y][x]>0)func2();
}

void func2(void){
  if(g[y][x]>0) x--,y++;
  if(x>=n || x<0 || y>=n)func1();
}

int main(void){

  while(cin >> n,n){
    for(int i=0;i<16;i++)
      for(int j=0;j<16;j++)
	g[i][j]=0;

      x=n/2;
      y=n/2+1;
    g[y][x]=1;

    now=2;

    for(int i=1;i<n*n;i++,now++){
      x++;
      y++;
      if(x>=n || x<0 || y>=n)func1();
	 if(g[y][x]>0)func2();
	 g[y][x]=now;
    }

      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  printf("%4d",g[i][j]);
	}
	cout << endl;
      }
    }
    
  return 0;
}

Measured memory_bytes: 1192
s=str(input())
l=list(s)
ans=0
for i in range(len(s)):
    if i%2==0:
        if l[i]=='L':
            ans+=0
        else:
            ans+=1
    else:
        if l[i]=='R':
            ans+=0
        else:
            ans+=1
if ans==len(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())
al = list(map(int,input().split()))

MOD = 10**9 + 7
N = 10**5+1

fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % MOD

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD

from collections import defaultdict
dic = defaultdict(int)

for idx, a in enumerate(al):
    if dic[a] == 1:
        e = idx
        v = a
    dic[a] += 1

for idx, a in enumerate(al):
    if a == v:
        s = idx
        break


for i in range(1, n+2):
    ans = comb(n+1, i)
    if s + n - e >= i - 1:
        ans -= comb(s+(n-e), i-1)
    ans %= MOD
    print(ans)




Measured memory_bytes: 67560
#include <stdio.h>

int euclid(int a, int b){
  while(a%b != 0){
      int r = a%b;
      a = b;
      b = r;
  }
  return b; 
}

int main(){
  int a,b,gcd;

  scanf("%d%d",&a,&b);

  if(a >= b) gcd = euclid(a,b);
  else gcd = euclid(b,a);

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

  return 0;
}





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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
ll a,b,d;
ll A[1000001];
ll H,M,HH,MM;
 
 
int main(){
    cin >> H >> M >> HH >> MM >> K;
    if(HH*60 + MM - K - H*60 - M>=0){
    cout << HH*60 + MM - K - H*60 - M << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

#define MIN(x,y) (((x)<(y))?(x):(y))
#define INFTY (1<<21)


int m, n, k, d, C[7], G[110][110], N, D[110][64];

int getID(char *str);
int isC(int x);
int bellman(void);

int main(void){
  char source[16], target[16];
  int cost,s,t;
  int i,j;
  while(scanf("%d%*c%d%*c%d%*c%d%*c",&m,&n,&k,&d) && m ){
    N = 2 + n + m;
    for(i=1;i<m+1;i++) scanf("%d%*c",&C[i]);
    for(i=0;i<N;i++) for(j=0;j<N;j++) G[i][j] = INFTY;
    for(i=0;i<d;i++){
      scanf("%s%*c%s%*c%d%*c",source,target,&cost);
      s = getID(source);
      t = getID(target);
      G[t][s] = G[s][t] = MIN(G[s][t], cost * k);
    }
    printf("%d\n",bellman());
  }
  return 0;
}

int getID(char *str){
  char num[16];
  if ( str[0] == 'H' ) return 0;
  if ( str[0] == 'D' ) return N - 1;
  strcpy(num,str+1);
  if ( str[0] == 'C' ) return atoi(num);
  return atoi(num) + m;
}

int isC(int x){
  return (1 <= x) && (x <= m);
}

int bellman(void){
  bool change;
  int minv;
  int i,o,u,v,b,j;

  for(i=0;i<N;i++) for(j=0;j<(1<<m);j++) D[i][j] = INFTY;
  D[0][0] = 0;
  for(o=0;o<N*(1<<m);o++){
	change=false;
    for(u=0;u<N;u++){
      for(v=0;v<N;v++){
	if ( u == v || G[u][v] == INFTY ) continue;
	for(b=0;b<(1<<m);b++){
	  if (isC(v) && (b&(1<<(v-1))) != 0 ) continue;
	  if ( isC(v) ) {
	    if ( D[u][b] + G[u][v] - C[v] < D[v][b|(1<<(v-1))] ) {
	      D[v][b|(1<<(v-1))] = D[u][b] + G[u][v] - C[v];
	      change = true;
	    }
	  } else {
	    if ( D[u][b] + G[u][v] < D[v][b] ){
	      D[v][b] = D[u][b] + G[u][v];
	      change = true;
	    }
	  }
	}
      }
    }
    if ( !change ) break;
  }
  minv = INFTY;
  for(i=0;i<(1<<m);i++) minv = MIN(minv, D[N-1][i]);
  return minv;
}

Measured memory_bytes: 688
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

bool binary_search(int n, int t, vector<int> S){
    int l = 0, r = n;
    while(l < r){
        int mid = (l + r) / 2;
        if(S[mid] == t) return true;
        else if(t < S[mid]) r = mid;
        else l = mid + 1;
    }
    return false;
}


int main(){
    int n, q;
    cin >> n;
    vector<int> S(n);
    for(auto &x : S) cin >> x;
    cin >> q;
    vector<int> T(q);
    for(auto &x : T) cin >> x;

    int cnt = 0;
    REP(i, q){
        if(binary_search(n, T[i], S)) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=998244353;
const int N=2e5+5;



int main(){
    int N; cin >> N;
    vi P(N), Q(N);
    for(auto &X: P) cin >> X;
    for(auto &X: Q) cin >> X;
    vi ord(N);
    for(int i=0; i<N; i++) ord[i]=i+1;
    int a, b, cnt=1;
    do{
        if(P == ord) a=cnt;
        if(Q == ord) b=cnt;
        cnt++;
    }while(next_permutation(all(ord)));
    cout << abs(a-b) << endl;
    return 0;
}

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

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

  int tmpN = N;
  int S_N = 0;
  while(tmpN > 0){
    S_N += (tmpN % 10);
    tmpN /= 10;
  }

  if(N % S_N == 0){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }

  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    deque<int> dq;
    rep(i, 0, N) {
        int p = lower_bound(dq.begin(), dq.end(), A[i]) - dq.begin();
        if(p == 0) dq.push_front(A[i]);
        else dq[p-1] = A[i];
    }
    cout << dq.size() << endl;
    return 0;
}


Measured memory_bytes: 1152
implicit none
integer :: n
character(10),allocatable :: str(:)
integer,allocatable :: ns(:)
integer :: i,j,k
logical :: flg

read *,n
allocate(str(n))
allocate(ns(n))

read *,str(1)
ns(1) = len_trim(str(1))

do i = 2, n
   read *,str(i)
   ns(i) = len_trim(str(i))
   if (str(i-1)(ns(i-1):ns(i-1)) /= str(i)(1:1)) then
      write(*,'(a)') 'No'
      stop
   endif
   do j = 1, i-1
      if (ns(i) /= ns(j)) then
         cycle
      endif
	  if (str(i)(1:ns(i)) .eq. str(j)(1:ns(i))) then
         write(*,'(a)') 'No'
         stop
      endif
   enddo
enddo

write(*,'(a)') 'Yes'
end

Measured memory_bytes: 256
loop do
    m, f, r = gets.chomp.split.map(&:to_i)
    # 範囲オブジェクト使えばいい
    break if [m, f, r].all?{ |i| i < 0}
    s = m + f
    ans = [m, f].any?{ |i| i<0 } || s < 30 ? "F" :
        (
            (30...50).include?(s) && r < 50 ? "D" :
            (
                (
                    (50...65).include?(s)) || ((30...50).include?(s) && r>=50 ) ? "C" :
                    ((65...80).include?(s) ? "B" :
                    "A"
                )
            )
        )
    puts ans
end


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

int main(){
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, i, x;
	long long sum = 0;
	int min = 1000000;
	int max = -1000000;
	scanf("%d", &n);
	for (i = 0;i < n;i++)
	{
		scanf("%d", &x);
		if (min >= x)
		{
			min = x;
		}
		if (max <= x)
		{
			max = x;
		}
		sum += (long)x;

	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */
const ll MOD = 1e9 + 7;

ll ex(ll n){
    ll ret = 1;
    for(ll i = 2;i <= n;++i){
        ret = (ret * i) % MOD;
    }
    return ret;
}
int main(){
    ll N, M; cin >> N >> M;
    if(abs(N - M) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(N == M){
        ll ans = ex(N);
        ans = (ans * ans) % MOD;
        cout << (ans * 2) % MOD;
    }else{
        ll ans = ex(N);
        ans = (ans * ex(M)) % MOD;
        cout << ans;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}
 
int main(){
	ll n;
	cin>>n;
	ll mn = 1000;
	for(ll i = 1; i * i <= n; i++){
		if(n%i==0){
			ll a = i;
			ll b = n/i;
			ll a1 = 0, b1 = 0;
			while(a){
				a1++;
				a/=10;
			}
			while(b){
				b1++;
				b/=10;
			}
			mn = min(mn,max((ll)a1,(ll)b1));
		}
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Ai = list(map(int, input().split()))

def calc(start): 
    di = dict()
    for i in range(start, N, 2):
        if Ai[i] in di:
            n = di[Ai[i]]
            di[Ai[i]] = n + 1
        else:
            di[Ai[i]] = 1
    l = []
    for k in di.keys():
        l.append([k, di[k]])
    l.sort(key=lambda x: x[1], reverse=True)
    return l

l1 = calc(0)
l2 = calc(1)

if l1[0][0] != l2[0][0]:
    print(N - l1[0][1] - l2[0][1])
elif len(l1) == 1 and len(l2) == 1:
    print(N // 2)
else:
    v1 = 100000000000000
    v2 = 100000000000000

    if len(l1) > 1:
        v1 = N - l1[1][1] - l2[0][1]
    if len(l2) > 1:
        v2 = N - l1[0][1] - l2[1][1]
    print(min(v1, v2))

Measured memory_bytes: 21340
n=gets.chomp.to_i
ans="Yes"
before=gets.chomp
after=""
st=[before]
(n-1).times{
  after=gets.chomp
  if after[0]!=before[-1] then
    ans="No"
  end
  for i in 0..st.length-1 do
    if after==st[i] then
      ans="No"
    end
  end
  before=after
  st.push(before)
}
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long n;
  cin>>n;
  long long a[n];
  long long s = 0;
  REP(i,n){
    cin>>a[i];
    s += a[i];
  }
  long long asum[n];
  REP(i,n){
    if(i==0){
      asum[i] = a[i];
    }else{
      asum[i] = asum[i-1] + a[i];
    }
  }
  
  long long ans = s;
  REP(i,n){
    long long temp = abs(asum[i] - (s - asum[i]));
    ans = min(ans, temp);
  }
  cout<<ans<<endl;
  
  return 0; 
}


Measured memory_bytes: 3328
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor
int main(){
    llong N;
    cin >> N;
    vector<llong> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    llong maxv=A[0];
    llong ans=0;
    for(int i=1; i<N; i++){
        if(A[i]<maxv){
            ans = ans + (maxv-A[i]);
        }
        if(A[i]>maxv){
            maxv = max(maxv, A[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

//数値から文字列に変換
string num2string(llong num){
    ostringstream oss;
    oss << num;

    return oss.str();
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<bool> ans(n, false);
  vector<int> co(n, 1);
  ans.at(0) = true;
  rep(i, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    co.at(y)++;
    if(ans.at(y) == false)ans.at(y) = ans.at(x);
    co.at(x)--;
    if(co.at(x) == 0) ans.at(x) = false;
  }
  int out = 0;
  rep(i, n) if(ans.at(i) == true) out++;
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 3736
s=int(input())
ss=s
#print(s)

def add(x):
    y=int(x/2)
    return y

def even(x):
    y=3*x+1
    return y

cnt=0
flag=0
for i in range(1000000):
    if flag==0:
        if s%2==0:
            s=add(s)
            cnt+=1
            if s==4:
                flag=1
        else:
            s=even(s)
            cnt+=1
            if s==4:
                flag=1

if ss==1 or ss==2 or ss==4:
  print(4)
else:
  print(cnt+4)




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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long P;
        P = sc.nextLong();
        long Q;
        Q = sc.nextLong();
        long R;
        R = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(P, Q, R);
    }
}

class Solver {
    public void solve(long P, long Q, long R) {
        long M = Math.max(P, Math.max(Q, R));
        System.out.println(P + Q + R - M);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,count=0;
    cin>>n;
    int h[n];
    int i;
    for(i=0;i<n;i++)
    cin>>h[i];
    int max=h[0];
    for(i=0;i<n;i++){
        if(h[i]>=max)
        {
            count++;
            max=h[i];
        }
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3560
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

n1, n2, n3 = 0, 0, 0
for pp in p:
    if pp <= a:
        n1 += 1
    elif pp <= b:
        n2 += 1
    else:
        n3 += 1
print(min(n1, n2, n3))


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

res = [i for i in range(1, 10)]

while K > len(res):
  newR = []
  for e in res:
    m = e % 10
    if m == 9:
      newR.extend([e * 10 + 8, e * 10 + 9])
    elif m == 0:
      newR.extend([e * 10, e * 10 + 1])
    else:
      newR.extend([e * 10 + m - 1, e * 10 + m, e * 10 + m + 1])
  K -= len(res)
  #print(res)
  res = newR

#print(res)

print(res[K - 1])

Measured memory_bytes: 10784
#!/usr/bin/env ruby
a, b, k = gets.chomp.split.map(&:to_i)

yakusu = []
common_yakusu = []

if a > b
  1.upto(b) do |i|
    yakusu << i if b % i == 0
  end

  yakusu.each do |y_i|
    common_yakusu << y_i if a % y_i == 0
  end

  common_yakusu = common_yakusu.reverse

  puts common_yakusu[k - 1]
else
  1.upto(a) do |i|
    yakusu << i if a % i == 0
  end

  yakusu.each do |y_i|
    common_yakusu << y_i if b % y_i == 0
  end

  common_yakusu = common_yakusu.reverse

  puts common_yakusu[k - 1]
end


Measured memory_bytes: 14388
use std::cmp;
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();
    let mut pos = vec![0; n];
    for i in 0..n {
        pos[a[i] - 1] = i;
    }

    let mut max = 0;
    let mut tmp = 1;
    for i in 1..n {
        if pos[i - 1] < pos[i] {
            tmp += 1;
        } else {
            max = cmp::max(max, tmp);
            tmp = 1;
        }
    }
    max = cmp::max(max, tmp);

    println!("{}", n - max);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    ll cnt = 0;
    if (a == b && b == c) {
        if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
            cout << 0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    while (true) {
        if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
            cout << cnt << endl;
            return 0;
        }
        ll tmpa = a, tmpb = b, tmpc = c;
        a = (tmpb + tmpc) / 2;
        b = (tmpa + tmpc) / 2;
        c = (tmpa + tmpb) / 2;
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  COUT(N / 3);
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    string s;
    cin>>n>>s;
    int w = 0;
    int e = 0;

    int ans=1000000;
    int tmp = 0;
    for(int i = 1; i < n; i++){
        if(s[i]=='E') e++;
    }
    ans = e;
    for(int i = 1; i < n; i++){
        if(s[i-1]=='W') w++;
        if(s[i]=='E') {
            e--;
        }
        tmp=w+e;
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 900
fun main(args:Array<String>?): Unit {
    while(true) {
        val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
        if (a == 0 && b == 0) return
        var single = a % b
        var double = (single * 10) % b
        while(single != double){
            single = (single * 10) % b
            double = (double * 100) % b
        }
        var loopLength = if (single != 0) {
            var length = 1
            single = (single * 10) % b
            while (single != double){
                length++
                single = (single * 10) % b
            }
            double = a
            repeat(length){
                double = (double * 10) % b
            }
            length
        }else {
            double = (a * 10) % b
            0
        }
        single = a
        var length = 0
        while(single != double){
            length++
            single = (single * 10) % b
            double = (double * 10) % b
        }
        println("$length $loopLength")
    }
}


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	
	int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	
	if (a - b - c - d == 7) printf("%d-%d-%d-%d=7\n", a, b, c, d);
	else if (a - b - c + d == 7) printf("%d-%d-%d+%d=7\n", a, b, c, d);
	else if (a - b + c - d == 7) printf("%d-%d+%d-%d=7\n", a, b, c, d);
	else if (a - b + c + d == 7) printf("%d-%d+%d+%d=7\n", a, b, c, d);
	else if (a + b - c - d == 7) printf("%d+%d-%d-%d=7\n", a, b, c, d);
	else if (a + b - c + d == 7) printf("%d+%d-%d+%d=7\n", a, b, c, d);
	else if (a + b + c - d == 7) printf("%d+%d+%d-%d=7\n", a, b, c, d);
	else if (a + b + c + d == 7) printf("%d+%d+%d+%d=7\n", a, b, c, d);
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func modInv(a, mod int) int {
	b := mod
	u := 1
	v := 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, A, B := sc.nextInt(), sc.nextInt(), sc.nextInt()
	sum := modPow(2, N, MOD) - 1
	if sum < 0 {
		sum += MOD
	}
	a := comb(N, A)
	b := comb(N, B)
	sum -= a
	if sum < 0 {
		sum += MOD
	}
	sum -= b
	if sum < 0 {
		sum += MOD
	}

	fmt.Fprintln(wtr, sum)
}

func comb(N, K int) int {
	k := 1
	n := 1
	for i := 1; i <= K; i++ {
		k *= i
		k %= MOD
		n *= (N - i + 1)
		n %= MOD
	}
	return (n * modInv(k, MOD)) % MOD
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        if(num == 7){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <complex>
#define rep(i,n) for (int i=0; i<n; i++)

int main() {
    int n;
    long a[200000], snk, ari, diff = 2147000000, sum = 0;
    scanf("%d", &n);
    rep(i,n) {
        scanf(" %ld", &a[i]);
        sum += a[i];
    }
    snk = 0;
    ari = sum;
    rep(i,n-1) {
        snk += a[i];
        ari -= a[i];
        long tmp = std::abs(snk - ari);
        if (tmp < diff)
            diff = tmp;
    }
    printf("%ld\n",diff);
    return 0;
}


Measured memory_bytes: 1664