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

using namespace std;

#define ll long long
#define l1(i, n) for (ll i = 1; i <= n; i++)
#define l0(i, n) for (ll i = 0; i < n; i++)
#define lo(i, s, n) for (ll i = s; i <= n; i++)
#define pb push_back
#define nl cout << "\n";

const ll sz = 2e5;

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

    ll n, k;
    cin >> n >> k;
    cout << min((n % k), abs((n % k) - k));
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

city = []
city.append(1)
cnt = [0] * (n + 1)
cnt[1] = 1

for i in range(1,n):
    next = a[city[i-1]-1]
    cnt[next] += 1
    if cnt[next] > 1:
        base = next
        break

    city.append(next)

start = city.index(base)
loop = len(city) - start

ans = (k - start) % loop

if k <= start:
    print(city[k])
else:
    city = city[start:]
    print(city[ans])

Measured memory_bytes: 32332
org_str = input()
n = len(org_str)
if n%2 == 0:
    N = int(n/2-1)
else:
    N = int((n-1)/2)

org_str1 = org_str[0:(N)]
org_str2 = org_str[(N+1):n]

new_str_list = list(reversed(org_str))
new_str = org_str[::-1]

new_str1_list = list(reversed(org_str1))
new_str1 = org_str1[::-1]

new_str2_list = list(reversed(org_str2))
new_str2 = org_str2[::-1]


if org_str == new_str and org_str1 == new_str1 and org_str2 == new_str2:
    print("Yes")
else:
    print("No")

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

#define BUF_SIZE (260)

int gcd(int m, int n) {
	int t;
	if (m < n) {
		t = m;
		m = n;
		n = t;
	}
	while (n > 0) {
		t = n;
		n = m % n;
		m = t;
	}
	return m;
}

char encode(char c, int alpha, int beta) {
	return ((alpha * (c - 'a') + beta) % 26) + 'a';
}

int judge(const char *text, const char *word) {
	char *p = strstr(text, word);
	if (p != NULL) {
		if (p == text && p[4] == ' ')
			return 1;
		if (*(p-1) == ' ' && (p[4] == ' '  || p[4] == '\n'))
			return 1;
	}
	return 0;
}

void decode(const char *code, char *buf) {
	int a, b, i;
	char tbl[26];

	for (a = 0;; a++) {
		if (gcd(a, 26) != 1) {
			continue;
		}
		for (b = 0; b < 26; b++) {
			memcpy((void*)buf, (void*)code, sizeof(char)*BUF_SIZE);
			for (i = 0; i < 26; i++) {
				tbl[encode('a'+i, a, b)-'a'] = 'a' + i;
			}
			for (i = 0; buf[i] != '\0'; i++) {
				if (buf[i] < 'a' || 'z' < buf[i])
					continue;
				buf[i] = tbl[buf[i]-'a'];
			}
			if (judge(buf, "that") || judge(buf, "this"))
				return;
		}
	}
}

int main() {
	int n;
	char code[BUF_SIZE], buf[BUF_SIZE];

	scanf("%d ", &n);
	while (n--) {
		fgets(code, BUF_SIZE, stdin);
		decode(code, buf);
		printf("%s", buf);
	}
	return 0;
}

Measured memory_bytes: 612
import java.util.*;
import java.io.*;
 
public class Main{
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        long X = s.nextLong();
        long A = 100;
        long i = 0;

        while(true){
            if(A >= X) break;
            A = A + A/100;
            i++;
        }

        System.out.println(i);
	}
} 

Measured memory_bytes: 35852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<char> a={'A','C','G','T'};
	int ans=0,sum=0;
	rep(i,s.size()){
		bool flg=false;
		rep(j,4) if(a.at(j)==s.at(i)) flg=true;
		if(flg){
			sum++;
		}
		else{
			ans=max(ans,sum);
			sum=0;
		}
	}
	ans=max(ans,sum);
	cout << ans << endl;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//文字から数値に変換
int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

