akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;

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

#define pb push_back
#define fe first
#define se second
#define all(a) (a).begin(),(a).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scn(n) scanf("%d",&n)
#define prn(n) printf("%d\n",n)
#define scnl(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mset(A, val) memset(A, val, sizeof(A))

const ll mod = 1e9 + 7ll;
const int N = (int)1e5 + 7;

int main(){
	
	fast_io;
	int n;
	cin>>n;
	string st;
	cin>>st;
	char cr=st[0];
	int ans=1;
	rep(i,1,n){
		if(st[i]!=cr){
			ans++;
			cr=st[i];
		} 
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
 
void main() {
	while(true) {
		string[] cin;
		cin=split(readln());
		int n=to!int(cin[0]),a=to!int(cin[1]),b=to!int(cin[2]),c=to!int(cin[3]),x=to!int(cin[4]);
		if(!(n||a||b||c||x)) break;
		int[] z=new int[n];
		cin=split(readln());
		for(int i=0; i<n; i++) z[i]=to!int(cin[i]);
		int d=0,cnt=0;
		for(int i=0; i<=10000; i++) {
			if(z[d]==x) d++;
			if(d==n) break;
			x=(a*x+b)%c;
			cnt++;
		}
		if(d==n) writeln(cnt);
		else writeln(-1);
	}
}


Measured memory_bytes: 1496
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
  int cnt=0;
  rep(i,0,3){
    if(s[i]=='1') cnt++;
  }
  cout<<cnt<<endl;
	
	return 0;
}

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

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

    int ans = a;
    int count = 1;

    if(b == 1) cout << 0 << endl; 
    else {
        for(;;){
                if(ans >= b) break;

                ans += (a - 1);
                count++;
                

            }
        cout << count << endl;
    }
   
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int NICO = 102;
int n, m, match[NICO];
bool us[NICO];
vector<int> g[NICO];
bool dfs(int x)
{
    for(int i=0;i<g[x].size();i++)
    {
        if(us[g[x][i]]) continue;
        us[g[x][i]] = 1;
        if(match[g[x][i]] == -1 || dfs(match[g[x][i]]))
        {
            match[g[x][i]] = x; 
            return 1;
        }
    }
    return 0;
}
int hungary()
{
    memset(match, -1, sizeof(match));
    int tot = 0;
    for(int i=0;i<n;i++)
    {
        memset(us, 0, sizeof(us));
        if(dfs(i)) tot ++;
    }
    return tot;
}
int a[NICO], b[NICO], c[NICO], d[NICO];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (int i = 1; i <= n; i ++) {
        scanf("%d %d", &c[i], &d[i]);
    }
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= n; j ++) {
            if (a[i]<c[j] && b[i]<d[j])
                g[i-1].push_back(j-1);
        }
    }
    printf("%d\n", hungary());
}







Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[5];
int b[5];
int main() {
	int t = 0;
	for (int i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
		t += a[i];
		b[i] = a[i] % 10;
		if (b[i] != 0) {
			t += 10 - b[i];
		}
	}
	sort(b, b + 5);
	int j;
	for (j = 0; j < 5 && b[j] == 0; j++) {
	}
	if (j < 5) {
		t -= 10 - b[j];
	}
	printf("%d\n", t);
	return 0;
}


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

using namespace std;

std::vector<int> dig;
long long dp[30][11][2];

long long getNum(int pos, int pre, int lim, bool first)
{
    if (pos < 0)
    {
        return 1;
    }
    if (!lim && dp[pos][pre][first] != -1)
    {
        return dp[pos][pre][first];
    }
    int e = lim ? dig[pos] : 9;
    long long res{0};
    for (int i = 0; i <= e; ++i)
    {
        if (first || std::abs(pre - i) <= 1)
        {
            res += getNum(pos - 1, i, lim && i == e, first && i == 0);
        }
    }
    if (!lim)
    {
        dp[pos][pre][first] = res;
    }
    return res;
}


