akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
    string str1,str2;
    int n,taro=0,hanako=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>str1>>str2;
        if(str1>str2)taro+=3;
        if(str1==str2){taro+=1;hanako+=1;}
        if(str1<str2)hanako+=3;
    }
    cout<<taro<<" "<<hanako<<endl;
    return 0;
}


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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[2011][2021];

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cntr=0,cntb=0;
  lp(i,s.size()){
    if(s[i]=='R') cntr++;
    else cntb++;
  }
  if(cntr>cntb) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A[100001];
  int n,a;
  cin >> n;
  REP(i,n){
      cin >> a;
      A[i+1] = a;
  }
  int cur = 1;
  set<int> st;
  int ans = 0;
  

  while(st.count(cur)!=1){
      ans++;
      st.insert(cur);
      cur = A[cur];
      if (cur == 2){
          cout << ans << endl;
          return 0;
      }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 5376
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
b = []
for i in range(28):
    n = int(input())
    b.append(n)
b.sort()
c = list(set(a)-set(b))
if c[0] > c[1]:
    print(c[1])
    print(c[0])
else:
    print(c[0])
    print(c[1])



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int h, w;
  cin >> h >> w;
  vs grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') {
        int cnt = 0;
        for (int k = 0; k < 4; k++) {
          int ii = i + d1.at(k), jj = j + d2.at(k);
          if (0 <= ii && ii < h && 0 <= jj && jj < w && grid.at(ii).at(jj) == '#') cnt++;
        }
        if (cnt == 0) {
          No();
          return 0;
        }
      }
    }
  }
  Yes();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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 (b<a) { a=b; return 1; } return 0; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};


