akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    vector<int> m;
    vector<int> f;
    vector<int> r;
    int count = 0;
    int x, y, z;

    while(1)
    {
        cin >> x >> y >> z;
        if(x == -1 && y == -1 && z == -1)
            break;
        else
        {
            m.push_back(x);
            f.push_back(y);
            r.push_back(z);
            count++;
        }
    }

    for(int i = 0; i < count; i++)
    {
        int sum = m[i] + f[i];
        if(m[i] == -1 || f[i] == -1)
            cout << "F" << endl;
        else if(sum >= 80)
            cout << "A" << endl;
        else if(sum >= 65 && sum < 80)
            cout << "B" << endl;
        else if(sum >= 50 && sum < 65 || r[i] >= 50)
            cout << "C" << endl;
        else if(sum >= 30 && sum < 50)
            cout << "D" << endl;
        else if(sum < 30)
            cout << "F" << endl;
    }
} 

Measured memory_bytes: 1212
import java.util.Scanner;

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

        Long N = sc.nextLong();
        Long K = sc.nextLong();
        
        Long result1=N%K;
        Long result2=Math.abs(K-result1);

        System.out.println(Math.min(result1, result2));
    }
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
void solve(){
	int N, W;
	cin >> N >> W  ;
	vector<ll>w(N+1),v(N + 1 );
	for (int i = 0 ; i < N ; ++i )
		cin >> w[i] >> v[i] ;

	vector<ll>dp(W+1 , 0 );
		
	for(int i = 0 ; i <= N  ; ++i)
	{
		vector<ll>new_dp(W+ 1 );
		for (int j = 0; j <= W ; ++j )
		{
			if (j-w[i] >=0 )
			{
				new_dp[j] = max(dp[j], dp[j-w[i]] + 1ll*v[i]);  
				
			}
			else
				new_dp[j] = dp[j]; 
				
		}
		dp = new_dp; 
	}

	cout << dp[W], br 
	
	
}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 4844
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>

#define maxn 305
#define INF 0x3f3f3f3f

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n,m,L;
int dis[maxn][maxn];

int main()
{
	memset(dis,INF,sizeof dis);
    n=getint(),m=getint(),L=getint();
	for(int i=1;i<=m;i++)
	{
		int u=getint(),v=getint(),w=getint();
		dis[u][v]=dis[v][u]=w;
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
		if(dis[i][j]<=L)dis[i][j]=1;
		else dis[i][j]=INF;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int Q=getint();
	while(Q--)
	{
		int u=getint(),v=getint();
		if(dis[u][v]==INF)printf("-1\n");
		else printf("%d\n",dis[u][v]-1);
	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=1e5+7;
ll cnt[N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,k; cin>>n;
	vector<ll> a(n+1);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll sum=0;
	for(int i=1; i<=n; i++) {
		sum+=a[i];
	}
	ll q; cin>>q;
	while(q--) {
		ll a,b; cin>>a>>b;
		sum-=a*cnt[a];
		sum+=b*cnt[a];
		cnt[b]+=cnt[a];
		cnt[a]=0;
		cout<<sum<<endl;
	}



	return 0;
}


Measured memory_bytes: 4836
n, m = map(int, input().split())
a = list(map(int, input().split()))

def fun(n, m, a):
    total = sum(a)
    num = float(total)/(4*m)
    flag = sum([i >= num for i in a])
    return flag >= m

ans = fun(n, m, a)

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
using System;
using System.Linq;

namespace AtCoder_Beginner_Contest_168
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var d = n % 10;
            if (d == 3)
            {
                Console.WriteLine("bon");
            }
            else if (d == 0 || d == 1 || d == 6 || d == 8)
            {
                Console.WriteLine("pon");
            }
            else {
                Console.WriteLine("hon");
            }
        }
        private static int[] ReadIntArray() => ReadIntArrayFrom_StringSplit(Console.ReadLine());

        private static int[] ReadIntArray(int size) => ReadIntArrayFrom_FixedSize(Console.ReadLine(), size);

        private static int[] ReadIntArrayFrom_StringSplit(string s) =>
                s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(int.Parse)
                .ToArray();


        private static int[] ReadIntArrayFrom_FixedSize(string s, int size)
        {
            var sLen = s.Length;
            var res = new int[size];
            var resIdx = 0;
            var start = 0;
            string ss;

            for (int i = 1; i <= sLen; i++)
            {
                if ((i == sLen || s[i] == ' '))
                {
                    ss = s.Substring(start, i - start);
                    {
                        res[resIdx++] = int.Parse(ss);
                        start = i + 1;
                    }
                }
            }
            return res;
        }

        //////////////////

        private static int ReadInt(string s) => int.Parse(s);

        private static int ReadInt() => int.Parse(Console.ReadLine());

        /////////

        static int Mod(int A, int n)
        {
            var a = A / n;
            if (A < 0)
            {
                return A - a * n + n;
            }
            else
            {
                return A - a * n;
            }
        }
    }
}


