akhauriyash/Code-Regression huggingface dataset:
import Data.List as L
import Control.Monad
ok' :: [Bool] -> [Int] -> Int -> Bool
ok' bit s p = ( length $ [] ++ [　() | si <- s, bit !! (si-1) ] ) `mod` 2 == p

ok :: [Bool] -> [[Int]] -> [Int] -> Int -> Bool
ok bit s p m = ( length $ [] ++ [ () | i <- [0..m - 1], ok' bit (s !! i) (p !! i) ] ) == m

main = do
        [n, m] <- fmap ( L.map read . L.words ) getLine :: IO [Int]
        s <- replicateM m $ fmap ( tail . L.map read . L.words ) getLine :: IO [[Int]]
        p <- fmap ( L.map read . L.words ) getLine :: IO [Int]
        let bits = sequence $ replicate n [False, True]
        print $ length $ [ () | bit <- bits, ok bit s p m ]

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

#define ff        first
#define ss        second
#define int       long long
#define pb        push_back
#define mp        make_pair
#define vi        vector<int>
#define pii       pair<int,int>
#define mii       map<int,int>
#define w(x)      int x; cin>>x; while(x--)
#define all(x)      (x).begin(),(x).end()
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define mod       1000000007

int dp[101][100001],val[101],wt[101];

void c()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int32_t main() {

    //c();
    int n,w; cin>>n>>w;
    rep(i,0,n) cin>>wt[i]>>val[i];

    rep(i,0,n+1) dp[i][0]=0;
    rep(j,0,w+1) dp[0][j]=0;

    rep(i,1,n+1)
        rep(j,1,w+1)
        {
            if(wt[i-1]<=j)
                dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }

     cout<<dp[n][w];
            
    return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

ll a,b,c,k;


int main()
{
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
    }
    else if (k<=a+b)
    {
        cout<<a<<endl;
    }
    else
    {
        cout<<a-(k-a-b)<<endl;
    }
    
    
    
    return 0;

}




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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new long[n];
            var b = new long[n];
            for (var i = 0; i < n; i++) {
               var t = Console. ReadLine().Split().Select(long.Parse).ToArray();
               a[i] = t[0];
               b[i] = t[1];
            }
            
            var minus = 0L;
            for (var i = n - 1; i >= 0; i--) {
               a[i] += minus;
               if (a[i] % b[i] != 0)
                   minus += b[i] - a[i] % b[i];
            }
            
            Console.WriteLine(minus);
        }
    }
}