int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> a(N, true);
  vector<int> h(N);

  for(auto& v: h){
    cin >> v;
  }

  for(int i = 0; i < M; ++i){
    int p, q;
    cin >> p >> q;
    --p;
    --q;
    
    if(h[p] <= h[q]){
      a[p] = false;
    }
    if(h[q] <= h[p]){
      a[q] = false;
    }
  }

  int ans = 0;

  for(auto v : a){
    if(v) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
    int a,b,c,n,i;

    scanf("%d",&n);
    for(i=1;i<=n;i++){
    scanf("%d %d %d",&a,&b,&c);
        if(((a*a)+(b*b)==(c*c))||((a*a)+(c*c)==(b*b))||((b*b)+(c*c)==(a*a))){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}
    

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


int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    if(q==1){
        cout<<0<<endl;
        return 0;
    }
    
    int res=1e9;
    
    for(int i=0;i<n;i++){
        int y=a[i];
        int cnt=0;
        int toru=0;
        multiset<int> buf;
        multiset<int> s;
        for(int j=0;j<=n;j++){
            if(j!=n && a[j]>=y){
                cnt++;
                buf.insert(a[j]);
            }
            else{
                bool danger=(j-cnt<=i && i<j);
                if(cnt>=k){
                    toru+=cnt-k+1;
                    int c=cnt-k+1;
                    for(auto &e:buf){
                        if(!c) break;
                        s.insert(e);
                        c--;
                    }
                    
                }
                else if(danger){
                    toru=-1e9;
                }
                buf=multiset<int>();
                cnt=0;                
            }
        }
        if(toru>=q){
            int index=0;
            int x;
            for(auto &e:s){
                if(index==q-1){
                    x=e;
                    break;
                }
                index++;
            }   
            res=min(res,x-y);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    map<char, int> mp;

    for(char c : s){
        mp[c]++;
    }

    ll sum = 0;
    for(auto p : mp){
        ll count = p.second;
        sum += count;
    }

    ll answer = 0;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    for(char c : alphabet){
        if(mp[c]==0){
            continue;
        }
        ll num = mp[c] * (sum - mp[c]);
        answer += num;
    }

    p(answer/2 + 1);
    
    return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        int t = 0;
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            t = f(i);
            if (t >= a && t <= b) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
    private static int f(int i) {
        int sum = 0;
        while (i > 0) {
            sum += i % 10;
            i = i / 10;
        }
        return sum;
    }
}

Measured memory_bytes: 23252
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, m = LI()
G = [[] for _ in range(n)]
for a, b, c in LIR(m):
    G[a - 1] += [(b - 1, c)]

# 負の閉路がなかったら高々n-1回で更新は終わるはずn回目に更新が起こったとしたら負の閉路がある。
def bellman_ford(G, s=0):
    n = len(G)
    dist = [-INF] * n
    dist[s] = 0
    v_nows = {s}
    for _ in range(n):
        v_changeds = set()
        for u in v_nows:
            for v, c in G[u]:
                if dist[u] + c > dist[v]:
                    dist[v] = dist[u] + c
                    v_changeds.add(v)
        v_nows = v_changeds
    if not v_changeds:
        return dist[n - 1]
    if n - 1 in v_nows:
        return 'inf'
    for i in v_nows:
        dist[i] = INF
    dq = deque(v_nows)
    while dq:
        u = dq.popleft()
        for v, c in G[u]:
            if v == n - 1:
                return 'inf'
            if dist[v] != INF:
                dist[v] = INF
                dq += [v]
    return dist[n - 1]



print(bellman_ford(G))



Measured memory_bytes: 45532
a = input()
l = len(a)
a = int(a)
num=0
if(l==6):
  num = 90909
elif(l==5):
  num = 909 + (a - 9999)
elif(l==4):
  num = 909
elif(l==3):
  num = 9 + (a - 99)
elif(l==2):
  num = 9
elif(l==1):
  num = a
print(num)
  

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=100000+5;
const int MOD=1000000000+7;
template<class T> inline void read(T &x){
	x=0;
	T f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	x*=f;
}
ll n;
ll ans=0;
int main(){
	read(n);
	for(ll i=1;i*i<=(n-1);i++){
		if((n-1)%i==0){
			ans+=2;
		}
		if(i*i==(n-1)){
			ans--;
		}
	}
	ans--;
//	cout<<ans<<" ";
	for(ll i=2;i*i<=n;i++){
		if(n%i!=0){
			continue;
		}
		ll p=n;
		while(p%i==0){
			p/=i;
		}
		if(p%i==1){
			ans++;
		}
	}
	printf("%lld\n", ans+1);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, K;
vector<int> a;
int dp[5010];

bool solve(int m){
	rep(i, 5010) dp[i] = 0;
	dp[0] = 1;
	rep(i,  N)for (int j = K; j >= 0; --j){
		if(i == m) continue;
		if(dp[j] == 0) continue;
		dp[min(5000, j + a[i])] = 1;
	}
	for (int i = max(0, K - a[m]); i < K; ++i){
		if(dp[i] == 1) return true; //必要
	}
	return false; //不必要
}

int main(void){
	cin >> N >> K;
	rep(i, N){
		int d; cin >> d;
		a.pb(d);
	}
	sort(all(a));
	
	int l = 0, r = N;//[l, r)
	while(r - l > 1){ //小さいやつほどfalse
		int m = (l + r) / 2;
		if(solve(m)) r = m;
		else l = m;
	}
	for (int i = max(0, l - 10); i <= min(N - 1, r + 10); ++i){
		// printf("i %d\n", i);
		if(solve(i)){
			printf("%d\n", i);
			return 0;
		}
	}
	printf("%d\n", N);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    if (n != 1) {
        int ans = pow((k - 1),(n - 1));
        cout << k * ans << endl;
    }else{
        cout << k << endl;
    }
    return 0;
}


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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int n;
string s;
ll a[26];

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

    cin >> n >> s;
    REP(i,n) {
        a[s[i]-'a']++;
    }

    ll ans = 1;
    REP(i,26) {
        ans *= a[i] + 1;
        ans %= MOD;
    }

    cout << (ans - 1 + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main (void){
  string S;
  int count=0;
  cin>>S;
  for(int i=0;i<6;i++){
    if(S[i]=='1'){
      count=count+1;
    }
  }
  cout<<count<<endl;
  return 0;
}


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

using namespace std;

#define INF (1e18);

typedef pair<long long,long long> P;

int main() {
    long long W,H;
    cin >> W >> H;
    long long N;
    cin >> N;

    vector<P> x,y;

    for(int i=0; i<N; ++i) {
        long long tempx, tempy;
        cin >> tempx >> tempy;
        x.push_back(P(tempx,i));
        y.push_back(P(tempy,i));
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    long long cx[2];
    long long cy[2];

    cx[0]=x[(N-1)/2].first;
    cx[1]=x[N/2].first;
    cy[0]=y[(N-1)/2].first;
    cy[1]=y[N/2].first;

    sort(x.begin(),x.end(),[](P& lhs, P& rhs) {
        return (lhs.second<rhs.second);
    });
    sort(y.begin(),y.end(),[](P& lhs, P& rhs) {
        return (lhs.second<rhs.second);
    });

    long long dist[4],max_dist[4];

    for(int i=0; i<4; ++i) {
        if(N%2==1 && i>0) continue;
        int ix=i/2;
        int iy=i%2;
        dist[i]=0; max_dist[i]=0;
        for(int j=0; j<N; ++j) {
            long long nowdist;
            nowdist=((cx[ix]>x[j].first)?(cx[ix]-x[j].first):(x[j].first-cx[ix]))
                +((cy[iy]>y[j].first)?(cy[iy]-y[j].first):(y[j].first-cy[iy]));
            dist[i]+=nowdist*2;
            max_dist[i]=max(max_dist[i],nowdist);
        }
        dist[i]-=max_dist[i];
    }

    long long ansx=cx[0],ansy=cy[0],ansdist=dist[0];
    if(N%2==0) {
        for(int i=1; i<4; ++i) {
            if(dist[i]<ansdist) {
                ansx=cx[i/2];
                ansy=cy[i%2];
                ansdist=dist[i];
            }
        }
    }
    cout << ansdist << endl;
    cout << ansx << " " << ansy << endl;
    return 0;
}


Measured memory_bytes: 6312
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;
	cin >> str;
	if(str.size() == 2 && str[0] == str[1])
	{
		cout << 1 << ' ' << 2 << endl;
		return 0;
	}
	
	REP(i,str.size()-2)
	{
		if(str[i] == str[i+1] ||
		str[i+1] == str[i+2] ||
		str[i] == str[i+2])
		{
			cout << i+1 << ' ' << i+3 << endl;
			return 0;
		}
	}
	
	cout << -1 << ' ' << -1 << endl;
			
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    int a = 0, b = 0;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        if(x%2){
            a++;
        }
        else b++;
    }
    ll res = 1;
    for(int i=1; i<=n; i++) res *= 3;
    ll m = 1;
    for(int i=1; i<=b; i++){
        m *= 2;
    }
    cout << res-m << "\n";
    return 0;
}


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

typedef long long ll;

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

    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end(),greater<int>());
    int ans = 0;
    for(int i=0;i<k;i++) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct tc
{
    string s;
    int x;
};
int main()
{
    int n;
    cin >> n;
    struct tc a[1000];
    for (int i = 1 ; i<= n; i++)
    {
        cin >>a[i].s >> a[i].x;
    }
    string x;
    cin >> x;
    int d;
    for (int i = 1 ; i<= n ; i++)
    {
        if (a[i].s==x)
            {
                d=i+1;
                break;}
    }
    int tong = 0 ;
    for (int i =d ; i <= n ; i++ )
    {
        tong += a[i].x;
    }
    cout << tong;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    int K; cin >> K;
    vi D(K);
    set<int> s;
    for(auto & e : D) cin >> e, s.insert(e);

    while(1){
        stringstream ss;
        ss << n;

        bool ok = true;
        for(auto & c : ss.str()){
            if(s.find(c - '0') != end(s)){
                ok = false;
            }
        }
        if(ok){
            cout << n << endl;
            return 0;
        }
        n++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
struct edge{
	int v,next;
}a[200001];
int n,u,v,tot=0,head[100001];
void add(int u,int v){
	a[++tot].v=v;
	a[tot].next=head[u];
	head[u]=tot;
}
int dfs(int u,int fa){
	int ret=0;
	for(int tmp=head[u];tmp!=-1;tmp=a[tmp].next){
		int v=a[tmp].v;
		if(v!=fa){
			ret^=(dfs(v,u)+1);
		}
	}
	return ret;
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	if(dfs(1,-1))puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 6912
import sys
N, C, K = list(map(int, input().split()))
listT = [int(input()) for _ in range(N)]

listT.sort(reverse = True)

count=0
while listT != []:
    bus =[]
    time = listT[0]
    count += 1
    while len(bus) != C and time - K <= listT[0]:
        bus.append(listT.pop(0))
        if listT ==[]:
            break

print(count)


Measured memory_bytes: 7384
program main
  implicit none
  integer, parameter :: binsize = 5000, nbin = 100
  integer :: n, i, t, l, r, numq, cnt(26, nbin)
  character(500000) :: s
  character(100) :: q
  character(1) :: c
  read *, n
  read *, s
  call prep
  read *, numq
  do i = 1, numq
    read *, t, l, q
    if (t == 1) then
      read (q, *) c
      call type1(l, c)
    else
      read (q, *) r
      call type2(l, r)
    end if
  end do
  contains

  subroutine prep()
    integer :: i, j, b
    cnt(:, :) = 0
    do i = 1, n
      j = iachar(s(i:i)) - iachar("a") + 1
      b = i_to_bin(i)
      cnt(j, b) = cnt(j, b) + 1
    end do
  end subroutine prep

  subroutine type1(i, c)
    integer, intent(in) :: i
    character(1), intent(in) :: c
    integer :: b, j
    b = i_to_bin(i)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) - 1
    s(i:i) = c(1:1)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) + 1
  end subroutine type1

  subroutine type2(l, r)
    integer, intent(in) :: l, r
    integer :: scnt(26), b, tot, a
    scnt(:) = 0
    do b = 1, nbin
      scnt(:) = scnt(:) + query(b, l, r)
    end do
    tot = 0
    do a = 1, 26
      if (scnt(a) > 0) tot = tot + 1
    end do
    print "(i0)", tot
  end subroutine type2

  pure integer function i_to_bin(i)
    integer, intent(in) :: i
    i_to_bin = (i - 1) / binsize + 1
  end function i_to_bin

  pure integer function b_to_i(b)
    integer, intent(in) :: b
    b_to_i = (b - 1) * binsize + 1
  end function b_to_i

  function query(b, l, r)
    integer :: query(26)
    integer, intent(in) :: b, l, r
    integer :: i, j, k, ic
    query(:) = 0
    i = b_to_i(b)
    j = i + binsize - 1
    if (r < i) return
    if (l > j) return
    if (l <= i .and. j <= r) then
      query(:) = cnt(:, b)
    else
      do k = max(i, l), min(j, r)
        ic = iachar(s(k:k)) - iachar("a") + 1
        query(ic) = query(ic) + 1
      end do
    end if
  end function query
end program main


Measured memory_bytes: 1980
s=input()
sf=int(s[:2])
sl=int(s[2:4])
if sf>=13 and 13>sl>0 or sf==0 and 13>sl>0:
  print('YYMM')
elif 12>=sf>0 and sl==0 or 13>sf>0 and sl>=13:
  print('MMYY')
elif 13>sf>0 and 13>sl>0 or 13>sf>0 and 13>sl>0:
  print('AMBIGUOUS')
else:
  print('NA')


Measured memory_bytes: 3060
import math

while True:
    N = int(input())
    if N != 0:
        sn = list(map(int, input().split()))

        m = sum(sn) / N
        alpha2 = 0

        for si in sn:
            alpha2 += (si - m)**2 / N

        alpha = math.sqrt(alpha2)
        print('{0:.8f}'.format(alpha))
    else:
        break


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

using namespace std;

typedef long long int ll;

int main() {
	int n;
	cin>>n;
	ll sum=0,mod=1e9+7,a[n],ans=0,x;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    } 
    for(int i=0;i<n;i++)
    {
        x=(sum-=a[i])%mod;
        x=(x*a[i])%mod;
        ans=(ans+x)%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 5192
#include<iostream>
#include<string>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

bool nlist[100010];

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  string str;
  str.reserve(N);
  cin >> str;
  int a = 0, b = 0;
  REP(i, 0, N) {
    if(str[i] == 'a') {
      if(a + b < A + B) {
	a++;
	nlist[i] = true;
      }else {
	nlist[i] = false;
      }
    }else if(str[i] == 'b') {
      if(a + b < A + B && b < B) {
	b++;
	nlist[i] = true;
      } else {
	nlist[i] = false;
      }
    }else {
      nlist[i] = false;
    }    
  }
  REP(i, 0, N) {
    cout << (nlist[i] ? "Yes" : "No") <<endl;
  }
  
  return 0;
}


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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    vector<int> ans(n, 0);
    int res = 0;
    for (int i = n-2; i >= 0; i--) {
        if(h[i] >= h[i+1]){
            ans[i] = ans[i+1] +1;
            res = max(res, ans[i]);
        }else{
            ans[i] = 0;
        }
    }
    cout << res << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int N, p[212345];
int r[212345], ans[2][212345];

int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &p[i]); }

	for (int i = 0; i < N; ++i)
	{
		r[p[i] - 1] = (i + 1);
	}
	for (int i = 0; i < N; ++i)
	{
		ans[0][i] = 20001 * (i + 1);
		ans[1][i] = 20001 * (N - (i + 1)) + r[i];
	}

	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < N - 1; ++j)
		{
			printf("%d ", ans[i][j]);
		}
		printf("%d\n", ans[i][N - 1]);
	}
	return 0;
}

