akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
//i ll be the king
ll fact[4005],invf[4005];
ll modexp(ll a,ll b)
{
	a%=mod;
	if(a==0||a==1)
	return a;
	if(b==0)
	return 1;
	if(b%2==0)
	{
		ll res=modexp(a,b/2);
		return (res*res)%mod;
	}
	return (a*modexp(a,b-1))%mod;
}
ll ncr(ll n, ll r)
{
	if(n<r||n<0||r<0)return 0;
	ll ans=(fact[n]*invf[r])%mod;
	ans=(ans*invf[n-r])%mod;
	return ans;
}
int main()
{
	sync;
	fact[0]=invf[0]=1;
	for(ll i=1;i<4005;i++)
	fact[i]=(fact[i-1]*i)%mod,
	invf[i]=(invf[i-1]*modexp(i,mod-2))%mod;
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=k;i++)
	{
		ll ans=ncr(k-1,i-1)*ncr(n-k-1,i-1);
		ans%=mod;
		ans*=(ll)2;
		ans%=mod;
		ans+=(ncr(k-1,i-1)*ncr(n-k-1,i-2))%mod;
		ans%=mod;
		ans+=(ncr(k-1,i-1)*ncr(n-k-1,i))%mod;
		ans%=mod;
		if(n==k&&i==1)ans=1;	
		cout<<ans<<"\n";
	}
}

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

#define MOD (int)(1e9+7)

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

	long long ans = 1;
	if (N > M + 1 || M > N + 1) {
		ans *= 0;
	}
	else if(N==M){
		for (int i = 1; i <= N; i++)ans = ans*i%MOD;
		for (int i = 1; i <= M; i++)ans = ans*i%MOD;
		ans = ans*2%MOD;
	}
	else {
		for (int i = 1; i <= N; i++)ans = ans*i%MOD;
		for (int i = 1; i <= M; i++)ans = ans*i%MOD;
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

void PrintDivision(int numerator, int denominator){
    int d, r;
    double f;
    d = numerator / denominator;
    r = numerator % denominator;
    f = (double)numerator / (double)denominator;
    cout << d << " " << r << " " << fixed << setprecision(8) << f << endl;
}

int main(){
    // ---------------------------
    // ITP_1_4_A: A/B Problem
    int a, b;
    std::cin >> a >> b;
    PrintDivision(a,b);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_B:
    // ---------------------------

    // ---------------------------
    // ITP_1_4_C:
    // ---------------------------

    // ---------------------------
    // ITP_1_4_D:
    // ---------------------------

    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll N, Y;
    cin >> N >> Y;

    rep(i, N + 1) {
        if (10000 * i > Y) break;
        rep(j, N + 1) {
            if (i + j > N) continue;
            if (10000 * i + 5000 * j > Y) continue;
            int k = N - (i + j);
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h1,h2, m1,m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int mk, hk;
    mk = k%60;
    hk = k/60;
    if(mk > m2) {
        hk++;
        m2 += 60;
    }
    cout << (h2 - hk - h1)*60 + (m2 - mk - m1) << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<algorithm>

#define MAX 101

using namespace std;

int main(){
	int n,m;
	int targ[MAX];
	int score[MAX]={0};
	int x,tmp=0;
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&targ[i]);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&x);
			if(targ[i]==x) score[j]++;
			else tmp++;
		}
		score[targ[i]]+=tmp;
		tmp=0;
	}
	for(int i=1;i<=n;i++) printf("%d\n",score[i]);
}

Measured memory_bytes: 3204
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, H;
    cin >> N >> H;

    vector<ll> A(N);
    vector<ll> B(N);
    FOR(i, 0, N){
        cin >> A.at(i);
        cin >> B.at(i);
    }

    sort(ALL(A), greater<ll>());
    sort(ALL(B), greater<ll>());
    
    int index_a = 0;
    int index_b = 0;

    int attack_num = 0;
    while(H > 0){
        // 投げつける
        if(index_b < N && A[index_a] < B[index_b]){
            H -= B[index_b];
            index_b++;
            attack_num++;
        }
        // あとは切るだけ
        else{
            ll damage = A[index_a];
            if(H % damage == 0){
                attack_num += H / damage;
            }else{
                attack_num += H / damage + 1;
            }
            H = 0;
        }
    }

    p(attack_num);

    return 0;
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if( A < B):
  if(C < D):
    print(A + C)
    
  else:
    print(A + D)
    
