akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
 int m,n;
 int i,j;
 int A[100][100];
 int B[100];
 int S[100]={0};

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

 for(i=0;i<m;i++){

   for(j=0;j<n-1;j++){
     scanf("%d ",&A[i][j]);
    }
     scanf("%d\n",&A[i][n-1]);

 }

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

 for(i=0;i<m;i++){
 
  for(j=0;j<n;j++){
    S[i]=S[i]+A[i][j]*B[j];
  }

 }


 for(i=0;i<m;i++){
  printf("%d\n",S[i]);
 }

return 0;

}

Measured memory_bytes: 644
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
	int k,a,b;
	string s;
	
	cin >> k;
	cin >> a >> b;
	
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			s = "OK";
			break;
		}	
		
	}
	
	if(s != "OK") cout << "NG" << endl;


	return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int c[8];
class DICE{
   public:
   void setdice(char a);
};

void DICE::setdice(char a){
   if(a=='S'){
       c[7]=c[1];
       c[1]=c[5];
       c[5]=c[6];
       c[6]=c[2];
       c[2]=c[7];
   }
   else if(a=='W'){
       c[7]=c[1];
       c[1]=c[3];
       c[3]=c[6];
       c[6]=c[4];
       c[4]=c[7];
   }
   else if(a=='N'){
       c[7]=c[1];
       c[1]=c[2];
       c[2]=c[6];
       c[6]=c[5];
       c[5]=c[7];
   }
   else{
       c[7]=c[1];
       c[1]=c[4];
       c[4]=c[6];
       c[6]=c[3];
       c[3]=c[7];
   }
}
int main(void){
   DICE dice;
   int n,a,b;
   for(int i=1;i<=6;i++){
       cin>>c[i];
   }
   cin>>n;
   for(int i=0;i<n;i++){
       cin>>a>>b;
       if(a==c[3] || a==c[4]){
           while(c[1] !=a) dice.setdice('E');
       }
       else{
           while(c[1] !=a) dice.setdice('S');
       }
       dice.setdice('N');
       while(c[1] !=b) dice.setdice('W');
       dice.setdice('S');
       cout<<c[3]<<endl;
   }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

string s;
ll n;

bool isorted(vector<pair<char,ll> >& a){

	For(i,1,a.size()){
		if(a[i].se>a[i-1].se) continue;
		else return 0;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	cin>>s;
	set<ll> f[10];
	ll index = 0;
	for(char c:s){
		f[c-'0'].insert(index++);
	}

	ll ans = 0;

	For(x,0,1000){
		string current = to_string(x);
		if(current.size()==1){
			current = "00" + current;
		}
		if(current.size()==2){
			current = "0" + current;
		}

		vector<pair<char,ll> > indices;
		ll prev = -1;

		For(i,0,3){
			ll c = current[i]-'0';
			if(f[c].size()==0) continue;
			if(f[c].upper_bound(prev)==f[c].end()) continue;

			prev = *f[c].upper_bound(prev);

			indices.pb({c,*f[c].upper_bound(prev)});
			// f[c].erase(f[c].begin());
		}

		if(indices.size()==3){
			ans++;
			// trace(current);
		}

		// for(pair<char,ll> c:indices){
		// 	f[c.fi].insert(c.se);
		// }

	}

	cout<<ans<<endl;






























	
}

Measured memory_bytes: 1664
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = []
for i in range(m):
    p,x = map(int, input().split())
    px.append((p-1,x))

for h in range(m):
    s = 0
    for j in range(n):
        if j == px[h][0]:
            s += px[h][1]
        else:
            s += t[j]
    print(s)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++){
		x = r * x - d;
		cout << x << '\n';
	}
}

Measured memory_bytes: 256
# a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split())
ans = B - A + 1


# 1 to X
def divnum(X, d):
    return X // d


divC = divnum(B, C) - divnum(A - 1, C)
divD = divnum(B, D) - divnum(A - 1, D)
divCD = divnum(B, lcm(C, D)) - divnum(A - 1, lcm(C, D))

print(ans - divC - divD + divCD)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, k;
    cin>>a>>b>>c;
    cin>>k;

    for(int i=0; i<k; i++){
        if(a>=b){
            b=b*2;
            //cout<<"b : "<<b<<endl;
        }else if(b>=c){
            c=c*2;
            //cout<<"c :"<<c<<endl;
        }
    }
    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int gcd(int x, int y) {
    while (y > 0) {
        int temp = y;
        y = x % y;
        x = temp;
    }
    return x;
}

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

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

    vector<int> lgcd(n+1);
    vector<int> rgcd(n+1);
    lgcd[0] = 0;
    rgcd[n] = 0;
    for (int i = 1; i <= n; i++)
    {
        lgcd[i]= gcd(a[i-1],lgcd [i-1]);
        rgcd[n-i]= gcd(a[n-i],rgcd [n-i+1]);
    }
    
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans,gcd(lgcd[i],rgcd[i+1]));
    }
    
    
    cout << ans <<endl;
    return(0);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int int64_t

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