Measured memory_bytes: 896
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

e = []
for k, v in c.items():
    if v > 3:
        e.append(k)
        e.append(k)
    elif v > 1:
        e.append(k)
e.sort(reverse=True)

if len(e)<2:
    print(0)
else:
    print(e[0]*e[1])

Measured memory_bytes: 22012
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s;
	int x;int y;
	x=(s[0]-'0')*10+s[1]-'0';
	y=(s[2]-'0')*10+s[3]-'0';
	//cout<<x<<" "<<y;
	if(!(1<=x&&x<=12)&&!(1<=y&&y<=12))
		cout<<"NA";
	if((1<=x&&x<=12)&&!(1<=y&&y<=12))
		cout<<"MMYY";
	if(!(1<=x&&x<=12)&&(1<=y&&y<=12))
		cout<<"YYMM";
	if((1<=x&&x<=12)&&(1<=y&&y<=12))
		cout<<"AMBIGUOUS";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d,p;
  cin>>a>>b>>c>>d>>p;
  cout<<min(a*p,b+max(0, p-c)*d)<<endl;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	if(a=='H'){
		if(b=='H')cout<<'H'<<endl;
		else cout<<'D'<<endl;
	}
	else{
		if(b=='H')cout<<'D'<<endl;
		else cout<<'H'<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int c[26];

int main(void)
{
	char str[1200];
	for (; scanf("%s", str) > 0;) {
		for (char *p = str; *p; p++) {
			if ('a' <= *p && *p <= 'z') {
				c[*p - 'a']++;
			} else if ('A' <= *p && *p <= 'Z') {
				c[*p - 'A']++;
			}

		}
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, c[i]); 
	}
	return 0;
}



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

