akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int ans = 0;
        ans += n * (n-1)/2;
        ans += m * (m-1)/2;
        System.out.println(ans);

    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    lli tmpX = X;
    lli tmpK = K;
    K -= (lli)(X / D);
    X -= (lli)(X / D) * D;
    if (K == 0)
    {
        cout << X << endl;
        return 0;
    }
    else if (K < 0)
    {
        cout << tmpX - tmpK * D << endl;
        return 0;
    }
    else
    {
        if (K % 2 == 0)
        {
            cout << X << endl;
        }
        else
        {
            cout << abs(X - D) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
void error(){W("WA");exit(0);}
int main(){
    string s;
    R(s);
    if(s[0]!='A')error();
    VI id;
    FOR(i,1,SZ(s)-1){
        if(s[i]=='C')id.PB(i);
    }
    if(SZ(id)!=1||id[0]==SZ(s)-1||id[0]==1)error();
    REPP(i,1,SZ(s)){
        if(i==id[0])continue;
        if(s[i]>'z'||s[i]<'a')error();
    }
    W("AC");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,c;
int main(){
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++){cin>>a[i];b[i]=a[i];}
    sort(b.begin(),b.end());
    if(b[n-2]==b[n-1])for(int i=0;i<n;i++)cout<<b[n-1]<<endl;
    else for(int i=0;i<n;i++)cout<<(a[i]==b[n-1]?b[n-2]:b[n-1])<<endl;
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100000];
    scanf("%s",s);
    int l =strlen(s);
    if(l>=6){
        if(s[2]==s[3] && s[4]==s[5])
        printf("Yes");
    else
        printf("No");
    }
    else
        printf("No");
    
    return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a

import sys
input = sys.stdin.readline

N, P = [int(x) for x in input().split()]

# 素因数分解
# 考え方：1~√nまで実際に割れるか試せば良いが、割れた場合は割れる限りその数で割り続ける
# 計算量：O(√n)
def prime_factorize(n):
    i = 2
    primes = []
    while i * i <= n:
        if n % i != 0:
            i += 1
            continue
        exp = 0
        while n % i == 0:
            exp += 1
            n = n // i
        primes.append([i, exp])
        i += 1
    # 最後に残った数は1か素数にしかならない
    if n != 1:
        primes.append([n, 1])
    return primes

primes = prime_factorize(P)

max_gcd_primes = [[prime[0],prime[1]//N] for prime in primes]
max_gcd = 1
for prime in max_gcd_primes:
    max_gcd *= prime[0] ** prime[1]
print(max_gcd)

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N; cin >> N;
    vector<ll> counter(5);
    string march = "MARCH";
    rep(i, N) {
        string s;
        cin >> s;
        int n;
        if ((n = march.find(s[0])) != string::npos)
            counter[n]++;
    }
    
    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 5; j++) {
            ll combi = 1;
            for (int k = 0; k < 5; k++) {
                if (k != i && k != j) {
                    combi *= counter[k];
                }
            }
            ans += combi;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, t;
vector<int> m, l, k;

bool solve(int ope)
{
    vector<int> opeEnd(t+1, 0);
    opeEnd[0] = ope;
    vector<bool> check(n, false);
    int opeRest = 0;
    int cusRest = n;

    for(int i=0; i<=t; ++i){
        opeRest += opeEnd[i];
        for(int j=0; j<n; ++j){
            if(opeRest == 0)
                break;
            if(!check[j] && i % (l[j] + k[j]) <= l[j]){
                if(i + m[j] > t)
                    return false;
                ++ opeEnd[i+m[j]];
                check[j] = true;
                -- opeRest;
                if(-- cusRest == 0)
                    return true;
            }
        }
    }

    return false;
}

int main()
{
    for(;;){
        cin >> n >> t;
        if(n == 0)
            return 0;

        m.resize(n);
        l.resize(n);
        k.resize(n);
        for(int i=0; i<n; ++i)
            cin >> m[i] >> l[i] >> k[i];

        int ret = 1;
        while(!solve(ret))
            ++ ret;

        cout << ret << endl;
    }
}

Measured memory_bytes: 924
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int func(int x){
    if (x % 2 == 0){
        return x / 2;
    }else{
        return 3 * x + 1;
    }
    
}

int main(){
    int s;
    cin >> s;
    int a[1000001];
    fill(a, a + 1000001, 0);
    a[s] = 1;
    int ans;
    for (int i = 2; true; i++){
        s = func(s);
        if (a[s] != 0){
            ans = i;
            break;
        }
        a[s] = 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4096
n,m = map(int,input().split())
class 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

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(n+1)
for i in range(m):
  x,y,z = map(int, input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)

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

int main(){
	 ll n, m, count = 0, sum = 0;
     cin>>n>>m;
     vector<int>v(n);
     for(int i =0; i<n; i++){
         cin>>v[i];
         sum += v[i];
     }
     ll y = ceil((double)((double)sum / (double)(4 * m)));
     for(int i =0; i<n; i++){
         if(v[i] >= y)
            count += 1;
     }
    if(count >= m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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;
using namespace std;
int main(void){
    string s;int k;cin>>s>>k;
    map<char,int> mp;
    map<string,int> mp2;
    rep(i,s.size()) mp[s[i]]++;
    priority_queue<string, vector<string>, greater<string> > que;
    int tmp=0;
    for(auto& p:mp){
        char c=p.first;
        rep(i,s.size()){
            if(s[i]==c){
                string t="";
                rep(j,5){
                    if(i+j>=s.size())break;
                    t.push_back(s[i+j]);
                    if(mp2[t]!=0)continue;
                    que.push(t);
                    tmp++;
                    mp2[t]++;
                }
            }
        }
        if(tmp>=5)break;
    }
    rep(i,k-1){
        //cout<<que.top()<<endl;
        que.pop();
    }
    cout<<que.top()<<endl;
}

Measured memory_bytes: 384
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var K = F();
		var m = long.MaxValue;
		for (var i = 0; i < (1 << N); i++)
		{
			var p = 1L;
			for (var j = 0; j < N; j++) if ((i & (1 << j)) != 0) p *= 2; else p += K;
			m = Min(m, p);
		}
		Console.WriteLine(m);
	}
}


Measured memory_bytes: 11092
N,x=map(int,input().split())
A=list(map(int,input().split()))
AA=sorted(A)
ans=0
for i in range(N):
  if x>=AA[i]:
    x-=AA[i]
    ans+=1
  else:
    x=0
    break
if x>0:
  print(ans-1)
else:
  print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        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);
    }
};

int n,m,q,row[300010],cnt[300010],col[300010];
vector<int> v[300010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++){
		int x,y;cin>>x>>y;
		row[x]++;col[y]++;
		v[y].push_back(x); 
	}
	int maxv=0;
	for(int i=1;i<=m;i++) maxv=max(maxv,col[i]);
	int tot=0;
	for(int i=1;i<=m;i++) if(col[i]==maxv) tot++;
	for(int i=1;i<=m;i++) if(col[i]==maxv){
		for(int j=0;j<v[i].size();j++) cnt[v[i][j]]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int val=row[i]+maxv;
		if(cnt[i]==tot) val--;
		ans=max(ans,val);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23464
def main():
    N = int(input())

    h = [int(i) for i in input().split()]

    h0 = h[0] - 1
    ans = 'Yes'
    for i in range(1, N):
        if h0 < h[i]:
            h0 = h[i] - 1
            # h1 = h[i] - 1
            # if h1 > h0:
            #     ans = 'No'
            #     break
            # else:
            #     h0 = h1
        elif h0 > h[i]:
            ans = 'No'
            break

    print(ans)

if __name__ == "__main__":
    main()



Measured memory_bytes: 20544
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]
        self.member_num = [1 for _ in range(size)]
 
    #representative
    def find(self,x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        m1=self.member_num[s1]
        m2=self.member_num[s2]
        if s1 != s2:
            if m1 != m2:
                if m1 < m2:
                    self.table[s1] = s2
                    self.member_num[s2]=m1+m2
                    return [m1,m2]
                else:
                    self.table[s2] = s1
                    self.member_num[s1]=m1+m2
                    return [m1,m2]
            else:
                self.table[s1] = -1
                self.table[s2] = s1
                self.member_num[s1] = m1+m2
                return [m1,m2]
        return [0,0]

N,Q = list(map(int,input().split()))

uf = UnionFind(N)

for i in range(Q):
    t,u,v = list(map(int,input().split()))
    
    if t==0:
        uf.union(u,v)
    else:
        if uf.find(u)==uf.find(v):
            print(1)
        else:
            print(0)

Measured memory_bytes: 93640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>
using namespace std;

vector<int> a;         //命令 a[1]-a[n] 1-n ->0-9,u
vector<vector<int> > ok;
//vector<vector<int> > doteki;
int n;
int sec(int p,int q);
void pr();

int main(){
  scanf ("%d",&n);
  while(n){
    int f=0;
    a.assign(n,0);
    ok.assign(n,a);
    //doteki.assign(n,a);
    for(int t=0;t<n;t++){
      scanf ("%d",&a[t]);
    }
    for(int s=0;(s+1)<n;++s){
      ok[s][s+1]=sec(s,s+1);
    }
    for(int t=3;t<n;t=t+2){
      for(int s=0;(s+t)<n;++s){
        f=0;
        for(int u=1;u<t-1;u=u+2){
          if(ok[s][s+u]&&ok[s+u+1][s+t]){
            f=1;
          }
        }
        if(f==1||(sec(s,s+t)&&ok[s+1][s+t-1])){
          ok[s][s+t]=t+1;
        }
      }
    }


    for(int x=1;x<n;++x){
      for(int y=0;y+x<n;++y){
        for(int z=y;z<y+x;++z){
          ok[y][y+x]=max(ok[y][y+x],ok[y][z]+ok[z+1][y+x]);
        }
        //pr();
      }
    }
    printf("%d\n",ok[0][n-1]);
    scanf ("%d",&n);
  }
}



//変化したところだけ見る



int sec(int p,int q){
  if(-1<=(a[p]-a[q])&&(a[p]-a[q])<=1){
    return 2;
    //ok[p][q]=1;
  }
  else{
    return 0;
    //ok[p][q]=0;
  }
}

void pr(){
  for(int x=0;x<n;++x){
    for(int y=0;y<n-1;++y){
      printf("%d ",ok[x][y]);
    }
    printf("%d\n",ok[x][n-1]);
  }
  printf("\n");
}



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

using namespace std;


int main(){
	int N,M;
  cin  >> N >> M;
  
  cout << (N-1)*N/2+(M-1)*M/2 << endl;
  
}





Measured memory_bytes: 256
import java.io.BufferedInputStream



// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    fun iterateTokens(): Iterator<String> {
        val reader = BufferedInputStream(System.`in`).bufferedReader()
        val iterator = reader.lineSequence()
                .map { it.split(" ") }
                .reduce { left, right -> left + right }
                .iterator()
        return iterator
    }
    val tokens = iterateTokens()
    val N = tokens.next().toLong()
    val V = LongArray(N.toInt())
    for(i in 0 until N.toInt()){
        V[i] = tokens.next().toLong()
    }
    val C = LongArray(N.toInt())
    for(i in 0 until N.toInt()){
        C[i] = tokens.next().toLong()
    }
    solve(N, V, C)
}

fun solve(N: Long, V: LongArray, C: LongArray){
    var ans = 0L
    for ( i in 0 until N.toInt()){
        if (V[i] - C[i] > 0){
        ans += V[i] - C[i]
        }
    }
    println(ans)
    return
}



Measured memory_bytes: 33832
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        map<char,char> mp;
        rep(i,n){
            char a,b;
            cin>>a>>b;
            mp[a]=b;
        }
        int nn;cin>>nn;
        rep(i,nn){
            char c;
            cin>>c;
            if(mp.count(c)){
                cout << mp[c];
            }else{
                cout << c;
            }
        }
        cout << endl;
    }
}

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


