akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
typedef pair<ld,int> pd;
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 1010;

vector <pd> adjlist[maxn];
pi pos[maxn];
ld dist[maxn];
ld rad[maxn];
ld sx,sy,ex,ey;
int n;

ld calcd(int x1,int y1,int x2,int y2) {
	int x = abs(x1 - x2), y = abs(y1 - y2);
	return sqrtl((ld)x*x + (ld) y*y);
}

priority_queue<pd,vector<pd>,greater<pd>> pq;

int32_t main() {
	FAST
	cin >> sx >> sy >> ex >> ey;
	cin >> n;
	
	for (int i =0;i<n;i++) {
		cin >> pos[i].f >> pos[i].s >> rad[i];
	}
	int S = n, T = n+1;
	
	for (int i =0; i<n;i++) {
		ld d = fmaxl(0LL,calcd(pos[i].f,pos[i].s,sx,sy) - rad[i]);
		adjlist[S].push_back(pd(d,i));
	}
	adjlist[S].push_back(pd(fmaxl(0LL,calcd(sx,sy,ex,ey)),T));
	
	for (int i =0;i<n;i++) {
		ld d = fmaxl(0LL,calcd(pos[i].f,pos[i].s,ex,ey) - rad[i]);
		adjlist[i].push_back(pd(d,T));
	}
	
	for (int i =0;i<n;i++) {
		for (int j=0;j<n;j++) {
			if (i == j) continue;
			ld d = fmaxl(0LL,calcd(pos[i].f,pos[i].s,pos[j].f,pos[j].s) - rad[i] - rad[j]);
			adjlist[i].push_back(pd(d,j));
			adjlist[j].push_back(pd(d,i));
		}
	}
	dist[T] = -1.0;
	dist[S] = 0.0;
	for (int i =0;i<n;i++) dist[i] = -1.0;
	pq.push(pi(0.0,S));
	
	while (!pq.empty()) {
		pd c = pq.top(); pq.pop();
		ld d = c.f; int x = c.s;
		if (d != dist[x]) continue;
		//cout << x << " " << dist[x] << "\n";
		for (auto i: adjlist[x]) {
			if (dist[i.s] == -1.0 or dist[i.s] > d + i.f) {
				dist[i.s] = d + i.f;
				//cout << "GO: " << i.s << " " << i.f << " " << dist[i.s] << "\n";
				pq.push(pd(dist[i.s],i.s));
			}
		}
	}
	cout << fixed << setprecision(10) << dist[T];
	
}













Measured memory_bytes: 75184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
  long x;
  cin>>x;
  while(!IsPrime(x)){
    x++;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N, M, C, B[20], A[200], i, j, count = 0, ans;
	scanf("%d%d%d", &N, &M, &C);
	for (j = 0; j < M; ++j) {
		scanf("%d", &B[j]);
	}
	for (i = 0; i < N; ++i) {
		ans = 0;
		for (j = 0; j < M; ++j) {
			scanf("%d", &A[i, j]);
			ans += A[i, j] * B[j];
		}
		if (ans + C > 0) {
			++count;
		}
	}
	printf("%d", count);
	return 0;
}



