akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

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

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

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

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

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

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

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

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

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

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

fn pro(x: i32) -> i64 {
    let mut ret = 1i64;
    for i in 2..x+1 {
        if i * i > x || ret > 1i64<<32 {
            return ret;
        }
        if x % i == 0 {
            ret *= i as i64;
            if i * i != x {
                ret *= (x / i) as i64;
            }
        }
    }
    0
}

fn test(x: i32) -> i32 {
    let mut ans = 0;
    for i in 2..x+1 {
        if pro(i) >= 2 * i as i64 {
            ans += 1;
        }
    }
    ans
}

fn solve() {
    input!(
        q: usize,
        n: [usize; q],
    );

    let mut rui = Vec::new();
    let si = 200010usize;
    rui.resize(si, 0i32);
    for i in 2..si {
        let p = pro(i as i32);
        if p < 2 * i as i64 {
            continue;
        }
        rui[i] += 1;
    }

    for i in 1..si {
        rui[i] += rui[i-1];
    }

    for _q in n {
//        if rui[_q] != test(_q as i32) {
//            println!("assert {}: {} != {}", _q, rui[_q], test(_q as i32));
//        }
        println!("{}", rui[_q]);
    }

//    for i in 2..100 {
//        println!("{}: {}", i, pro(i));
//    }
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 11132
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 101;
int a[N],n;

int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    int mx = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    int mn = (mx+1)/2;
    int ctmn = 0;
    //cout << mx << "," << mn << endl;
    for(int i = 0; i < n; ++i) {
        if(a[i] < mn) {
            cout << "Impossible\n";
            return 0;
        }
        if(a[i] == mn) ++ctmn;
    }
    if(mx%2 == 0) {
        if(ctmn != 1) {
            cout << "Impossible\n";
            return 0;
        }
    } else {
        if(ctmn != 2) {
            cout << "Impossible\n";
            return 0;
        }
    }
    for(int i = mn+1; i <= mx; ++i) {
        int ct = 0;
        for(int j = 0; j < n; ++j) {
            if(a[j] == i) ++ct;
        }
        if(ct < 2) {
            cout << "Impossible\n";
            return 0;
        }
    }
    cout << "Possible\n";
    return 0;
}

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

using namespace std;
 
int main(void) {
	int N, K, i;
	cin >> N;
	cin >> K;
	vector<int> input;
	input.reserve(N);
	for (i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		input.emplace_back(tmp);
	}
	sort(input.begin(), input.end());
	int sum = 0;
	for (i = 0; i < K; i++) {
		sum += input[i]; 
	}
	cout << sum << endl;
	return 0; 
}


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

priority_queue<string, vector<string>, greater<string> > que;
vector<string> v;
int j, y;
void dfs(int a, int b, string s);
int main(){
  cin >> j >> y;
  dfs(1, 0, "A");
  dfs(0, 1, "B");
  for(int i = 0; i < v.size(); i++) que.push(v[i]);
  string bef = "I";
  while(!que.empty()){
    string str = que.top();
    if(bef != str) cout << str << endl;
    que.pop();
    bef = str;
  }
}

void dfs(int a, int b, string s){
  if(a == j && b == y) v.push_back(s);
  if((a == 5 && b <= 3) || (a <= 3 && b == 5)) return;
  if((a == 6 && b == 4) || (a == 4 && b == 6)) return;
  if(a == 5 && b == 5) return;
  if(a == 6 || b == 6) return;
  dfs(a + 1, b, s + "A");
  dfs(a, b + 1, s + "B");
}

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

const int MOD = 1000000007;
int main() {
	int N, M;
	int64_t paturn = 1;
	cin >> N >> M;
	if (N >= M + 2 || N <= M - 2) cout << 0;
	else {
		for (int i = 1;i <= N;i ++) {
			paturn = (paturn * i) % MOD;
		}
		for (int i = 1;i <= M;i ++) {
			paturn = (paturn * i) % MOD;
		}
		if ((N + M) % 2 == 0) paturn = (paturn * 2) % MOD;
		cout << paturn;
	}
	return 0;
}
// 犬同士、及び猿同士が隣合わない→犬猿を(N+M)/2個並べ、左端に猿を置くか右端に犬を置く
// 次に、(N+M)%2==0なら左右反転版があるので、最終結果を2倍する
// この時、犬がN!通り、猿がM!通りの並べ方があるので、N!M!通りあるね

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
const int maxn = 110;
const int maxv = 100100;
ll n, w;
ll weight[maxn], value[maxn];
ll dp[maxv];

bool reach[maxv];