Measured memory_bytes: 18784
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int N;
int a,b;
int D;
vpint H,U,V;
set<pint> X,Y,G;
//頂点(x,y)からたどり着ける点を列挙する
void DFS(int x,int y){
	//削除する頂点集合
	set<pint> del;
	//X=x+D
	for(auto it=X.lower_bound(mp(x+D,y-D));it!=X.end() && (*it).first==x+D && (*it).second<=y+D;it++){
		int u=(*it).first,v=(*it).second;
		del.insert(mp(u,v));
	}
	//X=x-D;
	for(auto it=X.lower_bound(mp(x-D,y-D));it!=X.end() && (*it).first==x-D && (*it).second<=y+D;it++){
		int u=(*it).first,v=(*it).second;
		del.insert(mp(u,v));
	}
	//Y=y+D
	for(auto it=Y.lower_bound(mp(y+D,x-D));it!=Y.end() && (*it).first==y+D && (*it).second<=x+D;it++){
		int v=(*it).first,u=(*it).second;
		del.insert(mp(u,v));
	}
	for(auto it=Y.lower_bound(mp(y-D,x-D));it!=Y.end() && (*it).first==y-D && (*it).second<=x+D;it++){
		int v=(*it).first,u=(*it).second;
		del.insert(mp(u,v));
	}
	//見つけた頂点を到達可能頂点リストにいれ、頂点集合から削除する
	for(pint P:del){
		int u=P.first,v=P.second;
		U.pb(mp(u,v));
		V.pb(mp(v,u));
		X.erase(mp(u,v));
		Y.erase(mp(v,u));
	}
	//再起呼び出しをする
	for(pint P:del){
		DFS(P.first,P.second);
	}
}
int main(){
	cin>>N;
	cin>>a>>b;
	a--,b--;
	for(int i=0;i<N;i++){
		//盤面を45度回転させる
		int x,y;
		cin>>x>>y;
		H.pb(mp(x+y,x-y));
		X.insert(mp(x+y,x-y));
		Y.insert(mp(x-y,x+y));
	}
	D=max(abs(H[a].first-H[b].first),abs(H[a].second-H[b].second));
	//到達可能な点の集合を求める
	U.pb(mp(H[a].first,H[a].second));
	U.pb(mp(H[b].first,H[b].second));
	V.pb(mp(H[a].second,H[a].first));
	V.pb(mp(H[b].second,H[b].first));
	X.erase(mp(H[a].first,H[a].second));
	X.erase(mp(H[b].first,H[b].second));
	Y.erase(mp(H[a].second,H[a].first));
	Y.erase(mp(H[b].second,H[b].first));
	DFS(H[a].first,H[a].second);
	DFS(H[b].first,H[b].second);
	ll ans=0;
	sort(U.begin(),U.end());
	sort(V.begin(),V.end());
	//到達可能な頂点集合を順番に見て、到達可能な頂点集合から距離Dの頂点集合の数を足す
	for(pint P:U){
		int x=P.first,y=P.second;
		//4隅はXの条件に入れることにする
		//X=x+D
		ans+=upper_bound(U.begin(),U.end(),mp(x+D,y+D))-lower_bound(U.begin(),U.end(),mp(x+D,y-D));
		//X=x-D
		ans+=upper_bound(U.begin(),U.end(),mp(x-D,y+D))-lower_bound(U.begin(),U.end(),mp(x-D,y-D));
		//Y=y+D
		ans+=upper_bound(V.begin(),V.end(),mp(y+D,x+D-1))-lower_bound(V.begin(),V.end(),mp(y+D,x-D+1));
		//Y=y-D
		ans+=upper_bound(V.begin(),V.end(),mp(y-D,x+D-1))-lower_bound(V.begin(),V.end(),mp(y-D,x-D+1));
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
string s;
int calc(int l,int r){
    
    for(int i = l;i <= r;i++){
        if(s[i] == 'A'||s[i] == 'T'||s[i] == 'G'|| s[i]== 'C')continue;
        return 0;
    }
    return r-l+1;
}
signed main(){
    cin >> s;
    int ans = 0;
    int n = s.size();
    rep(i,n)for(int j = i;j < n;j++){
        ans = max(ans,calc(i,j));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC097 C - K-th Substring
s = input()
k = int(input())

n = len(s)
d = set()
l = []

for i in range(k):
    for j in range(n-i):
        d.add(s[j:j+i+1])
l = list(d)
l.sort()

print(l[k-1])

Measured memory_bytes: 4464
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<double> a(n);
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  double ans=sum/n;
  double sa=1e9;
  int id=0;
  for(int i=0;i<n;i++){
    if(sa>abs(ans-a[i])){
      sa=abs(ans-a[i]);
      id=i;
    }
  }
  cout<<id<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 322222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int r[N], c[N];
vi v[N];
int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	int mx = 0;
	for(int i = 1; i <= q; i ++)
	{
		int x, y;
		cin >> x >> y;
		r[x] ++;
		c[y] ++;
		mx = max(mx, c[y]);
		v[x].pb(y);
	}
	set<int> s;
	for(int i = 1; i <= m; i ++)
	{
		if(c[i] == mx)
			s.insert(i);
	}
	int ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int cnt = 0;
		for(auto it : v[i])
			cnt += s.count(it);
		if(cnt != s.size())
			ans = max(ans, r[i] + mx);
		else
			ans = max(ans, r[i] + mx - 1);
	}
	cout << ans;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;
#define log2ll(x) (63 - __builtin_clzll(x))

int lp[1000000];
vector<ll> p;

void sieve(int n) {
	for (int i = 2; i <= n; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			p.push_back(i);
		}
		for (int j = 0; j < (int) p.size() && p[j] <= lp[i] && i * p[j] <= n; j++)
			lp[i * p[j]] = p[j];
	}
}

int n;
ll s[200000];
unordered_map<ll, int> m;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  sieve(100000);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (ll pr : p) {
      if (pr * pr * pr > s[i])
        break;
      while (s[i] % (pr * pr * pr) == 0)
        s[i] /= pr * pr * pr;
    }
    m[s[i]]++;
  }
  int r = 0;
  for (auto & e : m) {
    if (e.first == 1)
      r++;
    else {
      ll h = e.first, o = 1;
      for (ll pr : p) {
        if (pr * pr > h || o > 10100100100LL)
          break;
        if (h % pr == 0) {
          h /= pr;
          o *= pr;
          if (o > 10100100100LL)
            break;
          if (h % pr == 0) {
            h /= pr;
          } else {
            o *= pr;
          }
        }
      }
      if (o > 10100100100LL || log2ll(o) + log2ll(h) * 2 > 40)
        r += e.second;
      else {
        o *= h * h;
        if (o > 10100100100LL || m.find(o) == m.end())
          r += e.second;
        else if (e.first < o)
          r += max(e.second, m[o]);
      }
    }
  }
  cout << r << "\n";
}


