akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 200005;
int n, m;
struct qq { int x, y; }s[N];
int ans = 0;
bool cmp(qq x, qq y) { return x.y < y.y; }
struct qt
{
	int l, r;
	int s1, s2;//ls,rs
	int c;//sum
	int lzy;
}tr[N * 2]; int num;
void update(int now)//pushup
{
	int s1 = tr[now].s1, s2 = tr[now].s2;
	tr[now].c = max(tr[s1].c, tr[s2].c);
}
void bt(int l, int r)//建树
{
	int a = ++num;//新节点编号
	tr[a].l = l; tr[a].r = r;
	if (l == r) { tr[a].c = l; return; }
	int mid = (l + r) >> 1;
	tr[a].s1 = num + 1; bt(l, mid);
	tr[a].s2 = num + 1; bt(mid + 1, r);
	update(a);
}
void push_down(int now)
{
	int s1 = tr[now].s1, s2 = tr[now].s2;
	int lzy = tr[now].lzy; tr[now].lzy = 0;
	tr[s1].lzy += lzy; tr[s1].c += lzy;
	tr[s2].lzy += lzy; tr[s2].c += lzy;
}
void change(int now, int l, int r, int x)
{
	if (l > r) return;
	if (tr[now].l == l && tr[now].r == r)
	{
		tr[now].lzy += x; tr[now].c += x;
		return;
	}
	push_down(now);
	int s1 = tr[now].s1, s2 = tr[now].s2;
	int mid = (tr[now].l + tr[now].r) >> 1;
	if (r <= mid) change(s1, l, r, x);
	else if (l > mid) change(s2, l, r, x);
	else change(s1, l, mid, x), change(s2, mid + 1, r, x);
	update(now);
}
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	scanf("%d%d", &n, &m);
	for (int u = 1; u <= n; u++)  scanf("%d%d", &s[u].y, &s[u].x);//y是L,x是R
	sort(s + 1, s + 1 + n, cmp);//L的升序
	bt(0, m + 1);//[0,m+1]内建树
	int now = 1;

	for (int u = 0; u <= m; u++)//椅子个数
	{
		
		while (now <= n && s[now].y <= u)//L小于等于u
		{
			//[1,R] += 1
			change(1, 1, s[now].x, 1);
			now++;
		}
		//
		ans = max(ans, -m - u - 1 + tr[1].c);
	}
	printf("%d\n", max(ans, n - m));
	return 0;
}

Measured memory_bytes: 11136
from math import floor, ceil
s = input()
k = int(input())

def f(s):
    b = ''
    ret = 0
    for i in s:
        if i==b:
            b = ''
            ret += 1
            continue
        b = i
    return ret

b = f(s*2) - f(s*1)
c = f(s*3) - f(s*2)
print(f(s) + b*floor(k/2) + c*ceil(k/2-1))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int A, B, C;

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

  cin >> A >> B >> C;

  int ans = max(0, C - max(A-B, 0));
  cout << ans << endl;
  return 0;
}

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

int cmp(const void *_a, const void *_b){
	int *a = (int*)_a;
	int *b = (int*)_b;
	if( *a > *b ) return -1;
	if( *a < *b ) return  1;
	return 0;
}

int main(){
	int d[5];
	scanf("%d %d %d %d %d",&d[0],&d[1],&d[2],&d[3],&d[4]);
	qsort(d,5,sizeof(int),cmp);
	printf("%d %d %d %d %d\n",d[0],d[1],d[2],d[3],d[4]);
	return 0;
}

Measured memory_bytes: 600
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = 1005;
ll a[MAX], b[MAX];
ll const MOD = 1e9 + 7;
ll mod_m(ll x, ll y) {
	return (x*y) % MOD;
}

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, 1, n) {
		cin >> a[i];
	}
	REP(j, 1, m) {
		cin >> b[j];
	}
	SORT(a, n); SORT(b, m);
	reverse(a + 1, a + 1 + n);
	reverse(b + 1, b + 1 + m);
	a[n + 1] = b[m + 1] = -1;
	ll cnt_i = 1; ll cnt_j = 1;
	ll ans = 1;
	ll hide = 0;
	PER(k, n*m, 1) {
		if (a[cnt_i] == k && b[cnt_j] == k) {
			cnt_i++; cnt_j++;
			hide++;
		}
		else if (a[cnt_i] == k) {
			ans = mod_m(ans, cnt_j - 1);
			cnt_i++;
			hide++;
		}
		else if (b[cnt_j] == k) {
			ans = mod_m(ans, cnt_i - 1);
			cnt_j++;
			hide++;
		}
		else {
			ll x = (cnt_i - 1)*(cnt_j - 1) - hide;
			ans = mod_m(ans, x);
			hide++;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int price;
  if (A >= 13) {
    price = B;
  }
  else if (A <= 5) {
    price = 0;
  }
  else {
    price = B / 2;
  }
  cout << price << endl;
}


Measured memory_bytes: 256
n = int(input())

if 1 <= n <= 8:
    print(n)

elif 9 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n - 90)
elif 1000 <= n <= 9999:
    print(909)