int main() {
	cin>>n>>w;
	reach[0] = true;

	for(int i=1;i<=1e5;i++) dp[i] = LLONG_MAX;
	for(int i=1;i<=n;i++) {
		cin>>weight[i]>>value[i];
		for(int j=1e5;j>=1;j--) {
			if(j-value[i] >= 0) {
				if(reach[j-value[i]]) {
					reach[j] = true;
					dp[j] = min(dp[j], dp[j-value[i]] + weight[i]);
				}
			} 
		}
	}
	
	ll result = 0LL;
	for(int i=0;i<=1e5;i++) {
		if(reach[i] && dp[i] <= w) {
			result = i;
		}
	}

	cout<<result<<"\n";
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

   static Scanner sc = new Scanner(System.in);

   static int n, m;

   static int[][] cost = new int[101][101];

   static int[][] time = new int[101][101];

   public static void main(String args[]){

      while(true) { 

         n = sc.nextInt(); 

         m = sc.nextInt();

         if (n == 0 && m == 0) break;

         //cost配列、time配列の初期化（INF値（2の29乗）を入力）

         for (int i = 0; i < m + 1; i++) {

            for (int j = 0; j < m + 1; j++) {

               cost[i][j] = time[i][j] = 1<<29;

            }

         }
         //隣接する頂点間のcostとtimeを登録

         for (int i = 0; i < n; i++) {

            int a = sc.nextInt();

            int b = sc.nextInt();

            cost[a][b] = cost[b][a] = sc.nextInt();

            time[a][b] = time[b][a] = sc.nextInt();

         }

         warshallFloyd();
         //出力処理

         int k = sc.nextInt();

         for (int i = 0; i < k; i++) {

            int start = sc.nextInt();

            int end = sc.nextInt();

            int r = sc.nextInt();

            if (r == 0) {

               System.out.println(cost[start][end]);

            } else {

               System.out.println(time[start][end]);

            }

         }

      }

   }

   static void warshallFloyd(){

      for (int k = 0; k <= m; k++) { 

         for (int i = 0; i <= m; i++) {

            for (int j = 0; j <= m; j++) {

               cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);

               time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);

            }

         }

      }

   }}

Measured memory_bytes: 75904
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll dp[334][334][334];
int main()
{
	int num,way;
	scanf("%d%d",&num,&way);
	dp[0][1][1]=1;
	for(int i=0;i<way;i++)
	{
		for(int j=1;j<=num;j++)
		{
			for(int k=1;k<=j;k++)
			{
				dp[i+1][j+1][k]+=dp[i][j][k]*(num-j);
				dp[i+1][j][k]+=dp[i][j][k]*(j-k);
				dp[i+1][j][j]+=dp[i][j][k]*k;
				dp[i+1][j+1][k]%=mod;
				dp[i+1][j][k]%=mod;
				dp[i+1][j][j]%=mod;
			}
		}
	}
	printf("%lld\n",dp[way][num][num]);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << (e - a > k ? ":(" : "Yay!") << '\n';
  return 0;
}

Measured memory_bytes: 256
program abc128c
      implicit none
      integer,allocatable,dimension(:)::k,p
      integer,allocatable,dimension(:,:)::s
      integer,dimension(10)::reader
      integer::n,m
      integer::i,j,l
      integer::ans,check,on,b
      

         read *, n,m
         allocate(k(m),p(m),s(m,10))  ! s(m,k(m))となるのが正しい

         s=0
         do i=1,m
            reader=0
            read *, k(i),reader(1:k(i))   ! readerは連結スイッチの一次記憶
            do j=1,k(i)
               s(i,reader(j))=1           ! 連結している電球のフラグを立てる
            end do
         end do

         read *, p(1:m)

         ans=0
         do i=0,2**n-1        ! 全てのスイッチを探索
            check=0
            do j=1,m          ! 全ての電球を探索
               b=i
               on=0
               do l=1,n
                  if (and(b,1)==1) on=mod(on+s(j,l),2)  ! and(i,j),or(i,j)はビット判定関数
                                                        ! and(b,1)==1 すなわち b(=i)が奇数
                  b=b/2
               end do
               if (on/=p(j)) check=1
            end do
            if (check==0) ans=ans+1
         end do

         print *, ans

   end program abc128c

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

using namespace std;

int main(){
  int n, a, count = 0;
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a;
    if((i % 2 != 0) && (a % 2 != 0)){ count++; }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b;a>=c;a--)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))
#define ctz(x) __builtin_ctz(x)
#define clz(x) __builtin_clz(x)
#define popcount(x) __builtin_popcount(x)
#define parity(x) __builtin_parity(x)

