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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

void solve() {
  int N, M;
  cin >> N >> M;
  int ac = 0, wa = 0;
  map<int, int> sub;
  for (int i = 0; i < M; i++) {
    int prob;
    string judge;
    cin >> prob >> judge;
    if (sub[prob] >= 0 && judge == "WA") {
      sub[prob]++;
    } else if (sub[prob] >= 0 && judge == "AC") {
      ac++;
      wa += sub[prob];
      sub[prob] = -1;
    }
  }
  cout << ac << ' ' << wa << endl;
}

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

  solve();

  return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            for (int i = 0; i < 3; i++)
            {
                if (S[i] == S[i + 1])
                {
                    Console.WriteLine("Bad");
                    return;
                }
            }

            Console.WriteLine("Good");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<algorithm>
#define int long long 
#define mod 1000000007
using namespace std;
signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t;cin>>t;
for(int i=0;i<t;i++) cout<<"ACL";

}





Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] strings = scanner.nextLine().split(" ");
        double[] dp = new double[n+1];
        dp[0]=1;
        for (int i = 0; i < n; i++) {
            double p = Double.parseDouble(strings[i]);
            for (int j = i+1; j > 0 ; j--) {
                dp[j]=dp[j]*(1-p)+dp[j-1]*p;
            }
            dp[0]*=(1-p);
        }
        double ans = 0;
        for (int i = n; i > n/2 ; i--) {
            ans+=dp[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 40556
#include <stdio.h>

int main(void) {
	char s[3][11] = { 0 };
	int i;

	scanf("%s %s %s", s[0], s[1], s[2]);
	
	for (i = 0; i < 3; i++) printf("%c", s[i][0] - 32);
	puts("");

	return 0;
}

Measured memory_bytes: 128
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  as <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve as

solve :: U.Vector Int -> Int
solve as = U.minimum $ U.zipWith (\l r -> abs (l - r)) ls rs
  where
    ls = U.scanl' (+) 0 as
    rs = U.scanr (+) 0 as

Measured memory_bytes: 9468
N = int(input())
c0=c1=c2=c3=0
for i in range(N):
  S = input()
  if S == "AC":
    c0+=1
  elif S == "WA":
    c1+=1
  elif S == "TLE":
    c2+=1
  elif S == "RE":
    c3+=1

print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)

Measured memory_bytes: 9196
#include <stdio.h>

using namespace std;

int main(){
    int C[10001] = {0};
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
    for(int i = 1; i < 10001; i++) C[i] += C[i-1];

    for(int i = n-1; i >= 0; i--) B[(C[A[i]]--)-1] = A[i];

    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}

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

using namespace std;

long long dp[105][100005];

long long MOD = 1000000007;

int main()
{
    int n, k;
    scanf("%i%i", &n, &k);
    dp[0][0] = 1;
    for (int x = 1; x <= n; x++)
    {
        long long a;
        scanf("%lli", &a);
        for (int y = 0; y <= k; y++)
        {
            dp[x][y] += dp[x-1][y] - (y-a > 0 ? dp[x-1][y-a-1] : 0);
            if (y > 0)
                dp[x][y] += dp[x][y-1];
            dp[x][y] %= MOD;
            dp[x][y] += MOD;
            dp[x][y] %= MOD;
        }
    }
    printf("%lli\n", dp[n][k] % MOD);
}


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

int main(void){
	char S[100002];
	scanf("%s",S);
	
	int start0=0,start1=0;
	for(int i=0;i<strlen(S);i++){
		if(i%2==0){
			if(S[i]=='0') start0++;
			else start1++;
		}
		else{
			if(S[i]=='1') start0++;
			else start1++;
		}
	}
	cout << min(start0,start1);
}

Measured memory_bytes: 384
S=int(input())

S1 = S // 100
S2 = S % 100

if S1 == 0:
    if S2 == 0 or S2 > 12:
        print('NA')
    else:
        print('YYMM')
elif S1 != 00 and S1 < 13:
    if S2 == 0 or S2 > 12:
        print('MMYY')
    else:
        print('AMBIGUOUS')
else:
    if S2 == 0 or S2 > 12:
        print('NA')
    else:
        print('YYMM')

Measured memory_bytes: 3064
n = gets.to_i
a,b = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
c = [0,0,0]
n.times do |i|
    if p[i] <= a
        c[0] += 1
    elsif p[i] <= b
        c[1] += 1
    else
        c[2] += 1
    end
end
puts c.min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,k,aa[110000],cnt=1,a=0;
pair<int,string> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>n>>k;
    while(1){
        if(cnt>n){
            cout<<a;
            return 0;
        }
        cnt*=k;
        a++;
    }
}