Measured memory_bytes: 128
s = input()
n1 = ''
n2 = ''
for i in range( (len(s)-1)//2 ):
    n1 += s[i]

for i in range((len(s)+2)//2, len(s)):
    n2 += s[i]

if n1 == n2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};


ld an(double h, double m)  
{  
    ld ho = 0.5 * (h * 60 + m);  
    ld mi = 6 * m;  
  
    ld ang = abs(ho - mi);  
  
    ang = min(360 - ang, ang);  
  
    return ang;  
} 

int main()
{
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	ld q= an(h, m);
	ld fuck = cos((pi*q/180.));
	ld c = sqrt(a*a+b*b-2*a*b*fuck);
	cout << setprecision(10) << fixed << c;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 4168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>

using namespace std;


int main() {

    unsigned long long N;scanf("%llu", &N);
    unsigned long long M;scanf("%llu", &M);

    unsigned long long ans = 0;

    if(N==1&&M==1){
        ans=1;
    }else {

        if (N >= 3 && M >= 3) {
            ans = (N - 2) * (M - 2);
        } else if (N == 1) {
            ans = M - 2;
        } else if (M == 1) {
            ans = N - 2;
        }
    }

    printf("%llu", ans);

    return 0;

}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto s = new long[][](M);
	foreach (i; 0..M)
	{
		auto tmp = RDR.ARR(-1L);
		s[i] = tmp[1..$];
	}
	auto p = RDR.ARR;
	
	long ans;
	foreach (i; 0..2^^N)
	{
		bool f()
		{
			foreach (j; 0..M)
			{
				long cnt;
				foreach (e; s[j])
				{
					auto bit = 1LU << e;
					if (i & bit)
						++cnt;
				}
				if (cnt % 2 != p[j]) return false;
			}
			return true;
		}
		if (f())
		{
			++ans;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

Console.ReadLine() |> (fun c -> if List.contains c ["a";"i";"u";"e";"o"] then "vowel" else "consonant") |> Console.WriteLine


Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  if (!k) {
    cout << n * n << endl;
    return 0;
  }
  long long ret = 0;
  for (int b = k + 1; b <= n; b++) {
    ret += n + 1 - (k * (n / b) + min(k, n % b + 1));
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

const ll MAX = 100010;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
  const ll mod=1e9+7;
  int n,k,i;
  ll a[100000];

  COMinit();
  cin>>n>>k;

  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);

  int left=0,right=n-1;
  ll sum=0;
  for(i=n-1;i>=k-1;i--){
    ll c=COM(i,k-1);
    sum+=(c*a[right])%mod;
    sum%=mod;
    sum-=(c*a[left])%mod;
    sum%=mod;

    left++;
    right--;
  }

  if(sum<0)sum+=mod;

  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double n,k;
    int cnt=1;
    cin >> n >> k;
    double m=k;
    while(1){
        m/=2;
        if(m<1) break;
        ++cnt;
    }
    vector<int> a(cnt+1,0);
    if(n>=k) a[0]=n-k+1;
    for(int i=1; i<=cnt; ++i){
        int x=(k-1)/pow(2,i-1);
        int y=(k-1)/pow(2,i);
        rep(j,n){
            if(x>j && y<=j) ++a[i];
        }
    }
    double res=a[0];
    for(int i=1; i<cnt+1; ++i){
        res+=a[i]/pow(2,i);
    }
    cout << fixed << setprecision(15) << (res/n) << "\n";
    return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int x , a , n; cin >> x >> n;
	int value;
	int ans = INT_MAX;
	set<int> hash;
	for(int i = 0 ; i < n ; i++){
		cin >> a;
		hash.insert(a);
	}
	if(n==0){
		cout<<x;
		return;
	}
	for(int i = -200 ; i <= 200 ; i++){
		if(hash.find(i) == hash.end()){
			if(abs(i-x) < ans){
				ans = min(ans,abs(i-x));
				value = i;
			}
		}
	}
	cout<<value;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3660
n = int(input())
s = list(input())
dp = [0 for i in range(n+1)]

for i in range(n):
    if (s[i] in s[i+1:]) and (s[i] not in s[:i]):
        dp[i+1] = dp[i]+1
    elif (s[i] not in s[i+1:]) and (s[i] in s[:i]):
        dp[i+1] = dp[i]-1
    else:
        dp[i+1] = dp[i]

print(max(dp))


Measured memory_bytes: 3064
n,m,x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
sum = Array.new(n + 2, 0)
a.each do |i|
    sum[i + 1] += 1
end
(n+2).times do |i|
    if i > 0
        sum[i] += sum[i - 1]
    end
end

p [sum[x], sum[n + 1] - sum[x]].min

Measured memory_bytes: 1788
a,b,c,d=map(int,input().split())
X=[a,b]
Y=[c,d]
if a<=0<=b:
    X.append(0)
if c<=0<=d:
    Y.append(0)
ans=-10**30
for x in X:
    for y in Y:
        if ans<x*y:
            ans=x*y
print(ans)



Measured memory_bytes: 61684
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int i=a;
		int x=0;
		while(i<=b){
			if(c%i==0){
				x++;
			}
			i++;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 26336
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {


	char str[1200] = { 0 };
	char newStr[1200] = { 0 };

	scanf("%[^\n]",&str);

	int i = 0;
	for (; i < 1200; i++) {
		if ((char)64 < str[i] && str[i] < (char)91) {
			newStr[i] = str[i] + (97 - 65);
		}
		else if ((char)96 < str[i] && str[i] < (char)123) {
			newStr[i] = str[i] - (97 - 65);
		}
		else {
			newStr[i] = str[i];
		}
		
	}
	printf("%s\n", newStr);

	return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<int> a(n);
   int cnt = 0;
   for(int i = 0; i < n;i++) {
      cin >> a[i];
      if(i%2==0&&a[i]%2==1)cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;

signed main(){
    cin >> N >> S;
    int l = 0;
    int n = 0;
    rep(i, N){
        if(S[i] == '(') n++;
        else{
            if(n > 0) n--;
            else{
                l++;
            }
        }
    }

    rep(i, l) cout << "(";
    cout << S;
    rep(i, n) cout << ")";
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
 
vector<int> len;
vector<map<int, int> > value;
 
int dfs(string& s, int& k)
{
    if(isdigit(s[k])){
        int ret = 0;
        while(k < s.size() && isdigit(s[k])){
            ret *= 10;
            ret += s[k] - '0';
            ++ k;
        }
        return ret;
    }
 
    char c = s[k];
    k += 2;
    int a = dfs(s, k);
    ++ k;
 
    if(k < s.size() && s[k] == '='){
        ++ k;
        if(a == -1 || a >= len[c])
            return -1;
        int ret = dfs(s, k);
        return value[c][a] = ret;
    }else{
        if(a == -1 || value[c].find(a) == value[c].end())
            return -1;
        else
            return value[c][a];
    }
}
 
int solve(vector<string>& s)
{
    len.assign(128, 0);
    value.assign(128, map<int, int>());
 
    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i].find('=') == string::npos){
            int k = 2;
            len[s[i][0]] = dfs(s[i], k);
        }else{
            int k = 0;
            if(dfs(s[i], k) == -1)
                return i + 1;
        }
    }
 
    return 0;
}
 
int main()
{
    for(;;){
        vector<string> s;
        for(;;){
            string t;
            cin >> t;
            if(t == ".")
                break;
            s.push_back(t);
        }
 
        if(s.empty())
            return 0;
 
        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1340
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (n * k % 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){  
	int K, S;
	cin >> K >> S;
	int pattarn = 0;
	for(int i = 0; i <= K; i++){
		for(int j = 0; j <= K; j++){
			int Z = S - (i + j);
			if(0 <= Z && Z <= K){
				pattarn++;
			}
		}
	}
	cout << pattarn << endl;
}

Measured memory_bytes: 256
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	rep(i, k){
		if (i % 2 == 0)b += a / 2, a /= 2;
		else a+=b/2,b/=2;
}
	cout << a << ' ' << b << endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[100005];
string s;
int main() {
	int i, k;
	cin>>s;
	n = s.size();
	for(i=0; i<n; i++) {
        if(s[i]=='R'){
            k=i;
        }else{
            a[k+(i-k)%2]++;
        }
    }
    for(i=n-1; i>=0; i--) {
        if(s[i]=='L'){
            k=i;
        }else{
            a[k-(k-i)%2]++;
        }
    }
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1024
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o E.exe E.cpp 
Execute: ./E
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
#include <unordered_set> 
using namespace std;

// Driver function to sort the vector elements by  
// first element of pair in descending order 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 

int main() { 	
	int h, w, m, 
		h_dummy,
		w_dummy; 
	vector<int>	h_vals (300000, 0), 
			w_vals (300000, 0); 
	vector<pair<int, int>> best_rows, best_cols; 
	set<pair<int, int>> bombs; 
		
	cin >> h >> w >> m;
	
	for(int i = 0; i < m; i++) {
		cin >> h_dummy; 
		cin >> w_dummy; 
		h_vals[h_dummy-1]++; 
		w_vals[w_dummy-1]++; 
		bombs.insert(make_pair(h_dummy-1, w_dummy-1));
	}
	
	for(int i = 0; i < h; i++) {
		if(h_vals[i] > 0) 
			best_rows.push_back(make_pair(h_vals[i], i)); 
	}
	
	for(int i = 0; i < w; i++) {
		if(w_vals[i] > 0) 
			best_cols.push_back(make_pair(w_vals[i], i)); 
	}
	
	sort(best_rows.begin(), best_rows.end(), sortinrev); 
	sort(best_cols.begin(), best_cols.end(), sortinrev); 
	
	int bomb_dummy; 
	if(bombs.find(make_pair(best_rows[0].second,best_cols[0].second)) != bombs.end()) 
		bomb_dummy = 1; 
	else 
		bomb_dummy = 0; 
	int max_value = best_rows[0].first + best_cols[0].first - bomb_dummy, 
		biggest_possible = best_rows[0].first + best_cols[0].first; 
	
	for(int i = 0; best_rows[i].first + best_cols[0].first >= max_value && i < best_rows.size(); i++) {
		for(int j = 0; j < best_cols.size() && best_rows[i].first + best_cols[j].first >= max_value; j++) {
		
			if(best_rows[i].first + best_cols[j].first < max_value) 
				break; 
		
			if(bombs.find(make_pair(best_rows[i].second,best_cols[j].second)) != bombs.end()) 
				bomb_dummy = 1; 
			else 
				bomb_dummy = 0; 
			
			if(best_rows[i].first + best_cols[j].first - bomb_dummy == biggest_possible) {
				max_value = biggest_possible; 
				break; 
			}
			
			if(max_value == biggest_possible) 
				break; 
			
			// cout << "Check: " << i << " " << j << "\t" << best_rows[i].first << " " << best_cols[j].first << " " << best_rows[i].first + best_cols[j].first - bomb_dummy << endl; 
		}
		if(max_value == biggest_possible) 
			break; 
	}
	
	cout << max_value << endl; 
	
	return 0; 
} 


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

void solve(){
   string s;
   cin >> s;
   cout << ((s[2]==s[3] && s[4]==s[5]) ? "Yes" : "No");
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t=1;
    while(t--)
    {
        solve();
    }

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

const long mod = 1000000007;

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

  int H, W, K;
  cin >> H >> W >> K;
  long dp[H + 1][W];
  fill(dp[0], dp[H + 1], 0);
  dp[0][0] = 1;

  for (int h = 0; h < H; ++h) {
    for (int b = 0; b < (1 << (W - 1)); ++b) { // 立っているbit = 横棒
      // 隣り合っているケース
      bool ok = true;
      for (int i = 0; i < W - 2; ++i) {
        if ((b >> i) % 4 == 3) {
          ok = false;
          break;
        }
      }
      if (!ok) {
        continue;
      }

      // 移動先
      int ws[W];
      for (int i = 0; i < W; ++i) {
        ws[i] = i;
      }
      for (int i = 0; i < W - 1; ++i) {
        if ((b >> i) % 2 == 1) {
          swap(ws[i], ws[i + 1]);
        }
      }

      // dpを計算
      for (int i = 0; i < W; ++i) {
        dp[h + 1][ws[i]] += dp[h][i];
        dp[h + 1][ws[i]] %= mod;
      }
    }
  }

  cout << dp[H][K - 1] << "\n";
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
    int r, c, i, j, a, sumOfR, sumOfC[101] = {};

    scanf("%d%d", &r, &c);
    for(i = 0; i < r; i++) {
        scanf("\n");
        sumOfR = 0;
        for(j = 0; j < c; j++) {
            scanf("%d", &a);
            printf("%d ", a);
            sumOfR += a;
            sumOfC[j] += a;
        }
        printf("%d\n", sumOfR);
        sumOfC[c] += sumOfR;
    }

    for(j = 0; j < c; j++) {
        printf("%d ", sumOfC[j]);
    }
    printf("%d\n", sumOfC[c]);
}



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

char S[ 100 ];
char T[ 100 ];

bool bChk( const char *A, const char *B )
{
int i;
char C;

	i = 0;
	while( ( C = B[ i ] ) != '\0' )
	{
		if( A[ i ] != '?' && A[ i ] != C ) return false;

		i++;
	}

	return true;
}

void Conv( char *A, const char *B, int iPos )
{
int i;
char C;

	i = 0;
	while( ( C = A[ i ] ) != '\0' )
	{
		if( C == '?' ) A[ i ] = 'a';

		i++;
	}

	i = 0;
	while( ( C = B[ i ] ) != '\0' )
	{
		A[ i + iPos ] = C;
		i++;
	}
}

bool Comp( const char *A, const char *B )
{
int i;
char C;
char D;

	i = 0;
	while( ( C = A[ i ] ) != '\0' )
	{
		D = B[ i ];
		if( C < D ) return false;
		if( C > D ) return true;

		i++;
	}

	return false;
}

int main()
{
int i;
int iEnd;
char C;
char X[ 100 ];
char Y[ 100 ];

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

	cin >> S;
	cin >> T;

	iEnd = strlen( S ) - strlen( T );
	if( iEnd < 0 )
	{
		cout << "UNRESTORABLE" << endl;

		return 0;
	}

	X[ 0 ] = '\0';
	for( i = 0; i <= iEnd; i++ )
	{
		if( ! bChk( S + i, T ) ) continue;

		strcpy( Y, S );
		Conv( Y, T, i );
		if( X[ 0 ] == '\0' )
			strcpy( X, Y );
		else if( Comp( X, Y ) )
			strcpy( X, Y );
	}

	if( X[ 0 ] == '\0' )
		cout << "UNRESTORABLE" << endl;
	else
		cout << X << endl;

	return 0;
}




Measured memory_bytes: 256
#C
import math

n,k=map(int,input().split())

data=[[0,1]]
for i in range(1,19):
    data.append([i,2**i])

j=0
while n*data[j][1]<k:
    j+=1

a=0
i=n

while i>=1:
    if i*data[j][1]>=k:
        a+=1/(n*data[j][1])
    else:
        j+=1
        a+=1/(n*data[j][1])
    i-=1

print(a)

Measured memory_bytes: 38768
#include "iostream"
#include "iomanip"

using namespace std;

int main() {
  int a, b, p, q, r;
  cin >> a >> b >> p >> q >> r;
  int dist = p * b - q * (b - a);
  cout << setprecision(15) << b + 1.0 * dist / (r + q) << endl;
  return 0;
}


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

int main() {
  int n;
	cin >> n;
	if(n % 2 == 0) {
		cout << (n / 2) - 1 << endl;
	}else {
		cout << ((n + 1) / 2) - 1 << endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>
#define ll long long 
#define rep(i,a) for(int i= 0;i < a;i++)
using namespace std;

int main() {
    #ifndef ONLINE_JUDGE
		freopen("input.txt", "r" , stdin);
		freopen("output.txt", "w" , stdout);
	#endif
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
   ll n,k;
   cin>>n>>k;
   ll a[n];
   rep(i,n){a[i] = 1;}
   while(k--)
   {
   	ll d;
   	cin>>d;
   	while(d--){
   		ll t;
   		cin>>t;
   		if(a[t-1] != 0) a[t-1] = 0;
   	}
   }
   ll c=0;
   rep(i,n){if(a[i] == 1) c++;
   }
   cout<<c;

   return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  vector<char> C(N);
  REP(i, N) cin >> C[i];
  int ans = 0;
  REP(i, 10) {
    REP(j, 10) {
      REP(k, 10) {
        int num = 0;
        REP(l, N) {
          if (num == 0) {
            if (C[l] == i + '0') num++;
          } else if (num == 1) {
            if (C[l] == j + '0') num++;
          } else if (num == 2) {
            if (C[l] == k + '0') ans++, num++;
          }
        }
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, CC;
        public int[,] D;
        public int[,] C;

        public void Run()
        {
            // input
            {
                var line = Input.ReadIntArray();
                N = line[0];
                CC = line[1];
                D = new int[CC, CC];
                C = new int[N, N];
            }

            for (int cfrom = 0; cfrom < CC; cfrom++)
            {
                var line = Input.ReadIntArray();
                for (int cto = 0; cto < CC; cto++)
                    D[cfrom, cto] = line[cto];
            }

            for (int y = 0; y < N; y++)
            {
                var line = Input.ReadIntArray();
                for (int x = 0; x < N; x++)
                    C[y, x] = line[x] - 1;
            }

            // Run
            var S = new long[CC, 3];
            for (int c = 0; c < CC; c++)
            for (int m = 0; m < 3; m++)
            {
                long s = 0;
                for (int y = 0; y < N; y++)
                for (int x = 0; x < N; x++)
                    if ((y + x) % 3 == m)
                        s += D[C[y, x], c];

                S[c, m] = s;
            }

            long ret = long.MaxValue;
            for (int c1 = 0; c1 < CC; c1++)
            for (int c2 = 0; c2 < CC; c2++)
            for (int c3 = 0; c3 < CC; c3++)
            {
                if (c1 == c2 || c1 == c3 || c2 == c3) continue;
                long r = S[c1, 0] + S[c2, 1] + S[c3, 2];
                ret = Math.Min(ret, r);
            }
            
            Console.WriteLine(ret);

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 17504
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n;
	cin >> n;
	cout << (n - 1) * n / 2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, W;
  cin >> N >> W;
  int64_t vec[N][2];
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec[i][j];
    }
  }
  int64_t dp[N][W+1]; 
  for(int i=0; i<N; i++){
    for(int j=0; j<W+1; j++){
      dp[i][j] = 0;
    }
  }
  
  for(int i=0; i<N; i++){
    int64_t x = vec[i][0];
    int64_t y = vec[i][1];
    dp[i][x] = max(dp[i][x],y);
    if(i != 0){
      for(int j=0; j<W+1; j++){
        if(dp[i-1][j] != 0 && j+x < W+1){
          dp[i][j+x] = max(dp[i][j+x], dp[i-1][j] + y);
        }
        dp[i][j] = max(dp[i][j], dp[i-1][j]);
      }
    }
  }
  
  int64_t ans = 0; 
  for(int i=0; i<W+1; i++){
    ans = max(ans,dp[N-1][i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 78336
n = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0
for i in range(n):
    candy = 0
    candy += sum(A1[:i+1])
    candy += sum(A2[i:])
    ans = max(ans, candy)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n;
	std::cin >> n;
	std::cout << (10000-n)%1000 << std::endl;
	return 0;
}


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

int64_t get_lcm32(vector<int> &a);

int main()
{

	int n,m;
	cin >> n >> m;

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

	for (int i=0;i<n;++i)
	{
		a[i]/=2;
	}

	// check count of pow2
	int count_of_pow2=-1;
	for (int i=0;i<n;++i)
	{
		int count=0;
		int aa=a[i];
		while ((aa%2)==0)
		{
			aa/=2;
			++count;
		}
		if (count_of_pow2>=0)
		{
			if (count!=count_of_pow2)
			{
				// not all pow2 are same, then no semi-common-multiple exists...
				cout << 0 << endl;
				return 0;
			}
		}
		else
		{
			count_of_pow2=count;
		}
	}

	int64_t lcm=get_lcm32(a);
	if (lcm<0)
	{
		cout << 0 << endl;
		return 0;
	}

	cout << m/lcm-m/(2*lcm) << endl;
	return 0;
}

int64_t get_lcm32(vector<int> &a)
{
	int64_t lcm;

	if (a.size()<=0)
	{
		return -1;
	}
	lcm=a[0];

	for (int i=1;i<a.size();++i)
	{
		lcm=lcm/__gcd(lcm,(int64_t)a[i])*a[i];
		if (lcm>=(int64_t)1<<32)
		{
			return -1;
		}
	}
	return lcm;
}









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

using namespace std;

int main()
{
  string S, T;
  int sum1[4001][26] = {{}}, sum2[4001][26] = {{}};

  cin >> S >> T;
  for(int i = 0; i < S.size(); i++) {
    for(int j = 0; j < 26; j++) sum1[i + 1][j] = sum1[i][j] + (S[i] == j + 'a');
  }
  for(int i = 0; i < T.size(); i++) {
    for(int j = 0; j < 26; j++) sum2[i + 1][j] = sum2[i][j] + (T[i] == j + 'a');
  }

  vector< int > array(26);
  for(int i = min(S.size(), T.size()); i >= 0; i--) {
    set< vector< int > > sets;
    for(int j = 0; j <= S.size() - i; j++) {
      for(int k = 0; k < 26; k++) array[k] = sum1[j + i][k] - sum1[j][k];
      sets.insert(array);
    }
    for(int j = 0; j <= T.size() - i; j++) {
      for(int k = 0; k < 26; k++) array[k] = sum2[j + i][k] - sum2[j][k];
      if(sets.find(array) != sets.end()) {
        cout << i << endl;
        return (0);
      }
    }
  }
}

Measured memory_bytes: 4684
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vi A(N);
  cin >> A;
  int ans = 0;
  rep(i, 0, N) {
    if ((i + 1) % 2 && A[i] % 2) {
      ans++;
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3652
#include<string>
#include<iostream>
#include<cmath>
#define MIN 1e13
typedef long long ll;
using namespace std;

int
main(void)
{
  int n; cin >> n;
  if(n % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  string s; cin >> s;
  int half_index = s.length() / 2;

  for(int i = 0; i < s.length() /2; ++i){
    if(s[i] != s[half_index]){
      cout << "No" << endl;
      return 0;
    } 
    half_index++;
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from math import ceil
def input():
    return sys.stdin.readline()[:-1]
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def main():
    N = int(input())
    P = []
    for _ in range(N):
        P.append(list(map(int,input().split())))
    P = sorted(P)
    K = []
    if N == 1:
        print(1)
        exit(0)
    for k in range(N-1):
        for l in range(k+1,N):
            a, b, c, d = P[k][0], P[k][1], P[l][0], P[l][1]
            e = c-a
            f = d-b
            K.append((e,f))
    C = Counter(K).most_common()
    S = set([])
    temp = 0
    for k in range(N-1):
        for l in range(k+1,N):
            a, b, c, d = P[k][0], P[k][1], P[l][0], P[l][1]
            e = c-a
            f = d-b
            if e == C[0][0][0] and f == C[0][0][1]:
                if k not in S or l not in S:
                    S.add(k)
                    S.add(l)
                    temp += 1
    print(N-temp)
if __name__ == '__main__':
    main()


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c && c == a){
    cout << 1 << endl;
  }
  else if (a != b && b != c && c != a){
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}


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

const int N = 3010;
string s, t;
int trace[N][N];
int dp[N][N];

int main() {
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    for(int i=0; i<=n; i++) {
        dp[i][0] = 0;
    }
    for(int j=0; j<=m; j++) {
        dp[0][j] = 0;
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if(s[i-1]==t[j-1]) {
                trace[i][j] = 0;
                dp[i][j] = dp[i-1][j-1] + 1;
            }else {
                if(dp[i-1][j]>dp[i][j-1]) {
                    trace[i][j] = 1;
                    dp[i][j] = dp[i-1][j];
                }else {
                    trace[i][j] = 2;
                    dp[i][j] = dp[i][j-1];
                }
            }
        }
    }
    string ans;
    while(n && m) {
//        printf("%d, %d : %d\n", n, m, trace[n][m]);
        if(trace[n][m] == 0) {
            ans.push_back(s[n-1]);
            --n; --m;
        }else if(trace[n][m] == 1) {
            --n;
        }else if(trace[n][m] == 2) {
            --m;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
    return 0;
}
/*
// memorize dp
int lcs(int n, int m) {
    if(n==0 || m == 0) return 0;
    if(dp[n][m]) return dp[n][m];
    if(s[n-1] == t[m-1]) {
        trace[n][m] = 0;
        dp[n][m] = lcs(n-1, m-1)+1;
    }else {
        int a = lcs(n-1, m);
        int b = lcs(n, m-1);
//        printf("%d, %d : %d, %d\n", n, m, a, b);
        if(a>b) {
            dp[n][m] = a;
            trace[n][m] = 1;
        }else {
            dp[n][m] = b;
            trace[n][m] = 2;
        }
    }
    return dp[n][m];
}
int main() {
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    memset(dp, 0, sizeof(dp));
    lcs(n, m);
    string ans;
    while(n && m) {
//        printf("%d, %d : %d\n", n, m, trace[n][m]);
        if(trace[n][m] == 0) {
            ans.push_back(s[n-1]);
            --n; --m;
        }else if(trace[n][m] == 1) {
            --n;
        }else if(trace[n][m] == 2) {
            --m;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 70912
n=int(input())
a=[int(i) for i in input().split()]
ans=True
c=[]
t=sum(a)//((n*(n+1))//2)

if sum(a)%((n*(n+1))//2)!=0:
    ans=False
else:
    for i in range(n):
        if i==0:
            d=a[0]-a[-1]
        else:
            d=a[i]-a[i-1]
        if (t-d)%n!=0 or d-t>0:
            ans=False
            break
if n==1:
    ans=True
print('YES' if ans else 'NO')

Measured memory_bytes: 62832
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func main() {
	sc.Split(bufio.ScanWords)
	A, B, K := getInt(), getInt(), getInt()

	if A >= K {
		out(A-K, B)
	} else {
		out(0, max(0, A+B-K))
	}
}


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

int main() {
  int N; cin>>N;
  int count=0;
  for(int i=1;i<=N;i+=2){
    int c=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0){
        c++;
      }
    }
    if(c==8){
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long long int a, b, c, d, tmp, tmp1, tmp2;
	cin >> a >> b >> c >> d;
	tmp1 = c;
	tmp2 = d;
	while (d % c != 0) {
		tmp = d % c;
		d = c;
		c = tmp;
	}
	long long int kouyaku =tmp1*tmp2/ c;
	long long int sum1 = b / tmp1;
	long long int sum2 = b / tmp2;
	long long int sum3 = b / kouyaku;
	long long int sum4 = (a - 1) / tmp1;
	long long int sum5 = (a - 1) / tmp2;
	long long int sum6 = (a - 1) / kouyaku;
	
	
	cout << b - ((sum1 + sum2 - sum3) + ((a - 1) - (sum4 + sum5 - sum6))) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();

		if (!s.startsWith("A")) {
			System.out.println("WA");
			return;
		}

		int cindex = -1;
		String ss = s.substring(2, s.length() - 1);
		for (int i = 0; i < ss.length(); i++) {
			if (ss.charAt(i) == 'C') {
				if (cindex == -1) {
					cindex = i + 2;
				} else {
					System.out.println("WA");
					return;
				}
			}
		}

		if (cindex == -1) {
			System.out.println("WA");
			return;
		}
		boolean flag = false;

		for (int i = 0; i < s.length(); i++) {
			if (i == 0 || i == cindex)
				continue;
			if (s.charAt(i) < 'a' || 'z' < s.charAt(i)) {
				flag = true;
			}
		}

		System.out.println(flag ? "WA" : "AC");

	}

}

Measured memory_bytes: 22484
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [IL()[::-1] for i in range(N)]

used = [-1]*N
updatelist = [i for i in range(N)]
total = N*(N-1)//2
cnt = 0
days = 0
ul = []
while updatelist:
  ul = []
  for i in updatelist:
    #print(a)
    #print(i+1)
    if len(a[i]) > 0 and used[i] != days:
      numIND = a[i][-1] -1
      #print(numIND+1)
      if a[numIND][-1] == i+1 and used[numIND] != days:
        a[i].pop(-1)
        a[numIND].pop(-1)
        used[i] = days
        used[numIND] = days
        ul.append(i)
        ul.append(numIND)
        cnt += 1
  else:
    updatelist = ul[:]
    if len(ul) != 0:
      days += 1
#print(a)
#print(cnt)
if cnt == total:
  print(days)
else:
  print(-1)

Measured memory_bytes: 59996
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,d,n;
    cin>>a>>n;
    int ara[n];
    int sum =0;
    for(int i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    if(sum>=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using std::sort;
using std::max;

int dp[400][400];
struct apply{
    int a, b, c;
}applys[10000];
bool comp(apply a, apply b){return a.a < b.a;}

int main(){
    int N;
    while(scanf("%d", &N) && N){
        for(int i=0 ; i<=366 ; i++)
            for(int j=0 ; j<=366 ; j++)
                dp[i][j] = 0;
        for(int i=0 ; i<N ; i++){
            scanf("%d %d %d", &applys[i].a, &applys[i].b, &applys[i].c);
        }
        sort(applys, applys+N, comp);
        int ptr = 0;
        for(int i=0;i<366;i++){
            while(ptr<N && applys[ptr].a==i){
                int k = applys[ptr].b+1;
                int c = applys[ptr].c;
                for(int j=366;j>=i;j--){
                    dp[k][j] = max(dp[k][j], dp[i][j]+c);
                    dp[j][k] = max(dp[j][k], dp[j][i]+c);
                }
                ptr++;
            }
            for(int j=i;j<=366;j++){
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
                dp[j][i+1] = max(dp[j][i+1], dp[j][i]);
            }
            dp[i+1][i+1] = max(dp[i+1][i+1], dp[i][i+1]);
        }
        printf("%d\n", dp[366][366]);
    }
    return 0;
}

Measured memory_bytes: 1636
s=input()
n=len(s)
l=[]
i = 0
cnt = 0
while i<n:
  if (len(l)%2) ^ (s[i]=='>'):
    l.append(cnt)
    cnt = 1
  else:
    cnt += 1
  i += 1
l.append(cnt)
if len(l)%2:
  l.append(0)
ans=0
for i in range(0,len(l),2):
  ans += l[i] * (l[i] - 1) // 2
  ans += l[i+1]*(l[i+1]-1) // 2
  ans += max(l[i],l[i+1])
print(ans)

Measured memory_bytes: 6304
import itertools
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
 
INF = 10 ** 18
answer = INF
for pattern in itertools.product(range(4), repeat = N):
  x = [0] * 4
  MP = 0
  for take, length in zip(pattern, L):
    if take == 3:
      continue
    if x[take] != 0:
      MP += 10
    x[take] += length
  if x[0] == 0 or x[1] == 0 or x[2] == 0:
    continue
  MP += abs(A-x[0])
  MP += abs(B-x[1])
  MP += abs(C-x[2])
  if answer > MP:
    answer = MP
print(answer)

Measured memory_bytes: 3064
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


H, A = fetch_int_input()
import math
print(math.ceil(H / A))


Measured memory_bytes: 38512
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 3005;

string s,t;
int n,m;
int dp[MAXN][MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>s>>t;
	n=s.length(), m=t.length();
	fore(i,0,n) fore(j,0,m)
	{
		if(i && j && s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j], dp[i-1][j-1]+1);
		if(i) dp[i][j]=max(dp[i][j], dp[i-1][j]);
		if(j) dp[i][j]=max(dp[i][j], dp[i][j-1]);
	}
	string ans;
	int i=n, j=m;
	while(i && j)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1]; i--; j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}
	
	reverse(ans.begin(), ans.end());
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 38784
import std.stdio, std.algorithm, std.string, std.conv, std.array;

void main()
{
    foreach(unused; 0 .. readln.chomp.to!int)
    {
        int left = 0, right = -1;
        bool flag = true;
        foreach(n; readln.split.map!(to!int))
        {
            if(n > left && n > right)
            {
                if(left > right) left = n;
                else             right = n;
            }
            else if(n > left) left = n;
            else if(n > right) right = n;
            else
            {
                flag = false;
                break;
            }
        }
        (flag ? "YES" : "NO").writeln;
    }
}

Measured memory_bytes: 1060