int main(){
  string str;
  cin >> str;
  int count = 0;
  
  for (int i=0; i < 3; i++){
    if(str.at(i) == 'A'){
      count++;
    }
  }
  
  if (count == 3 || count == 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n),f(n);
  ll ans = 0;
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> f[i];
  }
  sort(all(a),greater<ll>());
  sort(all(f));

  ll iFirst = 0;           // 探索範囲の最初の要素
  ll iLast  = INFLONG;  // 探索範囲の最後の要素
  ll iComp;                // 比較する要素
  ll nComped;              // 比較結果

  // 探索範囲がなくなったら終了
  while(iLast - iFirst > 0){
    iComp = (iFirst + iLast) / 2;  // 平均値をとる
    ll sum = 0;
    //cout << iFirst << " " << iLast << " " << iComp << endl;
    rep(i,n){
      //tmp1 = ((iComp % f[i]) && 1);
      tmp2 = iComp / f[i];
      //cout << a[i] << " " <<  tmp2 << endl;
      if(a[i]-tmp2 > 0){
        sum += a[i]-tmp2;
      }
    }
    //cout << sum << endl;
    if(sum > k){
      iFirst = iComp + 1;
    }else{
      iLast  = iComp;
    }
//    nComped = pnData[iComp] - num;
//
//    // 要素との差が０なら探索終了
//    if(nComped == 0)
//      return iComp;
//    // 探す値の方が大きいときは、iFirst を進める
//    if(nComped < 0)
//      iFirst = iComp + 1;
//      // 逆の時は iLast を戻す
//    else
//      iLast  = iComp - 1;
  }
  cout << iLast << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> eve(N+1/2+1);
    vector<ll> odd(N/2+1);//累積
    vector<ll> eves(N+1/2);
    vector<ll> odds(N/2);
    REP(i,N){
        if(i %2 == 0){
            ll tmp;
            cin >> tmp;
            eve[i/2+1] = eve[i/2]+tmp;
            eves[i/2] = tmp;
        }else{
            ll tmp;
            cin >> tmp;
            odd[i/2+1] = odd[i/2]+tmp;
            odds[i/2] = tmp;
        }
    }
    if(N %2 == 0){
        ll answer = odd[N/2]-odd[0]+eve[0];
        REP(i,N/2+1){
            chmax(answer,odd[N/2]-odd[i]+eve[i]);
        }
        cout << answer << "\n";
    }else{
        ll max0 = 0;
        ll max1 = 0;
        ll max2 = 0;
        REP(i,N/2){
            ll max0b = max0;
            ll max1b = max1;
            ll max2b = max2;
            max0 = max0b+eves[i];
            max1 = max(max1b + odds[i],max0b + odds[i]);
            max2 = max({max0b + eves[i+1],max1b + eves[i+1],max2b + eves[i+1]});
        }
        cout << max({max0,max1,max2}) << "\n";
    }
}