namespace Grading
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> grade = new List<string>();

            string input = "";
            while (true)
            {
                input = Console.ReadLine();
                if (input.Equals("-1 -1 -1"))
                {
                    break;
                }

                string[] temp = input.Split(' ');
                int t1 = int.Parse(temp[0]);
                int t2 = int.Parse(temp[1]);
                int t3 = int.Parse(temp[2]);

                if (t1 == -1 || t2 == -1)
                {
                    grade.Add("F");
                }
                else if(t1 + t2 >=80)
                {
                    grade.Add("A");
                }
                else if (t1 + t2 >= 65)
                {
                    grade.Add("B");
                }
                else if (t1 + t2 >= 50)
                {
                    grade.Add("C");
                }
                else if (t1 + t2 >= 30)
                {
                    if (t3 >= 50)
                    {
                        grade.Add("C");
                    }
                    else
                    {
                        grade.Add("D");
                    }
                }
                else
                {
                    grade.Add("F");
                }

            }

            foreach (string item in grade)
            {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 19976
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long int a[N];
    long long int total = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        total += a[i];
    }

    long long int ave = total / N;
    long long int ave2;
    if(total >= 0) ave2 = ave + 1;
    else ave2 = ave - 1;

    long long int cost = 0, cost2 = 0;
    for (int i = 0; i < N; i++)
    {
        cost += (a[i] - ave) * (a[i] - ave);
        cost2 += (a[i] - ave2) * (a[i] - ave2);
    }

    cout << min(cost, cost2) << endl;
}

