akhauriyash/Code-Regression huggingface dataset:
while True:
    try:
        mat = []
        for i in range(8):
            tmplst = list(input())
            mat.append(tmplst)
        
        a = []

        for j in mat:
            for k, num in enumerate(j):
                if num == '1':
                    a.append(k)

        if a[1] == a[0] +1:
            if a[2] == a[0] -1:
                print("G")
            elif a[2] == a[0]:
                print("A")
            elif a[2] == a[0] +1:
                print("E")
            else:
                print("C")

        else:
            if a[0] == a[3] +1:
                print("D")
            elif a[0] == a[3]:
                print("B")
            else:
                print("F")

        k = input()
    except EOFError:
        break


Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define endl '\n'
const int mx=1e5+5;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin >> n;
	++n;
	ll k=n;
	bool flag=false;
	vector <long long > v;
	while(k){
		v.push_back(k%10);
		k/=10;
	}
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();++i){
		if(v[i]!=9)flag=true;
	}
	if(flag==false){
		cout << 9*v.size() << endl;
	}
	else{
		cout << v[0]-1+v.size()*9-9 << endl;
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)

typedef long long ll;

int main(void)
{
	int n, p;
	while (cin >> n >> p, n|p) {
		int bowl = p;
		int idx = 0;
		vector<int> candidates = vector<int>(n, 0);
		for (;;) {
			if (bowl > 0) {
				bowl--;
				candidates[idx]++;
				if (candidates[idx] == p)
					break;
			} else if (bowl == 0) {
				swap(bowl, candidates[idx]);
			}
			idx = (idx+1)%n;
		}
		cout << idx << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>  
#include <map>  
#include <set>  
#include <string>  
#include<string.h>  
#include <cstring>  
#include <cstdio>  
#include <algorithm>  
#include <cmath>  
#include <queue>  
#include <vector>  
using namespace std;  
typedef long long ll;  
const int maxn=55;  
char mp[maxn][maxn];  
int f[maxn][maxn];  
int main(){  
    int h,w;  
    scanf("%d%d",&h,&w);  
    memset(f,0,sizeof(f));  
    for(int i=0;i<h;i++){  
        scanf("%s",mp[i]);  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#'){  
                if(i-1>=0){  
                    f[i-1][j]++;  
                }  
                if(j-1>=0){  
                    f[i][j-1]++;  
                }  
                if(i+1<h){  
                    f[i+1][j]++;  
                }  
                if(j+1<w){  
                    f[i][j+1]++;  
                }  
                if(i-1>=0&&j-1>=0){  
                    f[i-1][j-1]++;  
                }  
                if(i+1<h&&j-1>=0){  
                    f[i+1][j-1]++;  
                }  
                if(i-1>=0&&j+1<w){  
                    f[i-1][j+1]++;  
                }  
                if(i+1<h&&j+1<w){  
                    f[i+1][j+1]++;  
                }  
            }  
        }  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#') printf("#");  
            else printf("%d",f[i][j]);  
        }printf("\n");  
    }  
}  


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long minTime = Long.MAX_VALUE;
        for (int i = 0; i < 5; i += 1) {
            long time = sc.nextLong();
            if (time < minTime) {
                minTime = time;
            }
        }
        long time = N / minTime + (N % minTime == 0 ? 0 : 1) + 4;
        System.out.println(time);
    }

}


Measured memory_bytes: 22868
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#define INF 10**9+7
using namespace std;
using Graph = vector<vector<int> >;//Graph graph(ノードの数)で生成できる

bool check(long long a,long long b,long long c){
    return true;
}