Measured memory_bytes: 7960
qsort [] = []
qsort (x:xs) = (qsort [s | s <- xs, s < x]) ++ [x] ++ (qsort [g | g <- xs, g >= x])

main = do
  input <- getLine
  let tasks = qsort $ map read (words input) :: [Int]
  print $ (tasks !! 1 - tasks !! 0) + (tasks !! 2 - tasks !! 1)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int f;
    cin >> f;
    cout << (f-30)/2 << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	double a,b;
	cin>>a>>b;
	printf("%.9f\n",a*b/3.305785);
}

Measured memory_bytes: 1236
from collections import deque,Counter

N = int(input())
S = [input() for _ in range(N)]

slist = "abcdefghijklmnopqrstuvwxyz"

anscnt = Counter()
for s in slist:
    anscnt[s] = 50

for line in S:
    tmp = Counter(line)
    for s in slist:
        anscnt[s] = min(anscnt[s],tmp[s])

ans = []
for s in slist:
    ans.append(s * anscnt[s])

print(*ans,sep="")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int m, k; cin >> m >> k;
	if( !( 0 <= k && k <= (1<<m)-1 ) ){
		cout << -1 << endl;
		return 0;
	}
	if( m == 1 ){
		if( k == 1 ){
			cout << -1 << endl;
			return 0;
		}
	}
	if( k == 0 ){
		for( int i = 0; i < (1<<m); ++i ){
			cout << i << ' ' << i;
			if( i != (1<<m)-1 ) cout << ' '; 
		}
		cout << endl;
	} else{
		for( int i = 0; i < (1<<m); ++i ){
			if( i != k ) cout << i << ' ';
		}
		cout << k << ' ';
		for( int i = (1<<m)-1; i >= 0; --i ){
			if( i != k ) cout << i << ' ';
		}
		cout << k << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def make_divisors(n): # nの約数を列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

# 全ての合計の約数が答えの候補、上から可能かどうか見ていく
N, K = lr()
A = np.array(lr())
total = A.sum()
D = make_divisors(total) # 降順
for d in D:
    B = A % d   
    B.sort()
    inc = d - B
    B_cum = B.cumsum()
    inc_cum = inc.cumsum()
    for i in range(N):
        x = B_cum[i]
        y = inc_cum[N-1] - inc_cum[i]
        if x > K: # xは単調増加
            break
        if y > K:
            continue
        if (x+y) // 2 <= K:
            print(d); exit()


Measured memory_bytes: 14452
#include<bits/stdc++.h>
#define int ll
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 2e5+233;
int n,x[maxn],s[maxn],X;
signed main(){
	n = rd();X = rd();
	Rep(i,1,n) x[i] = rd(),s[i] = s[i-1] + x[i];
//	ans = n * X;
	__int128 ans = 1e30;
	for(int k=1;k<=n;++k){
		__int128 res = 0;
		__int128 t = 0,w;
		for(int j=n;j>0;j-=k){
			++t;
			if(t==1) w = 5; else w = 2 * t + 1;
//			printf("%lld * %lld\n",s[j]-s[max(0ll,j-k)],w);
			res += (__int128)(s[j] - s[max(0ll,j-k)]) * w;
		}
//		writeln(res);
		ans = min(ans,res+(n+k)*X);
	}
	writeln(ans);
	return 0;
}

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

F = []
for _ in range(N):
    F.append(list(map(int, input().split())))
    
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))
    