Measured memory_bytes: 5376
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a, b, c = r.split()
    #a = list(map(int, r.split()))
    #a,b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if n < 1200:
        print('ABC')
    else:
        print('ARC')

if __name__ == '__main__':
    main()


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

int main() {
    ll n, x;
    cin >> n;
    ll totd = 0;
    for(ll i=0; i<n; i++) {
        cin >> x;
        ll dbt = 0;
        while(x % 2 != 1) {
            x /= 2;
            dbt++;
        }
        totd += dbt;
    }
    cout << totd << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

fil x
 |x>0 = "Yes"
 |otherwise = "No"

main = do
 [n,k,q] <- map read . words <$> getLine
 ans <- map (pred.length) . group . sort . (++[1..n])<$> (replicateM q readLn :: IO [Int])
 mapM_ putStrLn $ map fil $ zipWith (\x y -> x-q+y) (replicate n k) ans

Measured memory_bytes: 41340
N,D = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(N)]

import itertools
import math
S = list(itertools.combinations(range(N), 2))
ans = 0
for k in S:
  a = 0
  for j in range(D):
    a += abs(pow(L[k[0]][j] - L[k[1]][j], 2))
  if math.sqrt(a).is_integer():
    ans += 1
print(ans)
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,b,a; cin >> n >> a >> b;
    if(a == 0){OUT(0); return 0;}
    int ans = 0;
    ans += n/(a+b) * a;
    int x = n%(a+b);
    if(x < a) ans += x;
    else ans += a;
    ANS;

    return 0;
}

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