Measured memory_bytes: 27552
#include<stdio.h>

long long int func(long long int a, long long int b, long long int d){
    return b/d - (a-1)/d;
}

void swap(long long int* a, long long int* b){
    long long int c=*a;
    *a=*b;
    *b=c;
}

long long int gcd(long long int a, long long int b){
    if(a<b){
        swap(&a,&b);
    }while(a%b!=0){
        long long int c=a%b;
        a=b;
        b=c;
    }
    return b;
}

int main(){
    long long int a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld", b-a+1 - func(a, b, c) - func(a, b, d) + func(a, b, c*d/gcd(c, d)));

    return 0;
}

Measured memory_bytes: 128
// C.

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n, m, ans;
	cin >> n >> m;
	LL a = min(n, m), b = max(n, m);
	if (a == 1) {
		ans = b == 1 ? 1 : b - 2;
	} else {
		ans = (a - 2) * (b - 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N; cin >> N;
	cout << N * N * N << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int f(string s, string t){
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += (s[i] != t[i]);
	}
	return ans;
}

int32_t main(){
    fast_io;
	string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = m;
    for (int i = 0; i + m - 1 < n; ++i)
    {
    	ans = min(ans, f(s.substr(i, m), t));
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	int n;
	int t;
	int *a;
	int count;

	int maxval = 0;
	int maxrev = 0;

	int i;

	scanf("%d%d",&n,&t);

	a = calloc(sizeof(int),n);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	for(i=n-1;i>=0;i--){
		if(a[i] > maxval){
			maxval = a[i];
		}else{
			if(maxval - a[i] == maxrev){
				count++;
			}else if(maxval - a[i] > maxrev){
				count = 1;
				maxrev = maxval - a[i];
			}
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 512
import heapq
n,m = map(int,input().split())#nは品物の数　mは割引券の数
a = sorted(list(map(int,input().split())),reverse = True)#値段一覧
a = list(map(lambda x: x*(-1), a))  
heapq.heapify(a)#リストを優先度付きキューへ入れる
highest = 0
ans = []
for i in range(m):
    highest = heapq.heappop(a)*(-1)#heappopでとりだし　heappop(リスト名)*(リストのインデックス)本来最小値を取り出すものである
    heapq.heappush(a,highest//2*(-1))#引数(挿入先リスト名,挿入する数値)
print(sum(a)*-1)

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = stoi(s);
    rep(i, s.length()) {
        ans += s[i] - '0';
    }
    if ( n % ans == 0 ) cout << "Yes" << endl;
    else                cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a,b;cin >> n >> a >> b;
  if(a>b) swap(a,b);
  if((b-a)%2==0){
    cout << abs(a-b)/2 << endl;
  }else{
    ll f = a -1 + (b-a+2)/2;
    ll s = n-b + (b-a+2)/2;
    cout << min(f,s)<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    vector<int> cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int n, m;
    cin >> n >> m;
    vector<int> used(m, 0);
    unordered_map<int, int> cost2val;
    for(int& val: used) {
        cin >> val;
        cost2val[cost[val]] = max(cost2val[cost[val]], val);
    }

    vector<int> dp(n+1, 0);
    vector<int> trace(n+1, -1);
    trace[0] = 0;
    vector<int> label(n+1, 0);
    int diff, digit;
    for(int i = 1; i <= n; i++) {
        for(auto& p: cost2val) {
            diff = p.first;
            digit = p.second;
            if (i - diff >= 0 && trace[i-diff] != -1) {
                if (dp[i-diff]+1 > dp[i]) {
                    dp[i] = dp[i-diff]+1;
                    trace[i] = i-diff;
                    label[i] = digit;
                }
                if (dp[i-diff]+1 == dp[i]) {
                    if (digit > label[i]) {
                        label[i] = digit;
                        trace[i] = i-diff;
                    }
                }
            }
        }
    }
    int idx = n;
    string ans;
    while (idx != 0) {
        ans += ('0' + label[idx]);
        idx = trace[idx];
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int mat(int *,int);
int main(){
  int i,n,tmp;
  int *p;
  scanf("%d",&n);
  p = malloc((n+1)*sizeof(int));
  for(i=0;i<=n;i++)
    {
      if(i==0)
	{
	  scanf("%d%d",&p[i],&p[i+1]);
	  i++;
	  continue;
	}
      scanf("%d%d",&tmp,&p[i]);
    }
  printf("%d\n",mat(p,n));
  return 0;
}
int mat(int *p,int n){
  int i,j,q,l,k;
  int m[100][100];
  for(i=1;i<=n;i++)
    {
      m[i][i]=0;
    }
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j=i+l-1;
	  m[i][j]=INT_MAX;
	  for(k=i;k<j;k++)
	    {
	      q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	      if(m[i][j]>q)
		{
		  m[i][j]=q;
		}
	    }
	}
    }
  return m[1][n];
}



Measured memory_bytes: 2056
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll w,h,x,y;

	cin >> w >> h >> x >> y;

	double ans = (double)(w*h) / 2;

	ll buf;

	if (x * 2 == w && y * 2 == h)
		buf = 1;
	else
		buf = 0;

	cout << fixed << setprecision(10) << ans << " " << buf;

}

Measured memory_bytes: 256
import java.util.Scanner;

//AtCoder Beginner Contest 128
//A	Apple Pie
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int P = sc.nextInt();
		sc.close();

		System.out.println((A * 3 + P) / 2);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
string s;
string t,a;
cin>>s>>t;
if (s.size()==t.size())a="No";
else
{
    for (int i=0;i<s.size();i++)
    {
        if (s[i]==t[i])
            a="Yes";
            else if (s[i]!=t[i])
            {
                a="No";
                break;
            }


    }
}
cout<<a;




    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3604
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

fac=fac_list(10**5+100,mod)
def C(n,r):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod

 
#main
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
if(K>=2):
    for a in range(0,N):
        ans+=C(a,K-1)*(A[a])
        ans%=mod
    for a in range(0,N):
        len=N-1-a
        ans-=C(len,K-1)*(A[a])
        ans%=mod
print(ans)



Measured memory_bytes: 22940
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a,b;
        a=sc.nextInt();
        b=sc.nextInt();
        int max,min;
        max=a;
        min=b;
        if(max<min){
            max=b;
            min=a;
        }
        int [] num1 = new int[max];
        for(int i=0;i<num1.length;i++){
            num1[i]=min;
            System.out.print(num1[i]);
        }
		

    }
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  ll M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  std::sort(A.begin(), A.end());

  std::vector<ll> cum(N + 1);;
  rep(i, N) {
    cum[i + 1] = cum[i] + A[i];
  }

  auto sub = [&](ll x) {
    ll cnt = 0;
    ll sum = 0;
    for(int i = N - 1; i >= 0; --i) {
      int ind = std::lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();

      cnt += N - ind;
      sum += (ll) (N - ind) * A[i] + cum[N] - cum[ind];
    }

    return std::make_pair(cnt, sum);
  };

  ll l = 0;
  ll r = 2 * A[N - 1] + 1;
  ll cnt = 0;
  ll ans = 0;
  while(r - l > 1) {
    ll m = (l + r) / 2;

    auto p = sub(m);
    if(p.first < M) {
      r = m;
      cnt = p.first;
      ans = p.second;
    } else {
      l = m;
    }
  }
  ans += (M - cnt) * l;

  std::cout << ans << '\n';
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans = 0;
void Main(){
    ll n, q;
    cin >> n >> q;
    ans = (n-2) * (n-2);
    map<int, int> imax, jmax;
    imax[0] = n-2;
    jmax[0] = n-2;
    For(_,0,q){
        int i, x;
        cin >> i >> x;
        x--;
        if(i == 1){
            auto itr = imax.upper_bound(x);
            itr--;
            ans -= itr->second;
            imax[x] = itr->second;
            if(jmax[0] > x-1){
                jmax[0] = x-1;
            }
        }
        else{
            auto itr = jmax.upper_bound(x);
            itr--;
            ans -= itr->second;
            jmax[x] = itr->second;
            if(imax[0] > x-1){
                imax[0] = x-1;
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 12964
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>		
using namespace std;
typedef long long ll;

int main()
{
	char a[200005], b[200005];
	scanf("%s%s", a + 1, b + 1);
	int n = strlen(a + 1);
	int c=0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != b[i])c++;
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 4144
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
surp = []
lack = 0
cnt = 0
ans = 0
if sum(a) < sum(b):
    print(-1)
    exit()
for i in range(n):
    if a[i] >= b[i]:
        surp.append(a[i] - b[i])
    else:
        lack += b[i] - a[i]
        ans += 1
surp.sort(reverse = True)
while lack > 0:
    lack -= surp[cnt]
    cnt += 1
    ans += 1
print(ans)

Measured memory_bytes: 18356
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {


	string S,T;

	cin >> S >> T;

	int ans=0;

	REP(i, S.size()) {
		if (S[i] != T[i])ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3860
#!/usr/bin/env python3
import math

a, b = map(int, input().split())
x = math.floor((a-1)/0.08)
y = math.floor((a+1)/0.08)
z = math.floor((b-1)/0.1)
w = math.floor((b+1)/0.1)

if y<z:
    print(-1)
    exit(0)

ans = []
for i in range(min(x,z), min(y,w)):
    if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 3064
N=int(input())
data=[]
for i in range(N):
  B,C=input().split()
  B=str(B)
  C=int(C)
  data.append([i+1,B,C])
  

data.sort(key=lambda x:x[2], reverse=True)
data.sort(key=lambda x:x[1])

for i in range(0,N):
  A=data[i]
  print(A[0])

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

using namespace std;

int n;
int a[200001];
int ans = 0;
int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i ++) {
		if (a[i] != i) continue;
		int tmp = i;
		while (tmp <= n && a[tmp] == tmp) ++ tmp;
		-- tmp;
		int sz = tmp - i + 1;
		ans += (sz + 1) / 2;
		i = tmp;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int MAXN = 100010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, a[MAXN];

int main() {

	int i;
	n = read();
	for(i = 1; i <= n; i++) a[i] = read();
	bool flag = true;
	while(true) {
		int c = 0;
		for(i = 1; i <= n; i++) if(~a[i]&1) c++;
		if(c & 1) {
			printf("%s\n", flag ? "First" : "Second");
			return 0;
		}
		else if(c < n-1) {
			printf("%s\n", flag ? "Second" : "First");
			return 0;
		}
		else {
			for(i = 1; i <= n; i++) 
				if(a[i] & 1) a[i]--;
			for(i = 1; i <= n; i++) if(a[i] == 0) break;
			if(i <= n) {
				printf("%s\n", flag ? "Second" : "First");
				return 0;
			}
			int g = a[1];
			for(i = 2; i <= n; i++)
				g = __gcd(g, a[i]);
			for(i = 1; i <= n; i++) a[i] /= g;
		}
		flag ^= 1;
		//printf("!\n");
	}
	return 0;
}


Measured memory_bytes: 640
n,a,b=map(int,input().split())
mod=10**9+7
sum=(pow(2,n,mod)-1)%mod
nume_a=1
deno_a=1
for i in range(n-a+1,n+1):
    nume_a=(nume_a*(i%mod))%mod
    deno_a=(deno_a*(i-(n-a+1)+1)%mod)%mod
ans_a=(nume_a*(pow(deno_a,mod-2,mod)))%mod
nume_b=1
deno_b=1
for i in range(n-b+1,n+1):
    nume_b=(nume_b*(i%mod))%mod
    deno_b=(deno_b*(i-(n-b+1)+1)%mod)%mod
ans_b=(nume_b*(pow(deno_b,mod-2,mod)))%mod
print((sum-ans_a-ans_b)%mod)


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


int main() {
  int n; cin >> n;
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 1; i < n; i++){
    int cnt = 0;
    
    for(char c = 'a'; c <= 'z'; c++){
      bool left = false, right = false;
      for(int j = 0; j < i; j++)
        if(s[j] == c) left = true;
      for(int j = i; j < n; j++)
        if(s[j] == c) right = true;
      if(left && right) cnt++;
    }
    if(ans < cnt) ans = cnt;
    }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string S;
	cin >> S;
	if ((S[0] == S[1] && S[1] == S[2]) || S[1] == S[2] && S[2] == S[3])cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int man,day,amari;
    int choco = 0;
    scanf("%d",&man);
    scanf("%d",&day);
    scanf("%d",&amari);
    int temp = 0;
    for(int i = 0;i < man;i++){
        scanf("%d",&temp);
        if(temp > day){
            choco += 1;
        }
        else if(day % temp == 0){
            choco += (day / temp);
        }
        else{
            choco += (day / temp + 1);
        }
    }
    choco += amari;   
    printf("%d\n",choco);
    return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    S = input_raw[0]
    count_list = []
    s_list = []
    j = 0
    count = 1
    for i in range(1, N):
        if S[i] == S[i - 1]:
            count += 1
        else:
            count_list.append(count)
            s_list.append(S[i - 1])
            count = 1
    count_list.append(count)
    s_list.append(S[N - 1])
    n = len(count_list)
    count = 1
    sum_list = [0 for i in range(n + 1)]
    for i in range(1, n + 1):
        sum_list[i] = sum_list[i - 1] + count_list[i - 1]

    max_s = 0
    for i in range(1, n + 1):
        if s_list[i - 1] == "0":
            k = 2 * K
        else:
            k = 2 * K + 1
        max_s = max(sum_list[i] - sum_list[max(i - k , 0)], max_s)
    print max_s








if __name__ == '__main__':
    main()


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

using namespace std;

int gcd(int a, int b) {
    if (b == 0) return a;
    int r = a % b;
    return gcd(b, r);
}
int main() {
    int A,B,K;
    cin >> A >> B >> K;
    for (int i = gcd(A,B); i>=1; i--) {
        if (A % i == 0 && B % i == 0) {
            K--;
            if (K == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
 
int main()
{
	string str;
	cin >> str;
 
	int mod = 1000000007;
	
	long long currPow = 1;
	vector <long long> A(str.length() + 1, 0), AB(str.length() + 1, 0), ABC(str.length() + 1, 0);
 
	//A[0] = 1;
 
	for (int i = 0; i < str.length(); i++)
	{
		A[i + 1] = A[i];
		AB[i + 1] = AB[i];
		ABC[i + 1] = ABC[i];
 
		if (str[i] == 'A')
			A[i + 1] = (A[i] + currPow) % mod;
 
		else if (str[i] == 'B')
			AB[i + 1] = (A[i] + AB[i]) % mod;
 
		else if (str[i] == 'C')
			ABC[i + 1] = (AB[i] + ABC[i]) % mod;
 
		else
		{
			A[i + 1] = (3 * A[i]) % mod + currPow % mod;
			AB[i + 1] = (3 * AB[i]) % mod + A[i] % mod;
			ABC[i + 1] = (3 * ABC[i]) % mod + AB[i] % mod;
 
			currPow = (3 * currPow) % mod;
		}
	}
 
	cout << ABC[str.length()] << endl;
	return 0;
}

Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;


int K;
int ans[100] = {};
int keta = 1;

void write()
{
	for (int i = keta - 1; i >= 0; i--)
	{
		cout << ans[i];
	}
	cout << endl;
}

void up(int k)
{
	ans[k]++;
	if (k == keta - 1 && ans[k] >= 10)
	{
		memset(ans, 0, sizeof(ans));
		ans[k + 1] = 1;
		keta++;
	}
	if (k == keta - 1)
	{
		return;
	}

	if (ans[k] >= 10)
	{
		up(k + 1);
		ans[k] = max(0LL, ans[k + 1] - 1);
	}
	else
	{
		if (abs(ans[k + 1] - ans[k]) > 1)
		{
			up(k + 1);
			ans[k] = max(0LL, ans[k + 1] - 1);
		}
	}
}

signed main()
{
	cin >> K;

	ans[0] = 1;
	
	for (int i = 0; i < K - 1; i++)
	{
		up(0);
	}

	write();
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	s64 X;
	u64 K, D;
	cin >> X >> K >> D;

	X = abs(X);

	if(X / D > K) {
		X = X - D * K;
	} else {
		u64 XpD = X / D;
		X = X - D * XpD;
		K = K - XpD;
		X = X - (K % 2) * D;
	}
	
	cout << abs(X) << endl;
	return 0;
	
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))

delisious = 0

for i in range(N):
    delisious += B[i]
    
for j in range(N-1):
    if A[j] + 1 == A[j+1]:
        delisious += C[A[j]-1]

print(delisious)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int x=sc.nextInt();
            int sum=0;
            if(n==0 && x==0)break;
            for(int i=1;i<=(n-2);i++){
                for(int j=i+1;j<=(n-1);j++){
                    for(int k=j+1;k<=n;k++){
                        if((i+j+k)==x)sum++;
                    }
                }
            }
            System.out.println(sum);
        }
    } 
}


Measured memory_bytes: 26312
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from heapq import heapify, heappush, heappop
    h1 = A[:N]
    h2 = [-a for a in A[2*N:]]
    heapify(h1)
    heapify(h2)

    s = sum(A[:N])
    ans = s
    S1 = [s]*(N+1)
    for i in range(N):
        c = A[N+i]
        if h1[0] < c:
            S1[i+1] = S1[i] - heappop(h1) + c
            heappush(h1, c)
        else:
            S1[i+1] = S1[i]
    s = sum(A[2*N:])
    ans -= s
    S2 = [s]*(N+1)
    for i in range(N):
        c = A[2*N-i-1]
        if -h2[0] > c:
            S2[N-i-1] = S2[N-i] + heappop(h2) + c
            heappush(h2, -c)
        else:
            S2[N-i-1] = S2[N-i]

    # print(S1, S2)
    for s1, s2 in zip(S1, S2):
        ans = max(ans, s1-s2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 121360
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <long long> A(N);
    vector <long long> ans(N);

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

    for (int b = 31; b >= 0; --b) {
        long long v = 1LL << b;

        vector <int> cnt(2);
        for (int i = 0; i < N; ++i) {
            if (A[i] & v) {
                ++cnt[1];
            } else {
                ++cnt[0];
            }
        }

        vector <int> cho(2, -1);
        vector <int> flag(2);
        for (int i = 0; i < 2; ++i) {
            flag[i] = cnt[i]%2;
        }

        // cout << "CNT " << cnt[0] << " " << cnt[1] << endl;

        for (int o = 0; o < 2 && cho[1] < 0; ++o) {
            for (int e = 0; e < 2; ++e) {
                int ores = ((flag[1]^1) * o) ^ (flag[0] * e);
                int eres = ((flag[0]^1) * e) ^ (flag[1] * o);

                if (ores == 1 && eres == 0) {
                    cho[0] = e;
                    cho[1] = o;
                    // cout << "GET IT " << b << " " << e << " " << o << endl;
                    break;
                }
            }
        }

        for (int i = 0; i < N; ++i) {
            if (A[i] & v) {
                ans[i] |= v * cho[1];
            } else {
                ans[i] |= v * cho[0];
            }
        }
    }


    string delimit;
    for (int i = 0; i < N; ++i) {
        cout << delimit << ans[i];
        delimit = " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6416
<?php

$page = array();
while($line = fgets(STDIN)){
	list($a, $b) = explode(" ", trim($line));
	/*if($page[$a] == ""){
		$page[$a] = array();
	}*/
	$page[$a][] = $b;
}

$word = array_keys($page);
sort($word);

foreach($word as $row){
	$arr = $page[$row];
	sort($arr, SORT_NUMERIC);
	echo $row."\n";
	echo implode($arr, " ")."\n";
}

Measured memory_bytes: 15252
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
typedef long long ll;
int n,mes[100110];
ll cost;
int main()
{
    scanf("%d",&n);
    ff(i,1,n) scanf("%d",&mes[i]);
    ff(i,1,n+1)
        cost+=abs(mes[i]-mes[i-1]);
    ff(i,1,n)
    {
        int val;
        if(mes[i-1]<=mes[i]&&mes[i]<=mes[i+1])val=0;
        else
        val=abs(mes[i]-mes[i-1])+abs(mes[i+1]-mes[i])-abs(mes[i-1]-mes[i+1]);
        printf("%lld\n",cost-val);
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <bitset>
using namespace std;

class UnionFindTree{
	typedef struct {
		int parent;
		int rank;
	}base_node;
	
	vector<base_node> node;
public:
	UnionFindTree(int n){
		node.resize(n);
		for(int i=0; i<n; i++){
			node[i].parent=i;
			node[i].rank=0;
		}
	}

	int find(int x){
		if(node[x].parent == x) return x;
		else{
			return node[x].parent = find(node[x].parent);
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}

	void unite(int x, int y){
		x = find(node[x].parent);
		y = find(node[y].parent);
		if(x==y) return;
		if(node[x].rank < node[y].rank){
			node[x].parent = y;
		}else if(node[x].rank > node[y].rank){
			node[y].parent = x;
		}else{
			node[x].rank++;
			unite(x,y);
		}
	}
};

int main_(){
	int n,m,p;
	cin >> n >> m >> p;

	UnionFindTree uft(n);

	vector<int> u(m),v(m);
	vector<int> e(m);
	vector<vector<int>> g(n);
	//vector<int> g(n);
	for(int i=0; i<m; i++){
		cin >> u[i] >> v[i];
		u[i]--; v[i]--;
		//g[u[i]] |= 1<<v[i];
		//g[v[i]] |= 1<<u[i];
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
		//e[i] = (1<<u[i]) | (1<<v[i]);
		uft.unite(u[i], v[i]);
	}
	bool connected = true;
	for(int i=1; i<n; i++){
		connected = connected && uft.same(0,i);
	}
	if(connected == false){
		printf("0.000000000000000000\n");
		return 0;
	}

	vector<int> edge_cnt(1<<n, 0);
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<m; j++){
			if((i>>u[j])&(i>>v[j])&1){
				edge_cnt[i]++;
			}
		}
	}

	vector<double> prob(1<<n, -1);
	prob[1] = 1;

	function<double(int)> dfs = [&](int s){
		if(prob[s] != -1) return prob[s];
		double res = 1.0;
		int s_ = s-1;
		for(int x=s_; x>=0; x=(x-1)&s_){
			int y = x|1;
			if(y==s) continue;
			double q = dfs(y);
			if(q<1e-13) continue;
			double tmp = 1.0;
			/*
			for(int i=0; i<m; i++){
				if( (((1<<u[i])&y) && ((1<<v[i])&(s^y))) or (((1<<v[i])&y) and ((1<<u[i])&(s^y))) ){
					tmp *= 0.01 * p;
				}
			}
			*/
			
			tmp = pow(0.01*p, edge_cnt[s] - edge_cnt[y] - edge_cnt[s^y]);

			res -= q * tmp;

			if(x==0) break;
		}
		return prob[s] = res;
	};

	double ans = dfs((1<<n)-1);
	printf("%.18f\n", ans);
	return 0;
}


int main(){
	auto start = clock();
	main_();
	//cerr << clock()-start << endl;
	return 0;
}

Measured memory_bytes: 3476
n,k = map(int,input().split())
s = input()
komoji = str.lower(s[k-1])
if k-1 != 0 and k-1 != n-1:
    sum = s[0:k-1] +komoji+s[k:]
elif k-1 == 0:
    sum = komoji + s[k:]
else:
    sum = s[0:k-1] + komoji
print(sum)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define D7K_ICPC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
ll n,x,z,a,k,b,c,d,m,y,t;
int main() {
    D7K_ICPC
    cin>>a;
    for(int i=1 ; i<=a; i++){
        cin>>c;
        if(i%2==1 && c%2==1)x++;
    }
    cout<<x;

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char[] S = scan.next().toCharArray();
		char[] T = scan.next().toCharArray();
		int count = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] != T[i]) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 32840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 準備
            List<string> lstT = new List<string>() { "eraser", "erase", "dreamer", "dream",    };

            // 解析
            string sR = "";
            sR = sS.Replace(lstT[0], "").Replace(lstT[1], "").Replace(lstT[2], "").Replace(lstT[3], "");
            string sOut = "NO";
            if (sR == "") { sOut = "YES"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    ll sum=0;
    for (auto c: s) sum+=(c-'0');
    if (sum%9) cout << "No\n";
    else cout << "Yes\n"; 
    return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int R,G;
    cin >> R;
    cin >> G;
    cout << G*2 - R;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int r; cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
#define endl "\n"

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> c(N);
    vector<vector<int>> a(N, vector<int>(M));
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
        for (int j = 0; j < M; ++j) {
            cin >> a[i][j];
        }
    }

    ll ans = INF;
    for (int i = 0; i < (1 << N); ++i) {
        vector<ll> skill(M, 0);
        ll sum = 0;
        for (int j = 0; j < N; ++j) {
            if (i & (1 << j)) {
                for (int k = 0; k < M; ++k) {
                    skill[k] += a[j][k];
                }
                sum += c[j];
            }
        }
        bool flag = true;
        for (int l = 0; l < M; ++l) {
            if (skill[l] < X) flag = false;
        }
        if (flag) ans = min(ans, sum);
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if((i<b)^(j<a))
				cout<<1;
			else
				cout<<0;
		}
		cout<<"\n";
	}
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dfs(const Graph& g, int from , int now, int K) {
    int mul = 0;
    ll ans = 1;
    if (from == -1) {
        mul = K -1;
    }else{
        mul = K -2;
    }
    if (K < g[now].size()) {
        return 0;
    }else{
        for (auto v : g[now]) {
            if (v == from) {
                continue;
            }
            ans *= mul;
            ans %= MOD;
            mul -= 1;
            ans *= dfs(g, now, v, K);
            ans %= MOD;
        }
    }
    return ans;
}

void Main() {
    int N, K;
    cin >> N >> K;
    Graph graph;
    graph.assign(N, vector<int>());
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    ll ans = dfs(graph,-1, 0, K);
    cout << ans * K % MOD << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 11648
#include <iostream>
#include <string>
using namespace std;
int main(){
int n,t[100],m,p[100000];
long long int x[100000];
int da,u=0,sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>t[i];
u=u+t[i];
}
cin>>m;
for(int i=0;i<m;i++){
cin>>p[i];
cin>>x[i];
}
for(int i=0;i<m;i++){
	sum=u-t[p[i]-1];
	sum=sum+x[i];
	cout<<sum<<endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int count =0;
  int b=1;
  for (int i=0;i<n;i++){
    count++;
    b=a[b-1];
    if(b==2){
      cout << count << endl;
      break;
    }
    if(i==n-1){
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cout << v << " ";  \
  }                    \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B >= C) {
    print("Yes");
  } else {
    print("No");
  }
}

Measured memory_bytes: 256
N = int(input())
H = list(map(lambda x: -int(x), input().split())) + [0]
cnt = 0

for i in range(N):
  while H[i] < 0:
    H[i] += 1
    j = i+1
    while H[j] < 0:
      H[j] += 1
      j += 1
    cnt += 1

print(cnt)

Measured memory_bytes: 9048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


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

  int d[200100];
  d[0] = 0;
  int cnt = 0;
  for(int i = 1; i < s.size(); i++) {
    if(s[i] != s[i-1]) {
      cnt++;
      d[cnt] = i;
    }
  }

  if (cnt == 0) {
    cout << s.size() << endl;
    return 0;
  }

  cnt++;
  d[cnt] = s.size();
  for (int i = cnt+1; i < n; i++) {
    d[i] = s.size();
  }

  int ans[100100];
  int fans = 0;
  if(s[0] == '0') {
    ans[0] = d[2*k];
    fans = ans[0];
  }
  for (int i = 0; i <= cnt; i++) {
    if (s[d[i]] == '1') {
    ans[i] = d[i+2*k+1] - d[i];
    }
    fans = max(fans, ans[i]);
  }

  cout << fans << endl;
}


Measured memory_bytes: 1280
import java.util.*;
// warm-up
// Definitely dont care about "Harshad" number. Nor Erdos nor bacon
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int s = 0;
		String tok = sc.next();
		for (char ch : tok.toCharArray()) s+=Character.getNumericValue(ch);
		System.out.println(Integer.parseInt(tok)%s==0 ? "Yes" : "No");
		sc.close();		
	}

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

}

Measured memory_bytes: 35500
#include<iostream>
using namespace std;
int main()
{
	int x, y;
	while (1){
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		else
			if (x < y)
				cout << x << ' ' << y << endl;
			else
				cout << y << ' ' << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if ((n | k) == 0) return;
			boolean[] bucket = new boolean[n + 1];
			for (int i = 0; i < k; i++) bucket[sc.nextInt()] = true;
			int max = 0;
			int p1 = 0;
			int p2 = 0;
			for (int i = 1; i <= n; i++) {
				if (bucket[i]) {
					p1++;
					p2++;
				} else if (bucket[0]) {
					int tmp = p1;
					p1 = 0;
					p2 = tmp + 1;
				} else {
					p1 = 0;
					p2 = 0;
				}
				max = Math.max(max, Math.max(p1, p2));
			}
			System.out.println(max);
		}
	}

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

Measured memory_bytes: 62100
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int h[n];
  for(int i=0;i<n;i++)cin>>h[i];
  int ng=0,ok=1e9,mid;
  while(abs(ok-ng)>1){
    mid=(ok+ng)/2;
    int c=0;
    for(int i=0;i<n;i++){
      if(h[i]>b*mid)c+=(h[i]-b*mid-1)/(a-b)+1;
    }
    if(c<=mid)ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 4420