elif 10000 <= n <= 99999:
    print(n - 9090)
else:
    print(90909)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

void solve(int tc) {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<ll> pro;
    pro.pb(a*c);
    pro.pb(a*d);
    pro.pb(b*c);
    pro.pb(b*d);
    sort(all(pro));
    cout<<pro[3]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    for(int tc=1; tc<=t; ++tc) {
        solve(tc);
    }    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
    int i;
    int counter[26]={0};
    char ch;
     
    while(scanf("%c",&ch)!=EOF){
        if(ch==EOF) break;
        int num=ch-'a';
        if(0<=num && num<26){
            counter[num]++;
        }else if(-32<=num && num<-6){
            counter[num+32]++;
        }
    //  printf("%c %d\n",ch,ch);
    }
     
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,counter[i]);
    }
    return 0;
}


Measured memory_bytes: 2084
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int n;
	static int[] a, b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		boolean[] use = new boolean[52];
		Arrays.fill(use, true);
		for (int i = 51; i > 0; i--) {
			use[i] = false;
			if (!judge(use)) {
				if (i == 51) {
					System.out.println(-1);
					return;
				}
				use[i] = true;
			}
		}

		long ans = 0;
		for (int i = 1; i < 51; i++) {
			if (use[i]) {
				ans += 1L << i;
			}
		}
		System.out.println(ans);
	}

	static boolean judge(boolean[] use) {
		List<Set<Integer>> list = new ArrayList<>(51);
		for (int i = 0; i < 51; i++) {
			list.add(new HashSet<>());
		}
		for (int i = 1; i < 51; i++) {
			for (int j = 1; j <= i; j++) {
				if (use[j]) {
					list.get(i).add(i % j);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			boolean[] visit = new boolean[51];
			Queue<Integer> que = new ArrayDeque<>();
			que.add(a[i]);
			visit[a[i]] = true;
			while (!que.isEmpty()) {
				int cur = que.poll();
				for (int next : list.get(cur)) {
					if (next >= b[i] && !visit[next]) {
						que.add(next);
						visit[next] = true;
					}
				}
			}
			if (!visit[b[i]]) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 25172
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    var fmin = Int.MAX_VALUE
    for (i in 1..Math.sqrt(n.toDouble()).toLong()) {
        if (n % i != 0L) continue
        val j = n / i
        val f = Math.max(i.toString().length, j.toString().length)
        if (f < fmin) {
            fmin = f
        }
    }
    println(fmin)
}


Measured memory_bytes: 33472
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int n, m;
vector<int> g[MAX];
bool mark[MAX];
deque<int> dq;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dq.push_back(1);
	mark[1] = true;
	bool flag = true;
	while(flag) {
		flag = false;
		for(int v: g[dq.front()]) if(!mark[v]) {
			dq.push_front(v);
			mark[v] = flag = true;
			break;
		}
	}
	flag = true;
	while(flag) {
		flag = false;
		for(int v: g[dq.back()]) if(!mark[v]) {
			dq.push_back(v);
			mark[v] = flag = true;
			break;
		}
	}
	cout << dq.size() << endl;
	for(int v: dq) cout << v << ' ';
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  vector<ll> a;
  int n;
  cin >> n;
  ll A;
  rep(i, 0, n - 1) {
    cin >> A;
    if (A == 0) {
      cout << 0 << endl;
      return 0;
    }
    a.push_back(A);
  }

  ll ans = 1;
  ll thr = pow(10, 18);
  rep(i, 0, n - 1) {
    // if (a[i] * ans <= pow(10, 18)) {
    if (a[i] <= thr / ans) {
      ans *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

    vector<int> a(n);
    vector<int> b(n);

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

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

    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
    }

    b[0] += a[0];

    for (int i = 1; i < n; i++) {
        b[i] += max(a[i], b[i - 1]);
    }

    cout << b[n - 1] << endl;
}


Measured memory_bytes: 504
#include <iostream>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    return b==0?a:gcd(b, a%b);
}

int main()
{
    ll x, y;
    cin>>x>>y;
    if(x % y == 0){
        cout<<-1<<endl;
    }
    else{
        cout<<x * y / gcd(x, y) - x<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){

	int n,ans=0,naga;
	char ch[12];
	cin >> ch >> n;
	naga = strlen(ch);
	while(n--){
		char tmp[22];
		cin >> tmp;
		int len = strlen(tmp);
		for(int i = 0;i < len;i++) tmp[len+i] = tmp[i];
		for(int i = 0;i < len*2-naga;i++){
			for(int j = 0;j < naga;j++){
				if(tmp[i+j] != ch[j])goto out;
			}
			ans++;
			break;
			out:
			;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1168
import java.util.*;

class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int kosu = sc.nextInt(),ond = sc.nextInt(),base = sc.nextInt();
        
      	int ans = -1;
      	double mm =Double.MAX_VALUE;
        for(int i=0;i < kosu;i++){
			double nam = Math.abs(base-(ond-0.006*sc.nextInt()));
			    if(nam <mm ) {
				        mm = nam;
				        ans = i + 1;
			}
      }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24276
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    if n % 2 == 0 {
        println!("0.5")
    } else {
        println!("{}", ((n / 2) as f64 + 1.0) / n as f64)
    }
}


Measured memory_bytes: 2208
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

struct edge {
  int t, c;
  edge() {}
  edge(int t, int c) : t(t), c(c) {}
};

int L;
int N, M;
vector<edge> g[20];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> L;
  int r = 0;
  while ((1LL << r) <= L) r++;
  r--;
  rep(i, 0, r) {
    g[i].eb(i+1, 0);
    g[i].eb(i+1, (1LL << i));
  }
  int ng = 1LL << r;
  repr(i, r-1, 0) {
    if (ng + (1LL << i) <= L) {
      g[i].eb(r, ng);
      ng += 1LL << i;
    }
  }
  N = r+1;
  rep(i, 0, N) M += g[i].size();
  cout << N << " " << M << endl;
  rep(i, 0, N) {
    for (edge e : g[i]) {
      cout << i+1 << " " << e.t+1 << " " << e.c << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,x;
int a;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n;
  x=100;
  while(x<n)
  { x+=x/100;
    a++;
  }
  cout<<a<<'\n';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n,a[1000005];
int k1[4]={1,1,0,0},k2[4]={1,0,0,1};
char s[1000005];
bool check(int x,int y,int n)
{
	a[0]=x;
	a[1]=y;
	for(int i=1;i<n-1;i++)
	{
		if(s[i]=='o')
		{
			if(a[i])
				a[i+1]=a[i-1];
			else
				a[i+1]=!a[i-1];
		}
		else
		{
			if(a[i])
				a[i+1]=!a[i-1];
			else
				a[i+1]=a[i-1];
		}
	}
	if(s[0]=='o')
	{
		if(a[0])
		{
			if(a[1]!=a[n-1])
				return 0;
		}
		else if(a[1]==a[n-1])
			return 0;
	}
	else
	{
		if(a[0])
		{
			if(a[1]==a[n-1])
				return 0;
		}
		else if(a[1]!=a[n-1])
			return 0;
	}
	if(s[n-1]=='o')
	{
		if(a[n-1])
		{
			if(a[0]!=a[n-2])
				return 0;
		}
		else if(a[0]==a[n-2])
			return 0;
	}
	else
	{
		if(a[n-1])
		{
			if(a[0]==a[n-2])
				return 0;
		}
		else if(a[0]!=a[n-2])
			return 0;
	}
	return 1;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<4;i++)
	{
		if(check(k1[i],k2[i],n))
		{
			for(int j=0;j<n;j++)
			{
				if(a[j])
					cout<<"S";
				else
					cout<<"W";
			}
			return 0;
		}
	}
	cout<<"-1";

	return 0;
}

Measured memory_bytes: 896
n=int(input())
alist = [int(i) for i in input().split()]
ans=0
 
for i in range(n-1):
	if alist[i]==i+1:
		temp=alist[i+1]
		alist[i+1]=alist[i]
		alist[i]=temp
		ans+=1
if alist[n-1]==n:
	ans+=1
print(ans)

Measured memory_bytes: 13880
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

fetchBook [] _ = []
fetchBook (b : bs) k
  | b > k = []
  | otherwise = b : fetchBook bs (k - b)

calc [] bs t k m m' = m'
calc as [] t k m m' = m'
calc (a : as) bs t k m m'
  | m'' > m' = calc as bs' t' k m'' m''
  | otherwise = calc as bs' t' k m'' m'
  where
    bs'' = fetchBook bs (k - t + a)
    lenBs = length bs''
    bs' = drop lenBs bs
    m'' = (m -1) + lenBs
    t' = t - a + sum bs''

getMax :: [Integer] -> Integer -> [Integer]
getMax [] _ = []
getMax (a : as) k
  | a > k = []
  | otherwise = a : getMax as (k - a)

main = do
  [n, m, k] <- getIntList
  as <- getIntList
  bs <- getIntList
  let as' = reverse (getMax as k)
  let lenAs = length as'
  let sumAs = sum as'
  if lenAs > 0
    then print $ calc as' bs sumAs k lenAs (lenAs + length (fetchBook bs (k - sumAs)))
    else print $ length (fetchBook bs k)


Measured memory_bytes: 44512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  string ac="AC";
  ll n=s.size();
  ll f=0;
  for(ll i=0;i<n-1;i++) {
    if(s.substr(i,2)==ac) f=1;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3), b(3);
    vector<vector<int>> c(3, vector<int>(3,0));

    rep(i,3)rep(j,3){
        cin>>c[i][j];
    }

    a[0]= 0;
    for(int i=0; i<3; i++){
        b[i] = c[0][i] - a[0];
        d(b[i])
    }
    for(int j=0; j<3; j++){
        a[j]  = c[j][0] - b[0];
    }
    bool ok = true;
    dump(a)
    dump(b)
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(not (a[i] + b[j] == c[i][j]))
                ok = false;
        }
    }
    cout << (ok?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N, i;
    char S[1000];
    scanf("%d", &N);
    scanf("%s", S);
    if (N%2==1) {
        printf("No");
        return 0;
    }
    for (i=0; i<N/2; i++) {
        if (S[i]!=S[N/2+i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int ans = 0;
	char a;
	REP(i, 3) {
		cin >> a;
		if (a == '1') ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#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 main() {
    //cout.precision(10);
    int k;
    cin >> k;
    long long a[100100];
    for(int i = 1; i <= k; i++){
        cin >> a[i];
    }
    if(a[k] != 2){
        cout << -1 << endl;
        return 0;
    }
    long long mini = 2;
    long long maxi = 3;
    for(int i = k - 1; i >= 1; i--){
        if(mini % a[i] == 0){
            mini--;
        }
        mini = (mini / a[i] + 1) * a[i];
        if(mini > maxi){
            cout << -1 << endl;
            return 0;
        }
        maxi = (maxi / a[i] + 1) * a[i] - 1;
    }
    cout << mini << " " << maxi << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int n = s.length();
        int out = 0;
        for(int i = 0; i < n; i++){
            a:for(int j = i; j <= n; j++){
                String t = s.substring(i, j);
                for(int k = 0; k < t.length(); k++){
                    if(t.charAt(k) != 'A' && t.charAt(k) != 'C' && t.charAt(k) != 'G' && t.charAt(k) != 'T') continue a;
                }
                out = Math.max(out, t.length());
            }
        }
        System.out.println(out);
    }


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


Measured memory_bytes: 35756
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bit(i) (1<<(i))
#define set(mask,i) (mask |= (1<<(i)))
#define get(mask,i) (mask & (1<<(i)))
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
const ll INF64 = (ll)1e15;
const int INF32 = (int)1e9;
const int64_t md = (int64_t)((int64_t)1e9 + 7);
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	int arr[n];
	for(int& el : arr) cin >> el;
	int dp[n + 1];
	for(int& el : dp) el = INF32;
	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		dp[i] = min(dp[i], dp[i-1]+abs(arr[i]-arr[i-1]));
		if(i-2 >= 0) dp[i] = min(dp[i], dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1];

	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n;
    cin >> n;
    cout << (n - 2) * 180 << endl;

    return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(u,v,cost){
    this.graph[u].push(v,cost);
  }
  add2(u,v,cost){
    this.graph[u].push(v,cost);
    this.graph[v].push(u,cost);
  }
  solve(start){
    const INF = 1e18;
    const g = this.graph;
    var pq = new priorityQueue();
    pq.push([0,start]);
    var dp = Array(g.length).fill(INF);
    dp[start] = 0;
    while(pq.size){
      var [t,v] = pq.pop();
      if(dp[v] < t)continue;
      for(var i = 0; i < g[v].length; i+=2){
        var V = g[v][i], c = g[v][i+1] + t;
        if(dp[V] <= c)continue;
        dp[V] = c;
        pq.push([c,V]);
      }
    }
    return dp;
  }
}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(x){
    const a = this.a;
    for(var i = a.length, j; i; i = j){
      j = i - 1 >> 1;
      if(x[0] >= a[j][0])break;
      a[i] = a[j];
    }
    a[i] = x;
  }
  pop(){
    const a = this.a, r = a[0], x = a.pop(), k = a.length;
    for(var i = 0, j; i < k >> 1; i = j){
      j = (i << 1) + 1;
      if(a[j+1] && a[j][0] > a[j+1][0])j++;
      if(a[j][0] >= x[0])break;
      a[i] = a[j];
    }
    if(k)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

const mx = 2500;

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,m,s] = nexts(3);
  var g = new dijkstra(mx * n);
  for(var i = 0; i < m; i++){
    var [u,v,a,b] = nexts(4);
    u--,v--;
    u *= mx, v *= mx;
    for(var j = mx; j-- > a;){
      g.add(u+j,v+j-a,b);
      g.add(v+j,u+j-a,b);
    }
  }
  for(var i = 0; i < n; i++){
    var [c,d] = nexts(2);
    var v = i * mx;
    for(var j = 0; j < mx-1; j++)g.add(v+j,v+Math.min(mx-1,j+c),d);
  }
  var dp = g.solve(Math.min(mx-1,s));
  var ans = xArray(1e18,n);
  for(var i = 1; i < n; i++){
    var v = i*mx;
    for(var j = 0; j < mx; j++){
      ans[i] = Math.min(ans[i],dp[v+j]);
    }
  }
  return ans.slice(1).join("\n");
}

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

int N;
int A[20];
int B[20];
int C[20];

int main() {
  cin >> N;
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  rep(i, N) {
    cin >> B[i];
  }
  rep(i, N-1) {
    cin >> C[i];
  }
  int sum = 0;
  int pre = A[0];
  sum += B[A[0]];
  rep(i, N-1) {
    sum += B[A[i+1]];
    if(A[i+1] == (pre+1)) {
      sum += C[pre];
    }
    pre = A[i+1];
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			int n=Integer.parseInt(inp.readLine());
			String aa[]=inp.readLine().split(" ");
			long arr[]=new long[n];

			for(int i=0;i<arr.length;i++)
			{
				arr[i]=Long.parseLong(aa[i]);
			}
			// PriorityQueue<Pair>pr=new PriorityQueue<>((a,b)->(int)(a.b-b.a));
			// boolean visited[]=new boolean[n];
			// visited[0]=true;
			// pr.offer(new Pair(0,(long)0));
			long cost[]=new long[n];
			cost[1]=Math.abs(arr[1]-arr[0]);
			for(int i=2;i<n;i++)
			{
				cost[i]=Math.min(cost[i-1]+Math.abs(arr[i]-arr[i-1]),cost[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			System.out.println(cost[n-1]);
		
	}
	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 36048
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=2e6+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),sum(0),n,m,x,y,t,i,j,temp,k,ans(0),mn(M),mx(-9e9);
vector<ll> v[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for(i=-200;i<200;i++)
	{
		for(j=-200;j<200;j++)
		{
			x=pow(i,5);
			y=pow(j,5);
			if(x-y==n)
			{
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	
}

Measured memory_bytes: 50928
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std;
 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   	int n;
   	cin>>n;
   	if(n)cout<<0;
   	else cout<<1;
	
	
 
 
 
 
 
 
 
	return 0;
}

Measured memory_bytes: 3604
import numpy as np 

n,u,v=map(int, input().split())
S = []
for _ in range(n-1):
    S.append(list(map(int, input().split())))

pt= [[0]*0 for i in range(n)] 
for i in range(n-1):
    pt[S[i][0]-1].append(S[i][1])
    pt[S[i][1]-1].append(S[i][0])

def bfs(v):
    d=[-1]*n
    d[v-1]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i-1]:
                if d[j-1]==-1:
                    d[j-1]=c
                    q1.append(j)
        q=q1
        c+=1
    return d
bfs_v=np.array(bfs(v))
bfs_u=np.array(bfs(u))
bfs_v_replace=bfs_v[bfs_v>bfs_u]
answer=np.max(bfs_v_replace)-1
print("{}".format(answer))

Measured memory_bytes: 47984
function main(input) {
  const lines = input.split('\n');
  delete lines[lines.length - 1];
  lines.forEach(v => {
    console.log(fn(v));
  });
}

function fn(v) {
  return 3 * v * v
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-09-20 17:31:24
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())
#define lc							id << 1
#define rc							lc | 1

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 998244353; // 1e9 + 9;

int n , k , P[MAXN] , fen[MAXN];
ll seg[MAXN << 2] , lz[MAXN << 2];

void shift(int id){
	lz[lc] = lz[lc] * lz[id] % MOD;
	lz[rc] = lz[rc] * lz[id] % MOD;
	seg[lc] = seg[lc] * lz[id] % MOD;
	seg[rc] = seg[rc] * lz[id] % MOD;
	lz[id] = 1;
}

void modify(int x , int v , int id = 1 , int l = 0 , int r = MAXN){
	if(r - l == 1){
		seg[id] = 1;
		return;
	}
	int mid = l + r >> 1;
	shift(id);
	if(x < mid)	modify(x , v , lc , l , mid);
	else	modify(x , v , rc , mid , r);
	seg[id] = (seg[lc] + seg[rc]) % MOD;
}

int get(int ql , int qr , int id = 1 , int l = 0 , int r = MAXN){
	if(qr <= l || r <= ql)	return 0;
	if(ql <= l && r <= qr)	return seg[id];
	int mid = l + r >> 1;
	shift(id);
	return (get(ql , qr , lc , l , mid) + get(ql , qr , rc , mid , r)) % MOD;
}

void add(int x){
	for( ; x < MAXN ; x += x & -x)	fen[x]++;
}

int get(int x){
	int ans = 0;
	for( ; x > 0 ; x -= x & -x)	ans += fen[x];
	return ans;
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	fill(lz , lz + MAXN * 4 , 1);

	cin >> n >> k;
	ll inv2 = poww(2 , MOD - 2 , MOD) , invk = poww(k , MOD - 2 , MOD);
	for(int i = 1 ; i <= n ; i++){
		cin >> P[i];
	}
	for(int i = 1 ; i <= k ; i++){
		modify(P[i] , 1);
		add(P[i]);
	}
	ll ans = 1ll * k * (k - 1) / 2 % MOD * inv2 % MOD;
	for(int i = k + 1 ; i <= n ; i++){
		ll x = 1ll * (k - 1) * invk % MOD;
		lz[1] = lz[1] * x % MOD;
		seg[1] = seg[1] * x % MOD;
		ans = (ans + seg[1] * inv2) % MOD;
//		cout << ans << sep << x << endl;
		x = (get(n) - get(P[i]) - get(P[i] + 1 , MAXN) + MOD) % MOD;
		ans = (ans + x) % MOD;
//		cout << i << sep << ans << endl;
		modify(P[i] , 1);
		add(P[i]);
	}
	cout << ans << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 15564
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 200005

int N;
int A[MAX_N], B[MAX_N];

void solve() {
  sort(A, A+N);
  sort(B, B+N);
  printf("%d\n", (N%2 == 1 ? B[N/2]-A[N/2] : (B[N/2]+B[(N-1)/2]-A[N/2]-A[(N-1)/2]))+1);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", A+i, B+i);
  }
  solve();
}


Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char s1 = sc.next().toUpperCase().charAt(0);
		char s2 = sc.next().toUpperCase().charAt(0);
		char s3 = sc.next().toUpperCase().charAt(0);

		System.out.println(s1 + "" + s2 + "" + s3);
	}

}


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

char G[8][8];

void solve(int x, int y) {
  const static int dx[] = {1,0,-1,0};
  const static int dy[] = {0,1,0,-1};
  G[y][x] = '0';
  for(int i = 0; i < 4; ++i) {
    for(int j = 1; j <= 3; ++j) {
      int nx = x + dx[i]*j;
      int ny = y + dy[i]*j;
      if(nx < 0 || nx >= 8) continue;
      if(ny < 0 || ny >= 8) continue;
      if(G[ny][nx] == '1') solve(nx,ny);
    }
  }
}

int main() {
  int T;
  cin >> T;
  for(int tc = 1; tc <= T; ++tc) {
    for(int i = 0; i < 8; ++i) {
      for(int j = 0 ; j < 8; ++j) {
	cin >> G[i][j];
      }
    }
    int x, y;
    cin >> x >> y;
    --x; --y;
    solve(x,y);
    cout << "Data " << tc << ":" << endl;
    for(int i = 0; i < 8; ++i) {
      for(int j = 0 ; j < 8; ++j) {
	cout << G[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  a.resize(n);

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

  int ret = INF;
  for (int l = 0, r = k-1; r < n; l++, r++) {
    int cost;
    if (a[l] == 0) {
      cost = a[r];
    } else if (a[r] == 0) {
      cost = abs(a[l]);
    } else if (a[l] < 0 && a[r] < 0) {
      cost = abs(a[l]);
    } else if (a[l] > 0 && a[r] > 0) {
      cost = a[r];
    } else {
      cost = min(abs(a[l]), a[r]) + abs(a[l]) + a[r];
    }
    ret = min(ret, cost);
  }
  cout << ret << endl;
}


Measured memory_bytes: 1024
n = int(input())

adj = [None]
for i in range(n):
    adj_i = list(map(int, input().split()[2:]))
    adj.append(adj_i)

isSearched = [None] + [False] * n

distance = [None] + [-1] * n

import collections

def bfs(u):
    isSearched[u] = True
    distance[u] = 0
    edge = collections.deque()
    edge.append(u)
    while edge:
        c_e = edge.popleft()
        for n_e in adj[c_e]:
            if not isSearched[n_e]:
                isSearched[n_e] = True
                distance[n_e] = distance[c_e] + 1
                edge.append(n_e)


bfs(1)

for i, x in enumerate(distance[1:], start=1):
    print(i, x)

Measured memory_bytes: 8004
import java.io.*;
import java.util.*;
public class Main implements Runnable {
    public void solve() throws Exception {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long x = sc.nextLong();
        int year = 0;
        long currentBalance = 100;
        //compound interest c = p*(1+r)^n;
        while (currentBalance<x){
            currentBalance+=currentBalance/100;
            year++;
        }
        out.println(year);
    }

    //main function//
    public static PrintWriter out;
    public static void main(String[] args) throws Exception {
        new Thread(null, new Main(), "", 1 << 26).start();
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    public void run() {
        try {
           solve();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        } finally {
            out.close();
        }
    }
}


Measured memory_bytes: 32964
//-*-coding:utf-8-*-
//----------------------------------------------------------
// module: main
//----------------------------------------------------------
#include <algorithm>
#include <vector>
#include <deque>
#include <map>

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int MAX_S = 100+100;

int w;
int h;

char m[MAX_S][MAX_S]; // map
bool u[MAX_S][MAX_S]; // used

typedef pair<int, int> pos;

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

pos getnext(int i, pos p){
    p.first += dx[i];
    p.second += dy[i];
    return p;
}

void walk(int x, int y){
    vector<pos> s;
    s.push_back(pos(x, y));
    char tile = m[y][x];

    while(!s.empty()){
        pos p = s.back();
        s.pop_back();

        if(u[p.second][p.first]) continue;
        u[p.second][p.first] = true;

        for (int i = 0; i < 4; ++i)
            {
                pos next = getnext(i, p);
                if (next.first < 0 || next.first >= w || next.second < 0 || next.second >= h)continue;
                if (m[next.second][next.first] != tile) continue;
                
                s.push_back(next);
            }
    }
}

void solve(){
    memset(u, 0, MAX_S*MAX_S);

    int count = 0;
    for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
                {
                    if(u[i][j]) continue;
                    count ++;
                    walk(j, i);
                }
        }
    printf("%d\n", count);
};

int main(int argc, char *argv[])
{
    while(true){
        scanf("%d %d", &h, &w);
        if(w <= 0) break;
        for (int i = 0; i < h; ++i)
            {
                scanf("%s", m[i]);
            }
        solve();
    }
    return 0;
}

Measured memory_bytes: 1520
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
	fastio;
  int n,m;
  cin>>n>>m;
  int tot=0;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    tot+=x;
  }
  if(tot>n)cout<<-1<<endl;
  else cout<< n - tot<<endl;
}

Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main
 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int T = sc.nextInt();
            int P = sc.nextInt();
            int R = sc.nextInt();
            if(T+P+R==0)break;
            int[][] pena = new int[T][P];
            int[][] score = new int[T][3];
            for (int i = 0; i < score.length; i++) {
                score[i][2]=i+1;
            }
            for (int i = 0; i < R; i++) {
                int t = sc.nextInt()-1;
                int p = sc.nextInt()-1;
                int time = sc.nextInt();
                String s = sc.next();
                if(s.charAt(0)=='C'){
                    score[t][0]++;
                    score[t][1]+= pena[t][p]*1200 + time;
                } else {
                    pena[t][p]++;
                }
            }
            Arrays.sort(score,new Comparator<int[]>(){
                @Override
                public int compare(int[] o1, int[] o2) {
                    if(o1[0]==o2[0]){
                        return o1[1]-o2[1];
                    }
                    return -(o1[0]-o2[0]);
                }
            });
            for (int i = 0; i < score.length; i++) {
                System.out.println(score[i][2]+" "+score[i][0]+" "+score[i][1]);
            }
        }
    }

}

Measured memory_bytes: 61924
// C - Guess The Number
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define NG puts("-1")

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	while(M--){
		int s,c; cin>>s>>c; s--, c+='0';
		if(T[s] !='-' && T[s] != c){ NG; return 0; }
		if(N!=1 && s==0 && c=='0'){ NG; return 0; }
		T[s] = c;
	}

	int ans = 1000;
	rep(i,1000){
		string A = to_string(i);
		if(A.size() != N) continue;
		bool ok = true;
		rep(j,N) if(T[j]!='-' && T[j]!=A[j]){ ok = false; break; }
		if(ok) ans = min(ans, i);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define MAXN 2005
#define MOD 998244353
int main()
{
          ll x;
	cin>>x;
	ll a = 100;
	ll t = 0;
	while(a<x&&t<=4000){
		a*=1.01;
		t++;
	}
	cout<<t;

}





Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;
                   
int a,b,c,d,e,f;
set<int> sa;
set<int> wa;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>a>>b>>c>>d>>e>>f;
  for(int i=0;i<=f;i+=c){
    for(int j=0;j<=f;j+=d){
      if(i+j<=f)sa.insert(i+j);
    }
  }
  for(int i=0;i*100<=f;i+=a){
    for(int j=0;j*100<=f;j+=b){
      if((i+j)*100<=f)wa.insert((i+j)*100);
    }
  }
  ll maxsatou=0;
  ll maxmizu=0;
  for(auto i=sa.begin();i!=sa.end();i++){
    for(auto j=wa.begin();j!=wa.end();j++){
      int satou=*i;
      int mizu=*j;
      if(satou+mizu>f)continue;
      if(100*satou>mizu*e)continue;
      if(satou*(maxmizu+maxsatou)>=maxsatou*(mizu+satou)){
        maxmizu=mizu;
        maxsatou=satou;
      }
    }
  }
  cout<<maxmizu+maxsatou<<" "<<maxsatou<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 384
from math import floor, ceil
a, b = map(int, input().split())
minim = ceil(max(a / 0.08, b / 0.10))
maxim = min((a + 1) / 0.08, (b + 1) / 0.10)
if minim >= maxim:
    print(-1)
else:
    print(minim)

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int left=0,right=n-1;
	int ans=0;
	while(left<right){
		if(s[left] != s[right]){
			if(s[left]!='x' && s[right]!='x'){
				cout<<-1<<endl;
				return 0;
			}
			ans++;
			if(s[left] == 'x') left++;
			else right--;
		}else{
			left++;
			right--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<cassert>
#include<climits>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 10010
 
using namespace std;
 
struct Data{
  int from,to,cost;
  Data(int from=-1,int to=-1,int cost=-1):from(from),to(to),cost(cost){}
};
 
bool cmp(const Data& p1,const Data& p2){ return p1.cost < p2.cost; }
 
int par[MAX+1];
 
void init(){ rep(i,MAX)par[i] = i; }
 
int find(int x){
  if( x == par[x] )return x;
  return par[x] = find(par[x]);
}
 
void unit(int x,int y){
  x = find(x);
  y = find(y);
  if( x != y)par[x] = y;
}
 
bool same(int x,int y){ return find(x) == find(y); }
 
int kruskal(vector<Data>& G){
  sort(G.begin(),G.end(),cmp);
  init();
  vector<int> vec;
  for(int i=0;i<G.size();i++){
    Data data = G[i];
    if(!same(data.from,data.to)){
      unit(data.from,data.to);
      vec.push_back(G[i].cost);
    }
  }
 
  sort(vec.begin(),vec.end());
  int len = vec.size();
 
  return vec[len/2];
 
}
 
 
int n,m;
 
int main(){
 
  while(cin >> n >> m,n|m){
    vector<Data> G;
    rep(i,m){
      int s,t,c;
      cin >> s >> t >> c;
      s--,t--;
      G.push_back(Data(s,t,c));
    }
    cout << kruskal(G) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b;
}

Measured memory_bytes: 256