else:
  if(C < D):
    print(B + C)
  
  else:
    print(B + D)


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

using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a,ll b)
{
    return a / gcd(a, b) * b;
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    ll pow = 0;
    cin >> v[0];
    ll a = v[0];
    while (a%2==0)
    {
        a >>= 1;
        pow++;
    }
    v[0] /= 2;
    ll l = 1;
    l = lcm(l, v[0]);
    for (ll i = 1; i < n; i++)
    {
        cin >> v[i];
         a = v[i];
        ll pow2 = 0;
        while (a % 2 == 0)
        {
            a /= 2;
            pow2++;
        }
        if(pow != -1 && pow != pow2)
        {
            cout << "0" << endl;
            return 0;
        }
        else
        {
            pow = pow2;
        }
        v[i] /= 2;
        l = lcm(l, v[i]);
    }
    m /= l;
    int ans = (m + 1) / 2;
    cout << ans << endl;
    return 0;
}

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

long long memo[101][100001];

long long knapsack(int N, int W, vector<long long>& weight, vector<long long>& value){
	if(N == 0 || W == 0){
		return 0;
	}
	if(memo[N][W] != -1) return memo[N][W];
	if(weight[N-1] > W){
		return memo[N][W] =  knapsack(N-1,W,weight,value);
	}
	else {
		return memo[N][W] = max(
			value[N-1] + knapsack(N-1, W - weight[N-1],weight,value),
			knapsack(N-1,W,weight,value)
		);
	}
}

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

	vector<long long>weight;
	vector<long long>value;

	memset(memo,-1,sizeof(memo));

	for(int i = 0; i < N; ++i){
		int w;
		int v;
		cin>>w>>v;
		weight.push_back(w);
		value.push_back(v);
	}
	// cout<<knapsack(N,W,weight,value);
	long long res = knapsack(N,W,weight,value);
	cout<<res<<endl;
}

Measured memory_bytes: 82516
#include <iostream>

using namespace std;

