akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
ll H[MAX_N];

int main()
{
	int n,k;
	cin >> n >> k;
	rep(i,n)
	{
		cin >> H[i];
	}
	sort(H,H+n);
	ll sum = 0;
	rep(i,n-k)
	{
		sum += H[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 5164
import io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val buf = StringBuilder.newBuilder
  s.foreach( _ match {
    case '0' => buf.append("0")
    case '1' => buf.append("1")
    case 'B' => if(!buf.isEmpty) buf.deleteCharAt(buf.length-1)
  })
  val ans = buf.toString
  println(ans)
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  rep(i, n) sort(s[i].begin(), s[i].end());
  map<string, int> mp;
  rep(i, n) ++mp[s[i]];
  ll ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ans += (ll)(*itr).second * ((*itr).second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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



int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i = 0; i<m;i++){
    cin >> a.at(i);
  }
  vector<long int> dp(n+1, 10000000009);
  dp.at(0) = 1;
  dp.at(1) = 1;
  for(int i = 0; i <m;i++){
    dp.at(a.at(i)) = 0;
  }
  for(int i = 2;i< n+1;i++){
    long int tmp = (dp.at(i-2) + dp.at(i-1)) % 1000000007;
    if(tmp < dp.at(i)) dp.at(i) = tmp;
  }
  cout << dp.at(n);
}

Measured memory_bytes: 1408
N = int(input())

def max_div(n):
    maximum = 0
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            maximum = i
    return maximum

P = max_div(N)
Q = N // P

print((P - 1) + (Q - 1))

Measured memory_bytes: 3068
import math

A, B, C, D = list(map(int, input().split()))

number_of_turns_takahsi = math.ceil(C / B)
number_of_turns_aoki = math.ceil(A / D)
# print(number_of_turns_takahsi, number_of_turns_aoki)

answer = 'Yes' if number_of_turns_takahsi <= number_of_turns_aoki else 'No'

print(answer)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int sum=0;
  cin>>a>>b;
  for(int i=a;i<b+1;i++){
    int k=i;
    int c;
    c=k%10*10000;
    k=k/10;
    c=c+k%10*1000;
    k=k/10;
    c=c+k%10*100;
    k=k/10;
    c=c+k%10*10;
    k=k/10;
    c=c+k%10;
    if(i==c){
      sum++;
    }
    else{
    }
  }
  cout<<sum<<endl;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans;
  if(a == b and b == c)ans =1 ;
  else if(a != b and b != c and c != a)ans = 3;
  else ans = 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DISP(x) for(auto _x: x) cout << _x << " "; cout << endl;
#define ALL(x) (x).begin(),(x).end()

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &_a : a) cin >> _a;
    sort(a.begin(), a.end());
    int maxe = *max_element(ALL(a));
    vector<int> y(maxe + 1, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = a[i]; j <= maxe; j += a[i]) {
            y[j]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (y[a[i]] == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8012
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<list>

using namespace std;


/*
//1
int main(){
	for(int i=0; i<7;i++){
		int a, b;
		cin >> a >> b;
		cout << a- b << endl;

	}

	return 0;
}
*/

/*
//2
int main(){
	int t[4] = {6000, 4000, 3000, 2000};
	for(int i=0; i<4; i++){
		int T,n;
		cin >> T >> n;
		T--;
		cout << t[T]*n << endl;
	}

	return 0;
}
*/


//3
int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		
		if(b >= 5 && p >= 2){
			int ans = (b*x + p*y)*0.8;
			cout << ans << endl;
		}
		else if(b >= 5 && p < 2){
			int ans = (b*x + 2*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
		else if(b < 5 && p >= 2){
			int ans = (5*x + p*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
		else{
			int ans = (5*x + 2*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
	}

	return 0;
}


/*
//4
int main(){


	return 0;
}
*/

/*
//5
int main(){


	return 0;
}
*/

/*
//6
int main(){
	int Q;
	cin >> Q;
	for(int i=0; i<Q; i++){
		int c,a,n;
		cin >> c >> a >> n;
		int ans = 0;
		while(c != 0 && a != 0 && n != 0){
			c--;
			a--;
			n--;
			ans++;
		}
		while(c >= 2 && a >= 1){
			c -= 2;
			a--;
			ans++;
		}
		while(c >= 3){
			c -= 3;
			ans++;
		}
		cout << ans << endl;
	}

	return 0;
}
*/

/*
//7
int main(){


	return 0;
}
*/

/*
//8
int main(){


	return 0;
}
*/

/*
//9
int main(){


	return 0;
}
*/

/*
//10
int main(){


	return 0;
}
*/




Measured memory_bytes: 3116
/*
 * 2330.cc: Earth Invasion Diary of Miyabi-sensei
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  int c = 0;
  ll e = 1;
  while (e < n) e *= 3, c++;

  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}

typedef struct{
  long long xz;
  long long yz;
}point;

point vector_plus(point a,point b){
  point r;
  r.xz=a.xz+b.xz;
  r.yz=a.yz+b.yz;
  return r;
}

point vector_minus(point a,point b){
  point r;
  r.xz=a.xz-b.xz;
  r.yz=a.yz-b.yz;
  return r;
}

//naiseki
long long dotproduct(point a,point b){
  return a.xz*b.xz+a.yz*b.yz;
}

//gaiseki
long long crossproduct(point a,point b){
  return a.xz*b.yz-a.yz*b.xz;
}

long long basedist(point a,point b){
  double x,y;
  x=b.xz-a.xz;
  y=b.yz-a.yz;
  return x*x+y*y;
}

double baselen(point a){
  return sqrt(a.xz*a.xz+a.yz*a.yz);
}

point base;

int vecsortfnc(const void *a,const void *b){
  double pa,pb;
  point va,vb;
  va.xz=(((point*)a)->xz);
  va.yz=(((point*)a)->yz);
  vb.xz=(((point*)b)->xz);
  vb.yz=(((point*)b)->yz);
  pa=crossproduct(base,va);
  pb=crossproduct(base,vb);
  if(pa>0&&pb<0){
    //printf("%lld %lld < %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
    return -1;
  }
  if(pa<0&&pb>0){
    //printf("%lld %lld > %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
    return 1;
  }
  if(pa>0){
    pa=dotproduct(base,va)*baselen(vb);
    pb=dotproduct(base,vb)*baselen(va);
    //printf("<%lld %lld>\n",pa,pb);
    if(pa>pb){
      //printf("%lld %lld < %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
      return -1;
    }
    if(pa<pb){
      //printf("%lld %lld > %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
      return 1;
    }
    //printf("%lld %lld == %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
    return 0;
  }
  else{
    pa=dotproduct(base,va)*baselen(vb);
    pb=dotproduct(base,vb)*baselen(va);
    //printf("[%lld %lld]\n",pa,pb);
    if(pa>pb){
      //printf("%lld %lld > %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
      return 1;
    }
    if(pa<pb){
      //printf("%lld %lld < %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
      return -1;
    }
    //printf("%lld %lld == %lld %lld\n",va.xz,va.yz,vb.xz,vb.yz);
    return 0;
  }
}

int main(void){
  long long i,j,n,m,k,a,b,c,h,w,r=0,l,t,st,fi;
  double res=0.0;
  point pts[2048],mp[2048];
  scanf("%lld",&n);
  c=0;
  for(i=0;i<n;i++){
    scanf("%lld%lld",&pts[c].xz,&pts[c].yz);
    mp[c]=pts[c];
    if(pts[c].xz==0 && pts[c].yz==0){c--;}
    c++;
  }
  base.xz=mod;
  base.yz=1;
  if(c==0){printf("%.12lf\n",0.0);return 0;}
  for(t=0;t<1;t++){
    //base=mp[t];
    qsort(pts,c,sizeof(pts[0]),vecsortfnc);
    for(i=0;i<c;i++){
      a=0;b=0;
      for(j=0;j<c;j++){
        a+=pts[(i+j)%c].xz;
        b+=pts[(i+j)%c].yz;
        res=dbmax(sqrt(a*a+b*b),res);
      }
    }
  }
  printf("%.12lf\n",res);
  return 0;
}


Measured memory_bytes: 252
(let ((a (read))
    (b (read))
    (k (read))
    (times 0))

    (loop for i from (min a b) downto 1 do
        (if (and (zerop (rem a i)) (zerop (rem b i)))
            (progn
                (incf times)
                (if (= k times)
                    (progn
                        (princ i)
                        (return)
                    )
                )
            )
        )
    )
)

Measured memory_bytes: 24272
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if N%2 == 1:
    ans = B[N//2] - A[N//2] + 1
else:
    a = A[N//2-1] + A[N//2]
    b = B[N//2-1] + B[N//2]
    ans = b - a + 1

print(ans)

Measured memory_bytes: 25456
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int i,x[300010],y[3000010],a[300010],b[300010],n,q,ans=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d ",&a[i]);
    b[i]=a[i];
  }
  sort(b,b+n);
  scanf("%d\n",&q);
  for(i=0;i<q;i++){
    scanf("%d %d\n",&x[i],&y[i]);
    x[i]--,y[i]--;
  }
  for(i=0;i<n;i++){
    if(a[i]!=b[i]){
      ans++;
    }
  }
  if(ans==0){
    printf("0\n");
    return 0;
  }
  for(i=0;i<q;i++){
    int res=0,res1=0;
    if(a[x[i]]==b[x[i]]){
      res++;
    }
    if(a[y[i]]==b[y[i]]){
      res++;
    }
    swap(a[x[i]],a[y[i]]);
    if(a[x[i]]==b[x[i]]){
      res1++;
    }
    if(a[y[i]]==b[y[i]]){
      res1++;
    }
    ans+=res-res1;
    if(ans==0){
      printf("%d\n",i+1);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}   


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

const int INF = 1e9;
int N, M;
vector<int> D, C;

int dfs(int i, int j) {
  static vector<vector<int>> memo(N, vector<int>(M, INF));
  if(i == N) return 0;
  if(M-j < N-i) return INF;
  if(memo[i][j] != INF) return memo[i][j];
  return memo[i][j] = min(dfs(i, j+1), D[i]*C[j] + dfs(i+1, j+1));
}

int main() {
  cin >> N >> M;
  D.resize(N);
  C.resize(M);
  for(auto v: {&D, &C}) for(auto& i: *v) cin >> i;
  cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 5988
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	int cnt = 0;
	for (int i = 2; i < n; i++)
	{
		vector<int> b(3);
		for (int j = 0; j < 3; j++)
		{
			b.at(j) = a.at(i - j);
		}

		sort(b.begin(), b.end());
		if (a.at(i - 1) == b.at(1))
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys, collections, bisect, math, itertools
from fractions import gcd 
#input = sys.stdin.readline #文字列入力のときは注意

m = int(input())
#s = input()
#a = [int(i) for i in input().split()]
a = [int(input()) for j in range(m+1)] # 縦「n」行

beki = 0
while a[-1] == 0:
    a.pop()
    beki+=1
if m != len(a)-1:
    m = len(a)
    a.append(0)


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
allprimes = get_sieve_of_eratosthenes(10010)

primes=[]
def get_sieve_of_eratosthenes2():
    prime = []
    data = [i + 1 for i in range(1, 35000)]
    c=abs(a[m])
    while True:
        p = data[0]
        if 10**9 <= p*p:
            return prime + data
        if c%p==0: primes.append(p)
        prime.append(p)
        data = [e for e in data if e % p != 0]

primes2=[]
def get_sieve_of_eratosthenes3():
    prime = []
    data = [i + 1 for i in range(1, 35000)]
    c=abs(a[0])
    while True:
        p = data[0]
        if 10**9 <= p*p:
            return prime + data
        if c%p==0: primes2.append(p)
        prime.append(p)
        data = [e for e in data if e % p != 0]


get_sieve_of_eratosthenes2()
get_sieve_of_eratosthenes3()
if len(primes) == 0 and abs(a[m]) != 1:
    primes.append(abs(a[m]))
if a[m]==0:
    primes = allprimes
if len(primes2) == 0 and abs(a[0]) != 1 and abs(a[0]) not in primes:
    primes2.append(abs(a[0]))
n=m


primes = sorted(list(set(primes + primes2)))
#print(a)
#print(primes)
for p in primes:
    if p > 10**4+5:
        if sum([i%p for i in a]) == 0:
            print(p)
        continue
    coeff = list(reversed(a))
    while len(coeff) > p:
#        print(coeff,p)
        t=coeff.pop()
        coeff[-p+1]+=t
            
#    print(coeff)
    if sum([i%p for i in coeff]) == 0:
        print(p)
        
        
        
    












Measured memory_bytes: 85972
n, m, l = map(int, input().split())
a = []
b = []
c = []
for i in range(n):
    c.append([0 for k in range(l)])
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(list(map(int, input().split())))
for s in range(n):
    for t in range(l):
        elm = 0
        for u in range(m):
            elm += a[s][u] * b[u][t]
        c[s][t] = elm
for i in c:
    print(" ".join(map(str, i)))


Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ll a; int b1, b2;
    scanf("%lld %d.%d", &a, &b1, &b2);
    ll b = b1*100 + b2;
    ll ans = a * b;
    ans /= 100;
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int w,a,b;
  cin >> w >> a >> b;

  if((a<=b && b<=a+w) || (a<=b+w && b+w<=a+w)) cout << 0 << endl;
  else if(abs(b-(a+w))<=abs(a-(b+w))) cout << abs(b-(a+w)) << endl;
  else cout << abs(a-(b+w)) << endl;
  return 0;
} 

Measured memory_bytes: 3540
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    long N;
    cin>>N;
    
    
    long count=0;
    for(int i=1;i<=N;i++){
        long p;
        cin>>p;
        
        if(p!=i) count++;
    }
    
    if(count<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
l=[-1]*N
a=[]
for i in range(M):
    s,c=map(int,input().split())
    if l[s-1]!=c and l[s-1]!=-1:
        a=-1
        break
    l[s-1]=c
else:
    for i in range(N):
        if l[i]==-1 and i:
            a.append(0)
        elif l[i]==-1:
            if N>1:
                a.append(1)
            else:
                a.append(0)
        else:
            a.append(l[i])
if a==-1:
    print(a)
elif a[0]==0 and N>1:
    print(-1)
else:
    print(*a,sep="")     

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int X = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();
    Arrays.sort(a);

    long[][] dp = new long[2][X + 1];
    for (int i = 0; i <= X; i++) dp[0][i] = i;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= X; j++) {
        int k = i % 2;
        dp[k][j] = (long) (i - 1) * dp[1 - k][j] % M;
        dp[k][j] += dp[1 - k][j % a[i - 1]];
        dp[k][j] %= M;
      }
    }
    System.out.println(dp[N % 2][X]);
  }
}


Measured memory_bytes: 25556
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    vector<int> a;
    int q, query, tmp;
    cin >> q;
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> tmp;
                a.push_back(tmp);
                break;
            case 1:
                cin >> tmp;
                cout << a[tmp] << endl;
                break;
            case 2:
                a.pop_back();
                break;
        }
    }
}


Measured memory_bytes: 3904
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	int i, max;
	string str[1000];
	cin >> max; getchar();
	for(i = 0; i < max; i++)
		getline(cin, str[i]);

	for(i = 0; i < max; i++)
	{
		string::size_type pos(str[i].find("Hoshino"));
		while(pos != string::npos)
		{
			str[i].replace(pos, strlen("Hoshina"), "Hoshina");
			pos = str[i].find("Hoshino", pos + strlen("Hoshina"));
		}
		cout << str[i] << endl;
	}
}

Measured memory_bytes: 1224
N, M = map(int, input().split())
results = [input().split() for _ in range(M)]
solved = set()
missed = dict()
penalty = 0

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p] if p in missed else 0
    else:
        missed[p] = missed[p] + 1 if p in missed else 1

print(len(solved), penalty)

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


int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int x,n;
        cin>>x>>n;

        if( n==0 )
        {
            cout<<x;
            return 0;
        }

        bool arr[200]={0};

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

        if( !arr[x] )
        {
            cout<<x;
            return 0;
        }
        int la=-1;
        int ra=-1;
        int l,r;
        for( int left=x-1 ; left>=0 ; left-- )
        {
            if( !arr[left] )
            {
                l=left;
                la=x-l;
                break;
            }
        }

        for( int right=x+1 ; right<=101 ; right++ )
        {
            if( !arr[right] )
            {
                r=right;
                ra=r-x;
                break;
            }
        }

        if( la<=ra )
            cout<<l;
        else
            cout<<r;

    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]){
            printf("%d %d\n", i+1, i+2);
            return 0;
        }
    }

    for(int i=0; i<s.size()-2; i++){
        if(s[i] == s[i+2]){
            printf("%d %d\n", i+1, i+3);
            return 0;
        }
    }

    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
long long a[5];
int main()
{     cin>>a[1]>>a[2]>>a[3];
      sort(a+1,a+4);
      cout<<a[1]+a[2]<<endl;
	  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  cout << string(s.length(), 'x') << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		int N = int.Parse(line[0]);
		int K = int.Parse(line[1]);

		//バケツ
		bool[] bucket = new bool[N];

		//読み込み
		for(int i=0; i<K; i++){
				int di = int.Parse(Console.ReadLine());
				int[] Ai = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
				foreach(int num in Ai){
						bucket[num-1] = true;
				}
		}

		//カウント
		int cnt = 0;
		foreach(bool has in bucket){
				if(!has){
						cnt ++;
				}
		}

		Console.WriteLine(cnt);

	}
}



Measured memory_bytes: 19476
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

struct Node;

using NodePtr = shared_ptr<Node>;

struct Node {
  NodePtr parent;

  // additional properties
  set<int> friends;
  set<int> blocks;
  int size;
};

struct DisjointSet {
  map<int, NodePtr> nodes;

  void make_set (int i) {
    NodePtr node = make_shared<Node>();
    nodes.insert(make_pair(i, node));
    node->parent = node;
    node->size = 1;
  }

  void unite (int ix, int iy) {
    NodePtr x = nodes.at(ix);
    NodePtr y = nodes.at(iy);
    NodePtr xRoot = find(x);
    NodePtr yRoot = find(y);

    if (xRoot == yRoot) return;

    xRoot->parent = yRoot;
    yRoot->size = yRoot->size + xRoot->size;
  }

  NodePtr find (NodePtr x) {
    if (x->parent == x) {
      return x;
    } else {
      // with path compression
      NodePtr root = find(x->parent);
      x->parent = root;
      return root;
    }
  }

  bool compare (int ix, int iy) {
    NodePtr x = nodes.at(ix);
    NodePtr y = nodes.at(iy);
    return find(x) == find(y);
  }

  // additional properties
  NodePtr get_node (int i) {
    return nodes.at(i);
  }
};

/**
 * main
 */
int main () {
  DisjointSet djs;

  int N, M, K;

  cin >> N >> M >> K;

  for (size_t i = 1; i <= N; i++) {
    djs.make_set(i);
  }

  // friend
  for (size_t i = 2; i <= 1 + M; i++) {
    int a, b;
    cin >> a >> b;
    djs.unite(a, b);

    djs.get_node(a)->friends.insert(b);
    djs.get_node(b)->friends.insert(a);
  }

  // block
  for (size_t i = 1 + M + 1; i <= 1 + M + K; i++) {
    int c, d;
    cin >> c >> d;

    djs.get_node(c)->blocks.insert(d);
    djs.get_node(d)->blocks.insert(c);
  }

  for (size_t i = 1; i <= N; i++) {
    NodePtr node = djs.get_node(i);
    NodePtr root = djs.find(node);

    int n_friends = 0;
    for (int fred : node->friends) {
      if (djs.compare(i, fred)) n_friends++;
    }

    int n_blocks = 0;
    for (int block : node->blocks) {
      if (djs.compare(i, block)) n_blocks++;
    }

    int n = root->size - n_friends - n_blocks - 1;

    printf("%d%c", n, (i == N) ? '\n' : ' ');
  }
}


Measured memory_bytes: 41600
//created by pyoxiao on 2020/04/26
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
map<string, int> st;
int n;
string s;
void solve() {
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> s;
        st[s] ++;
    }
    cout << st.size() << '\n';
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 19216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,b,a) for(int i = (b); i --> int(a);)
#define trav(i,v) for(auto&i:v)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pii> a(n);
	vector<long long> ans(n);
	rep(i,0,n){
		int k;
		cin >> k;
		a[i] = {k,i};
	}
	a.emplace_back(0,-1);
	sort(all(a));
	int mn = 1e9;
	rrep(i,sz(a),1){
		if(a[i].first == a[i-1].first) continue;
		mn = min(mn,a[i].second);
		ans[mn] += ll(a[i].first-a[i-1].first)*ll(sz(a)-i);
	}
	trav(i,ans) cout << i << endl;
}

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

using namespace std;

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

    for (int i = 0; i + 1 < s.length(); ++i) {
        if (s.substr(i, 2) == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 2000005
int fac[N],inv[N];
const int mod=1000000007;
void shai()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=2000000;i++){
		fac[i]=1ll*i*fac[i-1]%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	}
	for(int i=2;i<=2000000;i++)
		inv[i]=1ll*inv[i]*inv[i-1]%mod;
}
int C(int x,int y){return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;}
int ab(int x){return x<0?-x:x;}
int G(int x1,int y1,int x2,int y2){return C(ab(x1-x2)+ab(y1-y2),ab(x1-x2));}
int X[7],Y[7];
int F(int x,int y,int flg)// A point to a rectangle
{
	if(flg==1)
		return 1ll*(1ll*G(x,y,X[2],Y[2])+1ll*mod-1ll*G(x,y,X[1]-1,Y[2])+1ll*mod-1ll*G(x,y,X[2],Y[1]-1)+1ll*G(x,y,X[1]-1,Y[1]-1))%mod;
	else
		return 1ll*(1ll*G(x,y,X[5],Y[5])+1ll*mod-1ll*G(x,y,X[6]+1,Y[5])+1ll*mod-1ll*G(x,y,X[5],Y[6]+1)+1ll*G(x,y,X[6]+1,Y[6]+1))%mod;
}
int main()
{
	int i,ans=0,x,y;shai();
	for(i=1;i<=6;i++)scanf("%d",&X[i]);
	for(i=1;i<=6;i++)scanf("%d",&Y[i]);
	for(x=X[3];x<=X[4];x++){
		ans=(1ll*ans+1ll*F(x,Y[4],1)*F(x,Y[4]+1,3)%mod*(x+Y[4]+1)%mod)%mod;
		ans=(1ll*ans-1ll*F(x,Y[3]-1,1)*F(x,Y[3],3)%mod*(x+Y[3])%mod+mod)%mod;
	}
	for(y=Y[3];y<=Y[4];y++){
		ans=(1ll*ans+1ll*F(X[4],y,1)*F(X[4]+1,y,3)%mod*(y+X[4]+1)%mod)%mod;
		ans=(1ll*ans-1ll*F(X[3]-1,y,1)*F(X[3],y,3)%mod*(y+X[3])%mod+mod)%mod;
	}
	printf("%d",ans);
}

Measured memory_bytes: 15872
n = int(input())
A = [int(x) for x in input().split()]
l = []

a = 0
for i in reversed(A):
    a += i
    l.append(a)
l.pop(n-1)
ans = 0

l.reverse()
for i in range(n-1):
    ans += (A[i]*l[i])
print(ans%(10**9+7))


Measured memory_bytes: 102288
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________

	int n, x, y;
	cin >> n >> x >> y;
	//cout << x << y << en;
	int d[n] = {0};
	rep(i, 1, n)
	{
		rep(j, i + 1, n)
		{
			int yy = j - i;
			int xx = min(yy, min(abs(x - i) + 1 + abs(y - j), abs(y - i) + abs(x - j) + 1));
			/*if (i == 2 && j == 4)
			{
				cout << x << en;
				cout << x - i << en;
				cout << abs(x - i) << en;
				cout << y - j << en;
				cout << abs(y - j) + abs(x - i) + 1 << en;
				cout << abs(x - i) + abs(y - j) + 1 << en;
				cout << min(abs(x - i) + 1 + abs(y - j), abs(y - i) + abs(x - j) + 1) << en;
				cout << min(yy, min(abs(x - i) + 1 + abs(y - j), abs(y - i) + abs(x - j) + 1)) << en;
			}
			cout << "(" << i << "," << j << ")" << " ->" << x << en;*/
			d[xx]++;
		}
	}
	rep(i, 1, n - 1)
	{
		cout << d[i] << en;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, a[200];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    int k = 0;
    rep(i, 0, n) {
        cin >> a[i];
    }
    k = a[0];
    int cnt = 0;
    rep(i, 1, n) k = gcd(k, a[i]);
    if (k%2) {
        cout << 0 << endl;
    } else {
        while (k > 0) {
            k/=2;
            cnt++;
        }
        printf("%d\n", cnt-1);
    }
    return 0;
}


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

using namespace std;

void solve(int N, vector<int> a) {
  sort(a.rbegin(), a.rend());

  int alice = 0;
  int bob = 0;
  rep(i, N) {
    if (i % 2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }

  cout << (alice - bob) << endl;
}

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

  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  solve(N, move(a));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0,d=0,e=0,f=0,g=0;cin>>a;
  string b;
  rep(i,a){
    cin>>b;
     if(b.at(b.size()-1)=='A'&&b.at(0)=='B')e++;
    else if(b.at(0)=='B')f++;
    else if(b.at(b.size()-1)=='A')g++;
    for(int o=0;o<b.size()-1;o++){
      if(b.at(o)=='A'&&b.at(o+1)=='B')c++;
    }
  }
  if(e>=1&&f==0&&g==0)c--;
  cout<<c+min(e+g,f+e);
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc110/tasks/abc110_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

// 素因数分解
map<ll, int> enumpr(ll n) {
    map<ll, int> V;

    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            V[i]++;
            n /= i;
        }
    }
    if (n > 1)
        V[n]++;
    return V;
}

ll modpow(ll a, ll n) {
    ll r = 1;
    while (n)
        r = r * ((n % 2) ? a : 1) % MOD, a = a * a % MOD, n >>= 1;
    return r;
}

// 組み合わせを求める。n C k
ll comb(int P_, int Q_) {
    if (P_ < 0 || Q_ < 0 || Q_ > P_)
        return 0;
    ll p = 1, q = 1;
    Q_ = min(Q_, P_ - Q_);
    for (int i = 1; i <= Q_; i++)
        p = p * P_ % MOD, q = q * i % MOD, P_--;

    return p * modpow(q, MOD - 2) % MOD;
}
// 重複組み合わせを求める。n H k = (n + k - 1) C k
ll hcomb(int P_, int Q_) {
    return (P_ == 0 && Q_ == 0) ? 1 : comb(P_ + Q_ - 1, Q_);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    auto mp = enumpr(m);

    ll ans = 1;
    for (auto x : mp) {
        ans = (ans * hcomb(n, x.second)) % MOD;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, K; cin >> N >> K;
  vll a(N); FOR(i,N){ cin >> a[i]; a[i]--; a[i] %= K; }
    
  //main
  ll ans = 0;
  vll s(N+1); s[0] = 0; FOR(i,N){ s[i+1] = (s[i]+a[i])%K; }
  //FOR(i,N+1){ cout << s[i]; } cout << endl;
  
  map<ll,ll> mp;
  FOR(i,N+1){
    mp[s[i]] ++;
    if(i>=K){
      mp[s[i-K]] --; 
    }
    ans += (mp[s[i]]-1);
    //cout << (mp[s[i]]-1) << endl;
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  char tmp = 'A';
  int count = 0;
  rep(i,s.size()) {
    if(tmp != s.at(i)) count++;
    tmp = s.at(i);
  }

  cout << count << endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int D;
    cin>>D;
    int c[26];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    map<int,int> m;
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            map<int,int> ma=m;
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    ma[k]=0;
                }else{
                    ma[j]++;
                    a-=ma[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                m[y]=0;
            }else{
                m[j]++;
                ans-=m[j]*c[j];
            }
        }
        y++;
        cout << y <<endl;
    }


    



}


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

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

    int n;
    string s,t;
    string res;

    cin >> n;
    cin >> s >> t;
    
    int idx1 = 0;
    int idx2 = 0;

    for(int i=0;i<2*n;i++)
    {
    	if(i%2==0)
    	{
    		res += s[idx1++];
    	}
    	else
    	{
    		res += t[idx2++];
    	}
    }

    cout << res << '\n';

    return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> bs;
    bs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(bs));

    vector<ll> ans;
    while (bs.size() > 0) {
        // 値と位置番号が一致しているもで一番右にあるものを探す
        auto it = find_if(rbegin(bs), rend(bs),
            [i = (ll)bs.size()](auto n) mutable {
                return i-- == n;
            });
        if (it == rend(bs)) {
            // 見つからなければ、達成不可能
            cout << -1 << "\n";
            return;
        }

        // 答えに追加し、配列から削除
        ans.push_back(*it);
        bs.erase((++it).base());
    }

    // 逆順なのでリバースイテレータで出力
    copy(rbegin(ans), rend(ans), ostream_iterator<ll>(cout, "\n"));
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    int ans = 0;
    for (int i = 1; i*i <= m; i++)
    {
        if (m%i==0)
        {
            if (i <= m/n)
            {
                ans = max(ans,i);
            }
            if (m/i <= m/n)
            {
                ans = max(ans, m/i);
            }
            
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        int total = 0;
        for (int i = 0 ; i < n ; i++) {
            s[i] = sc.nextInt();
            total += s[i];
        }
        Arrays.sort(s);

        if (total % 10 != 0) {
            System.out.println(total);
        } else {
            for (int i = 0 ; i < n ; i++) {
                int temp = total - s[i];
                if (temp % 10 != 0 ) {
                    System.out.println(temp);
                    return;
                }
            }
            System.out.println(0);
        }

    }

}

Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main(void)
{
	int A, B;
	int add, sub, mul;
	cin >> A >> B;
	add = A + B;
	sub = A - B;
	mul=A *B;
	if (add >= sub && add >= mul)cout << add << endl;
	else if (sub >= add && sub >= mul)cout << sub<<endl;
	else {
		cout << mul<<endl;
	}

}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
list1 = [list(map(int,input().split())) for i in range(n)]
count = 0
for a in range(n):
  for b in range(a+1,n):
    x = 0
    for j in range (d):
      x = x + (list1[a][j] -list1[b][j])**2
    x = math.sqrt(x)
    if x == int(x):
      count +=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
double x[10], y[10], l[10];

double search(double X, double Y){
	double res = 1e+9;
	for(int i = 0; i < n; i++){
		double h = l[i] * l[i] - ((X - x[i]) * (X - x[i])) - ((Y - y[i]) * (Y - y[i]));
		res = min(res, h);
	}
	return res;
}

double searchY(double X){
	double left = -100.0, right = 100.0;
	for(int i = 0; i < 200; i++){
		double mid1 = (2 * left + right) / 3;
		double mid2 = (left + 2 * right) / 3;
		if( search(X, mid1) > search(X, mid2) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return search(X, left);
}

double searchXY(double left = -100.0, double right = 100.0){
	for(int i = 0; i < 200; i++){
		double mid1 = (2 * left + right) / 3;
		double mid2 = (left + 2 * right) / 3;
		if( searchY(mid1) > searchY(mid2) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return searchY(left);
}

int main(){
	while( cin >> n , n ){
		for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> l[i];
		double ans = sqrt(searchXY());
		printf("%.07f\n", ans);
	}
}

Measured memory_bytes: 1248
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int in[120];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&in[i]);
	}
	sort(in+1,in+1+n);
	if(in[1]==in[n])cout<<0<<endl;
	else
	{
		int sum;
		int ans=-1;
		for(int i=in[1];i<=in[n];i++)
		{
			sum=0;
			for(int j=1;j<=n;j++)
			{
				sum+=(i-in[j])*(i-in[j]);
			}
			if(ans==-1)ans=sum;
			else
			{
				ans=min(ans,sum);
			}
		}
		cout<<ans<<endl;
		
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = input()
if a.isupper():
    print('A')
else:
    print('a')


Measured memory_bytes: 65108
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<functional>
#include<set>
using namespace std;
#define MAX 10000000

int main(){
    int a,b,c;
    int ans=0;
    cin>>a>>b>>c;
    if(a==b)cout<<c;
    else if(a==c)cout<<b;
    else cout<<a;

    return 0;
}

Measured memory_bytes: 256
/*
  AOJ 2134
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <float.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define ONE_SIXTH (1.0/6.0)

double prob_table[21][12001];

void dice1(double p_after[],double p_before[],int turn)
{
  int i,j;
  for(i=0;i<=12000;i++)
    p_after[i]=0.0;
  for(i=turn;i<=6*turn;i++)
    for(j=1;j<=6;j++)
      p_after[i+j] += ONE_SIXTH * p_before[i];
}



void init()
{
  int i,j,k;
  double prob1[12001];
  double prob2[12001];

  prob1[0]=1.0;
  for(i=1;i<=12000;i++)
    prob1[i]=0.0;
  memcpy(&prob_table[0][0],prob1,sizeof(double)*12001);

  for(i=0;i<20;i++)
    {
      //printf("i=%d\n",i);
      for(j=0;j<100;j++)
	{
	  dice1(prob2,prob1,i*100+j);
	  memcpy(prob1,prob2,sizeof(double)*12001);
	}
	
      memcpy(&prob_table[i+1][0],prob1,sizeof(double)*12001);

      //for(k=0;k<=12000;k++)
      //if(prob_table[i+1][k]!=0.0)
      //printf("%d:%lg\n",k,prob_table[i+1][k]);
    }
}

void prepare(double prob[],int n)
{
  int i;
  double probw1[12001];
  memcpy(probw1,&prob_table[n/100][0],sizeof(double)*12001);
  memcpy(prob  ,&prob_table[n/100][0],sizeof(double)*12001);
  for(i=0;i<(n%100);i++)
    {
      dice1(prob,probw1,(n/100)*100+i);
      memcpy(probw1,prob,sizeof(double)*12001);
    }
}
main()
{
  int n,t,i,j;
  char color[2001];
  double prob[12001];
  double max_,p;

  init();
  
  while(scanf("%d %d",&n,&t) && (n||t))
    {
      scanf("%s",color);
      prepare(prob,t);
      /*
      for(j=10;j<20;j++)
	printf("[%d] %g\n",j,prob[j]);
      */
      max_=0.0;
      for(i=0;i<n;i++)
	{
	  for(p=0.0,j=t;j<=t*6;j++)
	    if(color[(i+j)%n]=='R')
	      {
		//printf("%d %lf[%d]\n",j,prob[(i+j)%n],(i+j)%n);
		p += prob[j];
	      }
	  max_=max(max_,p);
	}
      printf("%.9lf\n",max_);
    }
  return(0);
}

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

int main(){
long long n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
cout<<(b-a)/2<<endl;
  }
  else{
    long long c=min(a,n-b+1);
    cout<<c+(b-a-1)/2<<endl;
  }
}

Measured memory_bytes: 256