long long getNum(long long x)
{
    std::vector<int> d;
    do
    {
        d.push_back(x % 10);
        x /= 10;
    } while (x);
    memset(dp, -1, sizeof(dp));
    dig = std::move(d);
    return getNum(dig.size() - 1, 0, 1, true) - 1;
}

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

    int k;
    std::cin >> k;
    long long low{1}, high{1LL << 62};
    while (low < high)
    {
        auto mid = (low + high) >> 1;
        //std::cerr << mid << " " << getNum(mid) << "\n";
        if (getNum(mid) >= k)
        {
            high = mid;
        }
        else
        {
            low = mid + 1;
        }
    }
    std::cout << low << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int N;
ll dp[100010][3];
ll a[100010], b[100010], c[100010];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for(int i = 1; i <= N; i++){
        dp[i][0] = max(dp[i-1][1] + a[i-1], dp[i-1][2] + a[i-1]);
        dp[i][1] = max(dp[i-1][2] + b[i-1], dp[i-1][0] + b[i-1]);
        dp[i][2] = max(dp[i-1][0] + c[i-1], dp[i-1][1] + c[i-1]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    
    
    
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N;
    cin >> N;
    ll sum = 0;
    for(ll i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0) sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3224
import sys
sys.setrecursionlimit(100000)

def main():
  V, E = int(input()), int(input())
  L = []
  app = L.append
  visited = [0 for i in range(V)]
  edges = [[] for i in range(V)]
  
  def visit(x):
    if not visited[x]:
      visited[x] = 1
      for e in edges[x]:
        visit(e)
      app(x)
  
  for i in range(E):
    s, t = map(int,input().split())
    edges[s - 1].append(t - 1)
  
  for i in range(V):
    if not visited[i]:
      visit(i)
  L.reverse()
  
  flag = 0
  for i in range(V):
    print(L[i] + 1)
    if not flag and i < V - 1 and (L[i + 1] not in edges[L[i]]):
      flag = 1
  print(flag)
main()


Measured memory_bytes: 13288
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(n)]
under_t = []
for i in range(n):
    if ct[i][1] <= t:
        under_t.append(ct[i][0])
if len(under_t) == 0:
    print('TLE')
else:
    print(min(under_t))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  vi p(n);
  rep(i,n){
    cin >> p[i];
  }

  int min_p = n+1;
  int ans = 0;
  rep(i,n){
    if(p[i] <= min_p) ++ans;
    min_p = min(min_p,p[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	int a,b;
	cin >> a >> b;
	if (a == b) cout << "Draw";
	else if (a == 1) cout << "Alice";
	else if (b == 1) cout << "Bob";
	else if (a > b) cout << "Alice";
	else cout << "Bob";
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int solve_lsb(ll a, ll b) {
  // a<b
  if((b-a+1)%2==0) {
    ll c=(b-a-1)/2;
    if(b%2==1)
      c++;
    if(a%2==1)
      c++;
    return c%2;
  }
  ll c=(b-a)/2;
  return (c+b%2)%2;
}

ll f(ll a, ll b) {
  if(a==b)
    return a;
  ll ret=solve_lsb(a,b);
  for(ll i=1; i<50; i++) {
    ll base=1LL<<i;
    ll c=0;
    if((b-a+1<base)&&((base&b)==(base&a))) {
      c+=(b-a+1)*((base&a)!=0);
      if(c%2==1)
        ret+=base;
      continue;
    }
    c+=(base-(a%base))*((base&a) !=0);
    // cout << "i="<<i<<endl;
    // cout << "((base&a) !=0) = " << ((base&a) !=0) << endl;
    // cout << "((base&b) !=0) = " << ((base&b) !=0) << endl;
    // cout << "(base-(a%basse))=" << (base-(a%base)) << endl;
    // cout << "b%base="<<b%base<<endl;
    c+=(b%base+1)*((base&b) !=0);
    // if((base&b)==(base&a)) {
    //   c+=base;
    // }
    if(c%2==1) {
      // cout << "c="<<c<<endl;
      // cout << "base="<<base<<endl;
      ret+=base;
      // cout << "ret="<<ret<<endl;
    }
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll a,b;
  cin>>a>>b;
  cout << f(a,b) << endl;
  return 0;
}


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

int main(){
    int  N;
    cin >> N;
    long long int a[N];
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    int res_max=0;
    for(int i=0; i<N;++i){
        res_max+=a[i]-1;
    }
    cout << res_max;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    int n=0,w=0,s=0,e=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='N') n++;
        if(S[i]=='W') w++;
        if(S[i]=='S') s++;
        if(S[i]=='E') e++;
    }
    bool f=true;
    if(n==0){
        if(s!=0)f=false;
    }else{
        if(s==0)f=false;
    }
    if(w==0){
        if(e!=0) f=false;
    }else{
        if(e==0) f=false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    int N;
    cin >> N;

    for (int i = 0; i < 100 / 7; ++i) {
        for (int j = 0; j < 100 / 4; ++j) {
            if (4 * i + 7 * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int a[100010],b[100010];
int main(void)
{
     int n,m,k,i,j;
     scanf("%d",&n);
     for(i=1;i<=n;i++)
     {
          scanf("%d",&a[i]);
     }
     k=0;
     for(i=1;i<=n;i++)
     {
          if(i==1)
          {
               if(a[i]==i)
               {
                    k++;
                    swap(a[i],a[i+1]);
               }
               continue;
          }
          if(i==n)
          {
               if(a[i]==i)
               {
                    k++;
                    swap(a[i],a[i-1]);
               }
               continue;
          }
          if(a[i]==i)
          {
               swap(a[i],a[i+1]);
               k++;
          }
     }
     printf("%d\n",k);
     return 0;
}


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

int main(void){
 int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e ;
 if (a==0){cout << 1<<endl;}
 else if (b==0){cout << 2 << endl;}
 else if (c ==0){cout << 3 << endl;}
 else if (d== 0){cout << 4 << endl;}
 else if (e == 0){cout << 5 << endl;}
}

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

using namespace std;

int main(void){
	int h, n;
	cin >> h >> n;
	vector<int> v(n);

	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
	}

	if(h <= sum){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <cstring>
using namespace std;

vector<string> split(string s) {
    vector<string> ret;
    string buf;
    if (isupper(s[0])) {
        s[0] = tolower(s[0]);
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '_') {
            ret.push_back(buf);
            buf.clear();
        } else if (isupper(s[i])) {
            ret.push_back(buf);
            buf.clear();
            buf.push_back(tolower(s[i]));
        } else {
            buf.push_back(s[i]);
        }
    }
    ret.push_back(buf);
    return ret;
}

int main() {
    string s; char type;
    while (cin >> s >> type) {
        if (type == 'X') break;
        vector<string> words = split(s);

        string output;
        switch (type) {
            case 'L':
                for (int i = 1; i < words.size(); i++) {
                    words[i][0] = toupper(words[i][0]);
                }
                for (int i = 0; i < words.size(); i++) {
                    output += words[i];
                }
                break;
            case 'U':
                for (int i = 0; i < words.size(); i++) {
                    words[i][0] = toupper(words[i][0]);
                    output += words[i];
                }
                break;
            case 'D':
                for (int i = 0; i < words.size()-1; i++) {
                    words[i].push_back('_');
                }
                for (int i = 0; i < words.size(); i++) {
                    output += words[i];
                }
                break;
        }
        cout << output << endl;
    }
    return 0;
} 

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int a[3];
    while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF)
    {
        sort(a,a+3,cmp);
        if(a[0]==5&&a[1]==5&&a[2]==7)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


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

int main() {
    long long int a, b, c;
    cin >> a >> b >> c;

    if (a + b + 2 * sqrtl(a * b) < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    operation_count = int(input())
    incremental_value = int(input())
    candidates = list()

    for i in range(operation_count + 1):
        result = 2 ** i + (operation_count - i) * incremental_value
        candidates.append(result)

    print(min(candidates))


Measured memory_bytes: 2940
import java.util.*;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
    
        List<List<Integer>> graph = new ArrayList<>();
        for(int i = 0; i <= n; i++){
            graph.add(new ArrayList<>());
        }
        for(int i = 1; i <= m; i++){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
    
        int[] parent = new int[n+1];
        Arrays.fill(parent, -1);
        parent[1] = 0;
    
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        queue.add(1);
    
        while(!queue.isEmpty()){
            int u = queue.poll();
        
            graph.get(u).forEach((v) -> {
                if(parent[v] == -1){
                    parent[v] = u;
                    queue.add(v);
                }
            });
        }
        
        StringBuilder sb = new StringBuilder();
        sb.append("Yes").append(System.lineSeparator());
        for(int i = 2; i <= n; i++){
            sb.append(parent[i]).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 75996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int s = 0;
    for (int i = 0;; i++) {
        int t = n - r * i;
        if (t < 0) break;
        //t個をGとBで
        for (int j = 0;; j++) {
            int u = t - g * j;
            if (u < 0) break;
            if (u % b == 0) s++;
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  int ans=0;
  rep(i,0,N-K) ans+=A[i];
  cout<<ans<<endl;
  }


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
bool isSorted(int *arr, int n){
    //printf("%d ", arr[0]);
    for(int i=1; i<n; i++){
      //  printf("%d ", arr[i]);
        if(arr[i]!=arr[i-1]+1){
        //    printf("\n");
            return false;
        }
    }
    //printf("\n");
    return true;
}
int main(){
    int n, i, j, arr[51], tArr[51];
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &arr[i]);
    }
    bool can=false;
    if(isSorted(arr, n)){
        can=true;
    }
    for(i=0; i<n && !can; i++){
        if(arr[i]!=i+1){
            for(j=i+1; j<n; j++){
                memcpy(tArr, arr, sizeof(arr));
                swap(arr[i], arr[j]);
                if(isSorted(arr, n)){
                    can=true;
                }
                swap(arr[i], arr[j]);
            }
        }
    }
    printf("%s\n", (can ? "YES" : "NO"));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAX_FACT = 1e5 * 2 + 1;

ll fact[MAX_FACT], invFact[MAX_FACT], inv[MAX_FACT];

void init() {
  fact[0] = fact[1] = 1;
  invFact[0] = invFact[1] = 1;
  inv[1] = 1;
  for (auto i = 2; i < MAX_FACT; ++i)
  {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    invFact[i] = invFact[i - 1] * inv[i] % MOD;
  }
}

ll calcCombination(ll n, ll k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
}

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

  init();

  ll result = 0;
  for (int i = 1; i < N; i++) {
    result = (result + i * (N - i) * M % MOD * M % MOD) % MOD;
  }
  for (int i = 1; i < M; i++) {
    result = (result + i * (M - i) * N % MOD * N % MOD) % MOD;
  }
  result = result * calcCombination(N * M - 2, K - 2) % MOD;
  cout << result << endl;
  return 0;
}

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

int main() {
	vector <vector<int>> A(3, vector<int> (3));
	for (int i=0; i<3; i++){
	    for (int j=0; j<3; j++){
	        cin >> A.at(i).at(j);
	    }
	}
	int N;
	cin >> N;
	for (int i=0; i<N; i++){
	    int B;
	    cin >> B;
	    for (int j=0; j<3; j++){
	        for (int k=0; k<3; k++){
	            if (A.at(j).at(k)==B) A.at(j).at(k)=0;
	        }
	    }
	}
	bool bingo=false;
	for (int i=0; i<3;i++) {
	    if(A.at(i).at(0)==0 && A.at(i).at(1)==0 &&A.at(i).at(2)==0){
	    bingo=true;
	    }
	}
	for (int i=0; i<3; i++){
	    if (A.at(0).at(i)==0 && A.at(1).at(i)==0 && A.at(2).at(i)==0) bingo=true;
	}
	if (A.at(0).at(0)==0 &&A.at(1).at(1)==0&&A.at(2).at(2)==0) bingo=true;
	if (A.at(2).at(0)==0 &&A.at(1).at(1)==0&&A.at(0).at(2)==0) bingo=true;
	if (bingo) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
// #define INT_MAX 1000000000 this is wrong as INT_MAX is already included in header<climits> and  2147483647  
// #define INT_MIN -1000000000
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod1 1000000007
#define ll long long 
#define ld long double
#define vi vector <int>
#define vvi vector <vector<int>>
#define vll vector<long long>
#define vvl vector <vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define fs(x) fixed<<setprecision(x)
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; } 
constexpr int pct(int x) { return __builtin_popcount(x); } 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

template<class T>
T binpow(T a, T b, T m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
template<class T>
T extended_gcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    T x1, y1;
    T d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

vector<int>par,r;
int find(int a){
    if(par[a]<0){
        return a;
    }
    return par[a]=find(par[a]);
}
void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a == b)
    	return;
    if(r[a]>r[b]){
        par[b]=a;
        r[a]+=r[b];
    }else{
        par[a]=b;
        r[b]+=r[a];
    }
}
int main(){
	int n,m;
    cin>>n>>m;
    par=vector<int>(n,-1);
    r=vector<int>(n,1);
    while(m--){
        int a,b;
        cin>>a>>b;
        --a,--b;
        unite(a,b);
    }
    int mx=0;
    for(int i=0;i<n;i++){
        mx=max(mx,r[i]);
    }
    cout<<mx;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/

Measured memory_bytes: 4760
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
   ll n;
   cin>>n;
   vll a(n+1);
   a.at(0)=1;
   a.at(1)=1;
   rep(i,n-1){
       a.at(i+2)=a.at(i+1)+a.at(i);
   }
   cout<<a.at(n)<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 998244353;

int main()
{
  int h, w;
  cin >> h >> w;

  int a[30][30] = {};
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      int cnt = 0;
      for (int k = 0; k < h; ++k)
      {
        for (int l = 0; l < w; ++l)
        {
          cnt += min(abs(i - k) * a[k][l], abs(j - l) * a[k][l]);
        }
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 2000000000000000000
#define lli long long int
using namespace std;
lli dp[101][100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,W;
    cin>>n>>W;
    lli w[n+1], v[n+1];
    for(int i=1; i<=n; i++)
        cin>>w[i]>>v[i];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=W; j++)
        {
            if(j>=w[i])
            dp[i][j]=max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W];
    return 0;
}

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

int main()
{
    int n, a[5] = { 5, 7, 5, 7, 7 }, b[40];
    string s[40];

    while( cin >> n )
    {
        if( !n )
            break;

        for( int i = 0; i < n; i++ )
        {
            cin >> s[i];
            b[i] = s[i].size();
        }

        for( int i = 0; i < n; i++ )
        {
            int sum = 0, k = 0, j = i;
            while( a[k] >= sum && j < n )
            {
                sum += b[j];
                j++;
                if( sum == a[k] )
                {
                    k++;
                    sum = 0;
                }
            }
            if( k == 5 )
            {
                cout << i + 1 << endl;
                break;
            }
        }   
    }
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);

    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n - 1) cin >> c[i];

    int ans = 0;
    REP(i, n) {
        int add = 0;
        if (i != 0 && a[i - 1] + 1 == a[i]) {
            add = c[a[i - 1] - 1];
        }

        ans += b[a[i] - 1] + add;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = int(input())
i = 1
def collatz(x):
	if x%2 == 0:
		return int(x/2)
	else:
		return int(3*x+1)

while True:
	if s in [1,2,4]:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
   long long N,X;
   cin >> N >> X;
    long long L;
    long long D=0;
    long long ans = 1;
    for(int i = 0; i < N ;i++){
        cin >> L;
        D += L;
        if(D<=X){
            ans++;
        }else{
            break;
        }
    }
    cout << ans << endl;
    
    
    
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

ll mod = 1000000007;

int main() {

    int N,K;
    int a,b;
    Scd2(N,K);
    vector<vector<int> > e(N);

    Rep(i,N-1){
        Scd2(a,b);
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    int head = 0;
    Rep(i,N){
        if( e[i].size() == 1 ) head = i;
    }

    vector< int > pare(N);
    pare[head] = head;
    vector< bool > s(N,false);

    using pii = pair<int,int>;
    deque< int > d;
    d.push_back(head);

    int from;
    while( !d.empty() ){
        from = d.front();
        d.pop_front();
        s[from] = true;
        for( int to : e[from] ){
            if( !s[to] ){
                pare[to] = from;
                d.push_back(to);
            }
        }
    }

    vector< int > rema(N,K);
    Rep(i,N){
        if( pare[i] == i ) rema[i] = K;
        // else if( pare[i] == head ) rema[i] = K-1;
        else rema[i] = K-2;
    }

    s.assign(N,false);
    d.push_back(head);

    ll ans = 1;
    while( !d.empty() ){
        from = d.front();
        d.pop_front();
        // printf( "%d(%d): %d \n", from, pare[from], rema[pare[from]] );
        ans *= rema[pare[from ]];
        ans %= mod;
        rema[pare[from]]--;
        if( rema[pare[from]] < 0 ) rema[pare[from]]++;
        s[from] = true;
        for( int to : e[from] ){
            if( !s[to] ){
                d.push_back(to);
            }
        }
    }

    printf ("%llu\n", ans);


    return 0;
}



Measured memory_bytes: 7288
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

class CombMod:
	def __init__(self, N):
		facts = [1]
		rfacts = [1]
		for i in range(1, N+1):
			facts.append(facts[i-1]*i % mod)
			rfacts.append(pow(facts[i], mod-2, mod))
		self.facts = facts
		self.rfacts = rfacts

	def comb(self, n, k):
		return self.facts[n]*self.rfacts[k]*self.rfacts[n-k] % mod

	def perm(self, n, k):
		return self.facts[n]*self.rfacts[n-k] % mod

	def fact(self, k):
		return self.facts[n] % mod

	def rfact(self, k):
		return self.rfacts[n] % mod

N, M = rl()
cm = CombMod(M)

ans = 0
for i in range(0, N+1):
	ans += (-1)**i * cm.perm(M, i) * (cm.perm(M-i, N-i)**2) * cm.comb(N, i)
	ans = ans % mod
print(ans)


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

typedef long long int lli;

using namespace std;

const int MAX_VALUE = (1 << 30) + (1 << 30 - 1);

int main() {
	// your code goes here
	//cout << MAX_VALUE << endl;
	int  n, W, i, j, k;
	cin >> n >> W;
	lli ans[n+1][W+1];
	lli w[n], v[n];
	for (i = 0; i < n+1; i++)
	{
		ans[i][0] = 0;
		for (j = 1; j < W+1; j++)
		{
			ans[i][j] = -1;
		}
	}
	for (i = 0; i < n; i++)
	{
		cin >> w[i];
		cin >> v[i];
	}
	
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < W + 1; j++)
		{
			if (ans[i][j] == -1)
			{
				continue;
			}
			if (ans[i+1][j] < ans[i][j])
			{
				ans[i+1][j] = ans[i][j];
			}
			if ((j+w[i] <= W) && ((ans[i+1][j+w[i]]) < (ans[i][j] + v[i])))
			{
				ans[i+1][j+w[i]] = ans[i][j] + v[i];
			}
		}
		
	}
	lli max = ans[n][0];
	for (i = 1; i <= W; i++)
	{
		if (max < ans[n][i])
		{
			max = ans[n][i];
		}
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,a,b,sum;
  cin>>n;
  for(a=1;a<=3500;a++)
    for(b=a;b<=3500;b++){
      ll l=1,r=3501,m;
      while(r-l>1){
	m=(l+r)/2;
	sum=a*b*m*4;
	ll t=(a*b+b*m+m*a);
	if(sum==n*t){
	  cout<<a<<" "<<b<<" "<<m<<endl;
	  return 0; 
	} 
	else if(n*t<sum)r=m;
	else l=m;  
      }
    }
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s[] = new int[n+1];

		for(int i = 0; i < n; i++) {
			int val = Integer.parseInt(sc.next());
			s[val]++;
		}
		Arrays.sort(s);

		int ans = 0;
		int cnt = 0;
		for(int i = n; i > 0; i--) {
			ans += s[i];
			cnt++;

			if(cnt == k)
				break;
		}
		System.out.println(n - ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 43516
(defun prime-number-judgment (x)
  (let ((ans t))
    (if (<= x 1)
        (setf ans nil)
        (loop for i from 2 while (<= (* i i) x)
            if (zerop (rem x i))
            do (setf ans nil)))
    ans))

(defun next-prime ()
  (let ((x (read)))
    (loop for i from x
          if (prime-number-judgment i)
          do (return i))))

(format t "~D~%" (next-prime)) 


Measured memory_bytes: 5220
#include <bits/stdc++.h>
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define per(i,a,b) for(int i=(a);i>(b);i--)
    #define pb push_back
    #define ff first
    #define ss second
    #define endl '\n'
    #define mod 1000000007

    typedef long long ll;
    using namespace std;
    int main(){
        int n;
        cin>>n;
        int arr[2001]={0};
        arr[3]=arr[4]=arr[5]=1;arr[6]=2;arr[7]=3;
        int dp[2001]={0};
        dp[3]=dp[4]=dp[5]=dp[6]=dp[7]=1;
        rep(i,8,2001){
            arr[i]=1;
        }
        rep(i,8,2001){
            for(int j=i-3;j>2;j--){
                arr[i]=arr[i]%mod+arr[j]%mod;
            }

            }
        cout<<arr[n];

    return 0;
    }


Measured memory_bytes: 3596
/* Author: shriamrut
 * Language: C++17
 * Made on:16.02.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	//IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && c!=a) || (b==c && a!=b) || (a==c && b!=a))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
// //
// //累積和2d
// //(Y, X)
template <int H, int W> struct Sum2D {
    int sum[H][W];
    void set(int y, int x, int c) { sum[y][x] += c; }
    void build() {
        for (int y = 0; y < H; ++y) {
            for (int x = 0; x < W; ++x) {
                if (0 < y) sum[y][x] += sum[y-1][x];
                if (0 < x) sum[y][x] += sum[y][x-1];
                if (0 < y and 0 < x) sum[y][x] -= sum[y-1][x-1];
            }
        }
    }
    int get(int sy, int sx, int ty, int tx) {
        assert(sx <= tx and sy <= ty);
        int tmp = sum[ty][tx];
        if (0 < sx) tmp -= sum[ty][sx-1];
        if (0 < sy) tmp -= sum[sy-1][tx];
        if (0 < sx and 0 < sy) tmp += sum[sy-1][sx-1];
        return tmp;
    }
    int get(int length, int sy, int sx) {
        int tmp = sum[sy+length-1][sx+length-1];
        if (0 < sx) tmp -= sum[sy+length-1][sx-1];
        if (0 < sy) tmp -= sum[sy-1][sx+length-1];
        if (0 < sx and 0 < sy) tmp += sum[sy-1][sx-1];
        return tmp;
    }
    int get_rect(int h, int w, int sy, int sx) {
        int tmp = sum[sy+h-1][sx+w-1];
        if (0 < sx) tmp -= sum[sy+h-1][sx-1];
        if (0 < sy) tmp -= sum[sy-1][sx+w-1];
        if (0 < sx and 0 < sy) tmp += sum[sy-1][sx-1];
        return tmp;
    }
};

Sum2D<4010, 4010> sum;

int b[2002][2002];
int N, K;

int main() {
    cin >> N >> K;
    int KK = 2*K;
    rep(i, N) {
        int x, y;
        char color;
        cin >> x >> y >> color;
        if (color == 'W') y += K;
        y%=KK;
        x%=KK;
        b[y][x]++;
    }
    rep(y, 2*KK) rep(x, 2*KK) sum.set(y, x, b[y%KK][x%KK]);
    sum.build();
    int ans = 0;
    rep(y, KK+1) rep(x, KK+1) {
        ans = max(ans, sum.get(K, y, x)+ sum.get(K, y+K, x+K));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 78720
#include <iostream>
#include <vector> 
#include <cmath>
using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    string s = "abcdefghijklmnopqrstuvwxyz";

    string ans = "";
    while(n > 0) {
        int rem = n % 26;
        if(rem == 0) {
            ans.push_back('z');
            n = n / 26 - 1;
        } else {
            ans.push_back(s[rem - 1]);
            n /= 26; 
        }
    }
   
   for(int i = ans.size() - 1; i >= 0; i--) {
       cout << ans[i];
   }
   cout << endl;
   return 0;
}

Measured memory_bytes: 3632
#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 main()
{
	int N,M,K;
	cin >> N >> M >> K;
	rep(i,N+1)
	{
		rep(j,M+1)
		{
			int tmp = i*M + j*N - i*j*2;
			if (tmp == K)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	int ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0;
	//new
	int want=1,a;
	int nums[200000];
	cin >> a;
	rep(i, a) {
		cin >> nums[i];
		if (nums[i] == want) {
			want++;
			counter++;
		}
	}
	if (counter == 0) {
		cout << -1 << endl;
	}
	else {
		cout << a - counter << endl;
	}
}

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

struct Team
{
    int win, lose, num;
    char name;

    Team () {}
    Team ( int win, int lose, char name, int num) : win(win), lose(lose), name(name), num(num) {}

    bool operator < ( const Team &d ) const
    {
        return ( win < d.win || win == d.win && (lose > d.lose || lose == d.lose && num > d.num));    }

    bool operator > ( const Team &d ) const
    {
        return ( !(*this < d) );
    }
};

int main()
{
    int N;
    Team data[15];

    while ( cin >> N, N ) {
        for ( int i = 0; i < N; i++ ) {
            int win = 0, lose = 0;
            char name;
            cin >> name;
            for ( int j = 0; j < N - 1; j++ ) {
                int d;
                cin >> d;
                switch ( d ) {
                    case 0 :
                        win++;
                        break;
                    case 1 :
                        lose++;
                        break;
                }
            }
            data[i] = Team ( win, lose, name, i );
        }
        sort ( data, data + N, greater<>());
        for ( int i = 0; i < N; i++ ) {
            cout << data[i].name << endl;
        }
    }

    return ( 0 );
}


Measured memory_bytes: 3072
#include <iostream>

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

int main()
{
	int N;

	cin >> N;

	cout << (float)(N - N / 2) / (float)N << endl;

	return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [x, y] <- getInts
  print $ solve x y

solve :: Int -> Int -> Int
solve x y = x + y `div` 2

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
constexpr long MOD = 1e9 + 7;
using namespace std;

int alphacount[26][200000];

int main() {
    string s;
    cin >> s;
    
    REP(i,s.size()) {
        REP(j,26) {
            if (j == s[i] - 'a') {
                alphacount[j][i + 1] = alphacount[j][i] + 1;
            } else {
                alphacount[j][i + 1] = alphacount[j][i];
            }
        }
    }
    
    if (s.size() == 2 && s[0] == s[1]) {
        cout << "1 2" << endl;
        return 0;
    }
    
    int b = -1;
    int e = -1;
    for (int i = 3; i <= s.size(); i++) {
        REP(j,26) {
            if (alphacount[j][i] - alphacount[j][i - 3] >= 2) {
                b = i - 3 + 1;
                e = i;
            }
        }
    }
    
    cout << b << " " << e << endl;
}


Measured memory_bytes: 18816
#include<stdio.h>
int main(void){
	char a[1200];
	int i,n=0;
	while(1){
		scanf("%c",&a[n]);
		if(a[n]=='\n'){
			break;
		}
		n++;
	}
	for(i=0;i<=n;i++){
		if(a[i]>=0x41&&a[i]<=0x5A){
			a[i]+=32;
		}else if(a[i]>=0x61&&a[i]<=0x7A){
			a[i]-=32;
		}
		printf("%c",a[i]);
	}
	return 0;
}

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

int main() {
	// your code goes here
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s,t;
	while(cin>>s && cin>>t)
	{
		int n = s.size();
		int m = t.size();
		vector<vector<int>>dp(n+1,vector<int>(m+1,0));
	
	    for(int i=1;i<n+1;i++)
	    {
	    	for(int j=1;j<m+1;j++)
	    	{
	    		if(s[i-1]==t[j-1])dp[i][j] = 1+dp[i-1][j-1];
	    		else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	    	}
	    }
	    
	    string res;
	    int i=n,j=m;
	    while(i>0 && j>0)
	    {
	    	if(s[i-1]==t[j-1])
	    	{
	    		res+=s[i-1];
	    		i--;
	    		j--;
	    	}
	    	
	    	else if(dp[i][j-1] ==dp[i][j])j--;
	    	
	    	else i--;
	    }
	    
	    reverse(res.begin(),res.end());
	    cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 38496
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int INF=1001001001;
const int MOD=1000000007;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}



int main() {
  int n;
  cin>>n;
  vector<ll>d(n);
  rep(i,n){
    cin>>d[i];
  }
  int ans=d[0];
  rep(i,n-1){
    ans=gcd(ans,d[i+1]);
  }
cout<<ans;

  }


Measured memory_bytes: 1024