akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int     
int main(){
    int a[26]={0};
    string s;
    cin>>s;
    int f=0;
    for(int i=0;i<s.length();i++)a[s[i]-'a']++;
    for(int i=0;i<26;i++){
        if(a[i]==0){
            cout<<char(i+97);
            f=1;
            break;
        }
    }
    if(f==0)cout<<"None";
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<ll> X(N);
    for (auto& x : X) {
        cin >> x;
    }
    vector<map<ll, ll>> mods(M);
    rep(i, 0, N) {
        ++mods[X[i] % M][X[i]];
    }
    ll ans = 0;
    rep(m, 0, M / 2 + 1) {
        if (m == (M - m) % M) {
            ll cnt = 0;
            for (auto i : mods[m]) {
                cnt += i.second;
            }
            ans += cnt / 2;
        }
        else {
            ll cnt1 = 0, pair1 = 0;
            for (auto i : mods[m]) {
                cnt1 += i.second;
                pair1 += i.second / 2;
            }
            ll cnt2 = 0, pair2 = 0;
            for (auto i : mods[M - m]) {
                cnt2 += i.second;
                pair2 += i.second / 2;
            }
            ll min_cnt = min(cnt1, cnt2);
            ans += min_cnt;
            cnt1 -= min_cnt;
            cnt2 -= min_cnt;
            if (cnt1) {
                ans += min(cnt1 / 2, pair1);
            }
            else {
                ans += min(cnt2 / 2, pair2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 12032
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

class UnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x:int, y:int) -> bool:
        if self.isSame(x,y):
            #print("x and y has already united")
            return False
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = self.par[ry]
        else:
            self.par[ry] = self.par[rx]
            
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
                
        return True
                
    
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)
    
    
# edgesは(cost, prev_node, nex_node)をE本格納しているリスト
def kruskal(edges: list, node_num: int) -> int:
    edges.sort(key=lambda x:x[0])
    
    uf = UnionFind(node_num)
    rem = node_num-1
    ans = 0
    
    for cost, prev, nex in edges:
        if uf.find(prev) != uf.find(nex):
            uf.unite(prev, nex)
            ans += cost
            rem -= 1
            
        if rem == 0:
            break
        
    return ans

n = ni()
city = []

for i in range(n):
    city.append([i] + list(li()))

# x,y順にソートして2(N-1)本の辺の候補を出す (cost, from, to)
edges = []

city.sort(key=lambda x:x[1])
for i in range(n-1):
    edges.append((city[i+1][1] - city[i][1], city[i][0], city[i+1][0]))

city.sort(key=lambda x:x[2])
for i in range(n-1):
    edges.append((city[i+1][2] - city[i][2], city[i][0], city[i+1][0]))

# クラスカル法
ans = kruskal(edges, n)

print(ans)

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

using namespace std;

long long dp[3005][3005];

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    string s,t;
    cin >> s >> t;

    int n=s.size();
    int m=t.size();

    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
    {
        if (s[i-1]==t[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
        dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
    }

    string ans;
    int x=n,y=m;

    while (x>0 && y>0)
        if (s[x-1]==t[y-1] && dp[x-1][y-1]+1==dp[x][y])
    {
        ans+=s[x-1];
        x--;
        y--;
    }
    else if (dp[x-1][y]==dp[x][y])
        x--;
    else
        y--;

    reverse(ans.begin(),ans.end());
    cout << ans;
}


Measured memory_bytes: 70656
#include <cstdio>
int main(){
    int a,b;
    for(;;){
        scanf("%d%d",&a,&b);
        if(a==0 && b==0)break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}



Measured memory_bytes: 2596
#!/usr/bin/env python3
import sys


def modInverse(a, p):
    return pow(a, p-2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p

def solve(n: int, a: int, b: int):
    p = 10**9+7
    ans = pow(2, n, p) - 1 - modBinomial(n, a, p) - modBinomial(n,b,p)
    print((ans+p)%p)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	s.pop_back();
	for(int i = s.length(); i >= 0; i--){
		if(i % 2 == 0){
			REP(j, i / 2){
				if(s[j] != s[j + i / 2]) goto no;
			}
			cout << i << endl;
			return 0;
			no:;
		}
	}
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2:
        print('No')
        break
    else:
        x = a[i][1]
        y = a[i][2]
        t = a[i][0]
else:
    print('Yes')

Measured memory_bytes: 27428
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {

	int n;

	string s;

	int r = 0, b = 0;

	cin >> n >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')r++;
		else b++;
	}

	if (r > b)cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, ans = 0;
	scanf("%d", &n);
	rep(i, 0, n){
		int l, r;
		scanf("%d %d", &l, &r);
		ans += r-l+1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
from __future__ import division

maxn = 40000

def sieve(n):
    ret = []
    isPrime = [False if i % 2 == 0 else True for i in range(n + 1)]
    isPrime[0] = isPrime[1] = False
    ret.append(2)
    for i in range(3, n + 1, 2):
        if isPrime[i]:
            ret.append(i)
            for j in range(i * i, n + 1, i):
                isPrime[i] = False

    return ret

primes = sieve(maxn)

def factor(n):
    ret, idx = [], 0
    for p in primes:
        if n % p == 0:
            count = 0
            while n % p == 0:
                count += 1
                n //= p
            ret.append((p, count))

    if n > 1: ret.append((n, 1))
    return ret

def euler_phi(n):
    facts = factor(n)
    return reduce(lambda acc, (p, a):  acc * (p ** a - p ** (a - 1)), facts, 1)


if __name__ == '__main__':
    n = int(raw_input())
    print euler_phi(n)

Measured memory_bytes: 5852
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ts <- getIntList
    as <- getIntList
    let tans = reverse . fst $ foldl' f ([],0) ts
        aans = fst $ foldr (flip f) ([],0) as
    let ans = foldl' g 1 $ zipWith check tans aans
    print ans

f (hs,p) h | p == h = ((h,h):hs,h)
           | p > h = ((0,h):hs,h)
           | p < h = ((1,h):hs,h)

check (d1,h1) (d2,h2) | d1 == 1 && d2 == 1 && h1 == h2 = 1
                      | d1 == 1 && d2 == 1 = 0
                      | d1 == 0 || d2 == 0 = 0
                      | d1 == 1 && h1 > h2 = 0
                      | d2 == 1 && h1 < h2 = 0
                      | otherwise = min d1 d2

g a b = (a*b) `mod` 1000000007

Measured memory_bytes: 36392
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  
  int ans = 0;
  rep(i,n){
    ans += b[a[i]-1];
    if(i>0){
      if(a[i]-a[i-1] == 1){
        ans += c[a[i]-2];
      }
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,x,y=mii()

ans=10**100

for i in range(10**5 +1):
    ans = min(i*2*c + max(x-i,0)*a + max(y-i,0)*b,ans)


print(ans)

Measured memory_bytes: 64620
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [A, B] = lines[0].split(' ').map(Number)

const a = Math.ceil(A / 0.08)
const b = Math.ceil(B / 0.1)

let ans = null
if (a < b && Math.floor(b * 0.08) === A) {
    ans = b
} else if (a > b && Math.floor(a * 0.1) === B) {
    ans = a
} else if (a === b) {
    ans = a
} else {
    ans = -1
}
console.log(ans)

Measured memory_bytes: 29804
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    if(n <= k){
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.end());
    h.erase(h.begin()+n-k,h.end());
    ll ans = 0;
    for(int i = 0; i < h.size(); i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int a,b;
int f[10];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	rep(i,0,3)
		{
			cin>>a>>b;
			f[a]++;
			f[b]++;
		}
	int ff = 0;	
	rep(i,1,5)
	{
		if(f[i] > 2)
			ff = 1;
		if(f[i] == 0)
			ff = 1;
	}	
	if(!ff)
	{
		cout<<"YES"<<endl;
	}
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;


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

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

Measured memory_bytes: 3636
from collections import deque


N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
d = deque(T)
count = 0
while len(d) > 0:
    t = d.popleft() + K
    for i in range(C-1):
        if len(d) > 0 and d[0] <= t:
            d.popleft()
        else:
            break
    count += 1

print(count)


Measured memory_bytes: 13876
#include <iostream>
#include <string>
 
int main(void){
    int N,M,k;
  	int *ac_array;
    int *wa_array;
  	int *wa_count;
 
  	int ac_num = 0;
  	int wa_num = 0;
  	std::string S;
  
	std::cin >> N >> M;
  
  	ac_array = new int[N-1];
    wa_array = new int[N-1];
  	wa_count = new int[N-1];
  
  	for(int i = 0; i < N; i++){
      ac_array[i] = 0;
      wa_array[i] = 0;
      wa_count[i] = 0;
    }
  
  	for(int i = 0; i < M; i++){
    	std::cin >> k >> S;
        //まだ正解してない問題に対して処理する
      	if( ac_array[k-1] == 0){
      		if(S == "AC"){
              //正解なら正解した数として１を代入
              ac_array[k-1] = 1;
              //正解したらWAを反映
              wa_array[k-1] = wa_count[k-1];
           } else if(S == "WA") {
              //ミスったらミス数をカウントする
              wa_count[k-1] = wa_count[k-1] + 1;
           } 
        } else {
        //正解した問題に対しては何もしない
        }
    }
  
    for(int i = 0; i < N; i++){
      ac_num = ac_num + ac_array[i];
      wa_num = wa_num + wa_array[i];
    }
  
  	std::cout << ac_num << " " << wa_num;
  
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e2+5;
using namespace std;
char a[22][22];
int n, m, dx[] = {0, -1, 1, 0}, dy[] = {-1, 0, 0, 1};
int bfs(int i, int j)
{
	int lvl[22][22], mx = 0;
	bool vis[22][22] = {};
	lvl[i][j] = vis[i][j] = 1;
	queue <pair <int, int>> q;
	q.push({i, j});
	while (!q.empty())
	{
		int ci = q.front().F, cj = q.front().S;
		mx = max(mx, lvl[ci][cj]-1);
		q.pop();
		for (int k = 0; k < 4; k++)
		{
			int toi = ci + dx[k], toj = cj + dy[k];
			if (toi < n && toj < m && toi >= 0 && toj >= 0 && a[toi][toj] != '#' && !vis[toi][toj])
				vis[toi][toj] = 1, q.push({toi, toj}), lvl[toi][toj] = lvl[ci][cj] + 1;
		}
	}
	return mx;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int mx = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			if (a[i][j] == '.')
				mx = max(mx, bfs(i, j));
	}
	cout << mx;
	return 0;
}


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

int main(){
    int64_t W, H, X, Y;
    cin >> W >> H >> X >> Y;
    double ans = (double)W * H / 2;
    int dub = (2*X == W && 2*Y == H);
    cout << fixed << setprecision(20) << ans << " " << dub << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

void p(ld ans)
{
	cout << fixed << setprecision(12) << ans << '\n';
}

ll x[100001];
int r[100001];
ll d[100001];
vi perm;
const int LG = 61;
int st[LG][100001];

int getval(int x, ll k)
{
	int pos = x;
	for(int i = 0; i < LG; i++)
	{
		if(k&(1LL<<i))
		{
			pos = st[i][pos];
		}	
	}
	return pos;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i];
	ll m, k; cin >> m >> k;
	for(int i = 0; i < m; i++) 
	{
		cin >> r[i];
		r[i]--;
	}
	d[0] = 0;
	for(int i = 1; i < n; i++)
	{
		d[i] = x[i] - x[i-1];
	}
	for(int i = 0; i < n; i++) perm.pb(i);
	for(int i = 0; i < m; i++)
	{
		swap(perm[r[i]], perm[r[i]+1]); //check
	}
	vi perm2(n);
	for(int i = 0; i < n; i++)
	{
		perm2[perm[i]] = i;
	}
	for(int i = 0; i < n; i++)
	{
		st[0][i] = perm2[i];
	}
	for(int i = 1; i < LG; i++)
	{
		for(int j = 0; j < n; j++)
		{
			st[i][j] = st[i-1][st[i-1][j]];
		}
	}
	for(int i = 0; i < n; i++)
	{
		int pos = getval(i, k);
		perm2[pos] = i;
	}
	ld sum = ld(x[0]);
	for(int i = 0; i < n; i++)
	{
		sum += ld(d[perm2[i]]);
		p(ld(sum));
	}
}


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

signed main(){
  int D,N;
  cin>>D>>N;
  int ans=0;
  if(N==100)N+=1;
  if(D==0)ans=N;
  if(D==1)ans=N*100;
  if(D==2)ans=N*10000;
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+10;
const int mod=998244353;
int fac[N],inv[N];
int f[4],g[4];
char l[N];
int n;
int mul(int x,int y){return (ll)x*y%mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int dec(int x,int y){return x-y<0?x-y+mod:x-y;}
int get(char c){
	if (c=='R') return 1; else if (c=='G') return 2; else return 3;
}
void init(){
	fac[0]=1;
	for (int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
	inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) inv[i]=mul(inv[mod%i],mod-mod/i);
	for (int i=2;i<N;i++) inv[i]=mul(inv[i],inv[i-1]);
}
int C(int x,int y){
	if (x<0||y<0||x<y) return 0;
	return mul(fac[x],mul(inv[y],inv[x-y]));
}
int main(){
	scanf("%d",&n);
	init();
	scanf("%s",l+1);
	int s1=0,s2=0,sum=0;
	int ans=1;
	for (int i=1;i<=n*3;i++) {
		int t=get(l[i]);
		sum++;
		if (g[t]) {s1++;ans=mul(ans,g[t]); g[t]--;} else if ((f[1]+f[2]+f[3]-f[t])){
			if (f[1]&&t!=1) ans=mul(ans,f[1]),f[1]--,s2++,g[5-t]++;
			else 
		    if (f[2]&&t!=2) ans=mul(ans,f[2]),f[2]--,s2++,g[4-t]++;
		    else
		    if (f[3]&&t!=3) ans=mul(ans,f[3]),f[3]--,s2++,g[3-t]++;
		    else f[t]++;
 		} else f[t]++;
	}
	printf("%d\n",mul(ans,fac[n]));
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll k,cnt;
vector<ll>ans;
void dep(ll sum,ll keta,ll nowke){
	if(keta==nowke){
		ans.push_back(sum);
		return ;
	}
	ll now=sum%10;
	if(now>=1){
		dep(sum*10+now-1,keta,nowke+1);
	}
	dep(sum*10+now,keta,nowke+1);
	if(now<9){
		dep(sum*10+now+1,keta,nowke+1);
	}
}
int main() {
	cin>>k;
	for(ll i=1;i<=13;i++){
		for(ll j=1;j<=9;j++){
			dep(j,i,1);
		}
	}
	for(ll i=k-1;i<=k-1;i++){
	cout << ans[i]<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 68972
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int sum = 0;
	rep(i,n) rep(j,n) {
		if(i<j) {
			sum += a[i]*a[j];
		}
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
ans = []

n.times do
  x, y, b, p = gets.split.map(&:to_i)
  normal_sum = x * b + y * p

  if b >= 5 && p >= 2
    ans << normal_sum * 0.8
  else
    discount_sum = ([5, b].max * x + [2, p].max * y) * 0.8
    ans << [normal_sum, discount_sum].min
  end
end

ans.each do |a|
  p a.to_i
end



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

int main(){
int n,k;
cin>>n>>k;
if(n%2==0){
    if(k>n/2){
        cout<<"NO";
    }
    else{
        cout<<"YES";
    }
}
else{
    if(k>(n/2)+1){
        cout<<"NO";
    }
    else{
        cout<<"YES";
    }
}
return 0;}


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

int main()
{
  int N; cin >> N;
  
  int localmax = 0 , ans;
  for(int i = 1; i <= N; i++){
  	int n = i , count = 0;
    while(n > 0){
      n /= 2;
      count++;
    }
    if( count > localmax ){
      localmax = count;
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll a=(n+4)/11*2+1;
  ll b=(n+10)/11*2;
  co(rM(a,b))
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;

int main() {
	LL N,M,V,P;
	vector<LL> as;
	cin >> N >> M >> V >> P;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		as.push_back(a);
	}
	sort(as.begin(),as.end());
	int low=-1,hi=N-P;
	//cerr << (P>=V) << endl;
	while(low+1<hi){
		int m=(low+hi)/2;
		if(P>=V){
			if(as[m]+M>=as[N-P]){
				hi=m;
			}
			else{
				low=m;
			}
		}
		else{
			LL r=M*(V-P);
			int c=P-1;
			for(int j=0;j<N-(P-1);j++){
				if(j==m)continue;
				if(as[m]+M<as[j]){
					c++;
				}
				else{
				r-=min(M,as[m]+M-as[j]);
				}
			}
			//cerr << m << ", " << c << ", " << r << endl;
			if(c>=P||r>0){
				low=m;
			}
			else{
				hi=m;
			}
		}
	}
	//cerr << low << ", " << hi << endl;
	cout << N-hi << endl;

	return 0;
}



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

int main(){
    int H, W; cin >> H >> W;
    char S[H][W];
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            cin >> S[i][j];
        }
    }
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            cout << S[i][j];
        }
        cout << endl;
        for (int j=0; j<W; j++){
            cout << S[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef long long LL;
const int SIZE = 1000001;
const int ESIZE = 101;
LL L;
bool isPrime[SIZE];
LL P[SIZE];
int PC;
int E[ESIZE]; 
int EC;
int res;

void makePrimes() {
    PC = 0;
    memset( P, false, sizeof(P) );
    for ( int i = 3; i < SIZE; i += 2 ) {
        isPrime[i] = true; 
    }
    P[PC++] = 2;
    for ( int i = 3; i < SIZE; i += 2 ) {
        if ( ! isPrime[i] ) continue;
        P[PC++] = i;
        for ( int j = i + i; j < SIZE; j += i ) {
            isPrime[j] = false;
        }
    }
}

void init() {
    memset( E, 0, sizeof(E) );
}

void calcExp( LL L ) {
    EC = 0;
    int i = 0;
    for ( ; i < PC && L > 1; ++ i ) {
        LL p = P[i];
        if ( L % p == 0 ) {
            while ( L > 1 && L % p == 0 ) {
                E[EC] ++;
                L /= p;
            }
            EC ++;
        }
    }
    if ( i >= PC ) {
        E[EC++] = 1;
    }
}

void dfs( int k, int r ) {
    if ( k >= EC ) {
        res += r;
        return;
    }
    for ( int i = 0; i < E[k]; ++ i ) dfs( k+1, r );
    dfs( k+1, r*(E[k]+1) );
}

int solve() {
    calcExp(L);
    res = 0;
    dfs( 0, 1 );
    return floor((res+1)/2.0);
}

int main() {
    makePrimes();
    while ( cin >> L && L ) {
        init();
        cout << solve() << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int T; cin >> T;
  while(T--) {
    int N, K; cin >> N >> K;
    vector<int> a(N);
    rep(i, N) {
      cin >> a[i];
    }
    ll asum = 0;
    sort(a.begin(), a.end());
    rep(i, N - 1) {
      asum += a[i + 1] - a[i];
    }
    priority_queue<ll, vector<ll>> pq;
    rep(i, N - 1) {
      pq.push(a[i+1] - a[i]);
    }

    ll msum = 0;
    rep(i, N - 1) {
      if(K > 1) {
        K--;
        msum += pq.top();
        pq.pop();
      }
    }

    cout << asum - msum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5068
n,l=map(int,input().split())
 
min_abs=99999999999
min_abs_i=-1
n_aji=0
for i in range(1,n+1):
  aji=l+i-1
  aji_abs=abs(aji)
  if aji_abs < min_abs:
    min_abs = aji_abs
    aji_abs_i = i
  n_aji+=aji
 
print(n_aji-(l+aji_abs_i-1))

Measured memory_bytes: 9064
import sys,os
while 1:
    a = []
    for i in range(5):
        a.append(list(map(int, input().split())))
        if a == [[0,0]]:
            sys.exit(0)

    ans = 0
    abcde = "ABCDE"
    an = ""
    for j,i in enumerate(a):
        if ans < i[0]+i[1]:
            ans = i[0]+i[1]
            an = abcde[j]

    print(an,ans)


Measured memory_bytes: 5608
fun main(args:Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)
    val odd = A.filter { it % 2 == 0}.size
    println(Math.pow(3.0,A.size *1.0).toInt()-Math.pow(2.0,odd*1.0).toInt())    
}


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

int main(){
    int n,a,b,c,max;
    bool output[1000]={false};

    std::cin >> n;
    for (int i=0;i<n;++i)
    {
        std::cin >> a >> b >> c;
        if (a>b && a>c){
            max = a;
            a = 0;
        }
        else if (b>a && b>c){
            max= b;
            b = 0;
        }
        else if (c>a && c>b){
            max= c;
            c = 0;
        }
        if (pow(max,2) == pow(a,2)+pow(b,2)+pow(c,2)){
            output[i] = true;
        }
    }
    for (int i=0;i<n;++i){
        if (output[i]) std::cout << "YES" << std::endl;
        else std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    int ans = 0;
    FOR(i, 1, n + 1){
        int tmp = i;
        int dig, sum = 0;
        while(tmp){
            dig = tmp % 10;
            sum += dig;
            tmp /= 10;
        }
        if(x <= sum && sum <= y){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int K = 100000;
const int mod = 998244353;
int a[N], b[N], c[N], d[N], sz[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x, y;
        cin >> x >> y;
        a[x] = y;
        b[y] = x;
        d[i] = x;
    }
    set <int> s;
    for (int i = 1; i <= n; i++) s.insert(i);
    int k = n + 1;
    int z = 0;
    for (int i = 1; i <= n; i++){
        if (a[i] > k){
            s.erase(a[i]);
        } else{
            int x = *s.rbegin();
            if (x > k){
                for (int j = a[i]; j < k; j++){
                    c[b[j]] = c[b[k]];
                    sz[c[b[k]]]++;
                }
            } else{
                z++;
                for (int j = a[i]; j < k; j++){
                    c[b[j]] = z;
                    sz[z]++;
                }
            }
            k = a[i];
            s.erase(a[i]);
        }
    }
    for (int i = 1; i <= n; i++){
        cout << sz[c[d[i]]] << " ";
    }
}


Measured memory_bytes: 19316
import numpy as np

N = int(input())
A_u = np.cumsum(list(map(int,input().split())))
A_d = np.cumsum(list(map(int,input().split())))
ans = 0
if N == 1:
    print(A_u[0]+A_d[0])
    exit()
for i in range(N):
    if i == 0:
        ans = max(ans, A_u[i]+A_d[-1])
    else:
        ans = max(ans, A_u[i]+A_d[-1]-A_d[i-1])
print(ans)


Measured memory_bytes: 12508
a = int(input())

memo = [0]*100000

def  fib(n):

    if n == 0 or n ==  1:
        memo[n] =1

    if memo[n] == 0:
        memo[n] = fib(n-2) + fib(n-1)
        return memo[n]
    else:
        return memo[n]



print(fib(a))

    


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

#define SWAP(a, b) { int x=(a); (a)=(b); (b)=x; }

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

	cout << a << ' ' << b << ' ' << c << endl;

    return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String k = "No";
		String i = kb.next();
		if ((i.charAt(2) == i.charAt(3)) && (i.charAt(4) == i.charAt(5)))
			k = "Yes";
		System.out.println(k);
		kb.close();
	}

}


Measured memory_bytes: 22100
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as n



def main():

    N = int(input())
    ans =0
    for i in range(1,N+1):
        num =  int(N/i)
        ans += int(num*(num+1)/2 *i)

    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
N = int(input())
s_lst=[]
for i in range(2):
    s_lst.append(input())


if s_lst[0][0] == s_lst[1][0]:
    wasx = True
    ans, pos = 3, 1
else:
    wasx = False
    ans, pos = 6, 2

while pos < N:
    if s_lst[0][pos] == s_lst[1][pos]:
        if wasx:
            ans = (ans * 2) %1000000007
        wasx = True
        pos += 1
    else:
        if wasx:
            ans = (ans * 2) %1000000007
        else:
            ans = (ans * 3) %1000000007
        wasx = False
        pos += 2
print(ans)

Measured memory_bytes: 3064
n,m,x = gets.split.map(&:to_i)
list = []
n.times {list.push(gets.split.map(&:to_i))}
ans = 10**9

[1,0].repeated_permutation(n) do |perm|
    sum = [0]*(m+1)
    list.zip(perm).each do |i|
        tmp = i[0]*i[1]
        sum = sum.zip(tmp).map{|f,s| f+s} unless tmp.empty?
    end
    
    flag = true
    1.upto(m) do |i|
        flag = false if sum[i]<x 
    end
    ans = sum[0] if (flag and ans > sum[0])
end

p ans==10**9 ? -1 : ans

Measured memory_bytes: 14312
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  std::string s;
  std::cin >> s;
  bool foundA = false;
  int indexA = 0;
  int indexZ = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (foundA == false && s[i] == 'A')
    {
      indexA = i;
      foundA = true;
    }
    if (s[i] == 'Z')
    {
      indexZ = i;
    }
  }
  std::cout << indexZ - indexA + 1 << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;

int n;
int a[100011];
int r[100011][2];
int p[100011];
int ans;
int dp[100011][2];

int main()
{
    int i,j,k;
    
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        int xx=0,yy=a[i];
        while(yy>1)
        {
            yy>>=1;
            xx++;
        }
        if((a[i]^(1<<xx))!=0)
        {
            r[i][0]=xx+1;
            r[i][1]=xx;
            p[i]=xx+1;
        }
        else
        {
            r[i][0]=r[i][1]=p[i]=xx;
        }
    }
    
    memset(dp,-1,sizeof(dp));
    dp[0][0]=dp[0][1]=0;
    
    for(i=0;i<n;i++)
    {
        for(j=0;j<=1;j++)
        {
            if(dp[i][j]!=-1)
            {
                for(k=0;k<=1;k++)
                {
                    dp[i+1][k]=max(dp[i+1][k],dp[i][j]+min(r[i][1-j],r[i+1][k]));
                }
            }
        }
    }
    ans=0;
    for(i=1;i<=n;i++)
    {
        ans+=p[i];
    }
    
    ans-=max(dp[n][0],dp[n][1]);
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<vector>
#include<utility>
#include<cstring>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define ms(a,b)            memset(a, b, sizeof(a))
#define loop(i,a)          for(int i=1;i<=a;i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
using namespace std ;
typedef long long ll ;
int main()
{
  ll n,m,x,ans=0;
  cin >> n >> m ;
  while(m--)
  {
      cin >> x ;
      ans+=x ;
  }
  ans = n<ans ?  -1 : n-ans ;
  cout << ans << endl;
  return 0 ;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> chart(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> chart[i][j];
    }
  }
  for(int i=H-1;i >= 0;i--){
    bool triger = false;
    for(int j = 0;j<W;j++){
      if(chart[i][j]=='#'){
        triger = true;
        break;
      }
    }
    if(triger==false){
      chart.erase(chart.begin()+i);
    }  
  }
  for(int i=W-1;i >= 0;i--){
    bool triger = false;
    for(int j = 0;j<chart.size();j++){
      if(chart[j][i]=='#'){
        triger = true;
        break;
      }
    }
    if(triger==false){
      for(int k=0;k<chart.size();k++){           
        chart[k].erase(chart[k].begin()+i);
      }
    }   
  }
  for(int i=0;i<chart.size();i++){
  	for(int j=0;j<chart[0].size();j++){
    	cout << chart[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(all(A));
    bool ok=true;
    for(int i=1;i<N;i++) if(A[i]==A[i-1]) ok=false;
    
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
vi x, y, z;
bool is_edge(int i, int j, int s) {
  return abs(x[i] - x[j]) < s &&
        abs(y[i] - y[j]) < s &&
        abs(z[i] - z[j]) < s;
}
int kasanari(int i, int j, int s) {
  int nx = s - abs(x[i] - x[j]);
  int ny = s - abs(y[i] - y[j]);
  int nz = s - abs(z[i] - z[j]);
  return 2 * (nx * ny + ny * nz + nz * nx);
}
int n;
bool cycle;
int calc(int now, int prev, int st, int res, int k, int cnt, int s, vvi &g) {
  int mi = INF;
  for(auto &nxt: g[now]) {
    if(nxt == prev) continue;
    if(nxt == st) {
      res -= kasanari(now, nxt, s);
      if(cnt == k) chmin(mi, res);
      res += kasanari(now, nxt, s);
    } else {
      res += 6 * s * s;
      res -= kasanari(now, nxt, s);
      if(cnt != k) chmin(mi, calc(nxt, now, st, res, k, cnt+1, s, g));
      res -= 6 * s * s;
      res += kasanari(now, nxt, s);
    }
  }
  if(cnt == k && (!cycle || k != n)) chmin(mi, res);
  return mi;
}
bool solve() {
  int k, s; cin >> n >> k >> s;
  if(n == 0) return false;
  x.clear();
  y.clear();
  z.clear();
  x.resize(n);
  y.resize(n);
  z.resize(n);
  for(int i=0;i<(n);++i) cin >> x[i] >> y[i] >> z[i];
  if(k == 1) {
    cout << 6 * s * s << endl;
    return true;
  }
  vvi g(n);
  vi d(n);
  for(int i=0;i<(n);++i) {
    for(int j=0;j<(n);++j) {
      if(i == j) continue;
      if(is_edge(i, j, s)) {
        g[i].push_back(j);
        d[i]++;
        d[j]++;
      }
    }
  }
  cycle = true;
  for(int i=0;i<(n);++i) {
    cycle &= d[i] == 2;
  }
  int mi = INF;
  for(int i=0;i<(n);++i) {
    chmin(mi, calc(i, -1, i, 6 * s * s, k, 1, s, g));
  }
  cout << (mi == INF ? -1 : mi) << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(solve()) {}
}



Measured memory_bytes: 3156
#include<iostream>
using namespace std; // 575

const int MAX = 100;
const int MAX2 = 100001;
int main() {
	static int N, W, w[MAX], v[MAX];
	cin >> N >> W;
	for (int i = 0;i < N;++ i) cin >> w[i] >> v[i];
	static int dp[MAX2], ans = 0;
	for (int i = 1;i <= MAX2;++ i) dp[i] = W + 1;
	dp[0] = 0;
	for (int i = 0;i < N;++ i) for (int j = MAX2;j >= v[i];-- j) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
	for (int i = 0;i < MAX2;++ i) if (dp[i] <= W) ans = i;
	cout << ans;
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

今度は答えがO(Nv)に収まるのでこっちで探索
*/

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int w, h, n;
    int x[1001], y[1001];
    int ans = 0;

    cin >> w >> h >> n;

    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    for (int i = 0; i < n-1; i++) {
        if (x[i] - x[i+1] == y[i] - y[i+1]) {
            ans += abs(x[i] - x[i+1]);
        }
        else {
            if (x[i] > x[i+1] && y[i] > y[i+1]) {
                ans += abs(x[i] - min(x[i] - x[i+1], y[i] - y[i+1]) - x[i+1]);
                ans += abs(y[i] - min(x[i] - x[i+1], y[i] - y[i+1]) - y[i+1]);
                ans += min(x[i] - x[i+1], y[i] - y[i+1]);
            }
            else if (x[i] < x[i+1] && y[i] < y[i+1]) {
                ans += abs(x[i] + min(x[i+1] - x[i], y[i+1] - y[i]) - x[i+1]);
                ans += abs(y[i] + min(x[i+1] - x[i], y[i+1] - y[i]) - y[i+1]);
                ans += min(x[i+1] - x[i], y[i+1] - y[i]);
            }
            else {
                ans += abs(x[i] - x[i+1]) + abs(y[i] - y[i+1]);
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3088
'''
いちばん簡単なのは建物とフロアごとにリスト作って、足し引き
'''


#部屋、フロア、建物をクラスで定義。まあ、クラスにしなくてもいいんだけど

a = int(input())

n = 10
m = 3
o = 4
h = [
        [
            [0 for i in range(n)] 
         for j in range(m)] 
    for k in range(o)]


#w, x, y, z = 3, 1, 8, 4
for i in range(a):
    w,x,y,z = map(int, input().split())
    h[w-1][x-1][y-1] += z

#print(h[1][1])
#建物と建物仕切り
def makeFence():
    fence = '#' * 20
    print(fence)

#部屋を表示する関数
def showRoom(f):
    for k in range(len(f)-1):
        print(' ' + str(f[k]), end='')
    print(' ' + str(f[len(f)-1]))

#フロアを表示する関数
def showFloor(b):
    j = 0
    while j < len(b):
        f = b[j]
        showRoom(f)
        j += 1

def statusShow(h):
    for i in range(len(h)-1):
        b = h[i]
        showFloor(b)
        makeFence()
    showFloor(h[len(h)-1])

statusShow(h) 

   
#b = statusShow(h)
#makeFence()
#print(b)





Measured memory_bytes: 5636
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int a, b, c, d ;
    cin >> a >> b ;
    if(a < b) cout << 0 << "\n" ;
    else cout << 10 << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 256