Measured memory_bytes: 256
n, m = tuple([int(i) for i in input().split(' ')])

a = [0 for _ in range(n + 2)]
dp = [0 for _ in range(n + 2)]

for i in range(m):
    a[int(input())] = 1

dp[0] = 1
for i in range(n):
    if a[i + 1] != 1:
        dp[i + 1] += dp[i]

    dp[i + 1] %= 1000000007
    if a[i + 2] != 1:
        dp[i + 2] += dp[i]

    dp[i + 2] %= 1000000007

print(dp[n])


Measured memory_bytes: 7832
#include<stdio.h>

int main()
{
    int A, B, C, D, m, n, x= 0, y;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    m=abs(A-B);
    n=abs(B-C);
    y=abs(A-C);
    if(m<=D && n<=D)
        x=1;
    else if(y <= D)
        x=1;
    if(x == 1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k >> s;
    VI s_cnt;
    if(s.front() == '0') s_cnt.push_back(0);
    s_cnt.push_back(1);
    FOR(i, 1, s.size() - 1) {
        if(s[i] != s[i - 1]) s_cnt.push_back(1);
        else s_cnt.back()++;
    }
    if(s.back() == '0') s_cnt.push_back(0);

    VI s_sum((int)s_cnt.size() + 1, 0);
    REP(i, s_cnt.size()) s_sum[i + 1] = s_sum[i] + s_cnt[i];
    
    int ans = 0;
    for(int left = 0; left < (int)s_sum.size(); left += 2) {
        int right = min(left + k * 2 + 1, (int)s_sum.size() - 1);
        ans = max(ans, s_sum[right] - s_sum[left]);
    }
    cout << ans << ln;
    return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n,t,a;
  cin>>n>>t>>a;
  vector<int> h(n);
  r(i,n)cin>>h.at(i);
  double temp;
  double mean;
  double dis=1000000000;
  int ans;
  r(i,n){
    temp=t-h.at(i)*0.006;
    if(dis>abs(temp-a)){dis=abs(temp-a);ans=i;}
  }

  cout<<ans+1<<endl;



return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(ll, s, c);
    ll scc = min(s, c/2);
    ll cccc = (c - 2*scc)/4;
    Cout(scc + cccc);
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){

    int N,K;cin >> N >> K;

    vector<bool> dp(K+1,false);

    vector<int> a(N);
    REP(i,N) cin >> a[i]; 
    
    for(int i=1;i<=K;i++){
        REP(j,N) if(i-a[j]>=0) dp[i] = dp[i] || !dp[i-a[j]];
    }

    if(dp[K]) pl("First")
    else pl("Second")

    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np
N =int(input())

a = np.zeros((N, 2))
kyori = np.zeros(int(N*(N-1)/2))

for i in range(0,N):
    x,y= map(int, input().split())
    a[i][0]=x
    a[i][1]=y


count=0
for i in range(0,N-1):
    for j in range(i+1,N):
     kyori[count]=math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2) 
     count=count+1
  

print(2*sum(kyori)*(N-1)*math.factorial(N-2)/math.factorial(N))

Measured memory_bytes: 12396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<ll, ll> P;

ll modnum = 1000000000+7;

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;
}