constexpr int N = 100005;
int n;
int x[N];
int y[N];

void za(int* x) {
  static int z[N];
  for (int i = 0; i < n; ++i) {
    z[i] = x[i];
  }
  sort(z, z + n);
  map<int, int> m;
  for (int i = 0, v = 0; i < n; ++i) {
    if (m.find(z[i]) == m.end()) {
      m[z[i]] = v++;
    }
  }
  for (int i = 0; i < n; ++i) {
    x[i] = m[x[i]];
  }
}

int32_t main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  za(x);
  za(y);
  static int ix[N];
  static int iy[N];
  memset(ix, -1, sizeof(ix));
  memset(iy, -1, sizeof(iy));
  UnionFind uf(n + 1);
  for (int i = 0; i < n; ++i) {
    if (ix[x[i]] == -1) {
      ix[x[i]] = i;
    } else {
      uf.unionSet(ix[x[i]], i);
    }
    if (iy[y[i]] == -1) {
      iy[y[i]] = i;
    } else {
      uf.unionSet(iy[y[i]], i);
    }
  }
  static set<int> sx[N];
  static set<int> sy[N];
  for (int i = 0; i < n; ++i) {
    sx[uf.root(i)].insert(x[i]);
    sy[uf.root(i)].insert(y[i]);
  }
  int v = 0;
  for (int i = 0; i < n; ++i) {
    if (i != uf.root(i)) continue;
    v += sx[i].size() * sy[i].size() - uf.size(i);
  }
  cout << v << endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
//#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n;
vector<int> bl,wh;

vector<vector<int> > g;

void dfs(int v,int p=-1)
{
    int sz=g[v].size();
    for(int i=0;i<sz;i++)
    {
        int to=g[v][i];
        if(to==p)
            continue;
        dfs(to,v);
        bl[v]*=wh[to];
        wh[v]*=(bl[to]+wh[to]);
        bl[v]%=mod;
        wh[v]%=mod;
    }
}

void init()
{
    cin>>n;
    bl.resize(n,1);
    wh.resize(n,1);
    g.resize(n);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout<<(bl[0]+wh[0])%mod;
}
signed main()
{
    init();
    return 0;
}












Measured memory_bytes: 14208
import fractions
A,B,C,D = map(int , input().split())
E = C * D // fractions.gcd(C, D)
F = B//C - (A-1)//C 
G = B//D - (A-1)//D 
H = B//E - (A-1)//E
ans = (B-A+1) - (F+G-H)
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0, K = 0, S = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++){
    int x = 0; cin >> x;

    if (x <= (K - x))
      S += 2*x;
    else
      S += 2*(K - x);
  }

  cout << S << endl;
}

Measured memory_bytes: 256
<?php
// Your code here!
fscanf(STDIN,"%d",$n);
$line = explode(" ", trim(fgets(STDIN)));
// var_dump($line);
$even = [];
foreach($line as $v){
    if($v % 2 == 0){
        $even[] = $v;
    }
}
// var_dump($even);
foreach($even as $k => $e){
    if($e % 3 == 0 || $e % 5 == 0){
        $even[$k] = true;
    }else{
        $even[$k] = false;
    }
}
// var_dump($even);
$judge = true;
foreach($even as $j){
    $judge = ($judge && $j);
}
echo $judge ? 'APPROVED' : 'DENIED';
?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
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() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    ll T;
    cin >> n >> T;
    vll t(n);
    rep(i, n) cin >> t[i];
    ll ans = 0;
    rep(i, n) {
        if (i == n-1) ans += T;
        else {
            ans += min(t[i+1] - t[i], T);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int r;

    cin >> r;

    cout << r * r << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	void solver() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		for (int i = 0; i < n - 1; i++) {
			if (s.charAt(i) == s.charAt(i + 1)) {
				System.out.println((i + 1) + " " + (i + 2));
				return;
			}
		}
		
		for (int i = 0; i < n - 2; i++) {
			if (s.charAt(i) == s.charAt(i + 2)) {
				System.out.println((i + 1) + " " + (i + 3));
				return;
			}
		}
		System.out.println((-1+" "+-1));
	}
}


Measured memory_bytes: 13316
from heapq import heappush, heappop

