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

using namespace std;

int h, w, n, A[10050];
int grid[105][105];
int main(){
	cin >> h >> w >> n;
	for(int i = 1; i<=n; i++) cin >> A[i];
	int cur = 1;
	for(int i = 0; i<h; i++){
		if(i%2){
			for(int j = 0; j<w; j++){
				grid[i][j] = cur;
				A[cur]--;
				if(A[cur] == 0) cur++;
			}
		}else{
			for(int j = w-1; j>=0; j--){
				grid[i][j] = cur;
				A[cur]--;
				if(A[cur] == 0) cur++;
			}
		}
	}
	for(int i = 0; i<h; i++){ for(int j = 0; j<w; j++) cout << grid[i][j] << " "; cout << "\n"; }
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
vector<int> vt;
int n;
int ch[100100];
int cnt[100010];
int getidx(int x)
{
	return lower_bound(vt.begin(), vt.end(), x) - vt.begin();
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &ch[i]);
		vt.push_back(ch[i]);
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	for (int i = 0; i < n; i++)
	{
		ch[i] = getidx(ch[i]);
		cnt[ch[i]]++;
	}
	int dap = 0;
	for (int i = 0; i < vt.size(); i++)
	{
		if (vt[i] != cnt[i])
		{
			if (vt[i] > cnt[i])
				dap += cnt[i];
			else
				dap += (cnt[i] - vt[i]);
		}
	}
	printf("%d", dap);
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

vector<vector<int>> G;
vector<int> dp(100010, -1);

int memorize(int n)
{
    if (dp[n] != -1)
    {
        return dp[n];
    }

    int res = 0;
    for (auto x : G[n])
    {
        res = max(res, memorize(x) + 1);
    }

    return dp[n] = res;
}

int main(void)
{
    int N, M;
    int x, y;
    int i, j;
    int ans = 0;

    cin >> N >> M;

    G.assign(N, vector<int>());

    rep(i, 0, M - 1)
    {
        cin >> x >> y;
        --x;
        --y;
        G[x].push_back(y);
    }

    rep(i, 0, N - 1)
    {
        ans = max(ans, memorize(i));
    }

    cout << ans << endl;
}

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


void bubbleSort(int *A,int N,int& count){
    bool flag=true;
    while(flag){
        flag=false;
        for(int i=0;i!=N-1;++i){
            if(A[i]>A[i+1]){
                swap(A[i],A[i+1]);
                flag=true;
                ++count;
            }
        }
        --N;
    };
}

void print_A(int *A,int n){
    for(int i=0;i!=n;++i){
        cout<<A[i];
        if(i!=n-1)cout<<" ";
        else cout<<endl;
    }
}


int main(){
    int count=0;
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i!=n;++i){
        cin>>A[i];
    }
    
    //print_A(A,10);
    bubbleSort(A, n, count);
    print_A(A, n);
    cout<<count<<endl;

}





Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
/*
// get part of decimal
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
const long long mod = 1000000007;
const double eps = .0000000001;
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}

long long dp[9][101];

int main(){
    prep();
    int n, m, k;
    cin >> n >> m >> k;
    if (m == 1){
      cout << 1;
      return 0;
    }
    long long lim = pow(2, m-1)-1;

    dp[0][0] = 1;
    for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
        for (int k=0; k<=lim; k++){
          bitset<9> bs(k);
          bool good = true;
          for (int l=1; l<m-1; l++){
            if (bs[l] == 1 && bs[l-1] == 1){
              good = false;
              break;
            }
          }
          if (!good){
            continue;
          }
          if (j == 0){
            int right = bs[0];
            if (right){
              dp[j+1][i+1] += dp[j][i]; 
              dp[j+1][i+1] %= mod;
            }else{
              dp[j][i+1] += dp[j][i];
              dp[j][i+1] %= mod;
            }
          }else if (j == m-1){
            int left = bs[m-2];
            if (left){
              dp[j-1][i+1] += dp[j][i];
              dp[j-1][i+1] %= mod;
            }else{
              dp[j][i+1] += dp[j][i];
              dp[j][i+1] %= mod;
            }
          }else{
            int left = bs[j-1];
            int right = bs[j]; 
            // only 1 will happen
            if (left){
              dp[j-1][i+1] += dp[j][i];
              dp[j-1][i+1] %= mod;
            }
            if (right){
              dp[j+1][i+1] += dp[j][i];
              dp[j+1][i+1] %= mod;
            }
            if (!left && !right){
              dp[j][i+1] += dp[j][i];
              dp[j][i+1] %= mod;
            }

          }
        }//cout << j << " " << i << " " << dp[j][i] << endl;
      }
      
    }
    
    cout << dp[k-1][n];
    
    
    return 0;
}      

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[50][50] , res; 
bool check(int x , int y , int d){
	double res = 0;
	for(int i = 1; i <= d; i ++)
		res += (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
	return (sqrt(res) == int(sqrt(res)));
}
int main(){
	int n , d;
	cin >> n >> d;  
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= d; j ++)
			cin >> a[i][j];
	for(int i = 1; i <= n; i ++)
		for(int j = i + 1; j <= n; j ++)
			res += check(i , j , d);
	cout << res << "\n";
}

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

using namespace std;

int A[101010];
int n, s;

int main()
{
	int i;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d", A + i);
		s ^= A[i];
	}
	
	if(s != 0){
		printf("No\n");
		return 0;
	}
	
	sort(A, A + n);
	
	if(A[0] == 0 && A[n - 1] == 0){
		printf("Yes\n");
		return 0;
	}
	
	if(n % 3){
		printf("No\n");
		return 0;
	}
	
	if(A[0] != A[n / 3 - 1] || A[n / 3] != A[n * 2 / 3 - 1] || A[n * 2 / 3] != A[n - 1]){
		printf("No\n");
	}
	else printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	set<int> st[26],ts[26];
	string s,t;
	cin >> s >> t;
	int n = s.length();
	for(int i = 0;i < n;i++){
		st[s[i] - 'a'].insert(t[i] - 'a');
		ts[t[i] - 'a'].insert(s[i] - 'a');
	}
	bool flag = true;
	for(int i = 0;i < 26;i++){
		if(st[i].size() >= 2 || ts[i].size() >= 2) flag = false;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main(){
	int n,m,r;
	cin>>n>>m>>r;
	vector<int>v(r,0);
	vector<vector<int>>dist(200,vector<int>(200,1e9));
	for(int i=0;i<r;++i){
		int a;
		cin>>a;
		v[i]=--a;
	}
	for(int i=0;i<m;++i){
		int a,b,c;
		cin>>a>>b>>c;
		--a;--b;
		dist[a][b]=c;
		dist[b][a]=c;
	}
	for(int k=0;k<n;++k){
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				if(dist[i][j]>dist[i][k]+dist[k][j]){
					dist[i][j]=dist[i][k]+dist[k][j];
				}
			}
		}
	}
	int ans=1e9;
	sort(v.begin(),v.end());
	do{
		int d=0;
		for(int i=0;i<r-1;++i){
			d+=dist[v[i]][v[i+1]];
		}
		ans=min(ans,d);
	}while(next_permutation(v.begin(), v.end()));
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define prr pair<pr,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=1e7+5;
int seive[N],spf[N];
void build(){
    fr(i,2,N)
    seive[i]=1;
    fr(i,1,N)
    spf[i]=1;
    for(int i=2;i*i<N;i++){
        if(seive[i])
        for(int j=i*i;j<N;j+=i){
            seive[j]=0;
            if(spf[j]==1)
            spf[j]=i;
        }
    }
    fr(i,2,N)
    if(spf[i]==1)
    spf[i]=i;
}
ll f(int x){
    int ans=1;
    while(x>1){
        int y=spf[x];
        int c=0;
        while(x%y==0){
            c++;
            x/=y;
        }
        ans*=(c+1);
    }
    return ans;
}
void solve(){
    build();
//    fr(i,0,N)
//    cout<<"i="<<i<<" spf="<<spf[i]<<endl;
    ll n;
    cin>>n;
    ll ans=0;
    for(ll k=1;k<=n;k++){
        ans+=k*f(k);
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 81760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
  
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
  
using namespace std;
  
typedef pair<int, int> P;
  
int W, H, N;
char field[1002][1002];
  
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

int open[1002][1002];
bool visit[1001][1001];

int bfs(){
    priority_queue<pair<int, P>, vector<pair<int, P> >, greater<pair<int, P> > > q;
    q.push(MP(0, MP(0, 0)));
  
    while(!q.empty()){
		int t = q.top().first;
		P p = q.top().second;
        q.pop();

        if(visit[p.second][p.first]) continue;
        visit[p.second][p.first] = true;
  
        if(field[p.second][p.first] == 't') return t;
  
        rep(i, 4){
            int nx = p.first+dx[i], ny = p.second+dy[i];
            if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if(field[ny][nx] != '#') q.push(MP(t, MP(nx, ny)));
			else if(open[ny][nx] != 0) q.push(MP(max(t, open[ny][nx]), MP(nx, ny)));

        }
    }
  
    return -1;
}
  
int main(){
	cin >> W >> H;
    rep(i, H) rep(j, W) cin >> field[i][j];
    cin >> N;
	memset(open, 0, sizeof(open));
    rep(i, N){
        int x, y;
        cin >> x >> y;
		if(field[y][x] == '#' && !open[y][x]) open[y][x] = i+1;
    }
	cout << bfs() << endl;
  
    return 0;
}

Measured memory_bytes: 7132
#include<bits/stdc++.h>
using namespace std;
vector<int>num;
vector<long long>erge;
vector<long long>numb;
vector<long long>number;
int main(){
for(int i=0;i<1000000;i++){
	num.push_back(0);
}
erge.push_back(0);
erge.push_back(0);
for(int i=1;i<200001;i++){
	erge.push_back(erge[i]+i);
}
long long menge;
cin>>menge;
int numm;
numb.push_back(-1);
for(int i=0;i<menge;i++){
	cin>>numm;
	num[numm]++;
	numb.push_back(numm);
		number.push_back(numm);
}
long long rechner=0;
sort(numb.begin(),numb.end());
for(int i=1;i<menge;i++){
	if(numb[i]!=numb[i-1]){
		rechner+=erge[num[numb[i]]];
	}
}
for(int i=0;i<menge;i++){
	long long comp=erge[num[number[i]]]-erge[num[number[i]]-1];
	comp=rechner-comp;
	cout<<comp<<"\n";
	
}
 return 0;
}

Measured memory_bytes: 14316
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll xx=0;
    for(int i=0;i<n;i+=2)
    {
        xx^=a[i]^a[i+1];
    }
    for(int i=0;i<n;i++)
        cout<< (xx^a[i])<<' ';
}


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

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n ; i++)
        cin >> a[i];
    sort(a.begin(), a.end(), greater<>());
    bool flag = true;
    int sum = 0;
    for(int i : a)
        sum += i;
    for(int i = 0; i < m; i++)
    {
        if(a[i] < (float(sum)/float(4*m))) {flag = false; break;}
        // cout << (float(sum)/float(4*m)) << '\n';
    }
    cout << (flag ? "Yes" : "No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
from math import log10, floor

def k(a):
    return len(str(a))
N = int(input())
top = str(N)[0]
btm = str(N)[-1]
mid = str(N)[1:-1]
res = 0
for i in range(1,N+1):
    a = str(i)[0]
    b = str(i)[-1]
    ia = int(a)
    ib = int(b)
    if b == "0":
        continue
    if a == b and ia <= N:
        res += 1 # a
    if(ib * 10 + ia <= N):
        res += 1
    for d in range(1,7):
        if ib * (10**(d+1)) + ia > N:
            continue
        ng = 10**10
        ok = 0
        while ng - ok > 1:
            mid = (ng+ok)//2
            if ib * (10**(d + k(mid))) + mid*10 + ia > N:
                ng = mid
            else:
                ok = mid
        res += ok + 1
    # print(i)
    # print(b)
    # print(a)
    # print(ok)
    # print("----")
    # res += ok + 1

print(res)
        

Measured memory_bytes: 45224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
char str[maxn];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>str;
	if(str[2]==str[3]&&str[4]==str[5]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

const int DIV = 998244353;

// aの2^i乗のmod pを計算
vector<long long> pow_a(int a, int digit, int p) {
    vector<long long> v(digit);
    v[0] = (a % p);
    for (int i = 1; i < digit; ++i) {
        v[i] = ((v[i-1] * v[i-1]) % p);
    }
    return v;
}

// aのmod pでの逆元a^(p-2)を計算
long long inv_mod(int a, int p) {
    vector<long long> v;
    int digit = 30;
    v = pow_a(a, digit, p);
    
    long long ans = 1;
    for (int i = 0; i < digit; ++i) {
        if (((p-2) >> i) & 1) {
            ans = ((ans * v[i]) % p);
        }
    }
    return ans;
}

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

    // (m-1)^(n-k-1) mod DIVを求める
    long long a_temp = 1;
    for (int i = 0; i < n-k-1; ++i) {
        a_temp = ((a_temp * (m-1)) % DIV);
    }

    // n-1 C i mod DIVを計算
    vector<long long> c(k+1);
    c[0] = 1;
    // (m-1)^(n-k-1+i) mod DIVを計算
    vector<long long> a(k+1);
    a[0] = a_temp;
    for (int i = 1; i < k+1; ++i) {
        c[i] = ((n - i) % DIV);
        c[i] = ((c[i-1] * c[i]) % DIV);
        c[i] = ((c[i] * inv_mod(i, DIV)) % DIV);

        a[i] = ((a[i-1] * (m-1)) % DIV);
    }

    long long ans = 0;
    long long ans_temp = 0;
    for (int i = 0; i <= k; ++i) {
        ans_temp = (((m % DIV) * c[i]) % DIV);
        ans_temp = ((ans_temp * a[k-i]) % DIV);
        ans = ((ans + ans_temp) % DIV);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6288
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
long long a[100010][3]; 
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) 
      for (int j = 0; j < 3; ++j) 
        cin >> a[i][j];

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 3; ++j) 
      chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 0){
    cout << 2 << endl;
    return 0;
  }
  if (n == 1){
    cout << 1 << endl;
    return 0;
  }
  long long ans = 0;
  long long a = 2;
  long long b = 1;
  for(int i = 2; i <= n; i++){
    ans = a + b;
    a = b;
    b = ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    if (a < 3200 ) {
      System.out.println("red");
    } else {
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 21716
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	//出力
	console.log('%d',a*b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int n;
  cin>>n;
  int h[n];
  rep(i,n)
    cin>>h[i];
  int ans=0,active=0;
  rep(i,n){
    if(active>=h[i])
      active=h[i];
    else{
      ans+=h[i]-active;
      active=h[i];
    }
 //   cout<<"i== "<<i<<" active== "<<active<<endl;
   // cout<<"ans== "<<ans<<endl;
  }
    
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	Distance = parseInt(input[0], 10);
	Time = parseInt(input[1], 10);
	Speed = parseInt(input[2], 10);      
	//出力
	if ((Distance/Speed) <= Time) {
		console.log('Yes');
	} else {
		console.log('No');
	}
}  
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;

const int N = 3005;

ll dp[N][N];
string s, t, r;

ll calc(int i, int j) {
    if(i == s.size() || j == t.size()) return 0;

    ll &r = dp[i][j];

    if(r != -1) return r;

    if(s[i] == t[j]) return r = 1 + calc(i + 1, j + 1);
    else return r = max(calc(i + 1, j), calc(i, j + 1));
}

int main() {
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    calc(0, 0);
    int i = 0, j = 0;
    while(i < s.size() && j < t.size()) {
        if(s[i] == t[j]) r += s[i], i++, j++;
        else if(dp[i + 1][j] > dp[i][j + 1]) i++;
        else j++;
    }
    cout << r << endl;
    return 0;
}

// https://atcoder.jp/contests/dp/tasks/dp_f

Measured memory_bytes: 71040
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string.h>


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

int main() {
	int N;
	int cnt = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int e;
		scanf("%d", &e);
		if (isprime(e)) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}


Measured memory_bytes: 2752
#include<stdio.h>

#define MAX 10000
#define NIL -1


struct Node{
  int parent,left,right;
};

struct Node A[MAX];
int n,B[MAX],C[MAX];

void dep(int s,int t){
  if(s == NIL) return;
  B[s] = t;
  dep(A[s].left,t+1);
  dep(A[s].right,t+1);
}

int he(int s){
  int he1=0,he2 = 0;
  if(A[s].left !=NIL)
    he1 = he(A[s].left) +1;
  if(A[s].right!=NIL)
    he2 = he(A[s].right) +1;
  return C[s] = (he1>he2?he1:he2);
}

int sib(int s){
  if(A[s].parent == NIL)return NIL;
  if(A[A[s].parent].left != s&&A[A[s].parent].left!=NIL)
    return A[A[s].parent].left;
   if(A[A[s].parent].right != s&&A[A[s].parent].right!=NIL)
     return A[A[s].parent].right;
   return NIL;
}

void pr(int s){
  printf("node %d: ",s);
  printf("parent = %d, ",A[s].parent);
  printf("sibling = %d, ",sib(s));
  int deg = 0;
  if(A[s].left!=NIL)deg++;
  if(A[s].right!= NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",B[s]);
  printf("height = %d, ",C[s]);

  if(A[s].parent ==NIL){
    printf("root\n");
  }else if(A[s].left == NIL&&A[s].right == NIL){
    printf("leaf\n");
  }else {
    printf("internal node\n");
  }
}


int main(){

  int l,r,root = 0,w,i;
  scanf("%d",&n);

  for(i = 0;i<n;i++)A[i].parent = NIL;

  for(i = 0;i<n;i++) {
    scanf("%d %d %d",&w,&l,&r);
    A[w].left = l;
    A[w].right = r;
    if(l!=NIL) A[l].parent = w;
    if(r != NIL)A[r].parent = w;
  }

  for(i = 0;i<n;i++)
    if(A[i].parent == NIL)root = i;

  dep(root,0);
  he(root);

  for(i = 0;i<n;i++)
    pr(i);

  return 0;
  

}



Measured memory_bytes: 2000
#define f(a,b)F[a+b]*I[a]%M*I[b]%M
struct T{int a,b;}A[3333];
c(a,b)struct T*a,*b;{return a->a-b->a?:a->b-b->b;}
long h,w,P[3333],M=1e9+7,F[2<<17],I[2<<17];
p(a,b){return b?1L*p(1L*a*a%M,b/2)*(b%2?a:1)%M:1;}
i,j,k;
main(y)
{
	for(*F=*I=1;++k<2<<17;)I[k]=p(F[k]=F[k-1]*k%M,M-2);
	for(;~scanf("%d%d",&A[i].a,&A[i].b);i++)i||gets(P);
	qsort(A,i,sizeof(struct T),c);
	for(;j<i;j++)
	{
		P[j]=f(A[j].a-1,A[j].b-1);
		for(k=j;k--;)
		{
			(y=A[j].b-A[k].b)>=0?P[j]=(P[j]-f(A[j].a-A[k].a,y)*P[k]%M+M)%M:0;
		}
	}
	printf("%d",P[i-1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  int x,y;
  
  
  for(int i=0;i<S.size();i++){
    if(S[i]=='A'){
      x=i+1;
      break;
    }
  }
  
  for(int j=S.size()-1;j>=0;j--){
    if(S[j]=='Z'){
      y=j+1;
      break;
    }
  }
  
  
  cout<<y-x+1<<endl;
}

Measured memory_bytes: 3724
import sys
import copy


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = copy.copy(a)
    middle = len(a)//2-1
    ans = []

    for i in range(middle, -1, -1):
        s = 0
        b[i] = 0
        for j in range(i, n, i+1):
            s += b[j]
        b[i] = (s+a[i]) % 2

    for i in range(n):
        if b[i] == 1:
            ans.append(i+1)

    m = len(ans)
    print(m)
    if m > 0:
        print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69092
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
 	string s;
 	cin >> s;

 	int i;
 	for(i = 0; i < s.length(); i ++)
 	{
 		if(s[i] == ',')
 			cout << " ";
 		else
 			cout << s[i];
 	}   
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;

  int min_h = (int)1e9;
  int max_h = 0;
  int max_diff = 0;

  REP(i, n) {
    int h;
    cin >> h;

    max_h = max(h, max_h);

    if(!(h >= max_h - 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

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


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

int main() {
  int n, m;
  cin >> n >> m;
  int p;
  string S;
  
  set<int> seikai;
  vector<int> numwa(n, 0);
  
  int ac=0;
  int wa=0;
  
  rep(i, m){
    cin >> p >> S;
    p--;
    if(S=="WA" && !(seikai.count(p))){
      numwa[p]++;
    }else if(S=="AC" && !(seikai.count(p))){
        ac++;
        seikai.insert(p);
      }
  }
  rep(i, n){
    if(seikai.count(i)) wa = wa + numwa[i];
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 5376
import java.util.Scanner;

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

		int count=0;
		for(int i=0;i<s.length();i++) {
			if(i%2+'0' == s.charAt(i)) {

			}else {
				count++;
			}

		}

		int countrev=0;
		for(int i=0;i<s.length();i++) {
			if((i+1)%2+'0' == s.charAt(i)) {

			}else {
				countrev++;
			}

		}

		if(count>countrev) {
			System.out.println(countrev);
		}else {
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 26256
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(n) for (int i = 0; i < int(n); i++)
#define FOR1(m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[])
{
  string S;
  ull K;

  cin >> S >> K;

  int num_ones = 0;
  while (S[num_ones] == '1')
    num_ones++;

  if (num_ones >= K)
    printf("1\n");
  else
    printf("%c\n", S[num_ones]);
  
  return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    k,s = LI()
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            if s-k<=x+y and x+y<=s:
                ans += 1

    print(ans)
main()            


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

#define int long long
const int maxn = 2010, mod = 924844033;
int fact[maxn];
vector <vector <vector <int>>> dp, pd;
int S[maxn];
vector <vector <int>> KS;

int32_t main() {
	int n, k;
	cin >> n >> k;
	fact[0] = 1;
	for (int i = 1; i < maxn; i++) fact[i] = fact[i - 1] * i % mod;
	dp.resize(k);
	pd.resize(k);
	for (int i = 0; i < k; i++) {
		dp[i].resize(n / k + 2);
		pd[i].resize(n / k + 2);
		for (int j = 0; j <= n / k + 1; j++) {
			dp[i][j].resize(n / k + 2);
			pd[i][j].resize(n / k + 2);
		}
		dp[i][0][0] = pd[i][0][0] = 1;
	}
	for (int i = 0; i < n; i++) {
		dp[i % k][i / k + 1][0] = pd[i % k][i / k + 1][0] = 1;
		S[i % k] = i / k + 1;
		for (int j = 1; j <= i / k + 1; j++) {
			dp[i % k][i / k + 1][j] = pd[i % k][i / k + 1][j] = dp[i % k][i / k][j];
			if (i / k + 1 > 1) {
				dp[i % k][i / k + 1][j] = (dp[i % k][i / k + 1][j] + pd[i % k][i / k][j - 1]) % mod;
				pd[i % k][i / k + 1][j] = (pd[i % k][i / k + 1][j] + pd[i % k][i / k][j - 1]) % mod;
				dp[i % k][i / k + 1][j] = (dp[i % k][i / k + 1][j] + pd[i % k][i / k][j - 1]) % mod;
			}
			if (j >= 2 && i / k + 1 >= 2) {
				dp[i % k][i / k + 1][j] = (dp[i % k][i / k + 1][j] + dp[i % k][i / k - 1][j - 2]) % mod;
			}
//			cout << i % k << ' ' << i / k + 1 << ' ' << j << ' ' << dp[i % k][i / k + 1][j] << endl;
		}
	}
	KS.resize(k + 1);
	for (int i = 0; i <= k; i++) {
		KS[i].resize(n + 1);
	}
	KS[0][0] = 1;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j <= n; j++) {
			for (int d = 0; d <= min(j, n / k + 1); d++) {
				KS[i + 1][j] = (KS[i + 1][j] + dp[i][S[i]][d] * KS[i][j - d]) % mod;
//				cout << i + 1 << ' ' << j << ' ' << d << ' ' << KS[i][j] << ' ' << dp[i][S[i]][d] << ' ' << KS[i][j - d] << ' ' << S[i] << endl;
			}
//			cout << i + 1 << ' ' << j << ' ' << KS[i + 1][j] << endl;
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (i % 2) {
			ans = (ans - KS[k][i] * fact[n - i] % mod + mod) % mod;
		}
		else {
			ans = (ans + KS[k][i] * fact[n - i]) % mod;
		}
	}
	cout << ans;
}


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

using namespace std;

using ll = long long;

const int N = 101;

vector<int> g[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    if (n == 2) {
        cout << "1 2" << endl;
        return 0;
    }
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    pair<int, ll> ans{n + 1, 0};
    for (int r = 1; r <= n; r++) {
        vector<int> kek(n + 1), depth(n + 1);
        depth[r] = 1;
        kek[1] = g[r].size();
        queue<int> q;
        q.push(r);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : g[v]) {
                if (depth[u]) continue;
                depth[u] = depth[v] + 1;
                kek[depth[u]] = max<int>(kek[depth[u]], g[u].size());
                q.push(u);
            }
        }
        pair<int, ll> res{*max_element(depth.begin(), depth.end()), 1};
        for (int i = 1; i < res.first; i++) {
            res.second *= (i == 1 ? kek[i] : kek[i] - 1);
        }
        ans = min(ans, res);
    }

    for (int r1 = 1; r1 <= n; r1++) {
        for (int r2 : g[r1]) {
            vector<int> kek(n + 1), depth(n + 1);
            depth[r1] = depth[r2] = 1;
            kek[1] = max(g[r1].size(), g[r2].size()) * 2 - 2;
            queue<int> q;
            q.push(r1);
            q.push(r2);
            while (!q.empty()) {
                int v = q.front();
                q.pop();
                for (int u : g[v]) {
                    if (depth[u]) continue;
                    depth[u] = depth[v] + 1;
                    kek[depth[u]] = max<int>(kek[depth[u]], g[u].size());
                    q.push(u);
                }
            }
            pair<int, ll> res{*max_element(depth.begin(), depth.end()), 1};
            for (int i = 1; i < res.first; i++) {
                res.second *= (i == 1 ? kek[i] : kek[i] - 1);
            }
            ans = min(ans, res);
        }
    }

    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

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

        long a = scan.nextLong();
        String b = scan.next();

        long sum = a * Integer.parseInt(b.replace(".", ""));
        System.out.println(sum / 100);
    }
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

const int MAX = 510000;
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(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    
    COMinit();

    ll ans = 0;
    rep(k, h-a){
        ll c = COM(b+k-1, k);
        ans += c * COM(w-b-1+h-k-1, h-k-1);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
typedef vector<long long int> vl;
#define pb push_back
#define mp make_pair

ll expm(ll x, ll y, ll mod){
	ll ans = 1;
	while(y>0){
		if(y%2==1) ans*=x, ans%=mod, y--;
		else x*=x, x%=mod, y/=2;
	}
	return ans%mod;
}

ll exp(ll x, ll y){
	return expm(x,y,LLONG_MAX);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

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

	vector<int> dp(n,0);
	priority_queue<int> pq;
	pq.push(0);

	for(int i = n-2; i >= 0; i--) {
		int mi = -1;
		for(int j = 1; j <= k and i + j < n; j++) {
			int jump_cost = dp[i + j] + abs(h[i + j] - h[i]);
			if(mi == -1) 
				mi = jump_cost;
			else
				mi = min(mi, jump_cost);
			
		}
		dp[i] = mi;
	}

	cout << dp[0] << endl;
	return 0;
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll r;
	cin>>r;
	ld cc=(2*(3.14159)*r);
	cout<<cc<<endl;
}
int main(){
	solve();
	//freopen("filename.txt","r",stdin);
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3776
N = int(input())
works = []
for i in range(N):
    works.append(list(map(int, input().split())))
works = sorted(works, key=lambda x: (x[1], x[0]))
time = 0
isFail = False
for i in range(N):
    time += works[i][0]
    if time > works[i][1]:
        isFail = True
        break
print("YNeos"[isFail::2])

Measured memory_bytes: 67824
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        //w1から3しか重さが違わない
        int N = NextInt();
        long W = NextLong();
        long[] w = new long[N];
        int[] v = new int[N];
        long w1 = NextInt();
        w[0] = 0;
        v[0] = NextInt();
        for (int i = 1; i < N; i++)
        {
            w[i] = NextInt() - w1;
            v[i] = NextInt();
        }
        // i 個目の要素までの解 , 適当に , w1に相当する重さが何個あるか
        long[,,] dp = new long[N + 1, N + 1, 500];
        for (int i = 0; i <= N; i++)
            for (int j = 0; j <= N; j++)
                for (int k = 0; k < 500; k++) dp[i, j, k] = -INF;
        dp[0, 0, 0] = 0;

        for (int i = 0; i < N; i++)
            for (int j = N; j != -1; j--)
                for (int k = 400; k != -1; k--)
                {
                    if (dp[i, j, k] == -INF) continue;
                    dp[i + 1, j, k] = dp[i, j, k];
                    //現在j個使ってて余剰分 = k
                    if ((j + 1) * w1 + k + w[i] > W) continue;
                    dp[i + 1, j + 1, k + w[i]] = Math.Max(dp[i, j + 1, k + w[i]], dp[i + 1, j, k] + v[i]);
                }

        long ans = 0;
        for (int j = 0; j <= N; j++)
            for (int k = 0; k < 500; k++) ans = Math.Max(dp[N, j, k], ans);
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 50912
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x,a[100],i,k;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		x=x-a[i];
	}
	sort(a,a+n);
/*for(i=0;i<n;i++)printf("%d ",a[i]);
printf("\n");*/
	k=n;
	while(1){
		if(x-a[0]<0) break;
		x=x-a[0];    k++;
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    if(d>0 && d*d > 4*a*b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100000 + 1000], B[100000 + 1000], C[100000 + 100];
LL N;
int main()
{
#ifdef hk_cnyali
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif
	scanf("%lld", &N);
	for (LL i = 1; i <= N; ++i) scanf("%lld", &A[i]), B[i] = A[i], C[i] = A[i];
	LL Ans = 0;
	for (LL i = 1; i <= N; ++i)
		if (A[i] >= 2)
			Ans += A[i] / 2, A[i] -= (A[i] / 2) * 2;
	for (LL i = 1; i < N; ++i)
		if (A[i] && A[i + 1])
			++Ans, A[i] --, A[i + 1] --;
	LL Ans2 = 0;
	for (LL i = 1; i < N; ++i)
		if (min(B[i], B[i + 1]) > 0)
		{
			LL Min = min(B[i], B[i + 1]);
			Ans2 += Min, B[i] -= Min, B[i + 1] -= Min;
		}
	for (LL i = 1; i <= N; ++i)
		if (B[i] >= 2)
			Ans2 += B[i] / 2, B[i] -= (B[i] / 2) * 2;
	Ans = max(Ans, Ans2);
	Ans2 = 0;
	for (LL i = 1; i <= N; ++i)
	{
		if (C[i + 1] >= C[i] - C[i - 1])
		{
			Ans2 += C[i];
			if (C[i - 1] > C[i])
				Ans2 += ((C[i - 1] - C[i]) / 2);
			C[i + 1] -= max(0ll, (C[i] - C[i - 1]));
			C[i - 1] = max(0ll, C[i - 1] - C[i]);
			C[i - 1] -= (C[i - 1] / 2) * 2;
			C[i] = 0;
		}
		else 
		{
			Ans2 += (C[i - 1]);
			C[i] -= C[i - 1];
			Ans2 += (C[i] / 2);
			C[i] -= (C[i] / 2) * 2;
		}
		/*
		for (LL j = 1; j <= N; ++j)
			cout<<C[j]<<" ";
		cout<<" *"<<Ans2<<endl;
		*/
	}
	Ans = max(Ans, Ans2);
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
from numpy import argmax, argmin
N = int(input())
V = list(map(int, input().split()))
V1 = []
V2 = []
for i in range(N):
    if i%2==0:
        V1.append(V[i])
    else:
        V2.append(V[i])

Cnt = [0]*100001
for v in V1:
    Cnt[v] += 1
a1 = N//2-max(Cnt)
arg1 = argmax(Cnt)
Cnt[arg1] = 0
a11 = N//2-max(Cnt)


Cnt = [0]*100001

for v in V2:
    Cnt[v] += 1
a2 = N//2-max(Cnt)
arg2 = argmax(Cnt)
Cnt[arg2] = 0
a22 = N//2-max(Cnt)
#print(arg1, arg2, a1, a11, a2, a22)
if arg1==arg2:
    print(min(a1+a22, a2+a11))
else:
    print(a1+a2)



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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
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; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int A, B; cin >> A >> B;
    cout << (B % A == 0 ? A + B : B - A) << endl;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int x; cin>>x;

    vector<int> c = {100, 101, 102, 103, 104, 105};

    vector<bool> dp(x+1, false);
    dp[0] = true;

    for(int i=0; i<6; i++){
        for(int j=0; j<=x; j++){
            if(j - c[i] >= 0) dp[j] = dp[j] || dp[j - c[i]];
        }
    }

    cout << dp[x] << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

#[allow(unused_imports)]
use std::cmp::{min,max};

fn main(){
    input!{
        n: usize,
        m: usize,
        x: i32,
        y: i32,
        xx: [i32 ; n],
        yy: [i32 ; m],
    }
    let mut xx = xx; 
    xx.push(x);

    let mut yy = yy; 
    yy.push(y);
    
    let max_xx = xx.iter().max().unwrap();
    let min_yy = yy.iter().min().unwrap();

    println!("{}", if max_xx < min_yy {"No War"} else {"War"});
}


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

#define EPS (1e-7)
#define InF (1e9)
#define PI (acos(-1))
#define MAXn 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int main() {
    int n;
    cin >> n;
    bool flag = false;

    int ans;

    for(int i=1; i<10; i++) {
        if (n%i == 0) {
            ans = n/i;
            if (ans<10){
                flag = true;
                break;
            }
        }
    }
    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    cout << endl;
}



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

char chess(int h,int w){
    if((h+w)%2 == 0){
        return '#';
    }
    return '.';
}

int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H == 0&&W == 0){
            break;
        }
        for(int j = 0; j < H; j++){
            for(int i = 0; i < W; i++){
                cout << chess(i,j);
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3076
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

max_score = 0
first = True
for i in range(N):
  score = 0
  step = 0
  path = {}
  cumulative_score = []
  current_p = i
  cycle_passed = False
  while step < K:
    # record current step
    cumulative_score.append(score)
    
    # check if cycle is found
    if (not cycle_passed) and (current_p in path.keys()):
      # found a cycle 
      # calculate score sum within the cycle
      # calculate steps with in the cycle
      cycle_start_step = path[current_p]
      cycle_steps = step - cycle_start_step
      cycle_sum = cumulative_score[step] - cumulative_score[cycle_start_step]
      if cycle_sum < 0:
        # negative cycle
        # finish 
        break
      else:
        #positive cycle
        remain_steps = K - step
        if remain_steps > cycle_steps:
          cycle_times = (K - step) // cycle_steps - 1
          step += (cycle_times * cycle_steps)
          score += (cycle_times * cycle_sum)
          cycle_passed = True
        else:
          cycle_passed = True    
        
    # record current step
    path[current_p] = step
    
    # go to next step
    next_p = p_list[current_p-1]
    score += c_list[next_p-1]
    if (first):
      max_score = score
      first = False
    else:
      max_score = max(max_score, score)
    
    current_p = next_p
    step += 1

print(max_score)

Measured memory_bytes: 220424
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))
x = b[0]-b[1]+1
res = 10**100
 
for i in range(x):
    tmp = i + b[1] - 1
    res = min( a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])),res)
        
print(res)

Measured memory_bytes: 23088