int main(){
    long long A,B,C;
    cin >> A >> B >> C;
    if(A==B && A==C && B==C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){            
	string s, a ="10", b = "01";
	int t1 = 0, t2 = 0;
	cin >> s;
	int sz = s.size();
	for(int i = 0 ; i < sz ; i++){
		if(s[i] != a[i%2]) t1++;
		if(s[i] != b[i%2]) t2++;
	}
	cout << min(t1, t2) << endl;
	return 0;
}

Measured memory_bytes: 512
N, X, M = map(int, input().split())
T = []
K = [0]*M
p = X
for i in range(N):
    if K[p] == 1:
        break
    else:
        T.append(p)
    K[p] = 1
    p *= p
    p %= M

for i in range(N):
    if T[i] == p:
        break
ans = 0
ans += sum(T)
if N > len(T):
    L = sum(T[i:])
    q = len(T[i:])
    ans += L*((N-len(T))//q)
    ans += sum(T[i:i+(N-len(T)) % q])
print(ans)

Measured memory_bytes: 69448
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x


n, m = map(int, input().split())
lang = [list(map(int, input().split()))[1:] for _ in range(n)]

uf = Unionfind(n + m)
for i, li in enumerate(lang):
    for lij in li:
        uf.union(i, lij - 1 + n)
bool = all(uf.find(0) == uf.find(i) for i in range(1, n))
print('YES' if bool else 'NO')


Measured memory_bytes: 86772
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
#define ll long long
using namespace std;

int main() {
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  ll min_ = a;
  ll max_ = a;

  REP(i, n - 1) {
    ll delta = b - a;
    if (delta > 0) {
      min_ += c;
      max_ += d;
    } else {
      min_ -= d;
      max_ -= c;
    }

    a = (min_ + max_) / 2;
  }

  if (min_ <= b && b <= max_)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
s = input()
n = len(s)
ans = 0
cnt = 0
for i in range(n):
    if s[i] in ["A", "C", "G", "T"]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 5028
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

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

  int n;
  cin >> n;
  int rsl = 0;
  rep(i, 1, n + 1) {
    if(i % 2) {
      vector<int> tmp = divisor(i);
      if(tmp.size() == 8) ++rsl;
    }
  }
  cout << rsl << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define nl puts("")
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

void __print(int x) {cerr << x;} void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif
using ll = long long;
const int N = 100005;
const int MOD = 1000000007;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    ll i,n,k,sum=0;
    sl(n);
    unordered_map<ll,ll>mp;
    rep0(i,n)
    {
        sl(k);
        sum+=k;
        mp[k]++;
    }
    ll q,a,v;
    sl(q);
    while(q--)
    {
        sll(a,v);
        ll p=mp[a];
        if(p)
        {
            sum-=mp[a]*a;
            mp[a]=0;
            sum+=p*v;
            mp[v]+=p;
        }
        //db(mp);
        pf("%lld\n",sum);
    }
}


Measured memory_bytes: 7228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    vector<vector<int>> trie(1, vector<int>(26, -1));
    string t = " ";
    vector<ll> cnt(1), all(1);
    auto add = [&](string z) {
        int pos = 0;
        all[pos]++;
        for (int i = 0; i < (int)z.size(); i++) {
            if (trie[pos][z[i] - 'a'] == -1) {
                t.push_back(z[i]);
                pos = trie[pos][z[i] - 'a'] = (int)trie.size();
                trie.emplace_back(vector<int>(26, -1));
                cnt.emplace_back(0);
                all.emplace_back(0);
            } else {
                pos = trie[pos][z[i] - 'a'];
            }
            all[pos]++;
        }
        cnt[pos]++;
    };
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        add(s[i]);
    }
    vector<vector<ll>> a(trie.size(), vector<ll>(26));
    ll ans = 0;
    for (int i = trie.size() - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            if (trie[i][j] == -1) {
                continue;
            }
            for (int k = 0; k < 26; k++) {
                a[i][k] += a[trie[i][j]][k];
            }
        }
        if (i != 0) {
            a[i][t[i] - 'a'] = all[i];
        }
    }
    for (int i = 0; i < trie.size(); i++) {
        for (int j = 0; j < 26; j++) {
            if (trie[i][j] == -1) {
                continue;
            }
            if (cnt[trie[i][j]] != 0) {
                ll x = -1;
                for (int k = 0; k < 26; k++) {
                    if (trie[i][k] == -1) {
                        continue;
                    }
                    x += a[trie[i][k]][j];
                }
                ans += x;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 395324
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll ans,n,a[200001],tmp,viz[200001],k,mn;
set<int> st;
vector<int> vc;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i],st.in(a[i]);
    if(st.size()<=k) rc(0);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) viz[a[i]]++;
    for(int i=1;i<=n;i++) if(viz[i]==0) viz[i]=n+10;
    sort(viz+1,viz+1+n);
    for(int i=1;i<=st.size()-k;i++) ans+=viz[i];
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<ll, pii>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

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

    double p[n+1];
    fre(i,n) cin>>p[i];

    double prob[n+1][n+1];
    memset(prob, 0, sizeof(prob));
    prob[0][0] = 1;

    for(int j=1; j<=n; j++){

        for(int i=0; i<=n; i++){
            if(j<i) prob[i][j] = 0;
            else{
                prob[i][j] += prob[i][j-1]*(1-p[j]);
                if(i-1>=0)
                    prob[i][j] += prob[i-1][j-1]*p[j];
            }
        }
    }

    // fr(i,n+1){
    //     fr(j,n+1){
    //         cout<<prob[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    double ans=0;

    for(ll i=n; i>n/2; i--){

        ans+= prob[i][n];
    }

    cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

int main(){
	int K, N;
  	cin >> K >>  N;
  	vector<int> A(N);
  	
  	for(int i = 0; i < N; i++){
    	cin >> A.at(i);	
    }
  	
  	vector<int> B(N);
  	for(int i = 0; i < N - 1; i++){
    	B.at(i) = abs(A.at(i) - A.at(i+1));
//      	cout << B.at(i) << endl;
    }
   	if(A.at(0) == 0){B.at(N-1) = K - A.at(N-1);}
  	else {B.at(N-1) = K - A.at(N-1) + A.at(0);}
//    cout << B.at(N-1) << endl;
  	int mx = B.at(0);
  	int num = 0;
	sort(B.begin(),B.end());
//  	cout << num << endl;
 	cout << (K - B.at(N-1)) << endl;
} 


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//
vector<P> v;

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	int a, b, c; cin >> a >> b >> c;

	Print((a + b)*c / 2);

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>

using namespace std;

const int INF = 1000000007;

int main() {
	int N, a, b, c;
	scanf("%d", &N);
		
	vector<vector<int>> dp(3, vector<int>(N, 0));

	scanf ("%d%d%d", &a, &b, &c);
	dp[0][0] = a;
	dp[1][0] = b;
	dp[2][0] = c;
	
	for (int i = 1; i<N; i++) {
		scanf ("%d%d%d", &a, &b, &c);
		dp[0][i] = max(dp[1][i-1] , dp[2][i-1] ) + a;
		dp[1][i] = max(dp[0][i-1] , dp[2][i-1] ) + b;
		dp[2][i] = max(dp[1][i-1] , dp[0][i-1] ) + c;	
		//~ printf ("%d %d %d\n", dp[0][i], dp[1][i], dp[2][i]);
	}
	
	int m = max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]);
	printf ("%d", m);
	// 8 + 8 + 5+7+8+3+7
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include "atcoder/all"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int k;
	cin>>k;
	string rz;
	for(int i=0;i<k;i++)
	rz += "ACL";
	cout<<rz<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3648
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  int n;
  cin >> n;
  int ans=0;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<n;i++){
    if(a.at(i)>b.at(i)){
      ans=ans+a.at(i)-b.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int table[3][3];
	for(int i = 0; i < 3; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> table[i][j];
		}
	}
	int b1, b2, b3;
	for(int i = 0; i <= 100; i++)
	{
		for(int j = 0; j <= 100; j++)
		{
			for(int k = 0; k <= 100; k++)
			{
				b1 = table[0][2] - k;
				b2 = table[1][2] - k;
				b3 = table[2][2] - k;
				if(b1 + j == table[0][1] && b2 + j == table[1][1] && b3 + j == table[2][1] &&
				   b1 + i == table[0][0] && b2 + i == table[1][0] && b3 + i == table[2][0])
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
cnt=0
for i in a:
    if i<0:
        cnt+=1
if cnt%2==0:
    print(sum(map(abs,a)))
else:
    print(sum(map(abs,a))-2*min(map(abs, a)))

Measured memory_bytes: 60268
//A
#include<bits/stdc++.h>
using namespace std;
#define MAX 100002

int n;
int k;

vector<int> v;

long long int gcd(long long int a, long long int b){
	if (a > b){
		swap(a, b);
	}
	while (a){
		swap(a, b);
		a %= b;
	}
	return b;
}



int main(){
	cin >> n >> k;
	long long int gc = 0;
	int mx = 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		gc = gcd(gc, a);
		mx = max(mx, a);
	}
	if (k <= mx&&k%gc == 0){
		puts("POSSIBLE");
	}
	else{
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	ws   []int
	vs   []int
	memo [][]int
)

func rec(n, w int) int {
	if memo[n][w] != -1 {
		return memo[n][w]
	}

	ret := rec(n-1, w)
	if pw := w - ws[n-1]; pw >= 0 {
		ret = max(ret, rec(n-1, pw)+vs[n-1])
	}

	memo[n][w] = ret
	return ret
}

func solve() {
	n, w := getInt(), getInt()
	ws, vs = make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		ws[i] = getInt()
		vs[i] = getInt()
	}

	memo = make([][]int, n+1)
	for i := range memo {
		memo[i] = make([]int, w+1)

		if i == 0 {
			continue
		}
		for j := range memo[i] {
			memo[i][j] = -1
		}
	}

	ans := -1
	for i := 0; i <= n; i++ {
		ans = max(ans, rec(i, w))
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 83200
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long> A(N),B(N),C(N);
  for(long long &i:A)
    cin>>i;
  B[0]=0,C[N-1]=0;
  for(long long i=1;i<N;i++){
    B[i]=B[i-1]+A[i-1];
    C[N-i-1]=C[N-i]+A[N-i];
  }
  long long j=1000000000000000;
  for(long long i=1;i<N;i++)
    j=min(j,abs(B[i]-C[i-1]));
  cout<<j<<endl;
}

Measured memory_bytes: 7936
package main

import "fmt"

func main() {
	var s string
	var t string
	fmt.Scan(&s)

	switch s {
	case "Sunny":
		t = "Cloudy"
	case "Cloudy":
		t = "Rainy"
	case "Rainy":
		t = "Sunny"
	}

	fmt.Println(t)
}


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

int main() {
  int N, K, P, D, Q;
  cin >> N >> K;
  P=1;
  Q=0;
 while(N-P>=0){
   cin >> D ;
   if( D<= K/2){
     Q=Q+(D*2);
   P++;
   }
   else if( D>K/2){
     Q=Q+(K-D)*2;
     P++;
   }
 }
  cout << Q <<endl;
}


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


int main() {
  int N,K,D,S = 0;
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> D;
    if(D < K - D) {
      S += D * 2;
    }
    else {
      S += (K - D) * 2;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
const int MAX = 300005;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	int n ; cin >> n ;
	int x = 0 , y = 0 , t = 0 ;
	int t1 , x1 ,y1 ;
	
	for(int i = 0 ; i < n ; i++){
		cin >> t1 >> x1 >> y1 ;
		if(abs(x1 - x) + abs(y1 - y) > t1 - t) return cout << "No" << endl , 0 ;
		else if((t1 - t - abs(x1 - x) - abs(y1 - y)) % 2) return cout << "No" << endl ,0 ;
		t = t1 ; x = x1 ; y = y1 ;
	}
	cout << "Yes" << endl ;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



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

	if (a + b <= 9)
		cout << a + b << endl;
	else
		cout << "error" << endl;

}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
tmp_min = A[0]
tmp_diff = 0
for i in range(1, N):
    if A[i] < tmp_min: #今回の値が最小値の時-->最小値を更新する
        tmp_min = A[i]
        continue
    if A[i] - tmp_min == tmp_diff:
        ans += 1
    if A[i] - tmp_min > tmp_diff:
        ans = 1
        tmp_diff = A[i] - tmp_min

print (ans)
    
    

Measured memory_bytes: 14252
local k, n = string.match(io.read(), "(%d+) (%d+)")
k = tonumber(k)
n = tonumber(n)

local a = {}

for x in string.gmatch(io.read(), "(%d+)") do
    table.insert(a, tonumber(x))
end

table.sort(a, function(a, b) return a < b end)
table.insert(a, 1, a[n])
table.insert(a, k + a[2])

local ans = 9999999999

for i = 2, n+1 do
    local t = a[i - 1] - a[i]
    
    if t < 0 then
        t = t + k
    end

    ans = math.min(ans, t)
end

print(ans)

Measured memory_bytes: 10312
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long int
#define mod 1000000007
using namespace std;
int main() 
{
 
	 int a,b;
	 cin>>a>>b;
	 int c[4]={0};
	 c[a]=1;
	 c[b]=1;
	 for(int i=1;i<4;i++)
	 {
	 	if(c[i]==0)
	 	{
	 		cout<<i;
	 		return 0;
		 }
	 }
	}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    bool flag = true;
    REP(i, N - 1)
    {
        if (A[i] == A[i + 1])
        {
            flag = false;
            break;
        }
    }
    string ans;
    if (flag) ans = "YES";
    else ans = "NO";

    cout << ans << endl;
}


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


int N,table[8][8];
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
bool FLG,check[8][8];

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= N-1 && col >= 0 && col <= N-1)return true;
	else{
		return false;
	}
}

void dfs(int sum,int tmp_row,int tmp_col,int rest){

	if(FLG) return;

	if(sum == 0 && rest == 0){
		FLG = true;
		return;
	}

	if(sum == 0){

		for(int row = 0; row < N; row++){
			for(int col = 0; col < N; col++){
				if(check[row][col])continue;
				if(table[row][col] < 0){
					check[row][col] = true;
					dfs(abs(table[row][col]),row,col,rest-1);
					check[row][col] = false;
					return;
				}
			}
		}

	  }else{

		  for(int i = 0; i < 4; i++){
			  int adj_row = tmp_row+diff_row[i];
			  int adj_col = tmp_col+diff_col[i];

			  if(rangeCheck(adj_row,adj_col) == false || check[adj_row][adj_col] == true || table[adj_row][adj_col] < 0 || sum < table[adj_row][adj_col])continue;

			  check[adj_row][adj_col] = true;
			  dfs(sum-table[adj_row][adj_col],adj_row,adj_col,rest-1);
			  check[adj_row][adj_col] = false;
		  }
	  }
}


void func(){

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			scanf("%d",&table[row][col]);
			check[row][col] = false;
		}
	}

	FLG = false;

	dfs(0,0,0,N*N);

	if(FLG){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}
	return 0;
}