from itertools import product
joisino_store_product = list(product([0, 1], repeat=10))[1:]

def binary_compare(A, B):
    C = []
    for i, j in zip(A, B):
        if i == 1 and  j == 1:
            C.append(1)
        else:
            C.append(0)
    return C
  
sum_list = []

for joisino_store in joisino_store_product:
    C = []
    priceSum = 0
    
    for F_store in F:
        C.append(sum(binary_compare(joisino_store, F_store)))
    
    for C_num, P_list in zip(C, P):
        priceSum += P_list[C_num]
        
    sum_list.append(priceSum)
    
print(max(sum_list))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long int res = 0;
    for(int i = 0; i < n; i++){
        long long int aleft = -1;
        long long int aright = n;
        while(aright - aleft > 1){
            int mid = aleft + (aright - aleft)/2;
            if(a[mid] >= b[i]) aright = mid;
            else aleft = mid;
        }

        long long int cleft = -1;
        long long int cright = n;
        while(cright - cleft > 1){
            int mid = cleft + (cright - cleft)/2;
            if(c[mid] > b[i]) cright = mid;
            else cleft = mid;
        }

        res += aright * (n - cright);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 1000005
#define ip(n) int n; cin>>n;
#define ll long long int
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main(){
	FastIO
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	string s,t;
	cin>>s>>t;
	t.pop_back();
	if(s == t) cout<<"Yes";
	else cout<<"No";
	return 0; 
}


Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> m = new ArrayList<Integer>();
        ArrayList<Integer> f = new ArrayList<Integer>();
        ArrayList<Integer> r = new ArrayList<Integer>();
        int tempm, tempf, tempr;

        while (true) {
            tempm = sc.nextInt();
            tempf = sc.nextInt();
            tempr = sc.nextInt();

            if (tempm == -1 && tempf == -1 && tempr == -1)
                break;

            m.add(tempm);
            f.add(tempf);
            r.add(tempr);
        }

        for (int i = 0; i < m.size(); i++) {
            if(m.get(i) == -1 || f.get(i) == -1) System.out.println("F");
            else if(m.get(i) + f.get(i) >= 80) System.out.println("A");
            else if(m.get(i) + f.get(i) >= 65) System.out.println("B");
            else if(m.get(i) + f.get(i) >= 50) System.out.println("C");
            else if(m.get(i) + f.get(i) >= 30) {
                if(r.get(i) >= 50) System.out.println("C");
                else System.out.println("D");
            }
            else System.out.println("F");
        }

        sc.close();
    }
}