//文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) {
			return 1;
		} else if(strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) {
			return 1;
		} else if(strlen(H[h]) == 0){
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n;
	char str[L], com[9];
	for (i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		} else {
			if (find(str)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 15988
#include <iostream>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;
int main(void){
    long long int a,k,ans;
    cin>>a;
    k=floor(sqrtl(a));
    
    while(a%k!=0){
        k--;
    }
    
    k=a/k;
    ans=floor(log10l(k));
    cout<<ans+1;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll A, B, C;
string s, t;

int main(){
	cin >> s;
	p((char) (s[0]+1) );

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N,K,Q;
		N=scan.nextInt();
		K=scan.nextInt();
		Q=scan.nextInt();
		int A[]=new int[N];
		int i,a;
		for(i=0;i<N;i++){
			A[i]=0;
		}
		for(i=0;i<Q;i++){
			a=scan.nextInt();
			A[a-1]++;
		}
		for(i=0;i<N;i++){
			A[i]=A[i]+K-Q;
			if(A[i]>0)System.out.println("Yes");
			else System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 50344
#include <stdio.h>

main(){
  char data[81], temp[81];
  int i, j, k, p, t=0;

  while(1){
    p=0;
    for(i=0;i<80;i++){
      if(scanf("%c", &data[i])==EOF){
	t=1;
	break;
      }
      if(data[i]=='\n') break;
    }
    data[i]='\0';
    
    for(i=0;i<27;i++){
      for(j=0;data[j]!='\0';j++){
	temp[j]=data[j];
	if(data[j]>='a' && data[j]<='z'){
	  for(k=0;k<i;k++){
	    temp[j]++;
	    if(temp[j]>'z') temp[j]-=26;
	  }
	}
      }
      temp[j]='\0';
      for(j=0;temp[j]!='\0';j++){
	if(temp[j]=='t'){
	  if(temp[j+1]!='\0'){
	    if(temp[j+1]=='h'){
	      if(temp[j+2]!='\0'){
		if(temp[j+2]=='e'){
		  p=1;
		  break;
		}
		if(temp[j+2]=='i'){
		  if(temp[j+3]!='\0'){
		    if(temp[j+3]=='s'){
		      p=1;
		      break;
		    }
		  }
		}
		if(temp[j+2]=='a'){
		  if(temp[j+3]!='\0'){
		    if(temp[j+3]=='t'){
		      p=1;
		      break;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
      if(p==1) break;
    }
    for(i=0;i<80;i++){
      if(temp[i]=='\0') break;
      printf("%c", temp[i]);
    }
    if(t==1) break;
    else printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for ( v = 0; v < n; v++){
        if ( M[u][v] == 0) {
            continue;
        }
        if (color[v] == WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs(){
    int u;
    for ( u = 0; u < n; u++) {
        color[u] = WHITE;
    }
    tt = 0;
    for (u = 0; u < n; u++) {
        if ( color[u] == WHITE ) {
            dfs_visit(u);
        }
    }

    for (u = 0; u < n; u++) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main() {
    int u, v, k, i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++){
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }

    dfs();
    return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b;
   cin >> a >> b;
   cout << (a + b + 1)/2 << endl;
   return 0;
}

Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x:
            i = i+1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)
    return None
        
n = int(input())
A = [(i,int(j)) for i,j in [input().split() for i in range(n)]]
B = A.copy()
quickSort(A,0,n-1)
num = A[0][1]
pos = B.index(A[0])
ans = "Stable"
for i in A[1:]:
    if i[1] != num:
        num = i[1]
        pos = B.index(i)
    else:
        if pos > B.index(i):
            ans = "Not stable"
            break
        else:
            pos = B.index(i)
print(ans)
for i,j in A:
    print(i,j)


Measured memory_bytes: 38104
k,n = map(int,input().split())
a = list(map(int,input().split()))

dist = []
for i in range(0,n-1):
  dist.append(a[i+1]-a[i])#距離のリスト

longest = 0
for j in range(0,n-1):
  if dist[j] >= longest:
    longest = dist[j]

short_cont_1 = k-longest
short_cont_2 = a[n-1]-a[0]
if short_cont_1>=short_cont_2:
  print(short_cont_2)
else:
  print(short_cont_1)


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

using namespace std;

int absn(int n) {
	if (n < 0) {
		return -1 * n;
	}
	else {
		return n;
	}
}

int main() {

	int H, W;
	scanf("%d",&H);
	scanf("%d", &W);

	int A[H][W];
	int B[H][W];

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			//cout << A[i][j] << " " ;
			A[i][j] = absn(A[i][j] - B[i][j]);
			//cout << A[i][j] << endl;
		}
		//cout << endl;
	}

	bool C[H][W][6500];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 6500; k++) {
				C[i][j][k] = false;
			}
		}
	}

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

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

			int now = A[i][j];

			if (i == 0 && j == 0) {
				C[0][0][A[0][0]] = true;
			}else if (i == 0) {

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

					int nt = min(7000,absn(k - A[i][j]));
					int nu = min(7000, k+A[i][j]);
					//cout << nt << "  " << nu << endl;
					C[i][j][k] = C[i][j - 1][nu] || C[i][j][k];
					C[i][j][k] = C[i][j - 1][nt] || C[i][j][k];
				}
			}else if (j == 0) {
				for (int k = 0; k < 6401; k++) {
					int nt = min(7000, absn(k - A[i][j]));
					int nu = min(7000, k + A[i][j]);
					C[i][j][k] = C[i-1][j][nu] || C[i][j][k];
					C[i][j][k] = C[i - 1][j][nt] || C[i][j][k];
				}

			}else {
				for (int k = 0; k < 6401; k++) {
					int nt = min(7000, absn(k - A[i][j]));
					int nu = min(7000, k + A[i][j]);
					C[i][j][k] = C[i][j - 1][nu] || C[i][j][k];
					C[i][j][k] = C[i][j - 1][nt] || C[i][j][k];
					C[i][j][k] = C[i - 1][j][nu] || C[i][j][k];
					C[i][j][k] = C[i - 1][j][nt] || C[i][j][k];
				}
			}

		}
	}

	int ans = 6401;
	for (int l = 0; l < 6401; l++) {
		if (C[H-1][W-1][l]) {
			ans = min(ans, l);
			//cout << l << endl;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 40960
n,m,v,p=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
a.sort(reverse=True)

def f(x):
    if x>n-1:
        return False
    if x<p:
        return True
    if a[x]+m<a[p-1]:
        return False
    tmp=m*(p+n-x-1)
    for i in range(p-1,x):
        tmp+=a[x]+m-a[i]
    if tmp>=m*v:
        return True
    return False

left=0
right=n
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        left=mid
    else:
        right=mid
print(left+1)



Measured memory_bytes: 14964
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 100005
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,fa[N],root;
char s[N];
int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	for(int i=1;i<=n;i++) s[i]-=48;
	if(!s[1]||s[n]) return puts("-1"),0;
	for(int i=1;i<=n;i++) if(!s[i]&&s[n-i]) return puts("-1"),0;
	fa[1]=root=n;
	for(int i=2;i<n;i++)
		if(s[i]) fa[root]=i,root=i;else fa[i]=root;
	for(int i=1;i<=n;i++) if(fa[i]) printf("%d %d\n",i,fa[i]);
	return 0;
}


Measured memory_bytes: 2048
n, a, b, c = map(int, input().split())
mod = 10 ** 9 + 7
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (2 * n + 2)
fi = [1] * (2 * n + 2)
for i in range(1, 2 * n + 2):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
ans = 0
for i in range(n):
    ans += (comb(n + i - 1, i) * (pow(a * pow(a + b, mod - 2, mod), n, mod) * pow(b * pow(a + b, mod - 2, mod), i, mod) + pow(b * pow(a + b, mod - 2, mod), n, mod) * pow(a * pow(a + b, mod - 2, mod), i, mod)) * (n + i)) % mod
    ans %= mod
print(ans * 100 * pow(100 - c, mod - 2, mod) % mod)


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

int main(){
int a,b;
char op;

while(1){
cin >>a >>op >>b;
if(op=='?') break;

if(op=='+') cout << a+b << endl;
else if(op=='-') cout << a-b << endl;
else if(op=='*') cout << a*b << endl;
else if(op=='/') cout << a/b << endl;
}
return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){   
  ll X;
  cin >> X;
  int A,B;
  bool finished = false;
  for(int i = 0; i <= 119; i++){
    for(int j = -100; j <= 119; j++){
      A = i;
      B = j;
      if(i*i*i*i*i - j*j*j*j*j == X){
        finished = true;
        break;
      }
    }
    if(finished) break;
  }
  cout << A << " " << B << endl;
  
}


Measured memory_bytes: 3624
H,W = map(int,input().split())
A=[]
for i in range(H):
    A.append(list(input()))

for i in range(H):
    if A[i] == ['.'] * W:
        A[i] = ['-1'] * W
for j in range(W):
    count = 0
    for i in range(H):
        if A[i][j] == '#':
            break
        count += 1
    if count == H:
        for i in range(H):
            A[i][j] = '-1'
for a in A:
    if a == ['-1'] * W:
        continue
    ans = [ai for ai in a if not ai == '-1']
    print(''.join(ans))




Measured memory_bytes: 9288
#include <stdio.h>
 
int main(void){
  int n,i,now;
  int before = 10;
  scanf("%d",&n);
  for(i=0;i<4;i++){
    now = n % 10;
    n = n / 10;
    if(before == now){
      printf("Bad\n");
      return 0;
    }
    before = now;
  }
  printf("Good\n");
  return 0;
}

Measured memory_bytes: 128
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    int a; cin>>a;
    map<str, int> mp;
    int mx = 0;
    for(int q=0; q<a; q++){
        str t; cin>>t;
        mp[t]++;
        mx = max(mx, mp[t]);
    }
    for(auto i : mp){
        if(i.S==mx) cout<<i.F<<"\n";
    }
}

Measured memory_bytes: 23808
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    long[] a,b;

    private void solve() {
        N = nextInt();

        a = new long[N];
        for(int i = 0;i < N;i++) {
            a[i] = nextInt();
        }

        b = new long[N];
        for(int i = 0;i < N;i++) {
            b[i] = nextInt();
        }

        long count = 0;
        for(int i = 0;i < N;i++) {
            if (a[i] < b[i]) {
                count += (b[i] - a[i]) / 2;
            } else {
                count -= (a[i] - b[i]);
            }
        }

        if(count >= 0) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 26748
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
using namespace std;

unsigned short vis[1 << 24];
char c[16][20];
bool wall[256];
int tm0;

inline bool check(int u, int v){
	for(int i = 0; i < 24; i += 8){
		int p1 = v >> i & 255;
		if(p1){
			int j = i == 16 ? 0 : i + 8;
			if(wall[p1]){ return false; }
			int p2 = v >> j & 255;
			if(p1 == p2){ return false; }
			if(
				p1 == (u >> j & 255) &&
				p2 == (u >> i & 255)
			){
				return false;
			}
		}
	}
	return true;
}

int solve(int start, int goal){
	const int dif[5] = {0, -1, 1, -16, 16};

	queue<int> q;
	q.push(start);
	q.push(-1);
	int tm = tm0 + 1;
	vis[start] = tm;
	while(1){
		int u = q.front();
		q.pop();
		if(u < 0){
			q.push(-1);
			++tm;
		}
		else{
			for(int i1 = u & 255 ? 4 : 0; i1 >= 0; --i1)
			for(int i2 = u >> 8 & 255 ? 4 : 0; i2 >= 0; --i2)
			for(int i3 = u >> 16 ? 4 : 0; i3 >= 0; --i3){
				int v = u + dif[i1] + (dif[i2] << 8) + (dif[i3] << 16);
				if(vis[v] > tm0){ continue; }
				if(check(u, v)){
					if(v == goal){ return tm; }
					vis[v] = tm;
					q.push(v);
				}
			}
		}
	}
}

int main(){
	int w, h;
	while(scanf("%d%d%*d ", &w, &h), w){
		for(int i = 0; i < h; ++i){
			fgets(c[i], 20, stdin);
		}

		int goal = 0;
		int start = 0;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(c[i][j] == '#'){
					wall[i << 4 | j] = true;
				}
				else{
					wall[i << 4 | j] = false;
					if(isupper(c[i][j])){
						goal |= (i << 4 | j) << (c[i][j] - 'A') * 8;
					}
					else if(islower(c[i][j])){
						start |= (i << 4 | j) << (c[i][j] - 'a') * 8;
					}
				}
			}
		}

		int tm = solve(start, goal);
		printf("%d\n", tm - tm0);

		tm0 = tm + 1;
		if(tm0 > 55000){
			memset(vis, 0, sizeof vis);
			tm0 = 0;
		}
	}
}

Measured memory_bytes: 32808
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

#define MOD 1000000007

using namespace std;

int main()
{
	long long n, k;

	scanf("%lld %lld", &n, &k);

	long long sol = 0;

	for (long long i = k; i <= n + 1; i++)
	{
		sol = (sol + (((n - i + 1) % MOD)*i%MOD + 1) % MOD) % MOD;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 1732
n = int(input())
a = list(map(int,input().split()))
q = int(input())
for _ in range(q):
    b, m, e = map(int,input().split())
    tmp = a[:]
    for k in range(e-b):
        t = b + ((k+(e-m)) % (e-b))
        a[t] = tmp[b+k]

print(*a)



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

int main(){
  int c[3][3],x[3],y[3];
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      cin>>c[i][j];
    }
  }
  x[1]=0;
  for(int i=1;i<=3;i++){
    y[i]=c[1][i]-x[1];
    x[i]=c[i][1]-y[1];
  }
  bool at=true;
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      if(x[i]+y[j]!=c[i][j]){
        at=false;
      }
    }
  }
  if(at) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


Measured memory_bytes: 256
def _rot13(c,N):
    if 'A' <= c and c <= 'Z':
        # 13 文字分ずらす
        return chr((ord(c) - ord('A') + N) % 26 + ord('A'))

    if 'a' <= c and c <= 'z':
        # 13 文字分ずらす
        return chr((ord(c) - ord('a') + N) % 26 + ord('a'))

    # その他の文字は対象外
    return c


def rot13(s,N):
    # ジェネレータ内包表記で文字列に ROT13 を適用する
    g = (_rot13(c,N) for c in s)
    # 文字列に直す
    return ''.join(g)


def main():
    N = int(input())
    s = input()
    print(rot13(s,N))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    x,n = map(int,ipt().split())
    p = list(map(int,ipt().split()))
    for i in range(100):
        if not x-i in p:
            print(x-i)
            exit()
        if not x+i in p:
            print(x+i)
            exit()


    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9712
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

struct card{
    lli b;
    lli c;
    bool operator<(const card &another) const{
        return c>another.c;
    }
};

int main(){
    lli n,m,a,b,c,sum=0;
    card dat;
    vector<card> vec;
    priority_queue<lli,vector<lli>,greater<lli>> que;
    lli i,j;
    cin>>n>>m;
    rep(i,0,n){
        cin>>a;
        sum+=a;
        que.push(a);
    }
    rep(i,0,m){
        cin>>b>>c;
        dat={b,c};
        vec.push_back(dat);
    }
    sort(vec.begin(),vec.end());
    rep(i,0,m){
        rep(j,0,vec[i].b){
            if(que.top()<vec[i].c){
                sum-=que.top();
                que.pop();
                sum+=vec[i].c;
                que.push(vec[i].c);
            }
            else{
                break;
            }
        }
    }
    cout<<sum<<endl;
}


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


x = readint()

if x % 11 > 6:
    print(x // 11 * 2 + 2)
elif x % 11:
    print(x // 11 * 2 + 1)
else:
    print(x // 11 * 2)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  char str[1000],rep[1000],com[10],temp;
  int q,i,j,a,b,N;
  scanf("%s",str);
  scanf("%d",&q);
    for(i=0;i<q;i++)
      {
	scanf("%s",com);
	if(!strcmp(com,"print"))
	  {
	    scanf("%d",&a);
	    scanf("%d",&b);     
	    for(j=a;j<=b;j++)
	      {printf("%c",str[j]);}
	    printf("\n");
	  }      
	if(!strcmp(com,"reverse"))
	  {
	  scanf("%d",&a);
	    scanf("%d",&b);
	    for(j=0;j<=(b-a)/2;j++)
	      {
	      temp=str[j+a];
	    str[j+a]=str[b-j];
	    str[b-j]=temp;
	      }
	  }
	if(!strcmp(com,"replace"))
	  {
	    scanf("%d",&a);
	    scanf("%d",&b);
	    scanf("%s",rep);
	    for(j=0;j<b-a+1;j++)
	      {
		str[a+j]=rep[j];	
	      }
	  }
      }
    return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <string.h>
int main(void){
    int i,n,t,a,b,ans=0;
    scanf("%d %d",&n,&t);
    scanf("%d",&a);
    for(i=0;i<n-1;i++){
        scanf("%d",&b);
        if((b-a)>t){
            ans+=t;
        }
        else{
            ans+=b-a;
        }
        a=b;
    }
    ans+=t;
    printf("%d",ans);
}

Measured memory_bytes: 128
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: String -> [String] -> Int
solve w = iter where
    iter [] = 0
    iter (s:ss) = count (==w) (words (map toLower s)) + iter ss where
        count _ [] = 0
        count f (x:xs) = (if f x then 1 else 0) + count f xs

readUntil :: (String -> Bool) -> IO [String]
readUntil eof = iter where
    iter = getLine >>=
            (\a -> if eof a then return [] else fmap (a:) iter)

eof :: String -> Bool
eof s = s == "END_OF_TEXT"

main :: IO() 
main = do
    w <- getLine
    l <- readUntil eof
    print (solve w l)


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

int main(){
    int n, x, s=0, mini=1000000000;
    cin>>n>>x;
    for(int i=0; i<n; i++){
        int t;
        cin>>t;
        s+=t;
        mini=min(t,mini);
    }
    cout<<n+(x-s)/mini;
}


Measured memory_bytes: 256
def popcount(i):
    assert 0 <= i < 0x100000000
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
memo = [None] * 300000
def do2(x):
    if memo[x] is not None:
        return memo[x]
    cnt = 0
    while x != 0:
        x = x % popcount(x)
        cnt += 1
    memo[x] = cnt
    return cnt

def do():
    ll = int(input())
    s = input()
    n = int(s, 2)

    x = n
    cnt = 0
    ss = bin(x)[2:]
    cnt += 1
    num1 = ss.count("1")
    num1m = num1 - 1
    num1p = num1 + 1
    rs = ss[::-1]
    res1m = 0
    res1p = 0
    for j in range(len(rs)):
        if rs[j] == "1":
            if num1m != 0 and num1m != -1:
                res1m += pow(2, j, num1m)
                res1m %= num1m
            res1p += pow(2, j, num1p)
            res1p %= num1p

    #print(res1m, res1p, num1m, num1p)
    for i in range(len(s)):
        #print("i", i)
        if s[i] == "1": # 0になるから
            #print("down")
            #print(res1m, pow(2, ll - i -1, num1m))
            if num1m == 0 or num1m == -1:
                print(0)
                continue
            x = res1m - pow(2, ll - i -1, num1m)
            x %= num1m
        elif s[i] == "0": # 1になるから
            #print("up")
            #print(res1p, pow(2, ll - i -1, num1p))
            x = res1p + pow(2, ll - i-1, num1p)
            x %= num1p

        if x == 0:
            print(1)
            continue
        print(do2(x) + 1)
do()


Measured memory_bytes: 79552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
int main()
{
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];
    sort(p, p + n);
    p[n-1]=p[n-1]/2;
    int pp = 0;
    rep(i,n)pp+=p[i];
    cout << pp << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int H = n[0];
        int W = n[1];
        string frame = "";
        for (int i = 0; i < W + 2; i++)
            frame += "#";
        string[] s = new string[H];
        for (int i = 0; i < H; i++)
        {
            s[i] = "#" + Console.ReadLine() + "#";
        }
        Console.WriteLine(frame);
        for (int i = 0; i < H; i++)
            Console.WriteLine(s[i]);
        Console.WriteLine(frame);
    }
}


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

using namespace std;

struct RSQ {
    int n;
    vector<int> dat;

    RSQ(int n_) : n{n_} {
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        
        dat.assign(2 * n - 1, 0);
    }

    void add(int k, int a)
    {
        k += n - 1;
        dat[k] += a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }

    int sum(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) {
            return 0;
        }

        if (a <= l && r <= b) {
            return dat[k];
        } else {
            int vl = sum(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = sum(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
    
    /* sum [l, r] */
    int sum(int l, int r)
    {
        return sum(l, r + 1, 0, 0, n);
    }
};

int main()
{
    int N, Q;
    cin >> N >> Q;
    RSQ rsq(N);

    for (int i = 0; i < Q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            x--;
            rsq.add(x, y);
        } else {
            x--; y--;
            cout << rsq.sum(x, y) << endl;
        }
    }        
    return 0;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define sim template < class c
    #define ris return * this
    #define dor > debug & operator <<
    #define eni(x) sim > typename \
      enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug {
    #ifdef LOCAL
        ~debug() { cerr << endl; }
        eni(!=) cerr << boolalpha << i; ris; }
        eni(==) ris << range(begin(i), end(i)); }
        sim, class b dor(pair < b, c > d) {
        ris << "(" << d.first << ", " << d.second << ")";
        }
        sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
        }
    #else
    sim dor(const c&) { ris; }
    #endif
    };
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
     
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<long double> vld;
    typedef long long ll;
    typedef long double ld;
    #define PI 3.14159265358979323846
    #define sqr(a) ((a) * (a))
    #define len(V) (int)V.size()
    #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
    #define all(a) (a).begin(),(a).end()
    #define rall(a) (a).rbegin(),(a).rend()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define endl '\n'
    #define fix(a) fixed << setprecision(a)
    #define readv(x) for(auto &_ : (x)) {cin >> _;}
    #define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
    #define EPS 1e-6
    #define MAXN 100047
     
     
    void solve(){
    	int n; cin >> n;
    	string s; cin >> s;
    	int x = 0, mx = 0;
    	
    	for (auto el : s){
    		if (el == 'I') x++;
    		else x--;
    		if (x > mx) mx = x;
    	}
    	
    	cout << mx << endl;
    }
     
    int main() {
    	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    	
    	solve();
    	
    	return 0;
    }

Measured memory_bytes: 3656
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main() {
  bool notPrime[123456*2+1];
  memset(notPrime, false, sizeof(notPrime));
  for (int i = 2; i*i <= 123456*2; i++) {
    for (int j = i+i; j <= 123456*2; j+=i) {
      notPrime[j] = true;
    }
  }
  notPrime[0] = true;
  notPrime[1] = true;
  int memo[123456*2+1];
  memo[0] = 0;
  for (int i = 1; i <= 123456*2; i++) {
    memo[i] = memo[i-1]+!notPrime[i];
  }
  int n;
  while(true) {
    cin >> n;
    if (n == 0) break;
    std::cout << memo[2*n]-memo[n] << std::endl;
  }
}

Measured memory_bytes: 2372
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n;
vector<string> words;

void input() {
	cin >> n;
	string w;
	for (int i = 0; i < n; i++) {
		cin >> w;
		words.push_back(w);
	}
}

bool duplicationCheck() {
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (words.at(i) == words.at(j)) return true;
		}
	}
	return false;
}

bool isolatedCheck() {
	for (int i = 0; i < n - 1; i++) {
		int len = words.at(i).length();
		char tail = words.at(i).at(len - 1);
		char head = words.at(i + 1).at(0);
		if (tail != head) return true;
	}
	return false;
}

string solver() {
	if (duplicationCheck()) return "No";
	if (isolatedCheck()) return "No";
	return "Yes";
}

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

	input();
	cout << solver() << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q,ans;
int main()
{
	cin>>n>>m>>q;
	vector<int> a(q),b(q),c(q),d(q);
	for(int i=0;i<q;++i)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		--a[i],--b[i];
	}
	vector<vector<int> > V[11];
	for(int i=1;i<=m;++i) V[1].push_back({i});
	for(int i=1;i<n;++i)
	 for(auto&v : V[i])
	 {
	 	int k=v.back();
	 	for(int j=k;j<=m;++j)
	 	{
	 		auto v2=v;
	 		v2.push_back(j);
	 		V[i+1].push_back(v2);
		}
	 }
	for(auto&v : V[n])
	{
		int s=0;
		for(int i=0;i<q;++i)
		 if(v[b[i]]-v[a[i]]==c[i])
		  s+=d[i];
		ans=max(ans,s);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;


int solve(string S);


int main() {

	string S;

	cin >> S;

	if (solve(S)) {
		cout << "AC";
	}
	else {
		cout << "WA";
	}
	
	return 0;

}

int solve(string S) {
	int count = 0, key=0, c;
	if (S[0] != 'A') {
		return false;
	}

	for (int i = 2; i < S.size() - 1; i++) {
		if (S[i] == 'C') {
			count++;
			c = i;
		}
	}
	if (count != 1) {
		return false;
	}

	for (int i = 0; i < S.size(); i++) {
		if (i != 0 && i != c) {
			if (!islower(S[i])) {
				return false;
			}
		}
	}

	return true;
}

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

int main(){
    int N;
    double x, ret, FX;
    string ccy;
    cin >> N;

    ret = 0.0;
    FX = 380000.0;
    for (size_t i; i < N; ++i){
        cin >> x >> ccy;
        if (ccy == "JPY")
            ret += x;
        else
            ret += FX * x;
    }
    cout << fixed << setprecision(4) << ret << endl;
    return 0;
}

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

int main(){
    vector<int> min(5);
    for (int i=0;i<5;i++){
        cin >> min[i];
    }
    //10に足りない端数が１番大きいのを最後に持ってくれば
    //あとはどうでもよい
    vector<int> r(5);
    int ma = -1;
    for (int i=0;i<5;i++){
        r[i] = (10 - min[i] % 10) % 10;
        ma = max(ma,r[i]);
    }
    int ans = 0;
    for (int i=0;i<5;i++){
        ans += min[i] + r[i];
    }
    ans -= ma;

    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys


N,K = map(int,input().split())
#%%
ans = 0
for a in range(1,N+1):
    b = K-a%K
    c = K-a%K
    if b==0 or c==0:
        continue
    if (b+c)%K==0:
        if N%K>=b:
            tmpb = (N+K-1)//K
        else:
            tmpb = N//K
        if N%K>=c:
            tmpc = (N+K-1)//K
        else:
            tmpc = N//K
        ans += tmpb*tmpc

print(ans)

Measured memory_bytes: 3064
#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;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

struct Bit {
    int N;
    vector<int> bit;

    Bit(int n) {
        N = n;
        bit = vector<int>(N);
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, int x) {
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

const int PLUS = 100005;
ll f(int X, vector<int>& V) {
    int N = V.size();
    vector<int> A(N);
    rep(i, N) A[i] = V[i] < X ? -1 : 1;

    vector<int> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + A[i];

    ll cnt = 0;
    Bit bit = Bit(2 * PLUS);
    rep(i, N + 1) {
        cnt += bit.sum(sum[i] + PLUS);
        bit.add(sum[i] + PLUS, 1);
    }

    return cnt;
}

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    const ll M = (ll)N * (N + 1) / 2;

    vector<int> B = A;
    sort(B.begin(), B.end());

    int l = -1, r = N;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (M / 2 <= f(B[mid], A)) {
            l = mid;
        } else {
            r = mid;
        }
    }

    cout << B[l] << endl;
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    vector<lli> c(n-1), s(n-1), f(n-1);
    rep(i, n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i, n){
        lli t = 0;
        lli j = i;
        while(j < n){
            if(j < n-1){
                if(t < s[j]) t=s[j];
                else if(t%f[j] == 0);
                else t+=f[j]-t%f[j];
                t+=c[j];
            }
            j++;
        }
        cout << t << endl;
    }
    return 0;
}


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

int main(){
  string s, t, u;
  cin >> s;
  for(int i = 0; i <4; i++){
    t += s.at(i);
    u += s.at(i*2+4);
    u += s.at(i*2+5);
  }
  cout << t << ' ' << u << endl;
}


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

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		long k = parseLong(sc.next());
		sc.close();
		long a2 = Math.max(0, a-k);
		k-=a-a2;
		long b2 = Math.max(0, b-k);
		out.printf("%d %d%n", a2, b2);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
  	string a, b, c;
  	cin>>a>>b>>c;
  	char dif='A'-'a';
  	printf("%c%c%c\n",a[0] + dif , b [0] + dif , c [0] + dif );
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n;
	cin >> n;
	rep(i, 9) {
		rep(j, 9) {
			if ((i + 1) * (j + 1) == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 81;
const ll LINF = 1e18 + 5;
int h, w, a[N][N], b[N][N];
vector<vector<bitset<N*N*2>>> dp(N,vector<bitset<N*N*2>>(N));
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> w;
 	for(int i=1;i<=h;i++)
 		for(int j=1;j<=w;j++)
 			cin >> a[i][j];
 	for(int i=1;i<=h;i++)
 		for(int j=1;j<=w;j++)
 			cin >> b[i][j];
 	dp[1][1][abs(a[1][1]-b[1][1])] = 1;
 	for(int i=1;i<=h;i++)
 	{
 		for(int j=1;j<=w;j++)
 		{
 			int v = abs(a[i][j]-b[i][j]);
 			for(int k=0;k<=(i+j)*80;k++)
 			{	
 				if(dp[i-1][j][k])
				{
					dp[i][j][k+v] = dp[i-1][j][k];
	 				dp[i][j][abs(k-v)] = dp[i-1][j][k];
 				}
 				if(dp[i][j-1][k])
 				{
	 				dp[i][j][k+v] = dp[i][j-1][k];
	 				dp[i][j][abs(k-v)] = dp[i][j-1][k];
	 			}
 			}
 		}
 	}
 	for(int i=0;i<=(h+w)*80;i++) if(dp[h][w][i]) return cout << i, 0;
	return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <map>
using namespace std;
int main()
{
    string x;
    cin>>x;
    int c1=0,c2=0;
    bool b=0;
    if(x[0]=='W')b=1;
    for(int i=0;i<x.size();i++){
        if(b&&x[i]=='W'){c1++;b=0;}
        if(!b&&x[i]=='B'){c1++;b=1;}
    }
    cout<<c1-1;
    return 0;
}


Measured memory_bytes: 512
def main():
    n, m = map(int, input().split())
    p = 2**n
    dp = [10**7]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                if dp[t] > dp[s] + a:
                    dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == 10**7:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

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

typedef long long ll;

#define faster() ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const double eps = 1e-9;

const int N = 1e5 + 5;
int a[N], n, n1, n2;
map<int, int> m1, m2;

int main()
{
	faster();
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	for (int i = 0; i < n; i += 2)
		m1[a[i]]++;
	for (int i = 1; i < n; i += 2)
		m2[a[i]]++;

	int mx1 = 0, mx2 = 0;
	for (auto &it : m1)
	{
		if (it.S > mx1)
		{
			mx1 = it.S;
			n1 = it.F;
		}
	}
	for (auto &it : m2)
	{
		if (it.S > mx2)
		{
			mx2 = it.S;
			n2 = it.F;
		}
	}
	if (n1 != n2) cout << n - mx1 - mx2;
	else
	{
		int mxx1 = 0, mxx2 = 0;
		for (auto &it : m1)
		{
			if (it.F != n1 && it.S > mxx1)
				mxx1 = it.S;
		}
		for (auto &it : m2)
		{
			if (it.F != n2 && it.S > mxx2)
				mxx2 = it.S;
		}
		if (mxx1 > mxx2)
			cout << n - mxx1 - mx2;
		else
			cout << n - mx1 - mxx2;
	}
	return 0;
}

Measured memory_bytes: 5376
H,W=map(int, input().split())
S = [input() for i in range(H)]
m=H*W
l=[[None]*m for i in range(m)]
L=[0]*m
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            L[i*W+j]=1
for i in range(m):
    for j in range(m):
        if L[i] and L[j]:
            if i==j:
                l[i][j]=0
            elif abs(i-j)==W:
                l[i][j]=1
            elif i-j==1 and i%W!=0:
                l[i][j]=1
            elif j-i==1 and j%W!=0:
                l[i][j]=1
            else:
                l[i][j]=400
for i in range(m):
    if L[i]:
        for j in range(m):
            if L[j]:
                for k in range(m):
                    if L[k]:
                        if l[i][j]+l[i][k]<l[j][k]:
                            l[j][k]=l[i][j]+l[i][k]
M=0
for i in l:
    for j in i:
        if j:
            if M<j:
                M=j
print(M)


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

    int a = s/100;
    int b = s%100;

    bool abmm=false;
    bool amm=false;
    bool bmm=false;

    // if(a==0 || b==0){
    //     cout<<"NA"<<endl;
    //     return 0;
    // }

    if(1<=a && a<=12){
        amm=true;
    }
    if(1<=b && b<=12){
        bmm=true;
    }

    if(amm==true && bmm==true){
        cout<<"AMBIGUOUS"<<endl;
    }else if(amm==true){
        cout<<"MMYY"<<endl;
    }else if(bmm==true){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 3600
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n = read::<i64>();

    if n == 0 {
        println!("{}", 0);
        return;
    }


    let mut ans = "".to_string();
    while n != 0 {
        if n % 2 != 0 {
            n -= 1;
            ans = ans + "1";

        } else {
            ans = ans + "0";
        }
        n /= -2;

    }
    println!("{}", ans.chars().rev().collect::<String>());
}

Measured memory_bytes: 4352
#include<stdio.h>
long A, B, C;
int ans = 1;
long gcd(long a, long b){return b?gcd(b, a%b):a;}
int main(){
	scanf("%ld%ld", &A, &B);
	C = gcd(A, B);
	for(long i=2; i*i<=C; i++){
		if(C%i == 0){
			while(C%i == 0) C /= i;
			ans++;
		}
	}
	if(C > 1) ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1728