int main(){
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  
  if(n <= k){
    cout << x*n << endl;
  }
  
  else{
    cout << x*k + y*(n-k) << endl;
  }
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    int len = S.size();
    int c = 0;
    for(int i = 0; i < len; i++){
        if(S[i] != T[i]){
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3832
N,M,K = map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
a.insert(0,0)
b.insert(0,0)
b_num = sum(b)
b_best = M
j = M
a_num = 0
maxmize = 0
num = 0
for i in range(N+1):
  a_num +=a[i]
  flag = 1
  while flag == 1:
    num = b_num+a_num
    if num<=K:
      maxmize = max(M+i,maxmize)
      break
    else:
      if  not b:
        break
      else:
        j = b.pop()
        M-=1
        b_num = b_num-j
print(maxmize)    

Measured memory_bytes: 118352
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
vector<vector<int>> v(1001);

int target[201];
int res[201];

int math[1010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N, M;
    while (cin >> N >> M, N || M)
    {
        vector<int> v(N);
        for (int i = 0; i < N; ++i)
            cin >> v[i];

        int prev = 1;
        vector<int> v2(M);
        for (int i = 0; i < M; ++i)
            cin >> v2[i];

        int idx = 0;
        while (prev < N)
        {
            int next = prev + v2[idx];
            prev = next + v[next - 1];
            idx++;
        }
        cout << idx << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
package main

import (
	"fmt"
	"math"
)

func main() {
	list := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&list[i])
	}
	var k int
	fmt.Scan(&k)

	result := ":("
	for i := 0; i < 5; i++ {
		for j := 1; j < 5; j++ {
			if int(math.Abs(float64(list[i]-list[j]))) <= k {
				result = "Yay!"
			} else {
				result = ":("
				fmt.Println(result)
				return
			}
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
int main()
{
	int* A = 0;
	int N = 0;
	scanf("%d", &N);
	A = (int*)malloc(sizeof(int) * N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	qsort(A, N, sizeof(int), asc);

	for (int j = 0; j < N - 1; j++)
	{
		if (A[j] == A[j + 1])
		{
		printf("NO");
		return 0;
	    }
	}

	printf("YES");
	return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>
#include <deque>
#include <tuple>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)



using namespace std;


struct edge {//枝
    LL to,cost;
} ;


struct vertex{//頂点(枝付き)
	LL key;
    vector<edge> edges;
};

typedef vector<vertex> graph;//グラフ(枝付き頂点の集合として扱う)

edge edge_init(LL t,LL cos){//枝の初期化
	edge e = {.to = t, .cost = cos};

	return e;

}

vertex vertex_init(LL key,vector<edge> E){//頂点の初期化
	vertex v;

	v.key = key;

	rep(i, 0, E.size()){
				v.edges.push_back(E[i]);
	}

	return v;

}

vector<vertex> graph_init(LL V, LL key[],vector<edge> E[]){//グラフの初期化

	graph G;

	rep(i,0,V){
		vertex v = vertex_init(key[i],E[i]);
		G.push_back(v);
	}

	return G;

}

void dijkstra(LL s,LL V,vector<vertex> G, LL d[]) {

    priority_queue<pLL, vector<pLL>, greater<pLL> > que;

    fill(d,d+V,LLONG_MAX);
    d[s] = 0;
    que.push(pLL(0, s));

    while (!que.empty()) {
        pLL p = que.top();
        que.pop();
        LL v = p.second;
        if (d[v] < p.first) continue;

        rep(i,0, G[v].edges.size()) {
            edge e = G[v].edges[i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pLL(d[e.to], e.to));
            }
        }
    }

    return;
}



int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


LL gcd(LL i,LL j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

LL A(){
	string S;
	
	cin >> S;
	
	if(S[2] == S[3] && S[4] == S[5])
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

LL B(){

	return 0;
}

LL C(){

	return 0;
}

LL D(){
	 LL V, X, Y;

	 cin >> V >> X >> Y;



	 LL key[V] = {0};
	 vector<edge> E[V];


	 rep(i,0,V-1){
		E[i].push_back(edge_init(i+1,1));
		E[i+1].push_back(edge_init(i,1));
	 }

	 E[X-1].push_back(edge_init(Y-1,1));
	 E[Y-1].push_back(edge_init(X-1,1));

	 graph G = graph_init(V,key,E);

	 LL d[V][V];//d[i][j]はiからjへの最短距離が入る
	 LL count[V] = {0};

	 rep(i,0,V){
		 dijkstra(i,V,G,d[i]);

	 }

	 rep(i,0,V){
		 rep(j,i+1,V){
			  count[d[i][j]]++;

		 }
	 }

	 rep(i,1,V){
		 cout << count[i] << endl;
	 }

	return 0;
}

LL E(){

	return 0;
}

signed main() {
	A();
	//B();
	//C();
	//D();
	//E();
	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int a[12][12],sx,sy,n;
int fn(int x,int y,int p){
  int i;
  int ct=0;
  if(p==n){
    if(x==sx||y==sy)
      ct=1;
  }else{
    a[x][y]=0;
    for(i=1;a[x+i][y]==0;i++);
    if(a[x+i][y]!=-1)
      ct+=fn(x+i,y,p+1);
    for(i=1;a[x-i][y]==0;i++);
    if(a[x-i][y]!=-1)
      ct+=fn(x-i,y,p+1);
    for(i=1;a[x][y+i]==0;i++);
    if(a[x][y+i]!=-1)
      ct+=fn(x,y+i,p+1);
    for(i=1;a[x][y-i]==0;i++);
    if(a[x][y-i]!=-1)
      ct+=fn(x,y-i,p+1);
    a[x][y]=1;
  }
  return ct;
}
int main(){
  int i,j;
  int w,h;
  while(cin>>w>>h&&(w||h)){
    memset(a,-1,sizeof(a));
    n=0;
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	cin>>a[j][i];
	if(0){
	}else if(a[j][i]==1){
	  n++;
	}else if(a[j][i]==2){
	  sx=j;
	  sy=i;
	}
      }
    }
    cout<<fn(sx,sy,0)<<endl;
  }
  return 0;
}

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

struct cmp {
	int mod;
	cmp(int x) :mod(x) {}
	bool operator()(const int& a, const int& b)const {
		return a % mod < b % mod;
	}
};

int main() {
	int n; cin >> n;
	vector<int>a(n), b(n); for (auto&& x : a)cin >> x;for (auto&& x : b)cin >> x;
	int ans = 0;
	for (int i = 0; i < 30; i++) {
		sort(b.begin(), b.end(), cmp(1 << i));
		bool btoggle = false;
		for (int j = 0; j < n; j++) {
			btoggle ^= (b[j] >> i)& 1;
		}
		for (int j = 0; j < n; j++) {
			int v = (1 << i) - (a[j] % (1 << i)) - 1;
			int pos = upper_bound(b.begin(), b.end(), v, cmp(1 << i)) - b.begin();
			int pv = (a[j] >> i) & 1;
			bool toggle = (pv ? pos & 1 : (n - pos) & 1);
			toggle ^= btoggle;
			if (toggle)ans ^= (1 << i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

bool vis[10];

int n, k, x;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
		cin >> x, vis[x] = 1;
	for (int i = n; i <= 100000; i++)
	{
		int y = i, tag = 1;
		while (y && tag)
		{
			if (vis[y % 10])
				tag = 0;
			y /= 10;
		}
		if (tag)
		{
			cout << i << endl;
			break;	
		}
	}
	return 0;	
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val l = readLine.split(" ").map(i => (i.toInt + 1) / 2d)
  var max = l.slice(0, k).sum
  var tmp = max
  for (i <- k until n) {
    tmp = tmp - l(i - k) + l(i)
    max = math.max(max, tmp)
  }
  println(max)
}


Measured memory_bytes: 52624
#include <iostream>
#include <algorithm>
#define INF 99999999999
using namespace std;

typedef long long int lli;
int main(void){
	int n,m,a,b,c;
	cin>>n>>m;
	lli dp[n][n];

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)dp[i][j]=0;
			else dp[i][j]=INF;
		}
	}

	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		dp[a][b]=c;
	}

	for(int k=0;k<n;k++){
		for(int u=0;u<n;u++){
			for(int v=0;v<n;v++){
				if(dp[u][k]!=INF&&dp[k][v]!=INF)dp[u][v]=min(dp[u][v],dp[u][k]+dp[k][v]);
				if(u==v&&dp[u][v]<0){
					cout<<"NEGATIVE CYCLE"<<endl;
					return 0;
				}
			}
		}
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j!=n-1){
				if(dp[i][j]!=INF)cout<<dp[i][j]<<" ";
				else cout<<"INF"<<" ";
			}
			else{
				if(dp[i][j]!=INF)cout<<dp[i][j];
				else cout<<"INF";
			}
		}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 3200
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

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

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        string a,b;
        cin>>a>>b;
        if((ll)a.size() > 1 or (ll)b.size() > 1) cout<<"-1";
        else cout<<stoll(a)*stoll(b);
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = max({ a * c, a * d, b * c, b * d });
    cout << ans;
    return 0;
}

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

inline ll max_3(ll p, ll q, ll r)
{
    return max(max(p,q),r);
}
inline ll min_3(ll p, ll q, ll r)
{
    return min(min(p,q),r);
}
ll h, w;
ll case1()
{
    ll a = h*(w/3);
    ll b = h*((w-w/3)/2);
    ll c = h*w - a - b;
    return max_3(a,b,c)-min_3(a,b,c);
}
ll case2()
{
    ll a = w*(h/3);
    ll b = w*((h-h/3)/2);
    ll c = h*w - a - b;
    return max_3(a,b,c)-min_3(a,b,c);
}

ll case3()
{
    ll a, b, c;
    ll mindiff = LLONG_MAX;
    for (int i = 1; i<h; i++)
    {
        a = i*w;
        b = (h-i)*(w/2);
        c = (h-i)*w - b;
        mindiff = min(mindiff,max_3(a,b,c)-min_3(a,b,c));
    }
    return mindiff;
}

ll case4()
{
    ll a, b, c;
    ll mindiff = LLONG_MAX;
    for (int i = 1; i<w; i++)
    {
        a = i*h;
        b = (w-i)*(h/2);
        c = (w-i)*h - b;
        mindiff = min(mindiff,max_3(a,b,c)-min_3(a,b,c));
    }
    return mindiff;
}


int main()
{
    cin >> h >> w;
    cout << min(min(case1(),case2()),min(case3(),case4()));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = a/500;
		b=b*1000;
		long c = a%500;
		c = c-c%5;
		System.out.print(b+c);
	}
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int a, b, c, d; cin >> a >> b>> c>> d;
	while(1){
		c -= b;
		if(c<=0){
			cout << "Yes";
			return 0;			
		} 
		a -= d;
		if(a<=0){
			cout << "No";
			return 0;			
		}
	}
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum = 0;
	for(int i=1;i<=n;i+=2)
	{
		int chu = 0;
		for(int j=i;j;j--)
		{
			if(i%j == 0)chu++; 
		}
		if(chu == 8)
			sum++;
	 } 
	 cout<<sum<<endl; 
 } 

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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

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

const int INF = INT_MAX;

int main() {
	fastio;
	int n, k ; cin >> n >> k;
	vector < ll > v(n), dp(n, 0);
	
	for(int i = 0; i < n; ++i) cin >> v[i];

	for(int i = 1; i <= k; ++i) {
		dp[i] = abs(v[i] - v[0]);
	}

	for(int i = k + 1; i < n; ++i) {
		int mini = INF;
		for(int j = i - 1; j >= i - k; --j) {
			mini = min((ll) mini, dp[j] + abs(v[j] - v[i]));
		}
		dp[i] = mini;
	}

	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    uint N, K;
    cin >> N >> K;
    vector<int> A(N+1, 0);
    for (uint i=1; i<A.size(); ++i) 
        cin >> A[i];

    for (int i=K+1; i<A.size(); ++i) {
        if (A[i] > A[i-K])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 4052
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = [ni() for _ in range(n)]
c = Counter(li)
ans = 0
for k, v in c.items():
    if v % 2 == 1:
        ans += 1
print(ans)



Measured memory_bytes: 16792
/*input
10
1 1 5 1 4 5 5 4 9 4 
1 4 9 9 8 2 1 8 2 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int a[maxn],b[maxn],cnt[maxn],cnt2[maxn];
int nxt[maxn];
int lst[maxn];
vector<int> v[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    srand(time(NULL));
    int n;
    cin>>n;
    REP(i,n) cin>>a[i],cnt2[a[i]]++,v[a[i]].pb(i);
    REP1(i,n) v[i].pb(INF);
    REP(i,n){
        cin>>b[i],cnt[b[i]]++;
        //cout<<b[i]<<' ';
    }
    //cout<<'\n';
    //REP(i,n) cout<<a[i]<<' ';
    //cout<<'\n';
    set<pair<pair<pii,int>,int>> s;
    REP1(i,n) if(cnt[i]+cnt2[i]>n){
        cout<<"No\n";
        return 0;
    }
    reverse(b,b+n);
    vector<int> v;
    int x=-1;
    REP(i,n){
        if(a[i]==b[i]) v.pb(i),x=a[i];
    }
    if(x!=-1){
        REP(i,n){
            if(a[i]!=x and b[i]!=x){
                swap(b[i],b[v.back()]);
                v.pop_back();
            }
            if(!sz(v)) break;
        }
    }
    cout<<"Yes\n";
    REP(i,n){
        assert(a[i]!=b[i]);
        cout<<b[i]<<' ';
    }
}


Measured memory_bytes: 18812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    int min = 1000;
    for(int i = 0; i < s.size(); i++) {
        int x = stoi(s.substr(i,3));
        if(min > abs(x-753)) {
            min = abs(x-753);
        }
    }
    cout << min;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
queue<int> q;
int main(){
	vector<int> pf(1000);
	int n,mod=1e9+7;
	cin>>n;
	for (int i=1;i<=n;i++){
		int t=i;
		for (int j=2;j<=t;j++){
			while(t%j==0){
				pf[j]++;
				t/=j;
			}
		}
	}
	long long ans=1;
	for (int i=0;i<1000;++i){
		ans*=pf[i]+1;
		ans%=mod;
	}
	cout<<ans;
	
	 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

n = ii()

l = [2, 4, 5, 7, 9]
l2 = [0, 1, 6, 8]
if n % 10 in l:
    print('hon')
elif n % 10 in l2:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
  int main(){
  int N , K ;
  int a = 1 ;
  int b = 1 ;
  int c = 1 ;
  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    a = c + K ;
    b = 2 * c ;
    if(a < b){
      c = a ;
    }
    else {
      c = b ;
    }
  }
  cout << c << endl;
} 
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll N, K;
    cin >> N >> K;
    map<ll, ll>cnt;
    for(ll i = 0; i < N; i++){
        ll x;
        cin >> x;
        cnt[x]++;
    }
    vector<ll>vec;
    for(map<ll, ll>::iterator it = cnt.begin(); it != cnt.end(); it++){
        vec.push_back((*it).second);
    }
    ll ans = 0;
    sort(vec.begin(), vec.end());
    for(ll i = 0; vec.size() > K;i++){
        K++;
        ans += vec[i];
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 14964
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            int[] s = new int[13];
            int[] h = new int[13];
            int[] c = new int[13];
            int[] d = new int[13];
            for (int j = 0; j < num; j++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int value = int.Parse(input[1]) - 1;

                switch (input[0])
                {
                    case "S":
                        s[value] = 1;
                        break;
                    case "H":
                        h[value] = 1;
                        break;
                    case "C":
                        c[value] = 1;
                        break;
                    case "D":
                        d[value] = 1;
                        break;
                }
            } 

            for (int S=0; S<13; S++)
            {
                if (s[S] != 1) Console.WriteLine("S {0}", S + 1);
            }

            for (int H = 0; H < 13; H++)
            {
                if (h[H] != 1) Console.WriteLine("H {0}", H + 1);
            }

            for (int C = 0; C < 13; C++)
            {
                if (c[C] != 1) Console.WriteLine("C {0}", C + 1 );
            }

            for (int D = 0; D < 13; D++)
            {
                if (d[D] != 1) Console.WriteLine("D {0}", D + 1);
            }
            //Console.WriteLine();
        }
    }
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vii;

typedef long long int lld;

#define F first
#define S second

#define ERR 1e-9

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE

    int A, B, C;

    cin >> A >> B >> C;

    int biggest, ris = 0;
    biggest = max(A, B);
    ris += min(A, B);
    ris += min(biggest, C) + max(biggest, C)*10;

    cout << ris;

    return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
stores = sorted([[int(_) for _ in input().split()] for _0 in range(N)])

drinks = 0
cost = 0
for A, B in stores:
    if drinks == M:
        break
    num_to_buy = min(B, M - drinks)
    cost += A * num_to_buy
    drinks += num_to_buy
print(cost)


Measured memory_bytes: 22380
package main
 
import "fmt"
 
func main() {
  var b string
 
  fmt.Scan(&b)
  
  switch b {
    case "A": 
    	fmt.Println("T")
    case "T":
    	fmt.Println("A")
    case "G":
    	fmt.Println("C")
    default:
    	fmt.Println("G")
  }
  
}

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

int main() {
  int n;
  int k;
  int sum = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (k - x <= x) {
      sum += (k - x) * 2;
    }else
      sum += x * 2;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]
visited = [[False] * w for _ in range(h)]

sx, sy = 0, 0
gx, gy = w - 1, h - 1

que = deque()
que.append((sx, sy))
visited[sy][sx] = 1
while que:
    cx, cy = que.popleft()
    for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        nx, ny = cx + dx, cy + dy
        if (0 <= nx < w) and (0 <= ny < h) and (visited[ny][nx] is False) and (grid[ny][nx] == '.'):
            if ny == gy and nx == gy:
                visited[ny][nx] = visited[cy][cx] + 1
                break
            else:
                visited[ny][nx] = visited[cy][cx] + 1
                que.append((nx, ny))

if visited[gy][gx] is False:
    print(-1)
else:
    cnt = 0
    for y in range(h):
        for x in range(w):
            if grid[y][x] == "#":
                cnt += 1
    print(h * w - visited[gy][gx] - cnt)

Measured memory_bytes: 3572
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    ll x,y;
    cin>>a>>b>>c;
    if(a+b==c||a+c==b||a==b+c) Yes;
    else No;
    return 0;
}


Measured memory_bytes: 3584
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val num = StdIn.readLine()
    var arr = Array.ofDim[Int](4,3,10)

    for(i <- 1 to num.toInt){
      val in = StdIn.readLine().split(" ")
      arr(in(0).toInt-1)(in(1).toInt-1)(in(2).toInt-1) += in(3).toInt
    }

    for(i <- 0 until 4){
      for(j <- 0 until 3){
        for(k <- 0 until 10){
          print(" " + arr(i)(j)(k))
        }
        println
      }
      if(i != 3){
        println("####################")
      }
    }
  }
}

Measured memory_bytes: 44064
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;

void solve(){
    string s;
    cin>>s;
    int n=s.size();
    ll xx=0;
    for(int i=0;i<n;i++){
        xx+=(s[i]-'0');
    }
    if(xx%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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


Measured memory_bytes: 3780
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <ctime>
#include <cstdio>
#include <set>
using namespace std;

#define LL unsigned long long int
#define SZ 110

int g[SZ];

int mex(set<int> &grnd)
{
    int i=0;
    for(const int &x:grnd){
        if(x!=i)
            return i;
        i++;
    }
    return i;
}

int grundy(int n)
{
    if(g[n]!=-1) return g[n];
    if(n<2) return g[n]=0;

    set<int> grnd;

    for(int i=1; i<=n; i++)
        if(n%(n-i)==0)
            grnd.insert(grundy(n-i));

    return g[n]=mex(grnd);
}

int result(int n, int m)
{
    int jor=0;

    if(n&1) jor=grundy(m);

    return jor;
}

int towerBreakers(int n, int m)
{
    if(result(n, m)) return 1;
    return 2;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    LL n, a, k, i, sum=0, d;
    vector<int> h;

    cin >> n >> k;
    for(i=0; i<n; i++){
        cin >> d;
        h.push_back(d);
    }
    if(k>=n){
        puts("0");
        return 0;
    }
    sort(h.begin(), h.end());
    k=n-k;
    for(i=0; i<k; i++)
        sum+=h[i];
    cout << sum << endl;

    return 0;
}
/**
2
2 2
1 4

*/


Measured memory_bytes: 1400
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    #1 line 1 int
     return int(sys.stdin.readline().rstrip())
def LI():
    #1 line n int
     return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    #1 line 1 string
     return sys.stdin.readline().rstrip()
def LS():
    #1 line n strings
     return list(sys.stdin.readline().rstrip().split())

A,B,=LI()
x=A+B

if x%2==0:
    print(x//2)
else:
    print((x+1)//2)


Measured memory_bytes: 10016
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
k = 2
h = np.array(read().split(),dtype=np.int32)
dp = np.zeros(n,dtype=np.int32)

for i in range(1,n):
    l = max(i-k,0)
    dp[i] = np.min(np.abs(h[i]-h[l:i])+dp[l:i])
print(dp[-1])

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S,T;
    int A,B;
    string U;
    cin >> S >> T >> A >> B >> U;
    if(U == S)cout << A-1 << " " << B << "\n";
    if(U == T)cout << A << " " << B-1 << "\n";
}

Measured memory_bytes: 256
n,q = gets.split().map(&:to_i)
s = gets.chomp
lr = q.times.map{gets.split().map(&:to_i)}

count = []
count[0] = 0
(1..n-1).each do |i|
  if s[i-1..i] == "AC" then
    count[i] = count[i-1] + 1
  else
    count[i] = count[i-1]
  end
end

lr.each do |l,r|
  p count[r-1] - count[l-1]
end

Measured memory_bytes: 15688
h,w,m=map(int,input().split())

xsct=[0]*w
ysct=[0]*h
ips=set()
for _ in range(m):
    y,x=map(int,input().split())
    x,y=x-1,y-1
    xsct[x]+=1
    ysct[y]+=1
    ips.add((x,y))

xsmx=max(xsct)
ysmx=max(ysct)

xs=[x for x in range(w) if xsct[x]==xsmx]
ys=[y for y in range(h) if ysct[y]==ysmx]

ans=xsmx+ysmx-1
ok=False
for y in ys:
    for x in xs:
        if (x,y) not in ips:
            ans+=1
            ok=True
            break
    if ok:
        break

print(ans)


Measured memory_bytes: 176704
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string S;
  cin >> S;

  int N = S.size()+1;

  vector<pair<char,int>> v(0);
  int num = 1;
  char ch = S.at(0);
  for(int i = 0;i < N-1;i++) {
    if(i == N-2) {
      ch = S.at(N-2);
      v.push_back(make_pair(ch,num));
      break;
    }

    ch = S.at(i);
    if(S.at(i) == S.at(i+1)) {
      num++;
    }else {
      v.push_back(make_pair(ch,num));
      num = 1;
    }
  }

  int n = v.size();
  long long sum = 0;
  for(int i = 0;i < n-1;i++) {
    if(v.at(i).first == '>' && v.at(i+1).first == '<') continue;
    else if(v.at(i).first == '<' && v.at(i+1).first == '>') {
     long long M = max(v.at(i).second,v.at(i+1).second);
     long long m = min(v.at(i).second,v.at(i+1).second);
     sum += M*(M+1)/2 + m*(m-1)/2;
    }
  }

  if(S.at(0) == '>') sum += (long long)v.at(0).second*(v.at(0).second+1)/2;
  if(S.at(N-2) == '<') sum += (long long)v.at(n-1).second*(v.at(n-1).second+1)/2;


  cout << sum << endl;
}




Measured memory_bytes: 3068
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}

#define BEGIN_STACK_EXTEND(size)                                          \
  void* sem_ = malloc(size);                                              \
  void* seom_;                                                            \
  char* sedm_ = (char*)alloca((1 + (int)(((long long)sem_) & 127)) * 16); \
  *sedm_ = 0;                                                             \
  asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp"                       \
               : "=b"(seom_)                                              \
               : "a"((char*)sem_ + (size) - 1024));
#define END_STACK_EXTEND                         \
  asm volatile("mov %%rax, %%rsp" ::"a"(seom_)); \
  free(sem_);

//{{{ graph.hpp
#ifndef INCLUDE_GRAPH_HPP
#define INCLUDE_GRAPH_HPP
#include <vector>
#include <climits>
namespace orliv {
namespace graph {
struct Edge {
  typedef int weight_type;
  static constexpr weight_type INF =
      std::numeric_limits<weight_type>::max() - 100;

  int from, to;
  weight_type w;
  Edge(int from, int to, weight_type w = 1) : from(from), to(to), w(w) {}
  bool operator<(const Edge& rhs) const {
    if (w != rhs.w) return w > rhs.w;
    if (from != rhs.from) return from < rhs.from;
    return to < rhs.to;
  }
};

typedef Edge::weight_type Weight;
typedef std::vector<Edge> Edges;
typedef std::vector<Weight> Weights;
typedef std::vector<int> Path;
}
typedef std::vector<graph::Edges> Graph;
}
#endif
//}}}
//{{{ diameter.cc
#ifndef INCLUDE_GRAPH_HPP
#include "graph.hpp"
#endif

namespace orliv {
namespace graph {

namespace diameter_internal {
std::pair<Weight, int> dfs(const Graph& g, int v, int p = -1) {
  std::pair<Weight, int> r(0, ~v);
  for (const auto& e : g[v]) {
    if (e.to == p) continue;
    auto rr = dfs(g, e.to, v);
    rr.first += e.w;
    r = std::max(r, rr);
  }
  return r;
}
}

std::pair<Weight, std::pair<int, int>> diameter(const Graph& g, int v = 0) {
  auto r = diameter_internal::dfs(g, v);
  auto rr = diameter_internal::dfs(g, ~r.second);
  auto p = std::make_pair(~r.second, ~rr.second);
  if (p.first > p.second) std::swap(p.first, p.second);
  return std::make_pair(rr.first, p);
}
}
}
//}}}

using namespace std;

int f(const orliv::Graph& g) {
  BEGIN_STACK_EXTEND(128 * 1024 * 1024);
  auto r = orliv::graph::diameter(g);
  END_STACK_EXTEND;
  return r.first;
}

typedef long long ll;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}

int main() {
  int N = in();
  orliv::Graph g(N);
  for (int i = 0; i < N - 1; i++) {
    int s = in(), t = in(), w = in();
    g[s].emplace_back(s, t, w);
    g[t].emplace_back(t, s, w);
  }
  cout << f(g) << endl;
  return 0;
}

Measured memory_bytes: 17840
import java.util.Scanner;

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

Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    ll n,m;
    cin >> n >> m;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    ve<ll> s(n+1);
    map<ll,ll> mo;
    s[0] = 0;
    rep(i,n){
        s[i+1] = s[i] + a[i];
        s[i+1] %= m;
        mo[s[i+1]]++;
    }
    mo[0]++;
    ll ans = 0;
    for(P x: mo){
        ll cnt = x.second;
        ans += (cnt-1) * cnt / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8700