int main(){
    int n,ans = 0;

    cin >> n;

    for(int i = 1;i <= n;i++){
        int count = 0;
        if(i%2 == 0)continue;
        else{
            for(int j = 1;j <= i;j++){
                if(i%j == 0)count++;
            }
            if(count == 8)ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

int chmin(int &a, int b) {
	return a = min(a, b);
}

int main() {
	int H, W; cin >> H >> W;
	vector<string> s(H + 1);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
		s[i] += '@';
	}
	s[H] = string(W + 1, '@');
	vector<vector<int>> dp(H + 1, vector<int>(W + 1, 1e9));
	s[H - 1][W] = s[H][W - 1] = '.';
	dp[H - 1][W] = dp[H][W - 1] = 0;
	for (int i = H - 1; i >= 0; i--) {
		for (int j = W - 1; j >= 0; j--) {
			chmin(dp[i][j], dp[i + 1][j] + (s[i][j] == '#' && s[i][j] != s[i + 1][j]));
			chmin(dp[i][j], dp[i][j + 1] + (s[i][j] == '#' && s[i][j] != s[i][j + 1]));
		}
	}
	int ans = dp[0][0];

	for (int i = 0; i <= H; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = 1e9;
		}
	}
	dp[H - 1][W] = dp[H][W - 1] = 0;
	s[H - 1][W] = s[H][W - 1] = '#';
	for (int i = H - 1; i >= 0; i--) {
		for (int j = W - 1; j >= 0; j--) {
			chmin(dp[i][j], dp[i + 1][j] + (s[i][j] == '.' && s[i][j] != s[i + 1][j]));
			chmin(dp[i][j], dp[i][j + 1] + (s[i][j] == '.' && s[i][j] != s[i][j + 1]));
		}
	}
	chmin(ans, dp[0][0] + 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define lop(a,b,c) for(a=c;a<b;a++)
#define srt(v) v.begin(),v.end()
using namespace std;
int main()
{
    ll i,j,k,l,m,n,a;
    cin>>n;
    j=sqrt(n);
    k=n+10;
    lop(i,j+1,1)
    {
        if(n%i==0)
        {
            m=i+n/i-2;
            k=min(k,m);
        }
    }
    cout<<k;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {
    int S, W;
    cin >> S >> W;

    if (S <= W)cout << "unsafe" << endl;
    else cout << "safe" << endl;

}

Measured memory_bytes: 3636
def binarySerch(A, key):
    left = 0
    right = n
    while left <= right:
        mid = (left + right) // 2
        if int(A[mid]) == int(key):
            return True
        elif int(A[mid]) < int(key):
            left = mid+1
        else :
            right = mid-1
    return False

n = int(input())
S = input().split()
q = int(input())
T = input().split()

count = 0
for i in T:
    if (binarySerch(S, i)) == True:
        count += 1

print(count)
    


Measured memory_bytes: 15732
n,m=map(int,input().split())
d=[[10**18]*n for i in range(n)]
e=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
    e.append([a-1,b-1,c])
for i in range(n):
    d[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
print(sum(c>d[a][b]for a,b,c in e))

Measured memory_bytes: 42220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (a == 0) {
		cout << b / x - a / x + 1 << endl;
	} else {
		cout << b / x - (a - 1) / x << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3584
S = input()
T = input()
from collections import defaultdict
ds = defaultdict(int)
dt = defaultdict(int)
for i in range(len(S)):
    ds[S[i]] += 1
    dt[T[i]] += 1
ds = list(ds.values())
dt = list(dt.values())
ds.sort()
dt.sort()
for e1,e2 in zip(ds,dt):
    if e1 != e2:
        print('No')
        exit()
print('Yes')



Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VS = vector<string>;
#define rep(start, end) for(int loop_var = start; loop_var <= end; ++loop_var)
#define repconref(container) for(auto& container_element: container)
#define all(container) begin(container), end(container)
#define ftl ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    ftl;
    int n, l;
    cin >> n >> l;
    VS v(n);
    repconref(v) cin >> container_element;
    sort(all(v), [] (const string& a, const string& b) {
        return a + b < b + a;
    });
    repconref(v) cout << container_element;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();
		int rest = N % 10;
		if(rest == 3) {
			System.out.println("bon");
			return;
		}else if(rest == 0 | rest == 1 | rest == 6 | rest == 8) {
			System.out.println("pon");
			return;
		}else {
			System.out.println("hon");
			return;
		}
	}

}

Measured memory_bytes: 35672
N,M=map(int,input().split())
A=list(map(int,input().split()))

while M>0:
    A.sort(reverse=True)
    if A[0]==0:
        break
    judge=A[0]//2
    for i in range(len(A)):
        if A[i]>judge and M>0:
            A[i]=A[i]//2
            M-=1
        else:
            break
print(sum(A))


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

int main() {
    long long n;
    std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    std::vector<long long> sm, bg;
    for (int i = 0; i < (a.size() + 1) / 2; i++) {
        sm.push_back(a[i]);
    }
    for (int i = (a.size() + 1) / 2; i < n; i++) {
        bg.push_back(a[i]);
    }

    if (n == 2) {
        std::cout << a[1] - a[0] << std::endl;
        return 0;
    }
    if (n == 3) {
        std::cout << std::max(a[1] + a[2] - 2 * a[0], 2 * a[2] - a[1] - a[0]) << std::endl;
        return 0;
    }

    auto ret = 0ll;
    auto ret2 = 0ll;
    if (n % 2) {
        for (int i = 0; i < bg.size(); i++) ret += 2 * bg[i];
        for (int i = 0; i < sm.size(); i++) ret -= 2 * sm[i];
        ret += sm[sm.size() - 1] + sm[sm.size() - 2];
        for (int i = 0; i < bg.size(); i++) ret2 += 2 * bg[i];
        for (int i = 0; i < sm.size() - 1; i++) ret2 -= 2 * sm[i];
        ret2 += sm[sm.size() - 1];
        ret2 -= bg.front();
    } else {
        for (int i = 0; i < bg.size(); i++) ret += 2 * bg[i];
        for (int i = 0; i < sm.size(); i++) ret -= 2 * sm[i];
        ret -= bg.front();
        ret += sm.back();
    }

    std::cout << std::max(ret2, ret) << std::endl;

    return 0;
}

Measured memory_bytes: 2296
#include<iostream>

using namespace std;


int main() {
	int H, W;
	string s[105];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	for (int i = 0; i <= W + 1; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		cout <<'#'<< s[i]<<'#'<<endl;
	}
	for (int i = 0; i <= W + 1; i++) {
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 256
S = input()
r = False
L = []
R = []
for _ in range(int(input())):
    q = input().split()
    if q[0] == "1":
        r = not r
    else:
        if q[1] == "1":
            if r:
                R.append(q[2])
            else:
                L.append(q[2])
        else:
            if r:
                L.append(q[2])
            else:
                R.append(q[2])


if r:
    R.reverse()
    print("".join(R + list(S[::-1]) + L))
else:
    L.reverse()
    print("".join(L + [S] + R))

Measured memory_bytes: 8340
import sys

n,k = map(int, input().split( ))
a = list(map(int, input().split( )))
tmp = max(a)
tmp2 = max(tmp,n,k)+1
chk = [0]*(tmp2)

for i in range(n):
    chk[a[i]] += 1

if 0 in chk[1:k+1]:
    print(0)
    sys.exit()

right = n-1
left = 0
L = []

while right < n:
    while chk[a[right]] > 1 or a[right] > k:
        chk[a[right]] -= 1
        right -= 1
        
    ln = right - left + 1
    L.append(ln)
    
    while chk[a[left]] > 1 or a[left] > k:
        chk[a[left]] -= 1
        left += 1
    ln = right - left + 1
    L.append(ln)
    chk[a[left]] -= 1
    left += 1
    while chk[a[left-1]] == 0:
        right += 1
        if right >= n:
            break
        chk[a[right]] += 1
    ln = right -left +1
    L.append(ln)
print(min(L))    
    

    


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

def wa(n):
    w = 0
    while n != 0:
        w += n % 10
        n = int(n / 10)
    return w

ans = 0
for i in range(1, N+1):
    w = wa(i)
    if A <= w and w <= B:
        # print(i, w)
        ans += i

print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	if(m % n == 0){
		cout << m/n << endl;
		return 0;
	}
	int c = m/n;
	int ans = 1;
	for(int i = 2; i < c; i++){
		//cout << m-i*n << endl;
		if((m-i*n) % i == 0){
			//cout << "move" << endl;
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 


int main(){

    int a[3];
    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;

    return 0;
}

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

int main() {
  int n, i, ans = 0, l[1005], r[1005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  for (i = 0; i < n; i++) {
    ans += r[i] - l[i] + 1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N,K;
  cin >> N >> K;
  long quo = N / K;
  if (K % 2 == 1) {
    cout << quo * quo * quo << endl;
  } else {
    if (N - K * quo >= K / 2)cout << quo * quo * quo + (quo + 1)*(quo + 1)*(quo + 1) << endl;
    else cout << 2 * quo * quo * quo << endl;
  }
  return 0;
}


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

int main(){
  ll N; cin>>N;
  ll A,B; cin>>A>>B;
  ll C,D; cin>>C>>D;
  set<ll> high;
  bool j=false;
  if(A+D*(N-1)>=B){
    for(int i=0;i<N;i++){
      high.insert(A+D*(N-1)-i*(C+D));
    }
    auto x=high.lower_bound(B);
    if(*x-B<=(D-C)*(N-1)) j=true;
  }
  if(j)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 23680
r, c = map(int, input().split())

matrix = [[0] * (c + 1) for _ in range(r + 1)]

for i in range(r):
    row = [int(c) for c in input().split()]
    for j in range(c):
        matrix[i][j] = row[j]
    matrix[i][-1] = sum(row)

for j in range(c + 1):
    s = 0
    for i in range(r):
        s += matrix[i][j]
    matrix[-1][j] = s

for row in matrix:
    print(' '.join([str(i) for i in row]))



Measured memory_bytes: 5696
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	switch (n) {
		case 25: cout << "Christmas" << endl; break;
		case 24: cout << "Christmas Eve" << endl; break;
		case 23: cout << "Christmas Eve Eve" << endl; break;
		case 22: cout << "Christmas Eve Eve Eve" << endl; break;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i < 10)cnt++;
		else if (100 <= i && i < 1000)cnt++;
		else if (10000 <= i && i < 100000)cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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

int main() {
  int N, ans=0;
  cin >> N;
  vector<int> value(N);
  vector<int> cost(N);

  for (int i = 0; i < N; i++) cin >> value.at(i);
  for (int j = 0; j < N; j++) cin >> cost.at(j);
  
  for (int k = 0; k < N; k++) if (cost.at(k) < value.at(k)) ans += value.at(k) - cost.at(k);

  cout << ans << endl;
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
P, S = [], []
AC = [0 for n in range(N)]
WA = [0 for n in range(N)]
for m in range(M):
    p, s = input().split()
    p = int(p) - 1
    if AC[p] == 0 and s == 'WA':
        WA[p] += 1
    if s == 'AC':
        AC[p] = 1
AC_count = sum(AC)
WA_count = 0
for n in range(N):
    if AC[n] == 1:
        WA_count += WA[n]
print(AC_count, WA_count)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> A(n);

	for (int i = 0; i < n; i++)
		cin >> A[i];

	for (int j = 0; j < n; j++)
	{
		if (A[j] % 2 > 0)
			A[j] = 0;
	}
	int flag = 0;
	for (int k = 0; k < n; k++)
	{
		if (A[k] % 3 == 0 || A[k] % 5 == 0)
			flag = flag;
		else
			flag += 1;
	}
	if (flag > 0)
		cout << "DENIED";
	else
		cout << "APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N,a,xmin=0,ymin=0;
  cin>>W>>H>>N;
  int xmax=W,ymax=H;
  vector<vector<int>>xy(N,vector<int>(2));
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      cin>>xy.at(i).at(j);
    }
    cin>>a;
    if(a==1)xmin=max(xmin,xy.at(i).at(0));
    else if(a==2)xmax=min(xmax,xy.at(i).at(0));
    else if(a==3)ymin=max(ymin,xy.at(i).at(1));
    else if(a==4)ymax=min(ymax,xy.at(i).at(1));
    if(xmax<=xmin||ymax<=ymin){
      cout<<0<<endl;
      return 0;
    }
  }
  int ans=(xmax-xmin)*(ymax-ymin);
  cout<<ans<<endl;
  }

Measured memory_bytes: 256
// https://atcoder.jp/contests/arc062/tasks/arc062_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string s;
    cin >> s;
    int len = s.length(), ans = 0;
    REP(i, len) {
        if (i % 2 == 0) {
            if (s[i] == 'p') {
                ans--;
            }
        } else {
            if (s[i] == 'g') {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3700
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

ans = 99999999
ansplace = 0
for cnt, i in enumerate(h):
	if ans > abs(t-i*0.006-a):
		ans = abs(t-i*0.006-a)
		ansplace = cnt
print(ansplace+1)

Measured memory_bytes: 9212
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define STR_MAX 8000

struct point2d {
    int x;
    int y;
};
int main(void) {
    struct point2d goal;
    static char str[STR_MAX+1];
    get_str(str, STR_MAX+1);
    int len = strlen(str);
    str[len] = 'T'; // for guard
    get_int2(&goal.x, &goal.y);
    static int arr[STR_MAX+2];
    int aidx = 0;
    int i;
    for(i = 0; i < len+1; i++) {
        char ch = str[i];
        if(ch == 'F') {
            arr[aidx]++;
        } else { // 'T'
            aidx++;
        }
    }
    // if aidx is odd, make it even
    if(aidx%2 == 1) aidx++;
#ifdef DEBUG
    for(i = 0; i < aidx; i++) {
        printf(" %d", arr[i]);
    }
    putchar('\n');
#endif

    // for x
    static char dp[STR_MAX+5][2*STR_MAX+1];
    // ([0][len], [1][len]) = (.x=0, .y=0)
    dp[0][len+arr[0]] = 1;
    dp[1][len+arr[1]] = 1;
    dp[1][len-arr[1]] = 1;
    int pos;
    int flag_x = 0;
    int flag_y = 0;
    for(i = 2; i < aidx; i++) {
        int cnt = arr[i];
        for(pos = -len; pos <= len; pos++) {
            int ppos = pos+len;
            if(pos-cnt >= -len) dp[i][ppos] |= dp[i-2][ppos-cnt];
            if(pos+cnt <= len) dp[i][ppos] |= dp[i-2][ppos+cnt];
        }
    }

    flag_x = dp[aidx-2][len+goal.x]; // even
    flag_y = dp[aidx-1][len+goal.y]; // odd
#ifdef DEBUG
    printf("%d %d\n", flag_x, flag_y);
#endif
    printf("%s\n", (flag_x & flag_y) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 125056
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a,b;
	cin >> a >> b;
	int ans = 0;
	for(int i=0;i<3;i++)
		if(a[i]==b[i])	
			ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int64_t i,j,k,l;//preparation for
int main(){
    int n,k,s;
    cin>>n>>k;
    s=0;
    int p[n];
    int a[1001]={0};
    for(i=0;i<n;i++){
        cin>>p[i];
        a[p[i]]+=1;
    }
    j=0;
    while(k>0){ 
        if(a[j]!=0){
            s+=j;
            a[j]-=1;
            k-=1;
        }
        else{
            j+=1;
        }
    }
    cout<<s;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int x, y; cin >> x >> y;
  bool ok = false;
  REP(i, x+1) {
    ok |= 2 * i + 4 * (x - i) == y;
  }
  cout << (ok ? "Yes" : "No") << endl;

}
























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

using namespace std;
using ll = long long;

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

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

  vector<vector<int>> dp(2, vector<int>(n, 0));
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][0] + a[0][1];
  dp[1][0] = a[0][0] + a[1][0];

  for (int j = 1; j < n; j++) {
    dp[0][j] = max(dp[0][j], dp[0][j - 1] + a[0][j]);
    dp[1][j] = max(dp[1][j], dp[0][j] + a[1][j]);
    dp[1][j] = max(dp[1][j], dp[1][j - 1] + a[1][j]);
  }

  cout << dp[1][n - 1] << endl;

  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
//		int n = sc.nextInt();

		String string = sc.next();
		String[] s = string.split("");

//		int[] ans = new int[n];

		//-------------------------------------------------------------------------------------

		for(int i = 0; i < s.length; i++) {
			if(s[i].equals("?")) {
				if(i >= 1) {
					if(s[i-1].equals("P")) {
						s[i] = "D";
					}
				}
				if(!f) {
					s[i] = "D";
				}
			}
		}

		for(int i = 0; i < s.length; i++) {
			System.out.print(s[i]);
		}
		System.out.println();
		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 68604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N; cin >> N;
    vl A(N);
    vl sum(N);
    rep(i, N) {
        cin >> A[i];
        sum[i] = A[i];
    }
    const ll MOD = 1000000007;

    reverse(sum.begin(), sum.end());
    rep(i, N - 1) {
        sum[i + 1] += sum[i];
        sum[i + 1] %= MOD;
    }
    reverse(sum.begin(), sum.end());

    ll res = 0;
    rep(i, N - 1) {
        ll x = A[i] * sum[i + 1] % MOD;
        res += x;
        res %= MOD;
// cout << "i: " << i << ", A[i]: " << A[i] << ", sum[i + 1]: " << sum[i + 1] << ", res " << res << endl;
    }

    cout << res << endl;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int n,m,i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int n,m,dp[1000005];

int main()
{
    sf(n);
    ll ans  = 0,mn=1e18,mx=-mn,c = mn,z=mx,a=mn,b=mx, l =mn, r= mx;;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        mn = min(x+y,mn);
        mx = max(x+y,mx);
        ans = max(ans, abs(mn-mx));
        c = min(x-y,c);
        z = max(x-y,z);
        ans = max(ans,abs(c-z));
        a = min(a,-x+y);
        b = max(a,-x+y);

        ans = max(ans,abs(a-b));

        l = min(l,-x-y);
        r = max(r,-x-y);
        ans = max(ans,abs(l-r));
    }
    cout<<ans<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

int S[11][1001];

void solve()
{
    int H, W, K;
    cin >> H >> W >> K;

    REP0 (i, H)
    {
        REP0 (j, W)
        {
            char c;
            cin >> c;
            S[i][j] = c - '0';
        }
    }

    int ans = INTINF;

    REP0 (bit, 1 << (H - 1))
    {
        int bs = __builtin_popcount(bit);
        vector<int> cnt(bs + 1);
        int cut = bs;

        bool impossible = false;
        REP0 (j, W)
        {
            int row = 0;
            REP0 (i, H)
            {
                cnt[row] += S[i][j];
                if (bit & (1 << i))
                    row++;
            }

            if (*max_element(cnt.begin(), cnt.end()) > K)
            {
                if (impossible)
                {
                    // continueした直後に再びKを超える
                    // →この切り方では縦にどう切ってもKを超えてしまう
                    cut = INTINF;
                    break;
                }
                for (auto &a : cnt) a = 0;
                cut++;
                j--;
                impossible = true;
                continue;
            }
            impossible = false;
        }

        ans = min(ans, cut);
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

ll cnt[2019];

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

    int now = 0;
    ll ans = 0, p = 1;
    cnt[0] = 1;

    for (int i = s.size() - 1; i >= 0; i--) {
        now = (now + (s[i] - '0') * p) % 2019;
        ans += cnt[now]++;
        p = p * 10 % 2019;
    }

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


Measured memory_bytes: 3748
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, count=0, sum=0, min=1000000;
    cin >> N;

    vector<ll> A(N);

    for(i=0; i<N; i++){
        cin >> A.at(i);

        if(A.at(i) < 0){
            count++;
        }

        chmin(min, abs(A.at(i)));

        sum += abs(A.at(i));
    }

    if(count % 2 == 0){
        cout << sum << endl;
    }

    else{
        cout << sum-min*2 << endl;
    }

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[400], s[401], dp[401][401], INF = 1e15;

LL f(int l, int r) {
	if(r - l == 1) { return 0; }
	if(dp[l][r] > 0) { return dp[l][r]; }
	
	dp[l][r] = INF;
	incID(m, l + 1, r) { setmin(dp[l][r], f(l, m) + f(m, r) + (s[r] - s[l])); }
	
	return dp[l][r];
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	cout << f(0, n) << endl;
	
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

ll cnt[100010];

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

    ll n;
    cin>>n;
    ll sum = 0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cnt[a]++;
        sum += a;
    }
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        sum += cnt[a]*(b-a);
        cnt[b] += cnt[a];
        cnt[a] = 0;
        cout << sum << "\n";
    }

}

Measured memory_bytes: 4428
import sys
from sys import stdin

s = stdin.readline().rstrip()
if len(s) == 26:
    count = 1
    for i in range(1, len(s)):
        if s[-i] < s[-i - 1]:
            count += 1
        else:
            break
    if count == 26:
        print(-1)
    else:
        for i in sorted(s[-count:]):
            if s[-count - 1] < i:
                print(s[:-count-1] + i)
                sys.exit()
else:
    d = {}
    for i in range(26):
        d.update({i: 0})
    for si in s:
        d[ord(si) - 97] += 1
    for i in range(26):
        if d[i] == 0:
            s += chr(i + 97)
            print(s)
            sys.exit()


Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=2e5+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
char s[MAX_N];
int main()
{
	int sum=0; ss(s+1);
	int len=strlen(s+1);
	repi(i,1,len) sum+=(s[i]-'0');
	if(sum%9) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3820
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

answer=0
oklist=[False]*K
for i in range(N):
    if oklist[i%K]:
        oklist[i%K]=False
        if T[i]=="r":
            answer+=P
        elif T[i]=="s":
            answer+=R
        else:
            answer+=S
        continue


    if i>=K and T[i]==T[i-K]:
        oklist[i%K]=True
        continue
    
    if T[i]=="r":
        answer+=P
    elif T[i]=="s":
        answer+=R
    else:
        answer+=S

print(answer)


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    String places = scanner.nextLine();
    int count = 0;
    count += places.charAt(0) == '1' ? 1 : 0;
    count += places.charAt(1) == '1' ? 1 : 0;
    count += places.charAt(2) == '1' ? 1 : 0;
    System.out.println(count);
  }
}

Measured memory_bytes: 23252
fun main(args: Array<String>) {
    val s = readLine()!!
    val (gx, gy) = readLine()!!.split(' ').map { it.toInt() }

    val dx = mutableListOf<Int>()
    val dy = mutableListOf<Int>()
    s.split('T').forEachIndexed { i, sub ->
        if (i % 2 == 0) dx.add(sub.length) else dy.add(sub.length)
    }

    val x = dx.slice(1 until dx.size).sortedDescending()
            .fold(gx - dx[0]) { acc, i -> acc + if (acc > 0) -i else i }

    val y = dy.sortedDescending()
            .fold(gy) { acc, i -> acc + if (acc > 0) -i else i }

    println(if (x == 0 && y == 0) "Yes" else "No")
}


Measured memory_bytes: 40300
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	m := getNextInt(scanner)
	hh := getNextInt(scanner)
	mm := getNextInt(scanner)
	k := getNextInt(scanner)

	minutes := hh*60 + mm - h*60 - m
	fmt.Fprintln(writer, minutes-k)
}


Measured memory_bytes: 1800
n, k = map(int, input().split())
s = []
num = 0
for i in range(k):
    d = int(input())
    lists = list(map(int, input().split()))
    for j in range(d):
        s.append(lists[j])
for i in range(n):
    if i+1 not in s:
        num += 1
print(num)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int n;cin>>n;
  	vector<int> m(n);
  
  	for(int i=0;i<n;i++){
      cin>>m[i];
    }
  
  	set<int> values;
  	for(int i=0;i<n;i++){
    	values.insert(m[i]);
    }
  
  	cout<<values.size()<<endl;
}


Measured memory_bytes: 256
/*Author : Prokash
           JU CSE 48
           CF: epiprokash
           UVa: epiprokash
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/(gcd(a,b))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

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

int main(void){
  string t;
  string p;
  cin >> t;
  cin >> p;
  rep(i,(int)t.size()-(int)p.size()+1){
    rep(j,p.size()){
      if(i+j >= t.size() || t[i+j] != p[j])break;;
      if(j == p.size()-1){
        cout << i << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b <= 0 && c >= 0) {
    cout << b * c << endl;
    return 0;
  }

  if (a >= 0 && d <= 0) {
    cout << a * d << endl;
    return 0;
  }
  cout << max(a * c, b * d) << endl;
  return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int cnt[110000] = {};

int main(){
    long long int N, K, Q;
    cin >> N >> K >> Q;
    for(int i = 0; i < Q; i++){
        int A;
        cin >> A;
        cnt[A] += 1;
    }
    for(int i = 1; i <= N; i++){
        if(K - (Q - cnt[i]) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI a(n), b(n);
	rep(i,n) cin >>a[i];
	
	b=a;
	rep(i,n) b[i] -=i+1;
	//for(auto x :b) printf("%d, ",x); puts("");
	sort(all(b));
	int z = b[(n-1)/2];
	ll ans =0;
	rep(i,n) ans += abs(a[i] - (z+i+1));
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    int record[26] = {0};

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++){
        record[s[i] - 'a'] = 1;
    }


    if(s.size() < 26){
        for(int i = 0; i < 26; i++){
            if(record[i] == 0){
                char next = i + 'a';
                cout << s << next << endl;
                return 0;
            }
        }
    }

    if(s.size() == 26){
        for(int i = 25; i >= 0; i--){
            record[s[i] - 'a'] = 0;
            for(int j = s[i] - 'a' + 1; j < 26; j++){
                if(record[j] == 0){
                    for(int k = 0; k < i; k++){
                        cout << s[k];
                    }
                    char next = j + 'a'; 
                    cout << next << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
    }

}

Measured memory_bytes: 256
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = float('inf')
for i in range(ls - lt + 1):
    cnt = 0
    for j in range(lt):
        if s[i + j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 9108
# CODE FESTIVAL 2016 Final: A – Where's Snuke?
alphabets ='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
h, w = map(int, input().split())
s = [[s for s in input().split()] for _ in range(h)]

for i in range(h):
    if 'snuke' in s[i]:
        print(alphabets[s[i].index('snuke')] + str(i + 1))
        break

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#define MAX 104730

int num[MAX];

int main(void){
	int i, j, in, cnt, sum;
	for(i = 2; i < sqrt(MAX); i++){
		for(j = i; i * j < MAX; j++)	num[i*j] = 1;
	}

	while(1){
		scanf("%d", &in);
		if(in == 0)	break;
		cnt = 0; sum = 0;
		for(i = 2; i < MAX; i++){
			if(cnt == in)	break;
			if(num[i] == 0){
				sum += i;
				cnt++;
			}
		}
		printf("%d\n", sum);
	}

  return 0;
}

Measured memory_bytes: 1004