Measured memory_bytes: 3008
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,Y = inpl()

for y in range(N+1):
	for h in range(N+1-y):
		tmp = 10000*y + 5000*h
		n = N-y-h
		if Y-tmp == n*1000:
			print(y,h,n)
			sys.exit()

print(-1,-1,-1)


Measured memory_bytes: 4204
N = gets.to_i
A = gets.split.map(&:to_i)
order_A = Array.new()

(1..N).each do |i_A|
  oreder_A = A.shift
  order_A[oreder_A - 1] = i_A
end

#p order_A

ans = order_A.join(" ")
puts ans

Measured memory_bytes: 12548
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;
int main(){

  int N;
  cin>>N;
  int *H = new int[N];
  rep(i,0,N) cin>>H[i];
  int check=0;
  int *K = new int[N];
  K[0]=H[0]-1;
  if(K[0]==0) K[0]=1;
  rep(i,1,N){
    if(H[i]-K[i-1]>0){
      K[i]=H[i]-1;
    }else if(H[i]==K[i-1]){
      K[i]=H[i];
    }else{
      check=1;
      break;
    }
  }

  
  if(check) cout<<"No";
  else cout<<"Yes";
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

int main() {
    int n;
    cin>>n;
    int c =n%10;


    if(c==2){cout<<"hon"<<endl;}
    if(c==4){cout<<"hon"<<endl;}
    if(c==5){cout<<"hon"<<endl;}
    if(c==7){cout<<"hon"<<endl;}
    if(c==9){cout<<"hon"<<endl;}
     if(c==0){cout<<"pon"<<endl;}
     if(c==1){cout<<"pon"<<endl;}
     if(c==6){cout<<"pon"<<endl;}
     if(c==8){cout<<"pon"<<endl;}
     if(c==3){cout<<"bon"<<endl;}

 
}

Measured memory_bytes: 3596
//
//AtCoder Beginner Contest 175
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}


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

    vector<int> l(n);
    REP(i, n) cin >> l[i];

    sort(ALL(l));

    int ans=0;
    REP(i, n){
        FOR(j, i+1, n-1){
            FOR(k, j+1, n-1){
                if (l[i]==l[j]) continue;
                if (l[i]==l[k]) continue;
                if (l[j]==l[k]) continue;
                if (l[i]+l[j]<=l[k]) continue; 

                //cout << l[i] << " " << l[j] << " " << l[k] << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#include<cstdio>
#include<cstring>
int main()
{
	char x,y;
	while(cin>>x>>y)
	{
		if(x>y)
			cout<<">"<<endl;
		else if(x<y)
			cout<<"<"<<endl;
		else if(x==y)
			cout<<"="<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>


int main() {
  int H, W;
  int j, k;
  char square = '#';

  for (int i = 0; i < 300; i ++) {
    std::cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (j = 0; j < H; j ++) {
      for (k = 0; k < W; k ++) {
        std::cout << square;
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

void NO() {
	puts("-1");
	exit(0);
}

int main() {
	int n;
	scanf("%d", &n);
	ll answer = 0;
	vector<int> in(n);
	for(int & x : in) scanf("%d", &x);
	if(in[0]) NO();
	for(int i = 1; i < n; ++i) if(in[i] > in[i-1] + 1) NO();
	map<int, int> mapka;
	for(int i = 0; i < n; ++i)
		mapka[in[i]-i] = in[i];
	for(pair<int,int> p : mapka) answer += p.second;
	printf("%lld\n", answer);
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[3][1010];
ll xx[1000010];
ll x,y,z,k;
ll ans[3010];

ll f(ll p){
	//p以上になる個数
	ll cnt=0;
	rep(i,0,z){
		if(xx[0]+a[2][i]>=p){
			cnt+=x*y;
			continue;
		}
		ll l=0,r=x*y;//lはng,rはok
		while(r-l>1){
			ll m=(l+r)/2;
			if(xx[m]+a[2][i]>=p)r=m;
			else l=m;
		}
		cnt+=x*y-r;
	}
	return cnt;
}

int main(){
	scanf("%lld%lld%lld%lld",&x,&y,&z,&k);
	rep(i,0,x)scanf("%lld",&a[0][i]);
	rep(i,0,y)scanf("%lld",&a[1][i]);
	rep(i,0,z)scanf("%lld",&a[2][i]);
	
	ll cnt=0;
	rep(i,0,x)rep(j,0,y)xx[cnt++]=a[0][i]+a[1][j];
	sortup(xx,x*y);
	
	ll l=0,r=30000000001;//lはok,rはng
	while(r-l>1){
		ll m=(l+r)/2;
		if(f(m)>=k)l=m;
		else r=m;
	}
//	printf("%lld",l);
	//l以上を列挙すればよい
	ll aaa=0;
	rep(i,0,z){
		for(ll j=x*y-1;j>=0;j--){
			if(a[2][i]+xx[j]>l)ans[aaa++]=a[2][i]+xx[j];
			else break;
		}
	}
	sortdown(ans,aaa);
	rep(i,0,aaa)printf("%lld\n",ans[i]);
	rep(i,aaa,k)printf("%lld\n",l);
}

Measured memory_bytes: 15868
import sys

line = sys.stdin.readline().strip()
N, K = [int(x) for x in line.split()]

line = sys.stdin.readline().strip()
A = [int(x) for x in line.split()]

X = {}
for i in A:
    X[i] = X.get(i, 0) + 1

vs = sorted(list(X.values()))

r = 0

if len(vs) < K:
    r = 0
else:
    r = sum(vs[:-K])

print(r)


Measured memory_bytes: 35152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int h, w; cin >> h >> w;
    vector<string> data(h);
    rep(i,h) cin >> data[i];
    w += 2;
    h += 2;
    vector<vector<char>> field(h,vector<char>(w));
    rep(i,w) field[0][i] = '#';
    rep(i,w) field[h-1][i] = '#';
    rep(i,h) field[i][0] = '#';
    rep(i,h) field[i][w-1] = '#';
    for (int i = 1; i <= h-2; i++) {
        for (int j = 1; j <= w-2; j++) {
            field[i][j] = data[i-1][j-1];
        }
    }
    rep(i,h) {
        rep(j,w) cout << field[i][j];
        cout << endl;
    }
}

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

const int M = 1e6;

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	long long n, s; cin >> n >> s;
	for (int b = 2; b <= M; b++) {
		long long sum = 0, x = n;
		while (x) sum += x % b, x /= b;
		if (sum == s) {
			cout << b << "\n";
			return 0;
		}
	}
	for (int p = M; p >= 1; p--) {
		long long l = n / (p + 1), r = n / p;
		if (l < r) {
			long long low = p + n % r;
			if (low <= s && (s - low) % p == 0) {
				if (r - (s - low) / p > l) {
					cout << r - (s - low) / p << "\n";
					return 0;
				}
			}
		}
	}
	if (n == s) {
		cout << n + 1 << "\n";
		return 0;
	}
	cout << "-1\n";
	
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n&&j>=n;--i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mem(p,v) memset(p,v,sizeof(p))
#define present(c,x)    ((c).find(x) != (c).end())
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define debug4(x,y,z,a) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<" "<<#a<<" "<<a<<endl;
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
const long long inf = 1e18;
const lli MOD =998244353 ;
void show(vector<lli> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(vector<int> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(int a[], int arraysize){for (int i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(lli a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(bool a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(set<int> s){for (auto it = s.begin(); it != s.end(); it++){cout << *it << " ";}cout<<endl;}
void show(map<lli,lli> mp){for (auto it = mp.begin(); it != mp.end(); it++){cout << it->first << " "<<it->second<<endl;}cout<<endl;}
//Pair hashing is done using std::map ;
lli modpow(lli x,lli n){lli res=1;while(n>0){if(n&1) res=((res%MOD)*(x%MOD))%MOD;x=((x%MOD)*(x%MOD))%MOD;n>>=1;}return res;}
lli power(lli x, lli n){lli res=1;while(n>0){if(n&1) res=res*x;x=x*x;n>>=1;}return res;}

/////// ------ Main code starts here ------ /////
void solve()
{
    lli n,m;
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    fr(i,0,s.length())
    {
        if(s[i]=='R')
            cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}
int main()
{
    run;cout<<fixed<<setprecision(12);
    int t;
    t=1;
    while(t){solve();t--;}
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll x,y; cin>>x>>y;
	if(y-2*x>=0 and 4*x-y>=0 and (y-2*x)%2==0 and (4*x-y)%2==0) cout<<"Yes";
	else cout<<"No"; 
}


Measured memory_bytes: 3604