Measured memory_bytes: 5668
use proconio::*;

fn f(x: usize, y: usize, z: usize) -> usize {
    x*x + y*y + z*z + x*y + y*z + z*x
}

fn main() {
    input!{
        n: usize,
    }

    let mut ans = vec![0; n];
    for i in 1..=n {
        if f(i, 0, 0) > n {
            break;
        }
        for j in 1..=n {
            if f(i, j, 0) > n {
                break;
            }
            for k in 1..=n {
                let t = f(i, j, k);
                if t <= n {
                    ans[t-1] += 1;
                } else if t > n {
                    break;
                }
            }
        }
    }

    for i in 0..n {
        println!("{}", ans[i]);
    }
}


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

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

using namespace std;

int main(){
	int h,w; cin>>h>>w;
	vector<string> B(h);
	rep(i,h) cin>>B[i];

	vector<string> res1(h,string(w,'.'));
	vector<string> res2(h,string(w,'.'));
	rep(i,h) rep(j,w) {
		if(i==0 || (i<h-1 && j%2==0)) res1[i][j]='#';
		else                          res2[i][j]='#';
		if(B[i][j]=='#') res1[i][j]=res2[i][j]='#';
	}

	rep(i,h) cout<<res1[i]<<'\n';
	cout<<'\n';
	rep(i,h) cout<<res2[i]<<'\n';

	return 0;
}


Measured memory_bytes: 4620
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

		string s,b;
		cin>>s;
		cin>>b;
		if(s.length()!=b.length())
		cout<<"-1";
		
		else
		{
			int c=0;
			for(int i=0;i<s.length();i++)
			{
				if(s[i]!=b[i])
				c++;
			}
			cout<<c<<endl;
		}
	

	
}




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

using namespace std;

typedef pair<string, int> P;

//????????????????????????????????????
bool judge(string str) {
	for (int i = 0; i < str.size(); ++i) {
		if (str[0] != str[i]) return false;
	}
	return true;
}

//??£?????????2?????????????????§?????????????????????
char color(char a, char b){
	if((a == 'g' && b == 'r') || (a == 'r' && b == 'g'))return 'b';
	else if((a == 'b' && b == 'r') || (a == 'r' && b == 'b')) return 'g';
	else if((a == 'g' && b == 'b') || (a == 'b' && b == 'g')) return 'r';
}

int solve(string s ){

	queue<P> q;
	map<string, int> m;
	q.push(P(s, 0));	//?????\??????????????¶????????\??????

	while (!q.empty()) {	//?????\??????????????¶?????????????????§
		P p = q.front();
		q.pop();
		if(m[p.first]) continue;	//??????????????????
		string now = p.first;
		if (judge(now)) return p.second;
		m[p.first] = 1;
		for (int i = 0; i < now.size() - 1; ++i) {
			if (now[i] != now[i+1]){	//??£?????????2????????°????????¨???
				char tmp = color(now[i], now[i + 1]);
				string D = now;
				D[i] = tmp;
				D[i + 1] = tmp;
				q.push(P(D, p.second + 1));
			}
		}
	}
	return -1;
}