// dp[i][0] = i番目まで見たときに、Lのi番目とa+bのi番目が一致するときの最大値
// dp[i][1] = i番目まで見たときに、未満が確定

ll dp[100005][2];

int main() {
    string l; cin >> l;
    ll ans = 0;
    dp[0][0] = 1;
    rep(i, l.size()) {
        // aとbの和が1or0で考える
        // i桁目のa+b = 0
        if(l[i] == '0') {
            // かつl[i]が0の場合
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
        } else {
            // かつl[i]が1の場合
            // i番目のa+b=0ということは、次の状態は必ずL未満と言えるので
            dp[i+1][1] = (dp[i][0] + dp[i][1]) % modnum;
        }

        // i桁目のa+b = 1
        if(l[i] == '0') {
            // かつl[i]が0の場合

            // a+b = 1 , l[i] = 0　なので、dp[i+1][0]への遷移はありえない
            // 未満だけ遷移していく, {a=1,b=0}, {a=0,b=1}の2パターンなので、2をかける
            dp[i+1][1] += dp[i][1]*2;
            dp[i+1][1] %= modnum;
        } else {
            // かつl[i]が1の場合
            dp[i+1][0] += dp[i][0] * 2;
            dp[i+1][0] %= modnum;
            dp[i+1][1] += dp[i][1] * 2;
            dp[i+1][1] %= modnum;
        }
    }

    cout << (dp[l.size()][0]+dp[l.size()][1]) % modnum << endl;
    return 0;

}