//=======binarysearch===========
int bs(vector<int>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========


bool isprime(int x)
{
  if ( x == 2 ) return true;
  if ( x  < 2 ) return false;
  for ( int i = 2; i * i <= x; i++ )
    if ( x % i == 0 ) return false;


  if(x==0) return false;
  return true;
}


bool power_2(ll x){
  
  if(x==1){
    return true;
  }

  ll ans=1;

  while(ans<x){
    ans=ans*2;
  }


  if(ans==x){
    return true;
  }else{
    return false;
  }


}


int main(){


  int n;
  cin>>n;

  int a[100001];

  rep(i,1,n){
    cin>>a[i];
  }

int sum=0;

rep(i,1,n){
  sum=sum+a[i]-1;
}


cout<<sum<<endl;


}

Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 1e5 + 5;
int h[N], dp[N];

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int res = 0;
  for(int i = n - 2; i >= 0; i--) {
    if(h[i] >= h[i + 1]) {
      dp[i] = dp[i + 1] + 1;
      res = max(res, dp[i]);
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
	int a,b;
	cin >> a;
	cin >> b;
	
	int res = 1;
	int tmp = a;
	if(b != 1){
		while(1){
			if(tmp >= b) break;
			tmp = tmp-1+a;
			++res;
		}
		cout << res << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

static int i, j, q;

int main() {
    IO;
    //ifstream cin("In.txt");
    ll n,m,ca=0,cb=0,cc=0,ans=0,tmp;
    string st;
    cin>>n;
    f0(i,n){
        cin>>st;
        m=st.size();
        if(st[0]=='B' && st[m-1]=='A')
            cc++;
        else if(st[0]=='B')
            cb++;
        else if(st[m-1]=='A')
            ca++;
        f1(j,m-1){
            if(st[j-1]=='A' && st[j]=='B')
                ans++;
        }
    }
    if(ca || cb){
        ans += cc + min(ca,cb);
    }
    else if(cc){
        ans += cc-1;
    }
    cout<<ans<<endl;
    return 0;
}


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

l = []
ll = 0
for i in range(len(L)+1):
    for j in range(len(L)+1):
        if j == i:
            break
        ll = ll + L[j]
    l.append(ll)
    ll = 0

cnt = 0
for lll in l:
	if lll <= X:
		cnt = cnt + 1

print(cnt)

Measured memory_bytes: 3064
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    s = list(input())
    sl = list(reversed(s))
    n = len(s)
    cnt = 0
    for i in range(n):
        if s[i] == sl[i]:
            cnt+=1
    
    ans = (n-cnt)//2
    print(ans)

main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <limits>
int merge(std::vector<int>&A, int left, int mid, int right) {
	int cnt = 0;
	int n1 = mid - left, n2 = right - mid;
	std::vector<int>L(n1 + 1);
	std::vector<int>R(n2 + 1);
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = std::numeric_limits<int>::max();
	int i = 0, j = 0;
	for (int k = left; k < right; ++k) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
	return cnt;
}
int mergeSort(std::vector<int>&A, int left, int right) {
	int cnt = 0;
	if (left + 1 < right) {
		int mid = static_cast<int>((left + right) / 2. + 0.5);
		cnt += mergeSort(A, left, mid);
		cnt += mergeSort(A, mid, right);
		cnt += merge(A, left, mid, right);
	}
	return cnt;
}
int main(void) {
	std::ios::sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::vector<int>S(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> S[i];
	}
	int AnsCnt = mergeSort(S, 0, n);
	for (int i = 0; i < n; ++i) {
		if (i == n - 1) { std::cout << S[i] << std::endl; }
		else { std::cout << S[i] << " "; }
	}
	std::cout << AnsCnt << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 6716
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
vll a(3),b(3);
ll dp[30000010];
ll calc(vll a,vll b, ll M){
    memset(dp,0,sizeof(dp));
    rep(i,a.size()){
        for(ll v=0;v+a[i]<=M;v++){
            chmax(dp[v+a[i]],dp[v]+b[i]);
        }
    }
    ll res=M;
    rep(v,M+1){
        chmax(res,dp[v]+M-v);
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n;
    cin>>n;
    rep(i,3) cin>>a[i];
    rep(i,3) cin>>b[i];
    n=calc(a,b,n);
    n=calc(b,a,n);
    cout<<n<<endl;
    
    return 0;
}

Measured memory_bytes: 234752
def palindrome(string):
    return 1 if string==string[::-1] else 0

s = input()
if(palindrome(s)):
    n = len(s)
    if(palindrome(''.join(list(s)[:((n-1)//2)]))):
        if(palindrome(''.join(list(s)[((n+3)//2)-1:n]))):
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N;
int T[105];

int GCD(int a,int b){
    if(b==0)return a;
    return GCD(b,a%b);
}

int LCM(int a,int b){
    //cout<<GCD(a,b)<<endl;
    return a/GCD(a,b)*b;
}

signed main(){
    cin>>N;
    int time = 1ll;
    for(int i=0;i<N;++i){
        int t;
        cin>>t;
        time = LCM(max(t,time),min(t,time));
    }
    cout<<time<<endl;
}


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

int main() {
	
	int n1, a, ans = 0;
cin >> n1;

vector <int> p;
vector <int> n2;
vector <int> n;

for(int i = 1; i < n1+1; i++)
{
	cin >> a;

	ans += (abs(a));
	if(a >= 0)
		p.push_back(a);
	else n2.push_back(a);
}

sort(p.begin(), p.end());
sort(n2.begin(), n2.end());
int l = n2.size();
if(l > 0)
{
n.resize(l);
for(int i = 0; i < n2.size(); i++)
{
	n[l-1-i] = n2[i];
}
}

if(p.size() == 0 )
{
	ans = ans +(2*n[0]);
	cout << ans << endl;
	cout << n[0] << " " << n[1] << endl;
	ans = n[0]-n[1];
for(int i = 2; i < n.size(); i++)
{
	cout << ans << " " << n[i] << endl;
	ans = ans - n[i];
}
}


else if(n.size() == 0 )
{
	if(p.size() == 2)
	{
		cout << p[1] - p[0] << endl;
	cout << p[1] << " " << p[0] << endl;
	
	}
	else
	{
	ans = ans - (2*p[0]);
	cout << ans << endl;
	cout << p[0] << " " << p[1] << endl;
	ans = p[0]-p[1];
for(int i = 2; i < p.size()-1; i++)
{
	cout << ans << " " << p[i] << endl;
	ans = ans-p[i];
}
cout << p[p.size()-1] << " " << ans << endl;
}
}


else if(n.size() == 1 && p.size() > 1)
{
	cout << ans << endl;
	cout << n[0] << " " << p[0] << endl;
	ans = n[0]-p[0];
for(int i = 1; i < p.size() - 1; i++)
{
	cout << ans << " " << p[i] << endl;
	ans = ans - p[i];
}
cout << p[p.size() - 1] << " " << ans << endl;
}

else if(n.size() == 1 && p.size() == 1)
{
 cout << ans << endl;
 cout << p[0] << " " << n[0] << endl;
}

else if(p.size() == 1 && n.size() > 1)
{
	cout << ans << endl;
	cout << p[0] << " " << n[0] << endl;
	ans = p[0] - n[0];
for(int i = 1; i < n.size() ; i++)
{
	cout << ans << " " << n[i] << endl;
	ans = ans - n[i];
}
}

else
{
	cout << ans << endl;
	cout << n[0] << " " << p[0] << endl;
	ans = n[0]-p[0];
for(int i = 1; i < p.size() - 1; i++)
{
	cout << ans << " " << p[i] << endl;
	ans = ans - p[i];
}
cout << p[p.size() - 1] << " " << ans << endl;

ans = p[p.size() - 1] - ans;

for(int i = 1; i < n.size() ; i++)
{
	cout << ans << " " << n[i] << endl;
	ans = ans - n[i];
}
}
	// your code goes here
	return 0;
}


Measured memory_bytes: 2808
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll N, M, v, p;
    cin>>N>>M>>v>>p;
    vl as(N);
    cin>>as;
    sort(rng(as));
    reverse(rng(as));

    ll mi = N;
    rep(i, N) if (as[i] + M < as[p - 1]) {
        mi = i;
        break;
    }
    ll l = p - 1;
    ll r = mi;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        ll s = 0;
        s += M * (p - 1 + N - m);
        for (int i = p - 1; i < m; ++i) {
            s += as[m] + M - as[i];
        }
        if (s >= M * v) l = m;
        else r = m;
    }
    cout<<l + 1<<endl;
}

Measured memory_bytes: 1024
l=input("").split(" ")
n=int(l[0])
k=int(l[1])
aa=input("").split(" ")
lista=[]
for i in aa:
    lista+=[int(i)]
for i in range(k,n):
    if(lista[i-k]<lista[i]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 31436
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	    
	    int a = nums[0] * nums[1];
	    int b = nums[2] * nums[3];
	    int ans = Math.Max(a,b);
	    Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
N, K = gets.split.map(&:to_i)
xs, ys = [], []
N.times do |i|
    xs[i], ys[i] = gets.split.map(&:to_i)
end

xsort = xs.sort
ysort = ys.sort

xmap = {}
ymap = {}
xsort.each_with_index do |x, i|
    xmap[x] = i
end
ysort.each_with_index do |y, i|
    ymap[y] = i
end

imos = Array.new(N){Array.new(N, 0)}
N.times do |i|
    imos[xmap[xs[i]]][ymap[ys[i]]] = 1
end
(1...N).each do |i|
    (0...N).each do |j|
        imos[i][j] += imos[i - 1][j]
    end
end
(1...N).each do |j|
    (0...N).each do |i|
        imos[i][j] += imos[i][j - 1]
    end
end

ans = Float::INFINITY
(0...N).each do |x1|
    ((x1+1)...N).each do |x2|
        (0...N).each do |y1|
            ((y1+1)...N).each do |y2|
                area = (xsort[x2] - xsort[x1]) * (ysort[y2] - ysort[y1])
                next if area >= ans
                points = 0
                points += imos[x1-1][y1-1] if x1 > 0 && y1 > 0
                points += imos[x2][y2]
                points -= imos[x1-1][y2] if x1 > 0
                points -= imos[x2][y1-1] if y1 > 0
                ans = area if points >= K
            end
        end
    end
end

puts ans

Measured memory_bytes: 3836
N, A, B = map(int, input().split())
S = input()

passed = 1
passed_foreigners = 1
for c in S:
    if c == 'a':
        if passed <= A + B:
            print('Yes')
            passed += 1
        else:
            print('No')
    elif c == 'b':
        if passed <= A + B and passed_foreigners <= B:
            print('Yes')
            passed += 1
            passed_foreigners += 1
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 4016
#include <stdio.h>
#include <iostream>

long long mod = 1000000000 + 7;

long long findpower(long long x, long long n){
    long long result = 1;
    while (n != 0) {
        if (n % 2 == 1) {
            result = (result % mod) * (x % mod);
            result = result % mod;
            n--;
        } else if (n % 2 == 0) {
            x = ((x % mod)*(x % mod)) % mod;
            n = n/2;
        }
    }
    return result;

}


int main() {
    int n, a, b;
    int i,j,k;


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

    // compute 2^n - 1
    long long ans2pow = findpower(2, n);

    ans2pow = (ans2pow - 1) % mod;

    // find the factorials for nCa
    long long ntoa = 1;
    for(i = n; i > n-a; i--) {
        ntoa = (ntoa % mod) * (i % mod);
    }
    ntoa = ntoa % mod;

    long long ato1 = 1;
    for(i = a; i >= 1; i--) {
        ato1 = (ato1 % mod) * (i % mod);
    }
    ato1 = ato1 % mod;

    // compute ato1 to the MOD-2 power
    long long ansapow = findpower(ato1, mod-2);

    long long nCa = ((ansapow % mod) * (ntoa % mod)) % mod;

    // find the factorials for nCb
    long long ntob = 1;
    for(i = n; i > n - b; i--) {
        ntob = (ntob % mod) * (i % mod);
    }
    ntob = ntob % mod;

    long long bto1 = 1;
    for(i = b; i >= 1; i--) {
        bto1 = (bto1 % mod) * (i % mod);
    }
    bto1 = bto1 % mod;

    // compute bto1 to the MOD-2 power
    long long ansbpow = findpower(bto1, mod-2);

    long long nCb = ((ansbpow % mod) * (ntob % mod)) % mod;

    //printf("%lld %lld %lld \n", ans2pow, nCa, nCb);

    long long ans  = (ans2pow % mod - nCa % mod - nCb % mod) % mod;


    if(ans < 0) {
        printf("%lld", mod + ans);
    } else {
        printf("%lld", ans);
    }

    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	int num, time, i, j, k, rec, cx, cy, height,he;
	cin >> num;
	int x[num], y[num], h[num];
	for (i = 0; i < num; i++)cin >> x[i] >> y[i] >> h[i];
	rec = -1;
	for (i = 0; i < num; i++) {
		if (h[i] != 0) {
			rec = i;
			break;
		}
	}
		for (i = 0; i <= 100; i++) {
			for (j = 0; j <= 100; j++) {
				time = 0;
				height = h[rec] + abs(i - x[rec]) + abs(j - y[rec]);
				for (k = 0; k < num; k++) {
					if (h[k] == max((height - abs(i - x[k]) - abs(j - y[k])), 0)) time++;
				}
				if (time == num) {
					cx = i;
					cy = j;
					he = height;
					break;
				}
			}
			if (time == num)break;
		}

		cout << cx << " " << cy << " " << he;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n;
int a[20];
int flg[10000000];

void dfs(int x,int sum){
  if(x==n){
    flg[sum]=1;
    return;
  }
  dfs(x+1,sum);
  dfs(x+1,sum+a[x]);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  dfs(0,0);
  int q,key;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if( flg[key]==1 ){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}






Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int n;
  cin >> n;
  
  int ans;
  ans = floor((n+1)/2);
  
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    // cout << S << " " << T << "\n";
    if (S == T) {
        cout << "Yes";
        return 0;
    }

    for (int i; i < S.length(); i++) {
        char rotation;
        rotation = S.back();
        S.pop_back();
        S = rotation + S;
        if (S == T) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define _ 800005
#define ll long long
using namespace std ;

#define int ll 

IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

int seqL[_] , seqR[_] , n , K , cov[_ << 2] , A[_] , B[_] , X[_ << 1] , xox , nL ;
ll Ans  , f[_] , SUM ; 

IL void PushDown(int o) {
	if(!cov[o]) return ;
	cov[o << 1] = cov[o] ; cov[o << 1 | 1] = cov[o] ; cov[o] = 0 ; return ;
}
void Insert(int o , int l , int r , int ql , int qr , int v) {
	if(ql > qr) return ;
	if(ql <= l && r <= qr) {cov[o] = v ; return ; }
	int mid = (l + r) >> 1 ;
	PushDown(o) ;
	if(ql <= mid) Insert(o << 1 , l , mid , ql , qr , v) ;
	if(qr  > mid) Insert(o << 1 | 1 , mid + 1 , r , ql , qr , v) ;
	return ; 	
}
int Query(int o , int l , int r , int ps) {
	if(l == r) return cov[o] ;
	int mid = (l + r) >> 1 ; PushDown(o) ;
	return ps <= mid ? Query(o << 1 , l , mid , ps) : Query(o << 1 | 1 , mid + 1 , r , ps) ;
}

IL void Init() {
	n = gi() ; K = gi() ;
	for(int i = 1; i <= n; i ++) A[i] = gi() , B[i] = gi() ;
	for(int i = 1; i <= n; i ++) if(2 * A[i] > K && B[i] == 1) {puts("-1") ; exit(0) ; } 
	for(int i = 1; i <= n; i ++) SUM += A[i] , A[i] = (A[i] + A[i - 1]) % K  ;
	nL = 0 ;
	for(int i = 1; i <= n; i ++)
		if(B[i] == 1) {
			seqL[i] = ((-2ll * A[i - 1]) % K + K) % K ;
			seqR[i] = ((-2ll * A[i]) % K + K) % K ; 
		}
		else seqL[i] = 0 , seqR[i] = K - 1 ; 
	for(int i = 1; i <= n; i ++) X[++xox] = seqL[i] , X[++xox] = seqR[i] ;
	sort(X + 1 , X + xox + 1) ; xox = unique(X + 1 , X + xox + 1) - X - 1 ;
	for(int i = 1; i <= n; i ++) {
		seqL[i] = lower_bound(X + 1 , X + xox + 1 , seqL[i]) - X ;
		seqR[i] = lower_bound(X + 1 , X + xox + 1 , seqR[i]) - X ; 
	}
	return ;
}

IL int Dist(int u , int v) {return (v + K - u) % K ; }


ll ask(ll pos){
    ll choose=Query(1,1,xox,pos);
    if(!choose) return 0;
    return (f[choose]+(X[seqL[choose]]-X[pos]+K)%K) ;
}

#undef int

int main() {
	Init() ; 
	f[n + 1] = 0 ;
	/*
	Insert(1 , 1 , xox , 1 , xox , n + 1) ;
	for(int i = n,v; i >= 1; i --) {
		f[i] = f[v = Query(1 , 1 , xox , seqL[i])] + 1ll * (v <= n) * Dist(X[seqL[i]] , X[seqL[v]]) ;
		if(seqL[i] > seqR[i]) Insert(1 , 1 , xox , seqR[i] + 1 , seqL[i] - 1 , i) ;
		else if(seqL[i] < seqR[i]) {
			Insert(1 , 1 , xox , 1 , seqL[i] - 1 , i) ;
			Insert(1 , 1 , xox , seqR[i] + 1 , xox , i) ;
		} 
	}
	*/
	for(int i=n;i>=1;i--){
        f[i]=ask(seqL[i]);
		if(seqL[i] > seqR[i]) Insert(1 , 1 , xox , seqR[i] + 1 , seqL[i] - 1 , i) ;
		else Insert(1 , 1 , xox , 1 , seqL[i] - 1 , i) , Insert(1 , 1 , xox , seqR[i] + 1 , xox , i) ;
    }
	Ans = f[1] ;
	/*
	for(int i = 1,v; i <= xox; i ++) 
		Ans = min(Ans , f[v = Query(1 , 1 , xox , i)] +  1ll * (v <= n) * Dist(X[i] , X[seqL[v]])) ;
	*/
	
    for(int i=xox;i>=1;i--) Ans=min(Ans,ask(i));
	Ans = Ans + 2ll * SUM ; 
	cout << Ans << endl ; return 0 ; 
}


Measured memory_bytes: 15360
#include<stdio.h>

int main(){
	char s[1001];scanf("%s",s);
	int nwes[4]={0},i=0;
	while(s[i]!=0){
		if(s[i]=='N')nwes[0]=1;
		if(s[i]=='W')nwes[1]=1;
		if(s[i]=='S')nwes[2]=1;
		if(s[i]=='E')nwes[3]=1;
		i++;
	}
	if(nwes[0]==1&&nwes[1]==1&&
	nwes[2]==1&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else if(nwes[0]==1&&nwes[1]==0&&
	nwes[2]==1&&nwes[3]==0){
		puts("Yes");
		return 0;
	}else if(nwes[0]==0&&nwes[1]==1&&
	nwes[2]==0&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else{
		puts("No");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 128
c = [list(map(int, input().split())) for i in range(3)]

d = [list([c[i][j+1] - c[i][j] for j in range(2)]) for i in range(3)]

if d[1] == d[0] and d[2] ==d[0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	long long x, ans;
	cin >> x;

	int uresisa1000=0, uresisa5=0;

	uresisa1000 = x / 500;
	uresisa5 = (x % 500) / 5;

	ans = 1000*uresisa1000 + 5*uresisa5;
	cout << ans << endl;
	return 0;
}

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

#define lli long long int
#define ld long double
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n)  \
  ld n;        \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LDV(a, n)            \
  vector<ld> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define sum(n) accumulate(n.begin(), n.end(), 0);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(N)
  for(lli i = 0;i <= N / 4;i++) {
    for(lli u = 0;u <= (N - i * 4) / 7;u++) {
      if(i * 4 + u * 7 == N)  {
        yes
      }
    }
  }
  no
}


Measured memory_bytes: 256
#include <stdio.h>

int isprime(int n)
{
  if (n == 2)
    return 1;
  if (n < 2 || n % 2 == 0)
    return 0;
  for (int i = 3; i * i <= n; i+=2)
    if (n % i == 0)
      return 0;
  return 1;
}

int main(void)
{
  int n, no, cnt = 0;
  
  scanf("%d", &n);
  
  while (n--) {
    scanf("%d", &no);
    if(isprime(no))
      cnt++;
  }
  
  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 2088
require 'prime'

N = STDIN.gets.to_i

primes = {}
for i in 2..N
  divs = Prime.prime_division(i)
  divs.each do |n, pow|
    primes[n] ||= 0
    primes[n] += pow
  end
end

ans = []

n24 = []
n14 = []
n2 = []
n4 = []
primes.each do |n, pow|
  if pow >= 74
    ans.push([[n, 74]])
  end

  if pow >= 24
    n24.push(n)
  end

  if pow >= 14
    n14.push(n)
  end

  if pow >= 4
    n4.push(n)
  end

  if pow >= 2
    n2.push(n)
  end
end

# 25*3
n24.each do |v1|
  n2.each do |v2|
    if v1 != v2
      ans.push([[v1, 24], [v2, 2]])
    end
  end
end

# 15*5
n14.each do |v1|
  n4.each do |v2|
    if v1 != v2
      ans.push([[v1, 14], [v2, 4]])
    end
  end
end

# 5*5*3
n4.each do |v1|
  n4.each do |v2|
    next unless v1 < v2
    n2.each do |v3|
      if v1 != v2 && v2 != v3 && v1 != v3
        # puts v1**4 * v2**4 * v3**2
        ans.push([[v1, 4], [v2, 4], [v3, 2]])
      end
    end
  end
end

puts ans.length

Measured memory_bytes: 2044
import java.util.Scanner;
public class Main
{
    public static void main(String[]args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sumatoria=0;
        for(int i=0;i<=n;i++)
        {
          if((i%3!=0)&&(i%5!=0))
          sumatoria = sumatoria+i;
         }
        System.out.print(sumatoria);
    }
}

Measured memory_bytes: 35816
N,C = gets.split.map(&:to_i)
d = C.times.map{gets.split.map(&:to_i)}
c = N.times.map{gets.split.map{|i|i.to_i-1}}

cnt = Array.new(3).map{Array.new(C,0)}

N.times do |i|
    N.times do |j|
        cnt[(i+j)%3][c[i][j]] += 1
    end
end

sums = Array.new(3).map{Array.new(C,0)}
3.times do |i|
    C.times do |j|
        C.times do |k|
            sums[i][j] += cnt[i][k]*d[k][j]
        end
    end
end

ans = 1000000000
C.times do |i|
    C.times do |j|
        next if i == j
        C.times do |k|
            next if j == k || i == k
            ans = sums[0][i]+sums[1][j]+sums[2][k] if ans > sums[0][i]+sums[1][j]+sums[2][k]
        end
    end
end

puts ans

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if (k >= a) {
        k -= a;
        a = 0;
        cout << a << " " << max(b-k, 0ll) << endl;
    }
    else {
        cout << a-k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

class Test
{

    public static void Main()
    {
        var ii1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var n = ii1[0];
        var k = ii1[1];
        bool[] digit = new bool[10];
        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        
        while(true)
        {
            bool check = false;
            var s = n.ToString();

            for(int i=0;i<s.Length;i++)
            {
                if (arr.Contains(s[i] - '0'))
                {
                    check = true;
                    break;
                }
            }

            if (!check)
                break;
            n++;
        }

        Console.Write(n);



    }


}

















Measured memory_bytes: 23008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <functional>
#include <algorithm>
using namespace std;

int ans, a[3];

int main() {
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int op1 = a[2]-a[1];
  ans += op1;
  a[1] += op1;
  a[0] += op1;
  int op2 = (a[2]-a[0])/2;
  ans += op2;
  a[0] += op2*2;
  if(a[0] != a[2]) ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
   char str[6];
   scanf("%s",str);
    char arc[] = "ARC";
   char abc[] = "ABC";
   if(strcmp(str,abc)==0){
    printf("%s",arc);
  }else{
    printf("%s",abc);
  }
    return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vecV(n);
  for (int i=0; i<n; i++) cin >> vecV.at(i);
  vector<int> vecC(n);
  for (int i=0; i<n; i++) cin >> vecC.at(i);
  
  vector<int> vecP(n);
  for (int i=0; i<n; i++) vecP.at(i)=vecV.at(i)-vecC.at(i);
  
  int s=0;
  for (int i=0; i<n; i++) {
    if (vecP.at(i)>0) s+=vecP.at(i);
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define kk 1000000007
int n,m,k,a,b,c,tmp,cc[300005];
vector<int > ee;
map<int ,int > mm;
char g;
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<=n;i++){
		for (int j=0;j<=n;j++){
			if (i+j <= k && k-i-j<=n) tmp++;
		}
	}
	printf("%d\n",tmp);
}

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if((x-r)>=0 && (y-r)>=0 && (x+r)<=w && (y+r)<=h)    cout<<"Yes";
    else    cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3108
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    L = len(s)
    dp = [[0] * 13 for _ in range(L + 1)]
    dp[0][0] = 1

    for i in range(L):
        for j in range(13):
            if s[i] == "?":
                for k in range(10):
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j] % mod
            else:
                k = int(s[i])
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j] % mod

    print(dp[-1][5] % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 61788
#include<cstdio>
#include<cmath>
#include<climits>
#include<cctype>
#include<clocale>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	string S;
	bool flag = true;
	bool flag2 = true;
	int cnt = 0;
	int val = -1;
	cin >> S;
	if (S[0] != 'A') flag = false;
	rept(i, 2, S.length()-1) if (S[i] == 'C') {
		cnt++;
		if (cnt == 1) val = i;
	}
	if (cnt == 1 && flag) {
		rept(i, 1, S.length()) {
			if (i == val) continue;
			if (!(bool)islower(S[i])) {
				flag2 = false;
				break;
			}
		}
		if (flag2) cout << "AC" << endl;
		else cout << "WA" << endl;
	}
	else cout << "WA" << endl;

	return 0;
}




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

int main()
{
const int iMod = 1000000007;
int i;
int j;
int N;
int M;
long long iVal;
long long iH;
long long iW;

	cin >> N;
	cin >> M;

vector<int> X( N );
vector<int> Y( M );

	for( i = 0; i < N; i++ ) cin >> X[ i ];
	for( i = 0; i < M; i++ ) cin >> Y[ i ];

	iW = 0;
	for( i = 1; i < N; i++ )
	{
		iVal = X[ i ] - X[ i - 1 ];
		iVal %= iMod;
		iVal *= i;
		iVal %= iMod;
		iVal *= N - i;
		iVal %= iMod;
		iW += iVal;
		iW %= iMod;
	}

	iH = 0;
	for( i = 1; i < M; i++ )
	{
		iVal = Y[ i ] - Y[ i - 1 ];
		iVal %= iMod;
		iVal *= i;
		iVal %= iMod;
		iVal *= M - i;
		iVal %= iMod;
		iH += iVal;
		iH %= iMod;
	}

	cout << ( iW * iH ) % iMod << endl;

	return 0;
}






Measured memory_bytes: 1024
n = gets.to_i
as = gets.split.map &:to_i

ts = Array.new(as.size, nil)

MOD = 10 ** 9 + 7

t = 0

(as.size - 1).downto(1){ |i|
	t = (t + as[i]) % MOD
	ts[i - 1] = t
}

sum = 0

(0...as.size - 1).each{|i|
	sum += (as[i] * ts[i]) % MOD
	sum = sum % MOD
}

puts sum


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<int> a(h,0),b(w,0);
  vector<vector<char>> g(h,vector<char>(w));
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> g.at(i).at(j);
      if(g.at(i).at(j)=='#'){
        a.at(i)++;
        b.at(j)++;
      }
    }
  }
  
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a.at(i)!=0&&b.at(j)!=0){
        cout << g.at(i).at(j);
      }
    }
    if(a.at(i)!=0){
      cout << endl;
    }
  }
}

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

#define MAXN 100001

struct data{
	int a,b;
	bool operator<(const data &d)const{
		return b<d.b;
	}
}a[MAXN];

int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&a[i].a,&a[i].b);
	}
	sort(a+1,a+m+1);
	int now=0,ans=0;
	for(int i=1;i<=m;++i)
	{
		if(now<=a[i].a)
		{
			now=a[i].b;
			++ans;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S = list(input())
T = list(input())

N = len(S)
for i in range(N): #スタート位置
    flag = True
    for j in range(N):
        if S[(i + j) % N] == T[j]:
            continue
        flag = False
        break
    if flag:
        print ('Yes')
        exit()

print ('No')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int i,n,result=0;
  int a[100010],b[100010],c[100010];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
  }
  for(i=0;i<n;i++){
    cin >> b[i];
  }
  for(i=0;i<n-1;i++){
    cin >> c[i];
  }
  for(i=0;i<n;i++){
    if(i!=n-1 && a[i]+1==a[i+1]){
      result += c[a[i]];
    }
    result += b[a[i]];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int D;
    cin >> D;
    if (D == 25){
        cout << "Christmas" << endl;
    }
    else if (D == 24){
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256