int main() {
	string worm;
	while (cin >> worm) {
		if (worm == "0") break;
		int count = solve(worm);
		if (count == -1) cout << "NA" << endl;
		else cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 4932
import numpy as np
import sys
input = sys.stdin.readline  #文字列入力では注意！

N,W = map(int,input().split())

dp = np.zeros(W+1, dtype=np.int64)
for i in range(N):
    w,v = map(int,input().split())
    np.maximum(dp[:-w]+v, dp[w:], out = dp[w:])

print(dp[-1])


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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  int D=0;
  int64_t ans=0;
  if(D<=X){
    ans++;
  }
  for(int i=0;i<N;i++){
    cin >> L.at(i);
    D=D+L.at(i);
    if(D<=X){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<set>
#include<string.h>
using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b;
    else if(a>=6)
        cout<<b/2;
    else
        cout<<"0";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	string S; cin>>S;
	int curr=0,mx=0;
	for(auto i:S){
		if(i=='R') curr++;
		else{
			mx=max(mx,curr);
			curr=0;
		}
	}
	mx=max(mx,curr);
	cout<<mx; 
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int s, w;
  cin >> s >> w;
  cout << (s <= w ? "unsafe" : "safe") << endl;
  return 0;
}

Measured memory_bytes: 3632
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    j = i + 1
    if j < N and A[i] + A[j] > X:
        d = min(A[j], (A[i] + A[j]) - X)
        ans += d
        A[j] -= d
    if A[i] + A[j] > X:
        d = min(A[i], (A[i] + A[j]) - X)
        ans += d
        A[i] -= d

print(ans)

Measured memory_bytes: 14252
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
p, q, r = cnt[1], cnt[2], cnt[3]

dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]

for k in range(r + 1):
    for j in range(r + q + 1):
        for i in range(n + 1):
            if not (0 < i + j + k <= n):
                continue
            if i > 0:
                dp[i][j][k] += dp[i - 1][j][k] * i
            if j > 0:
                dp[i][j][k] += dp[i + 1][j - 1][k] * j
            if k > 0:
                dp[i][j][k] += dp[i][j + 1][k - 1] * k
            dp[i][j][k] += n
            dp[i][j][k] /= (i + j + k)

print(dp[p][q][r])


Measured memory_bytes: 254600
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
  satisfaction+=B[A[i]-1]
    
  if  i<=N-2:
      if  A[i]+1==A[i+1]:
          satisfaction+=C[A[i]-1] 
  else:
      pass

print(satisfaction)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, L;
  vector<string> v;
  string s;
  cin >> N >> L;
  while(N--) {
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  for(auto it: v) cout << it;                                                            
}

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

int main() {
    ll n, m;
    cin >> n >> m;

    vvl a(n, vl(m));  // a[i][j] : 人iがj番目に好きなスポーツ
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    vl used(m);  // used[i] : 0のときスポーツiを実施する。1のとき実施しない
    vl v(n);  // v[i] : 人iが参加するスポーツの番号
    ll ans = n;
    rep(loop, m) {
        vl cnt(m);  // cnt[i] : スポーツiに参加する人数
        rep(i, n) {
            // 実施されているスポーツの中で人iの最も好きなスポーツを探す
            while(used[ a[i][v[i]] ]) {
                v[i]++;
            }
            cnt[ a[i][v[i]] ]++;  // 人iはスポーツa[i][v[i]]に参加
        }
        pair<ll, ll> p = make_pair(-1, -1);  // p = (参加人数の最大値, 参加人数最大のスポーツの番号)
        rep(i, m) {
            chmax(p, make_pair(cnt[i], i));
        }
        chmin(ans, p.first);  //「参加人数の最大値」の最小値を更新
        used[p.second] = 1;  // 以降p.second番目のスポーツは実施しない
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
		sc.close();
		if(a <= 0 && b >= 0){
            System.out.println("Zero");
        }else if(a > 0 || (a < 0 && (b-a)%2 == 1)){
            System.out.println("Positive");
        }else{
        	System.out.println("Negative");
        }
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  if(S.length() <= K){
    cout << S << endl;
  }else{
    cout << S.substr(0, K) + "..." << endl;
  }
}

Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] N = new int[4];
        for(int i = 0; i < N.length; i++) {
            N[i] = sc.nextInt();
        }
        Arrays.sort(N);

        if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> In_list(N);
	vector<vector<bool>> Out_list(N, vector<bool>(M, false));

	for (int i = 0; i < N; i++)
	{
		cin >> In_list.at(i);
	}

	for (int i = 0; i < N; i++)
	{
		bool flag = true;
		for (int j = 0; j < M; j++)
		{
			if (In_list.at(i).at(j) == '.' && flag != false)
			{
				flag = true;
			}
			else
			{
				flag = false;
			}
		}
		if (flag == true)
		{
			for (int j = 0; j < M; j++)
			{
				Out_list.at(i).at(j) = true;
			}
		}
	}

	for (int j = 0; j < M; j++)
	{
		bool flag = true;
		for (int i = 0; i < N; i++)
		{
			if (In_list.at(i).at(j) == '.' && flag != false)
			{
				flag = true;
			}
			else
			{
				flag = false;
			}
		}
		if (flag == true)
		{
			for (int i = 0; i < N; i++)
			{
				Out_list.at(i).at(j) = true;
			}
		}
	}

	for (int i = 0; i < N; i++)
	{
		bool flag = false;
		for (int j = 0; j < M; j++)
		{
			if (Out_list.at(i).at(j) == false)
			{
				cout << In_list.at(i).at(j);
				flag = true;
			}
		}
		if (flag == true)
		{
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 250001,M = 1e9 + 9,M1 = 1e9 + 7,b = 103,b1 = 11;
int cs[N],cs1[N],p[N],p1[N],n;
map<pair<int,int>,int>mp;
void add(int &a,int b){
	a+=b;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
void add1(int &a,int b){
	a+=b;
	if(a >= M1)a-=M1;
	if(a < 0)a+=M1;
}
int power(int base,int to){
	int ret = 1;
	while(to){
		if(to&1)ret = ret*1LL*base%M;
		to>>=1;
		base = base*1LL*base%M;
	}
	return ret;
}
int power1(int base,int to){
	int ret = 1;
	while(to){
		if(to&1)ret = ret*1LL*base%M1;
		to>>=1;
		base = base*1LL*base%M1;
	}
	return ret;
}
int main(){
//	freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	p[0] = p1[0] = 1;
	char c;
	int inv = power(b,M - 2),inv1 = power1(b1,M1 - 2);
	for(int i = 1;i <= n;i++){
		scanf(" %c",&c);
		cs[i] = cs[i - 1];
		p[i] = p[i - 1];
		cs1[i] = cs1[i - 1];
		p1[i] = p1[i - 1];
		if(c == '+')add(cs[i],p[i]),add1(cs1[i],p1[i]);
		else if(c == '-')add(cs[i],-p[i]),add1(cs1[i],-p1[i]);
		else if(c == '>')p[i] = p[i]*1LL*b%M,p1[i] = p1[i]*1LL*b1%M1;
		else if(c == '<')p[i] = p[i]*1LL*inv%M,p1[i] = p1[i]*1LL*inv1%M1;
	}
	long long ans = 0;
	for(int i = 0;i <= n;i++){
		ans+=mp[{cs[i],cs1[i]}];
		mp[{(cs[n]*1LL*p[i] + cs[i] + M)%M,(cs1[n]*1LL*p1[i] + cs1[i] + M1)%M1}]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 35328
s = input()
head = int(s[:2])
tail = int(s[2:])


def is_only_year(a):
    return a == 0 or a > 12


def is_month(a):
    return 0 < a <= 12


if is_only_year(head) and is_month(tail):
    print("YYMM")
elif is_month(head) and is_only_year(tail):
    print("MMYY")
elif is_month(head) and is_month(tail):
    print("AMBIGUOUS")
else:
    print("NA")


Measured memory_bytes: 2940
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),k=sc.nextInt(),ans=1;
    for(int i=1;i<=n;i++){
      if(i==1){
        ans*=k;
      }else{
        ans*=(k-1);
      }
    }
    System.out.println(ans);
  }
}


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

int main(){
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    int ans=0;
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans+=A[i]*A[j];
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> v(5);
  for(int i = 0; i < 5; i++) cin >> v[i];
  sort(v.begin(), v.end());
 
  cout << (N+v[0]-1)/v[0] + 4LL << endl;
  
  return 0;
}

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

int main() {
  int n,k,cnt,sum=0;
  cin >> n >> k;
  int a[n];
  for(int i=0 ;i<n ;i++){
    cin >> a[i];
    if(a[i] == 1){
      cnt = i;
    }
  }
  for(int i=1 ;i<=n ;i++){
    if(n <= k + (k-1)*(i-1)){
      cout << i << endl;
      break;
    }
  }
}

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

int LOGN = 20;

int v[100009], a[100009];

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

    for(int i = 1; i <= n; i ++)
        std::cin >> v[i];

    for(int i = 1; i <= n; i ++)
        a[i] = v[i];

    std::sort(a+1, a+n+1);

    int ans=0;
    for(int i = 1; i <= n; i ++){
        int rez = 0;
        for(int pas = 1 << LOGN; pas; pas >>= 1)
            if(rez + pas <= n && a[rez + pas] <= v[i])
                rez += pas;
        if((rez + i) % 2)
            ans ++;
    }

    std::cout << ans/2;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void){
    IOS;
    int n; cin >> n;
    string s; cin >> s;
    int l = 0, r = s.size()-1, cnt = 0;
    while (l <= r){
        while (l <= r && s[l] == 'R') l++;
        while (l <= r && s[r] == 'W') r--;
        if (l <= r) cnt++, swap(s[l], s[r]);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3776
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = x / 500;
    int b = x - (a * 500);
    int score = a * 1000;
    int c = b / 5;
    score += c*5;
    System.out.println(score);

   
    
    
    
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	string a, b;
	cin >> a >> b;
	if (a == "H") {
		if (b == "H")
		{
			cout << "H" << endl;
		}
		else {
			cout << "D" << endl;
		}
	}
	if (a == "D") {
		if (b == "H") {
			cout << "D" << endl;
		}
		else {
			cout << "H" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll ans = 0;
  REP(i,SZ(s)) ans += (s[i]=='1');
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<long double> point;

int main() {
  int n; cin >> n;
  vector<point> v(n);
  for (int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    v[i] = point(x, y);
  }

  sort(v.begin(), v.end(), [](point& p, point& q) {
    return arg(p) < arg(q);
  });

  long double ans = 0;
  for (int i = 0; i < n; i++) {
    point p(0, 0);
    for (int j = 0; j < n; j++) {
      p += v[(i + j) % n];
      ans = max(ans, abs(p));
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <set>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

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

int main()
{
    scanf("%d %d", &N, &W);
    REP(i, N)
        scanf("%d %d", &w[i], &v[i]);
    vector <vector <long long int>> dp(N+1, vector<long long int>(100001, 10000000000000));
    dp[0][0] = 0;
    FOR(i, 1, N+1) {
        REP(j, 100001) {
            if (j>=v[i-1]) {
                if (dp[i-1][j-v[i-1]]!=10000000000000)
                    dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);
                else
                    dp[i][j] = dp[i-1][j];
            } else
                dp[i][j] = dp[i-1][j];
        }
    //REP(j, 28)
    //    cout << dp[i][j] << " ";
    //cout << endl;
    }
    //}
    //REP(i, 100)
    //    cout << dp[N][i] << " ";
    //cout << endl;
    for (int i=100000; i>=0; i--) {
        if (dp[N][i]<=W) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

int main() {    
    Int h, w; 
    cin >> h >> w;
    Int n;
    cin >> n;
    Int x = max(h , w);
    dump(n / x + (n % x == 0 ? 0 : 1));
    return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


ll ara[Max];

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=true;

      string str;

     cin>>n;


     for(i=1; i<=n; i++)
     {
         cin>>a;

         ara[a]++;


     }

     for(i=1; i<=100000; i++)
        ara[i]+=ara[i-1];

    for(i=1; i<=100000; i++)
    {
        if(ara[i]==n-ara[i])
        {
          ans++;
        }
    }





     cout<<ans<<endl;





}



Measured memory_bytes: 4456
#include <stdio.h>

int main(){
   int n ; 
   scanf("%d",&n);
   int i , j ;
   int x = n/7;
   int y = n/4 ;
   int count = 0;
   for(i = x ; i>=0 ; i--){
       for(j=0 ; j<=y ; j++){
           if(7*i + 4*j == n){
               count++;
               break;
           }
           if(7*i+4*j>n){
               break;
           }
       }
       if(count!=0){
           break;
       }
   }
   
   if(count!=0){
       printf("Yes");
   }
   else{
       printf("No");
   }
  
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    cout << n-k+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 0; i < (int)(n); i+=2)
using vi=vector<int>;  using vs=vector<string>;
using gi=greater<int>;

int main() {
    int n; cin>>n;
    vi v(n+1);
    rep(i,n) cin>>v.at(i);

    int M=0,a=0,b=0;
    
    sort(v.begin(),v.end(),gi());
    
    rep2(i,n){
        a+=v.at(i);
        b+=v.at(i+1);
    } 

    cout<<a-b<<endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] arg) {
    Scanner sc = new Scanner(System.in);

    // 先頭行は不要なので読み捨てる
    sc.nextLine();

    // 2行目の内容をint型の配列に格納
    int[] numbers = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::valueOf).toArray();
    sc.close();

    // 配列をソート
    for (int i = 1; i < numbers.length; i++) {
      int key = numbers[i];
      int j = i - 1;
      System.out.println(String.join(" ",
          Arrays.stream(numbers).boxed().map(String::valueOf).collect(Collectors.joining(" "))));
      while (j >= 0 && numbers[j] > key) {

        numbers[j + 1] = numbers[j];
        j--;
      }
      numbers[j + 1] = key;
    }
    System.out.println(String.join(" ",
        Arrays.stream(numbers).boxed().map(String::valueOf).collect(Collectors.joining(" "))));
  }
}


Measured memory_bytes: 33732
from bisect import bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(1, n - 1):
    for j in range(i + 1, n):
        c_min_len = l[j] - l[i]
        x = i - bisect_right(l, c_min_len)
        ans += max(0, x)
print(ans)

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

int main(){
    string s;
    set<char> set;
    cin >> s;
    for (int i=0; i<s.size(); i++){
        set.insert(s[i]);
    } 
    if (set.size() == s.size()) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005;
int n,i,j,k,a,b,head[N],adj[N*2],nxt[N*2];
void dfs(int x,int dad,int d)
{
	if(d>b)
		a=x,b=d;
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad)
			dfs(adj[y],x,d+1);
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	b=-1;
	dfs(1,-1,0);
	b=-1;
	dfs(a,-1,0);
	if(b%3==0||b%3==2)
		printf("First");
	else
		printf("Second");
	return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>

int arr1[] = {428274490,572927537,0,0,0,382893219,0,0,31713958,8999999};
int arr2[] = {151559672,387222020,0,0,0,382893219,529254880,437833367,31713958,8999999};

char ch[20];
int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 7, stdin);
    int res = 1;
    if (ch[1] == ' '){
        if (ch[4] == '3'){
            if (ch[6] == '4'){
                res = 65;
            } else if (ch[5] == '0'){
                fread(ch, sizeof(char), 3, stdin);
                if(ch[2] == '3') {
                    res = 823951039;
                }
            }
        } else if (ch[2] != ch[4]){
            res = 3;
        }
    } else if (ch[0] < '3'){
        res = arr1[ch[1]-'0'];
    }else{
        res = arr2[ch[1]-'0'];
        if(ch[2]=='8')res = 632611002;
    }
    printf("%d\n", res);
    return 0;
}

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

int main(){
  int n,k,b,ans=0;
  cin>>n>>k;
  for (int i=0;i<n;i++){
    cin>>b;
    if (b<k-b){
      ans+=b*2;
    }else{
      ans+=(k-b)*2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv){
 
  int N;
  
  cin >> N;
  
  if( N == 1 ){
    cout << "Hello World" << endl;
  }else if(N == 2){
    int A,B;
    cin >> A;
    cin >> B;
    
    cout << A + B << endl;
  }
  
  return 0;
}

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

using ll=long long;

bool tacticX(ll n,ll &b1,ll &b2){
  if(b1+b2*2<=n) return true;

  ll tmp=min(b1,n);
  b1-=tmp;
  n-=tmp;
  tmp=min(b2,n/2);
  b2-=tmp;
  n-=tmp*2;
  if(n){
    b2--;
    b1++;
    n--;
  }
  return false;
}

bool tacticY(ll n,ll &b1,ll &b2){
  if(b1+b2*2<=n) return true;
  ll tmp=min(n,b2);
  b2-=tmp;
  b1+=tmp;
  n-=tmp;
  tmp=min(n,b1);
  b1-=tmp;
  n-=tmp;
  return false;
}


int main(){
  ll n,m;
  cin>>n>>m;
  ll sc0=0;
  {
    ll a2=n,a1=0;
    ll b2=m,b1=0;
      while(true){
	if(tacticX(a2+a1,b1,b2)) break;
	sc0++;
	if(tacticY(b1+b2,a1,a2)) break;
	sc0++;
      }
  }
  
  ll sc1=0;
  {
    ll a2=n,a1=0;
    ll b2=m,b1=0;
      while(true){
	if(tacticY(a2+a1,b1,b2)) break;
	sc1++;
	if(tacticX(b1+b2,a1,a2)) break;
	sc1++;
      }
  }
  cout<<min(sc0,sc1)<<endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int MAX = 1e6 + 5;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(MAX);
    rep(i,n) cnt[a[i]]++;
    int p = 1;
    for(int i = 2; i < MAX; i++){
        int tmp = 0;
        for(int j = i; j < MAX; j += i){
            tmp += cnt[j];
        }
        p = max(tmp, p);
    }
    if(p == 1){
        cout << "pairwise coprime" << endl;
    }else if(p < n){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 11160
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b,c;cin >> a >> b >> c;
    if(a+b == c || b +c == a|| c+a == b)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<stack>
#include<list>
#include<set>
#define mod 1000000007

using namespace std;

#define DEBUG_FLAG

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#ifdef DEBUG_FLAG
    #define dbgout(fmt, ...) fprintf(stderr, "\033[1;33mDEBUG(%s:%d):\t\033[0m" fmt, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define dbgout(fmt, ...) 
#endif

int main(void)
{
    char num[5];
    num[0]=num[1]=num[2]= '-'; // 初始化成无效值
    int N, M;
    scanf("%d%d", &N, &M);
    num[N] = 0;
    int si, ci;
    while (M--)
    {
        scanf("%d%d", &si, &ci);
        if (num[si-1] == '-' || num[si-1] == '0' + ci) {
            num[si-1] = '0' + ci;
        } else {
            printf("-1\n");
            return 0;
        }
    }
    if (num[0] == '-' && N > 1) num[0] = '1';
    for (int j = 0; j < N; j++) {
        if (num[j] == '-') num[j] = '0';
    }
    if (num[0] == '0' && (num[1] != 0 || N > 1)) printf("-1\n");
    else printf("%s\n", num);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;


char a[100010];

int main()
{
	vector < int > v;
	for (int i = 1; i < 10; ++i)
	 {
	 	for (int j = 1; j < 10; ++j)
	 	{
	 		v.push_back(i*j);
	 	}
	 } 
	 int n;	cin >> n;
	 bool check = false;
	 for(auto x : v){
	 	if(x == n){
	 		check = true;
	 		break;
	 	}
	 }
	 if(check)
	 	cout << "Yes" << endl;
	 else
	 	cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

static const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, vector<int> &visited)
{
    bool all_visited = count(visited.begin(), visited.end(), 1) == visited.size();
    if (all_visited)
    {
        return true;
    }
    int ret = 0;
    for (int i = 0; i < N; ++i)
    {
        if (graph[v][i] == false)
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        // 探索ごとにvisitedがあるのが大事だなー
        auto copy_visited = visited;
        copy_visited[i] = true;
        ret += dfs(i, N, copy_visited);
    }
    return ret;
}

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    vector<int> visited(N, 0);
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}

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

int main(){
  int r,d,x0;
  cin >> r >> d >> x0;

  int ans = x0;
  for (int i = 0;i < 10;i++){
    ans = r*ans - d;
    cout << ans << "\n";
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#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 all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll N,M,X;
    cin >> N >> M >> X;

    vector<ll> Ci_vec(N);
    vector<vector<ll>> Aij_vec(N, vector<ll>(M));

    rep(i,N){
        cin >> Ci_vec[i];
        rep(j,M){
            cin >> Aij_vec[i][j];
        }
    }

    vector<ll> result_vec;
    vector<ll> on_off_vec;

    rep(i,pow(2,N)){
        ll target_number = i;
        // cout << i << "/////" << "\n";
        vector<ll> check_vec(M);
        ll amount = 0;
        rep(j,N){
            if(target_number >= pow(2,N-j-1)){
                // cout << pow(2,M-j-1) << "\n";
                target_number -= pow(2,N-j-1);
                rep(k,M){
                    check_vec[k] += Aij_vec[N-j-1][k];
                }
                amount += Ci_vec[N-j-1];
            }
        }
        bool check = true;
        rep(j,M){
            // cout << check_vec[j] << "\n";
            if(check_vec[j] < X){
                check = false;
            }
        }
        if(check){
            result_vec.push_back(amount);
            // cout << amount << "\n";
        }
    }
    ll result = 1000000000;
    // cout << result_vec.size() << "\n";
    rep(i,result_vec.size()){
        result = min(result,result_vec[i]);
    }
    if(result == 1000000000) result = -1;
    cout << result;
}

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

int a[200001], ans, n, k, tmp;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a[tmp]++;
    }
    sort(a, a + n + 1);
    for (int i = 0; i <= n - k; i++) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024