Measured memory_bytes: 26132
using System;
using System.Linq;
using System.Collections.Generic;

namespace N
{
    class Program
    {
        static bool IsOK(int[] arr, int index, int key)
        {
            if (arr[index] >= key) return true;
            else return false;
        }

        static int Binary_search(int[] arr, int key)
        {
            int ng = -1;
            int ok = arr.Count();

            while (ok - ng > 1)
            {
                int mid = ng + (ok - ng) / 2;

                if (IsOK(arr, mid, key)) ok = mid;
                else ng = mid;
            }

            return ok;
        }
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a); Array.Sort(b);
            long ret = 0;
            for (long i = 0; i < x[0]; i++)
            {
                ret += (x[1] - (long)Binary_search(b, a[i])) * a[i];
            }
            for (long i = 0; i < x[1]; i++)
            {
                ret += (x[0] - (long)Binary_search(a, b[i])) * b[i];
            }
            Dictionary<int, Tuple<int, int>> dic = new Dictionary<int, Tuple<int, int>>();
            for (int i = 0; i < x[0]; i++)
            {
                if (!dic.ContainsKey(a[i])) dic[a[i]] = new Tuple<int, int>(0, 0);
                dic[a[i]] = new Tuple<int, int>(dic[a[i]].Item1 + 1, dic[a[i]].Item2);
            }
            for (int i = 0; i < x[1]; i++)
            {
                if (!dic.ContainsKey(b[i])) dic[b[i]] = new Tuple<int, int>(0, 0);
                dic[b[i]] = new Tuple<int, int>(dic[b[i]].Item1, dic[b[i]].Item2 + 1);
            }
            foreach (var item in dic)
            {
                ret -= (long)item.Key * item.Value.Item1 * item.Value.Item2;
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 53160
n,d,a=[int(j) for j in input().split()]
xh=[[int(j) for j in input().split()] for i in range(n)]
xh.sort()
from collections import deque
q=deque()
ans=0
dmg=0
for x,h in xh:
    while q and q[0][0]<x:
        i,j=q.popleft()
        dmg-=j
    r=h-dmg
    if r<=0:
        continue
    p=-(-r//a)
    dmg+=p*a
    ans+=p
    q.append((x+2*d,p*a))
print(ans)






Measured memory_bytes: 53960
'''
問題：
    私たちは N 人で旅行しようとしており、
    その交通手段として電車とタクシーがあります。

    電車を使うと 1人あたり A円かかります。
    タクシーを使うと N人で B円かかります。

    全員の交通費の合計は最小でいくらになるでしょうか。
'''

'''
制約：
    入力は全て整数である。
    1 ≤ N ≤ 20
    1 ≤ A ≤ 50
    1 ≤ B ≤ 50
'''

# 標準入力から N, A, B の値を取得する
n, a, b = map(int, input().split())

# 合計の交通費を計算・比較し、最小の交通費を出力する
result = 0

if (n * a) >= b:
    result = b
else:
    result = (n * a)

print(result)


Measured memory_bytes: 9104
#include <iostream>
#include <string>

using namespace std;

char str[15];
int size;
string in;

bool check(){
  if(size < 3) return false;
  if(str[size/2-1] == 'i' && str[size/2] == 'w' && str[size/2+1] == 'i'){
    bool f = true;
    for(int i=0;;i++){
      if(str[i] == 'i' && str[size-1-i] == 'i') break;
      if(str[i] == '(' && str[size-1-i] == ')') continue;
      if(str[i] == ')' && str[size-1-i] == '(') continue;
      if(str[i] == '{' && str[size-1-i] == '}') continue;
      if(str[i] == '}' && str[size-1-i] == '{') continue;
      if(str[i] == '[' && str[size-1-i] == ']') continue;
      if(str[i] == ']' && str[size-1-i] == '[') continue;
      f = false;
      break;
    }
    return f;
  }
  return false;
}

int solve(int p){
  int res = 0;
  if(p == in.size()){
    if(check()) res = size;
  }else if(in[p] == 'i' || in[p] == 'w'){
    str[size] = in[p];
    ++size;
    res = solve(p+1);
    --size;
  }else{
    int tmp = solve(p+1);
    str[size] = in[p];
    ++size;
    res = max(tmp, solve(p+1));
    --size;
  }
  return res;
}

main(){
  cin >> in;
  size = 0;
  cout << solve(0) << endl;
  return 0;
}

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

using namespace std;

int main(){
  long long i,n,j,s;
  string S;
  cin >> S;
  j=0;
  s=0;
  for (i=0;i<S.size();i++) {
    if (S[i]=='B') {
      j++;
    } else {
      s+=j;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 640
#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 mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	map<string,int> m;
	int maxx=0;
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		if(!m[s]) m[s]=1;
		else ++m[s];
		maxx=max(maxx,m[s]);
	}
	for(auto x:m){
		if(x.second==maxx) cout<<x.first<<endl;
	}
	return 0;	
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<string> v(n);
    REP(i, n){
        string s;
        cin >> s;
        sort(all(s));
        v[i] = s;
    }
    sort(all(v));
    v.push_back("a");

    ll ans = 0;
    int l = 0, r = 1;
    while(r <= n){
        if(v[l] == v[r]){
            r++;
        }else{
            ans += (ll)(r - l)*(r - l - 1)/2;
            l = r;
            r = l + 1;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector> 
#include <algorithm>
#include <functional>

using namespace std;
int main(void){
    int n,k,b,c=0;
    vector<int> a;
    cin>>n>>k;
    for(int i=0;i<n;i++){cin>>b;a.push_back(b);}
    sort(a.begin(),a.end());
    for(int i=0;i<k;i++)c+=a[n-1-i];
    cout<<c;
}


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

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

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

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

int main(){
    int A,B; cin >> A >> B;
    string S; cin >> S;
    bool f=true;
    for(int i=0;i<A+B+1;i++){
        if(i==A){
            if(S[i]!='-') f=false;
        }else{
            if(S[i]=='-') f=false;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter 
def partition(A,p,r):
    x = A[r][1]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def quicksort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quicksort(A,p,q-1)
        quicksort(A,q+1,r)
A = []
n = int(input())
for i in range(n):
    a,b = map(str,input().split())
    A.append([a,int(b)])

B = [i for i in A]
quicksort(A,0,n-1)

B.sort(key=itemgetter(1))

if A == B:
    print("Stable")
else:
    print("Not stable")
for i in A:
    print(i[0],i[1])


Measured memory_bytes: 19736
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	int n,k;
	cin >> n >> k ;
	map<int,int>b;
	while(k--)
	{
		int d;
		cin >> d;
		while(d--)
		{
			int x;
			cin >> x;
			b[x]++;
		}
	}
	for(i=1;i<=n;i++)
		if(b[i] == 0)
			sum++;
	cout << sum << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {//Read line, and split it by whitespace into an array of strings
            string[] tokens = Console.ReadLine().Split();

            //Parse element 0
            int a = int.Parse(tokens[0]);

            //Parse element 1
            int b = int.Parse(tokens[1]);

            int p = a + b;
            int min = a - b;
            int mul = a * b;
            double[] data = { p,min,mul };
            double max = data.Max();
            Console.WriteLine(+ max);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

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

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    //COMinit();
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    REP(i,a) cin>>p[i];
    REP(i,b) cin>>q[i];
    REP(i,c) cin>>r[i];
    sort(ALL(p));
    sort(ALL(q));
  	/*cout<<"p:";
    for(auto& i:p)cout<<i<<" ";
  	cout<<endl;
  	cout<<"q:";
    for(auto& i:q)cout<<i<<" ";
  cout<<endl;
  cout<<"r:";
    for(auto& i:r)cout<<i<<" ";
  cout<<endl;*/
    REP(i,x) r.push_back(p[a-1-i]);
    REP(i,y) r.push_back(q[b-1-i]);
    sort(ALL(r));
  	/*cout<<"r':";
    for(auto& i:r)cout<<i<<" ";
      cout<<endl;*/
    ll sum=0;
    REP(i,x+y+1){
        sum+=r[r.size()-i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int a, b, k;
    cin >> a >> b >> k;

    if (b - k + 1 <= a + k - 1)
    {
        rem(i, a, b + 1)
        {
            cout << i << "\n";
        }
    }
    else
    {
        rem(i, a, a + k)
        {
            cout << i << "\n";
        }
        rem(i, b - k + 1, b + 1)
        {
            cout << i << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256