def dijkstra(x,Route):
    n=len(Route)
    D=[float('inf')]*n
    D[x]=0
    hq=[(0,x)]
    while hq:
        c,u=heappop(hq)
        if D[u]<c:
            continue
        for v,cost in Route[u]:
            if D[u]+cost<D[v]:
                D[v]=D[u]+cost
                heappush(hq,(D[v],v))
    return D

def dist(V1,V2):
    return max(0,((V2[0]-V1[0])**2+(V2[1]-V1[1])**2)**0.5-(V1[2]+V2[2]))

sx,sy,gx,gy=map(int,input().split())
n=int(input())
V=[(sx,sy,0)]+[tuple(map(int,input().split())) for _ in range(n)]+[(gx,gy,0)]
Edges=[[] for _ in range(n+2)]
for i in range(n+1):
    for j in range(i+1,n+2):
        d=dist(V[i],V[j])
        Edges[i].append((j,d))
        Edges[j].append((i,d))
print(dijkstra(0,Edges)[-1])

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

int main()
{
    string s;
    cin>>s;
    if(s == "SAT") cout<<"1"<<endl;
    else if(s=="SUN") cout<<"7"<<endl;
    else if(s=="MON") cout<<"6"<<endl;
    else if(s=="TUE") cout<<"5"<<endl;
    else if(s=="WED") cout<<"4"<<endl;
    else if(s=="THU") cout<<"3"<<endl;
    else if(s=="FRI") cout<<"2"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

template <typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

template <typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

int dp[100010];

int N, W;
int w[100010], v[100010];

signed main() {
    while (cin >> N) {
        cin >> W;
        // dump(W);
        rep(i, N) cin >> w[i] >> v[i];
        rep(i, 100001) dp[i] = 1e18;
        dp[0] = 0;
        rep(i, N) {
            for (int j = 100000; j >= 0; --j) {
                if (j-v[i] >= 0) {
                    chmin(dp[j],
                          dp[j-v[i]] + w[i]);
                }
            }
            // rep(i, 30) {
            //     if (dp[i] == 1e18) cout << "INF";
            //     else cout << dp[i];
            //     cout << ' ';
            // }
            // cout << endl;
        }

        int ans = -1;
        for (int i = 100000; i >= 0; --i) {
            if (dp[i] <= W) {
                ans = i;
                break;
            }
        }

        cout << ans << endl;;
    }
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int K;
	int S;
	scanf("%d %d",&K,&S);
	int count=0;
	for(int i=0;i<K+1;i++){
		for(int j=K;j>i-1;j--){
			for(int k=K;k>j-1;k--){
				if(i+j+k==S){
					//printf("%d %d %d\n",i,j,k);
					if(i==j){
						if(j==k){
							count+=1;
						} else{
							count+=3;
						}	
					} else if(j==k){
						count+=3;
					} else{
						count+=6;
					}
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

const int N = 100'009;

int a[N];
int b[N];
int ab[N];
int o[N];

int main() {
  int n;
  scanf("%d", &n);
  long long sa = 0, sb = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", a + i, b + i);
    sa += a[i];
    sb += b[i];
    ab[i] = a[i] + b[i];
  }
  long long ans = min(sa, sb);
  if (n % 2 == 0) {
    sort(ab, ab + n);
    long long cur = 0;
    for (int i = 0; i < n / 2; ++i) {
      cur += ab[i];
    }
    ans = min(ans, cur);
  }
  auto cmp_mn = [](int i, int j) {
    int mni = min(a[i], b[i]);
    int mnj = min(a[j], b[j]);
    int mxi = max(a[i], b[i]);
    int mxj = max(a[j], b[j]);
    if (mni != mnj) {
      return mni > mnj;
    }
    if (mxi != mxj) {
      return mxi > mxj;
    }
    return i < j;
  };
  auto cmp_mx = [](int i, int j) {
    int mni = min(a[i], b[i]);
    int mnj = min(a[j], b[j]);
    int mxi = max(a[i], b[i]);
    int mxj = max(a[j], b[j]);
    if (mxi != mxj) {
      return mxi < mxj;
    }
    if (mni != mnj) {
      return mni < mnj;
    }
    return i < j;
  };
  set<int, decltype(cmp_mn)> mn(cmp_mn);
  set<int, decltype(cmp_mx)> mx(cmp_mx);
  long long cur = 0;
  for (int i = 0; i < n; ++i) {
    cur += min(a[i], b[i]);
    mn.insert(i);
    mx.insert(i);
  }
  while ((int)mn.size() >= 3) {
    int i = *mn.begin();
    int j = *mx.begin();
    if (i != j) {
      cur -= min(a[i], b[i]);
      cur += max(a[j], b[j]);
      mn.erase(i);
      mn.erase(j);
      mx.erase(i);
      mx.erase(j);
    } else {
      long long tmp_mn = cur;
      tmp_mn -= min(a[i], b[i]);
      mx.erase(i);
      int k_mn = *mx.begin();
      tmp_mn += max(a[k_mn], b[k_mn]);
      mx.insert(i);
      long long tmp_mx = cur;
      tmp_mx += max(a[i], b[i]);
      mn.erase(i);
      int k_mx = *mn.begin();
      tmp_mx -= min(a[k_mx], b[k_mx]);
      mn.insert(i);
      mn.erase(i);
      mx.erase(i);
      if (tmp_mn < tmp_mx) {
        cur = tmp_mn;
        mn.erase(k_mn);
        mx.erase(k_mn);
      } else {
        cur = tmp_mx;
        mn.erase(k_mx);
        mx.erase(k_mx);
      }
    }
    ans = min(ans, cur);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 10880
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb, cc, dd;
	cin >> aa >> bb >> cc >> dd;
	int64 ans = aa * cc;
	ans = max(ans, aa * dd);
	ans = max(ans, bb * cc);
	ans = max(ans, bb * dd);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	x = 0
	while n>0
		n=div(n,k)
		x += 1
	end
	println(x)
end

main()

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

#define s second
#define f first

const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;

long long fact[maxn];
long long n, k;
long long a[maxn];
long long ans;

void in();
void solve();
void out();
long long c(long long a, long long b);
long long inv(long long a);
long long pwr(long long a, long long b);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> k;
    for(long long i = 0; i < n; i++)
        cin >> a[i];
}

void solve(){
    fact[0] = 1;
    for(long long i = 1; i <= n; i++)
        fact[i] = fact[i - 1] * i % mod;
    sort(a, a + n, greater<int>());
    for(long long i = 0; i < n; i++){
        if(i >= k - 1)
            ans = ans - c(i, k - 1) * a[i] % mod + mod;
        if(i <= n - k)
            ans = ans + c(n - i - 1, k - 1) * a[i] % mod;;
        ans %= mod;
    }
}

void out(){
    cout << ans;
}

long long c(long long a, long long b){
    return fact[a] * inv(fact[b]) % mod * inv(fact[a - b]) % mod;
}

long long inv(long long a){
    return pwr(a, mod - 2);
}

long long pwr(long long a, long long b){
    if(b == 0)
        return 1;
    long long c = pwr(a, b / 2);
    if(b % 2)
        return a * c % mod * c % mod;
    return c * c % mod;
}


Measured memory_bytes: 1792
def solve():
  ans = [0,0]
  N, M = map(int, input().split())
  WAs = [0]*N
  for i in range(M):
    p, S = input().split()
    p = int(p)
    if WAs[p-1]>=0:
      if S=='WA':
        WAs[p-1] += 1
      if S=='AC':
        ans[0] += 1
        ans[1] += WAs[p-1]
        WAs[p-1] = -1
  return ans
print(*solve())

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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int n; cin >> n;
    vector<int> count(10005);
    int a = sqrt(n);
    
    for(int i=1; i < a; ++i)
    {
        for(int j=1; j < a; ++j)
        {
            for(int k=1; k < a; ++k)
            {
                int s = i*i+j*j+k*k+i*j+j*k+k*i;
                if(s < 10005)
                    count[s-1] += 1;
            }
        }
    }

    if(n == 0)
        pri(0);
    else
    {
        rep(i,n)
            pri(count[i]);
    }
    return 0;
}


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

using namespace std;

int
main(void){
	int h, w; cin >> h >> w;
	vector<string> vec(h);
	for(int i = 0; i < h; i++) cin >> vec[i];
	for(int i = 0; i < h; i++){
		cout << vec[i] << "\n" << vec[i] << "\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

// n以下の整数が素数であるか判定(エラトステネスの篩) : O(NloglogN)
bool *isprime;
void sieve(llong n) {
    free(isprime);
    isprime = (bool *)malloc(sizeof(bool) * (n + 1));
    for(int i = 0; i <= n; ++i) isprime[i] = i >= 2;

    for(int i = 2; i <= n / 2; ++i)
        if(isprime[i])
            for(int j = 2 * i; j <= n; j += i)
                isprime[j] = false;
}

int N;
int main(int argc, char **argv) {
    cin >> N;
    sieve(55555);

    vector<int> res;
    for(int i = 2; i <= 55555; ++i)
        if(isprime[i] && i % 5 == 1) {
            res.push_back(i);
            if(res.size() == N) break;
        }

    for(int i = 0; i < N; ++i) {
        if(i != 0) cout << " ";
        cout << res[i];
    }
    cout << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, a;
	cin >> n;
	vector<int> stu(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		stu[a - 1] = i + 1;
	}

	for(const auto& s : stu)
	{
		cout << s << " ";
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3668
/*
	Author: houtaru
	Create: 17.12.2017 20:54:07
*/
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;

int n;
int cnt[maxn];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		if (x > n) ans++; else cnt[x]++;
	}
	for (int x = 1; x <= n; ++x)
		ans += cnt[x] >= x ? cnt[x] - x : cnt[x];
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
int a, b;
cin>>a>>b;
if(a+b >= 10) puts("error");
else cout<<(a+b)<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

P projection(P a1, P a2, P p) {
    return a1 + dot(a2-a1, p-a1) / norm(a2-a1) * (a2-a1);
}

P reflection(P a1, P a2, P p) {
    return 2.0 * projection(a1, a2, p) - p;
}

int main() {
    double a,b,c,d,e,f;
    P x1, x2, q;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &a, &b, &c, &d, &e, &f)) {
        x1 = P(a,b);
        x2 = P(c,d);
        q = P(e,f);
        P ans = reflection(x1, x2, q);
        printf("%.8f %.8f\n", ans.X, ans.Y);
    }
    return 0;
}

Measured memory_bytes: 1260
# A - Grouping
x, y = [int(s) for s in input().split()]
groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

is_same = False

for group in groups:
    if x in group and y in group:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int A1,A2,A3,sum=0;
    
    scanf("%d%d%d\n",&A1,&A2,&A3);
    sum= A1+A2+A3;
    if(sum>=22){
        printf("bust");
    }
    else{
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int M,d,ans=0;
	scanf("%d%d",&M,&d);
	for(int m=1;m<=M;m++)
		for(int i=1;i<=d;i++){
			int n=i%10;
			int N=i/10%10;
			ans+=((n*N==m)&&(n>=2)&&(N>=2));
		}
	printf("%d\n",ans);
    return 0;
}

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

int main() {
  string A,B;
  cin >> A >> B;
  if(A.size() > B.size()) {
    cout << "GREATER" << endl;
  }
  else if(A.size() < B.size()) {
    cout << "LESS" << endl;
  }
  else {
    bool D = false;
    for(int i = 0;i < A.size();i++) {
      if(A.at(i) > B.at(i)) {
        cout << "GREATER" << endl;
        D = true;
        break;
      }
      else if(A.at(i) < B.at(i)) {
        cout << "LESS" << endl;
        D = true;
        break;
      }
    }
    if(D == false) {
      cout << "EQUAL" << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<vector<int>> TD(N);
  for (int i = 0; i < N; i++) {
    int t, d;
    cin >> t >> d;
    TD[--t].push_back(d);
  }

  vector<int> y0, y1;
  for (int i = 0; i < N; i++) {
    if (TD[i].empty()) continue;
    sort(TD[i].begin(), TD[i].end());
    y1.push_back(TD[i].back());
    TD[i].pop_back();
    y0.insert(y0.end(), TD[i].begin(), TD[i].end());
  }
  sort(y0.begin(), y0.end(), greater<int>());
  sort(y1.begin(), y1.end(), greater<int>());
  ll k, sumn = 0;
  k = max(0, (int)(K - y0.size()));
  for (int i = 0; i < k; i++)
    sumn += y1[i];
  for (int i = 0; i < K - k; i++)
    sumn += y0[i];
  ll res = 0;
  while (true) {
    res = max(res, sumn + k * k);
    if (k >= K || k >= y1.size()) break;
    sumn += y1[k];
    sumn -= y0[K - k - 1];
    k++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 6396
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
flag = 0
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        flag = 1
    else:
        ans[s-1] = c
if N != 1 and ans[0] == 0:
    flag = 1
elif N == 1 and ans[0] == 0:
    print(0)
    exit()
if N == 1:
    if ans[0] == -1:
        print(0)
        exit()
for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0
    ans[i] = str(ans[i])
ans = ''.join(ans)
if flag == 1:
    print(-1)
    exit()
print(int(ans))


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // long startTime = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] x = new long[N];
        long[] y = new long[N];
        long[] z = new long[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
        }
        sc.close();

        long max = 0;

        long v1 = calc(N, M, x, y, z, true, true, true);
        max = Math.max(max, v1);
        long v2 = calc(N, M, x, y, z, true, true, false);
        max = Math.max(max, v2);
        long v3 = calc(N, M, x, y, z, true, false, true);
        max = Math.max(max, v3);
        long v4 = calc(N, M, x, y, z, false, true, true);
        max = Math.max(max, v4);
        long v5 = calc(N, M, x, y, z, true, false, false);
        max = Math.max(max, v5);
        long v6 = calc(N, M, x, y, z, false, false, true);
        max = Math.max(max, v6);
        long v7 = calc(N, M, x, y, z, false, true, false);
        max = Math.max(max, v7);
        long v8 = calc(N, M, x, y, z, false, false, false);
        max = Math.max(max, v8);

        System.out.println(max);

        // System.out.println(System.currentTimeMillis() - startTime);

    }

    public static long calc(int N, int M, long[] x, long y[], long z[], boolean xMinus, boolean yMinus,
            boolean zMinus) {
        List<Long> sortList = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            long t = ((xMinus) ? -x[i] : x[i]) + ((yMinus) ? -y[i] : y[i]) + ((zMinus) ? -z[i] : z[i]);
            sortList.add(t);
        }
        // ソート
        sortList.sort(Comparator.reverseOrder());

        // M番目までの値を計算
        long count = 0;
        for (int i = 0; i < M; i++) {
            count += sortList.get(i);
        }

        return count;
    }
}


Measured memory_bytes: 26360
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007


int main() {
  int K,S,ans=0;
  cin >> K >> S;

  for(int i=0; i <= K ; i++){
    for(int j=0; j <= K ;j++){
      int a = S - i - j;
      if(0 <= a && a <= K) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,i,num=0,max=0;
	char a;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>a;
		if(a=='I')
		num++;
		else
		num--;
		if(max<num)
		max=num;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 256
[N,K] = list(map(int,input().split()))
A = []
d = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))

L = [1]*N
for i in range(K):
    B = A[i]
    for S in B:
        L[S-1]=0

print(sum(L))

Measured memory_bytes: 67572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			int result = calcPattern(n);
			
			System.out.println(result);
		}
		

	}
	
	static int calcPattern(int n){
		int count = 0;
		
		for(int i = 1; i < n; i++){
			int sum = i;
			for(int j = i + 1 ; j < n ; j++){
				sum += j;
				
				if(sum == n){
					count++;
					break;
				}
			}
		}
		
		return count;
	}
}

Measured memory_bytes: 24628
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, L, T;
std::vector<ll> vs;
ll cnt;

int main()
{
  scanf( "%lld%lld%lld", &N, &L, &T );
  rep( i, N )
  {
    ll X, W;
    scanf( "%lld%lld", &X, &W );

    if( W == 1 )
    {
      vs.emplace_back( (X+T)%L );
      cnt -= (T-(L-X)+L)/L;
    }
    else
    {
      vs.emplace_back( ((X-T)%L+L)%L );
      cnt += (T-(X+1)+L)/L;
    }
  }

  cnt = (cnt%N+N)%N;

  std::sort( all(vs) );

  rep( i, N )
    printf( "%lld\n", vs[(i-cnt+N)%N] );
  
  return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define F first
#define S second
#define pi pair <int, int>
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define watch(x) cout << (#x) << " = " << (x) << "\n"
#define PI 3.14159265359
#define MOD 1000000007
#define INF 1000000000000000005

using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	int T = 1;
	//cin >> T;
	while(T--){
		string s;
		cin >> s;
		int n = 3, i;
		bool fg = true;
		for(i = 0; i < n; i++){
			if(s[i] != 'R'){
				fg = false;
				break;
			}
		}
		if(fg){
			cout << 3 << "\n";
			continue;
		}
		if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')){
			cout << 2 << "\n";
		}
		else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
			cout << 1 << "\n";
		}
		else{
			cout << 0 << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3648
#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;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=998244353;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;

    int n,m,k,ans=0,val,val1;
    cin>>n>>m>>k;

    vi fac(n+2,0);

    fac[0]=1;
    fac[1]=1;

    repa(i,2,n)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }

    rep(i,k+1)
    {
        val=fac[n-i-1]*fac[i];
        val%=mod;

        val1=fac[n-1]*power(val,mod-2);
        val1%=mod;

        val=power(m-1,n-i-1);
        val*=val1;
        val%=mod;

        val*=m;
        val%+mod;
        ans+=val;
        ans%=mod;
    }

    

    cout<<ans<<endl;
    
}


Measured memory_bytes: 4784
n,ma,mb=map(int,input().split())
el=[list(map(int,input().split())) for i in range(n)]
sa=sum(i[0] for i in el)
sb=sum(i[1] for i in el)
sa1=sa+1
sb1=sb+1

inf=10000000000
x=[[inf]*(sb1) for i in range(sa1)]
x[0][0]=0
for i in range(n):
    now=el[i]
    x_sub=[[0]*(sb1) for i in range(sa1)]
    for k in range(sa1):
        for l in range(sb1):
            if x[k][l]!=inf and k+now[0]<sa1 and l+now[1]<sb1:
                x_sub[k+now[0]][l+now[1]]=x[k][l]+now[2]
    for k in range(sa1):
        for l in range(sb1):
                if x_sub[k][l]!=0:
                    x[k][l]=min(x[k][l],x_sub[k][l])
mi=min(sa//ma,sb//mb)
ans=inf
for i in range(1,mi+1):
    ans=min(ans,x[ma*i][mb*i])
if ans==inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 5368
import copy
import collections

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = copy.copy(s)
for i in range(n):
  if l[i] in t:
    s.remove(l[i])
    t.remove(l[i])

if not s:
  print(0)
else:
  num = collections.Counter(s)
  print(max(num.values()))

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main(){
    int a,b,k;

    cin >> k >> a >> b;

    for(int i = a;i <= b;i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

 
int main(){
  ll n,k;
  cin >> n >> k;
  vector<int>h(n);
  rep(i,n){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  ll ans=0;
  rep(i,n-k){
    ans+=h[i];
  }
  cout << ans << endl;
    
}
      
  
  
  

Measured memory_bytes: 1024
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();
        double arr[]=new double[n];
        double sum=0;
        for (int i=0;i<n;i++)
        {
            arr[i]=sc.nextDouble();

        }
        Arrays.sort(arr);
        sum=arr[0];
 for (int i=0;i<n-1;i++)

            sum=(sum+arr[i+1])/2;

        System.out.println(sum);
    }
}


Measured memory_bytes: 26580
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <iterator>
#define INF 100000100
using namespace std;


int minimize(int start, int goal, map<int,int>* mp,int n);


int main(void){
  int n,m;
  while(true){
    cin>>n>>m;
    if(n==0 and m==0){break;}
    map<int,int> costs[n];
    map<int,int> times[n];
    int a,b,c,t;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>t;
      a--;
      b--;
      costs[a][b]=c;
      costs[b][a]=c;
      times[a][b]=t;
      times[b][a]=t;
    }
    int k;
    cin>>k;
    int p,q,r;
    for(int i=0;i<k;i++){
      cin>>p>>q>>r;
      p--;
      q--;
      if(r==0){
        cout<<minimize(p,q,costs,n)<<endl;
      }
      else{
        cout<<minimize(p,q,times,n)<<endl;
      }
    }
  }
  return 0;
}

int minimize(int start, int goal, map<int,int>* mp,int n){
  int d[n];
  for(int i=0;i<n;i++){
    d[i]=INF;
  }
  d[start]=0;
  vector<int> next,_next;
  next.push_back(start);
  while(next.size()>0){
    _next.clear();
    for(auto iter=next.begin();iter!=next.end();iter++){
      int s=*iter;
      for(auto iter2=mp[s].begin();iter2!=mp[s].end();iter2++){
        int key=iter2->first;
        int value=iter2->second;
        if(d[key]>d[s]+value){
          d[key]=d[s]+value;
          _next.push_back(key);
        }
      }
    }
    next.clear();
    copy(_next.begin(),_next.end(),back_inserter(next));
  }
  return d[goal];
}



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

int main(){
  string s;
  string t = "CF";
  cin >> s;
  int idx=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]==t[idx]) idx++;
    if(idx==2) break;
  }
  if(idx==2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

int digit_sum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int N; cin >> N;
    int ans = 1e9;
    for (int A = 1; A < N; ++A) {
        int B = N - A;
        ans = min(ans, digit_sum(A) + digit_sum(B));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    if(k == 0) {
        out(n*n);
        re0;
    }

    ll ans = 0;
    exrep(b, k+1, n) {
        ll c = (n+1)/b;
        ll d = (n+1)%b;
        ans += c*(b-k) + max(0LL, d-k);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
tiles = list(map(int, input()))

even = tiles[0::2]
odd = tiles[1::2]

even0 = even.count(0)
even1 = even.count(1)
odd0 = odd.count(0)
odd1 = odd.count(1)

if even0 >= max(even1, odd0, odd1) or odd1 >= max(even0, even1, odd0):
    print (even1 + odd0)

elif even1 >= max(even0, odd0, odd1) or odd0 >= max(even0, even1, odd1):
    print (even0 + odd1)

Measured memory_bytes: 4640
N,K=map(int,input().split())
A=list(map(int,input().split()))
mi=[]
pu=[]
ze=[]
lp=0
lz=0
lm=0
for i in A:
    if i>0:
        pu.append(i)
        lp+=1
    elif i==0:
        ze.append(i)
        lz+=1
    else:
        mi.append(-i)
        lm+=1
P=lp*(lp-1)//2+lm*(lm-1)//2
Z=lz*(lp+lm)+lz*(lz-1)//2
M=lp*lm
mi.sort()
pu.sort()
if K<=M:
    l=0
    r=10**18
    K=M-K
    while r-l!=1:
        a=(l+r)//2
        numa=0
        pos=lp-1
        for i in range(lm):
            while pos!=-1:
                if pu[pos]>a//mi[i]:
                    pos-=1
                else:
                    break
            numa+=pos+1
        if numa>K:
            r=a
        else:
            l=a
    print(-r)
elif K<=M+Z:
    print(0)
else:
    k=K-M-Z
    l=0
    r=10**18
    while r-l!=1:
        a=(l+r)//2
        cnt1=0
        cnt2=0
        pos1=lm-1
        pos2=lp-1
        for i in range(lm):
            tmp=0
            while pos1!=-1:
                if mi[pos1]>a//mi[i]:
                    pos1-=1
                else:
                    break
            tmp+=pos1+1
            if mi[i]**2<a:
                tmp-=1
            cnt1+=tmp
        for i in range(lp):
            tmp=0
            while pos2!=-1:
                if pu[pos2]>a//pu[i]:
                    pos2-=1
                else:
                    break
            tmp+=pos2+1
            if pu[i]**2<a:
                tmp-=1
            cnt2+=tmp
        numa=(cnt1+cnt2)//2
        if numa>=k:
            r=a
        else:
            l=a
    print(r)

Measured memory_bytes: 99028
n = int(input())
s = []
fl = [[] for _ in range(n)]
ans = "Yes"
for i in range(n):
    w = input()
    if w in s:
        s.append(w)
        fl[i] = [w[0], w[-1]]
        ans = "No"
    else:
        s.append(w)
        fl[i] = [w[0], w[-1]]

for i in range(n - 1):
    if fl[i][1] != fl[i + 1][0]:
        ans = "No"
print(ans)


Measured memory_bytes: 9200
#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 x, a, b;
  cin >> x >> a >> b;

  int remaining = x - a;
  while ((remaining - b) >= 0) {
    remaining -= b;
  }

  cout << remaining << endl;

  return 0;
}





Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    char a = s.charAt(0);
    int b = (int)a;
    b++;
    char c = (char)b;
    System.out.println(c);


  }
}


Measured memory_bytes: 23252
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N-1)]
from collections import deque
l = [deque() for _ in range(N+1)]
ans = [0]*N
for a,b in ab:
  l[a].append(b)
  l[b].append(a)
  
r = [0]*(N+1)
i = 0
p = l[1]
q = deque()
flag = [False]*(N+1)
flag[1]=True
while (len(p)!=0)or(len(q)!=0):
  if i%2==0:
    while len(p)!=0:
      j = p.pop()
      if flag[j]:
        continue
      else:
        q.extend(l[j])
        flag[j]=True
        r[j]=1
    i+=1
  else:
    while len(q)!=0:
      j = q.pop()
      if flag[j]:
        continue
      else:
        p.extend(l[j])
        flag[j]=True
    i+=1
a = deque(range(1,N+1,3))
b = deque(range(2,N+1,3))
c = deque(range(3,N+1,3))
x = sum(r)
if x<=N//3:
  for i in range(1,N+1):
    if r[i]==1:
      ans[i-1]=c.pop()
    else:
      if len(a)!=0:
        ans[i-1]=a.pop()
      elif len(b)!=0:
        ans[i-1]=b.pop()
      else:
        ans[i-1]=c.pop()
elif (N-x)<=N//3:
  for i in range(1,N+1):
    if r[i]==0:
      ans[i-1]=c.pop()
    else:
      if len(a)!=0:
        ans[i-1]=a.pop()
      elif len(b)!=0:
        ans[i-1]=b.pop()
      else:
        ans[i-1]=c.pop()
else:
  for i in range(1,N+1):
    if r[i]==1:
      if len(a)!=0:
        ans[i-1]=a.pop()
      elif len(c)!=0:
        ans[i-1]=c.pop()
      else:
        ans[i-1]=b.pop()
    else:
      if len(b)!=0:
        ans[i-1]=b.pop()
      elif len(c)!=0:
        ans[i-1]=c.pop()
      else:
        ans[i-1]=a.pop()
        
print(' '.join(map(str,ans)))

Measured memory_bytes: 204456