// 161999316
// 162261460
//    524288

Measured memory_bytes: 2048
#include <stdio.h>

int main()
{
  int i,j,flag,A[100],N,temp,cnt=0;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
  flag=1;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	cnt++;
      }
    }
  }
  for(i=0;i<N-1;i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[N-1],cnt);

  return 0;
}

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

void kochCurve(int n, pair<double, double> s, pair<double, double> e){
	if(n == 0) return;

	pair<double, double> l, r, m;
	l.first = (2.0 * s.first + e.first) / 3.0;
	l.second = (2.0 * s.second + e.second) / 3.0;
	r.first = (s.first + 2.0 * e.first) / 3.0;
	r.second = (s.second + 2.0 * e.second) / 3.0;
	m.first = (r.first - l.first) / 2.0 - (r.second - l.second) * sin(acos(-1.0)/3.0) + l.first;
	m.second = (r.first - l.first) * sin(acos(-1.0)/3.0) + (r.second - l.second) / 2.0 + l.second;

	kochCurve(n-1, s, l);
	printf("%.12lf %.12lf\n", l.first,  l.second);
	kochCurve(n-1, l, m);
	printf("%.12lf %.12lf\n", m.first,  m.second);
	kochCurve(n-1, m, r);
	printf("%.12lf %.12lf\n", r.first,  r.second);
	kochCurve(n-1, r, e);
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%.12lf %.12lf\n", 0.0, 0.0);
	kochCurve(n, make_pair(0.0, 0.0), make_pair(100.0, 0.0));
	printf("%.12lf %.12lf\n", 100.0, 0.0);
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int ans=0;
    if(K>0)
    {
        ans+=min(K,A);
        K -=min(K,A);
    }
    if(K>0)
    {
        K -=min(K,B);
    }
    if(K>0)
    {
        ans -= min(K,C);
        K-= min(K,C);
        
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int main(void)
{
	char str[4] = {
		0,
	};
	scanf("%s", str);

	if (str[0] == '7' || str[1] == '7' || str[2] == '7')
		printf("Yes");
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> va(A);
    REP(i,A) cin >> va[i];
    vector<int> vb(B);
    REP(i,B) cin >> vb[i];
    vector<int> avail(M+1);
    REP(i,M) {
        int x,y,c;
        cin >> x >> y >> c;
        avail[i] = va[x-1]+vb[y-1]-c;
    }
    sort(ALL(va));
    sort(ALL(vb));
    avail[M] = va[0]+vb[0];
    sort(ALL(avail));
    cout << avail[0] << endl;
}

int main() {
    solve();
    return 0;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K-1) == 'A')
    S.at(K-1) = 'a';
  else if (S.at(K-1) == 'B')
    S.at(K-1) = 'b';
  else
    S.at(K-1) = 'c';
  cout << S << endl;
  return 0;
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<vector<int>>f(n,vector<int>(10)),p(n,vector<int>(11));
    rep(i, 0, n)rep(j, 0, 10)cin >> f[i][j];
    rep(i, 0, n)rep(j, 0, 11)cin >> p[i][j];
    ll ans = inf*(-1);
    for(int bit=1; bit<(1<<10); bit++){
        ll temp = 0;
        rep(i, 0, n){
            int cnt = 0;
            rep(j, 0, 10){
                if(bit&(1<<j))if(f[i][j]==1)cnt++;
            }
            temp += p[i][cnt];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
n,m=map(int, input().split(" "))
arr=[]
for i in range(m):
    a,b=map(int, input().split(" "))

    arr.append([a,b])

#arr.sort(key=lambda x:x[0])
arr.sort(key=lambda x:(x[0],x[1]))
left=0
num=0
count=0
for i in range(len(arr)):
    if arr[i][0]==left:
        pass
    if arr[i][1]<=num:
        num=arr[i][1]
    if arr[i][0]-num>=0:
        count+=1
        num=arr[i][1]
        left=arr[i][0]
    #print(arr[i],count)
print(count)

Measured memory_bytes: 27700