akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  (readln.chomp[0]+1).to!char.writeln;
}


Measured memory_bytes: 256
x,y = gets.chomp.split(" ").map(&:to_i)
    
    a = (2 * y) - x
    b = (2 * x) - y
    
    MOD = (10 ** 9) + 7
 
    
    if (a < 0) or (b < 0) or (a % 3 != 0) or (b % 3 != 0)
      puts 0
    else
        
      def kaijo(a, b)
        return (a..b).inject(1) {|i, j| (i * j) % MOD}
      end
   
      def joho_gyakugen(a, b)
        return ruijo(kaijo(a, b), MOD-2)
      end
      
      def ruijo(tei, bekisu)
        if bekisu == 0
          return 1
        elsif bekisu % 2 == 0
          return ruijo((tei ** 2) % MOD, bekisu / 2)
        else
          return tei * ruijo((tei ** 2) % MOD, bekisu / 2)
        end
      end
   
      n = [a, b].min / 3
      m = [a, b].max / 3
      total = n + m
      #if n == 0
        #puts 1
      #else
        result = (kaijo(m + 1, total) * joho_gyakugen(1, n))
        puts result % MOD
      #end
    end

Measured memory_bytes: 14372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

void swap(long long *A,long long *B){
    long long T;
    T=*A;
    *A=*B;
    *B=T;
}

int main(void){
    int n,r=0,b=0;
    scanf("%d",&n);
    char s[150];
    scanf("%s",s);
    for (int i=0; i<n; i++){
        if (s[i]=='R'){
            r++;
        } else {
            b++;
        }
    }
    if (r>b){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


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

	int odd[100001];
	int even[100001];
	for (int i = 0; i <= 100000; i++){
		odd[i] = 0;
		even[i] = 0;
	}

	for (int i = 0; i < n; i++){
		if (i % 2) odd[v[i]]++;
		else even[v[i]]++;
	}

	vector<pair<int, int> > vecodd;
	vector<pair<int, int> > veceven;
	vecodd.push_back(make_pair(0, 0));
	veceven.push_back(make_pair(0, 0));

	for (int i = 0; i <= 100000; i++){
		if (odd[i] != 0) vecodd.push_back(make_pair(odd[i], i));
		if (even[i] != 0) veceven.push_back(make_pair(even[i], i));
	}

	sort(vecodd.begin(), vecodd.end(), greater<pair<int, int> >());
	sort(veceven.begin(), veceven.end(), greater<pair<int, int> >());

	int max_even_id = veceven[0].second, max_odd_id = vecodd[0].second;
	int max_even = veceven[0].first, max_odd = vecodd[0].first;
	int max_even_2nd = veceven[1].first, max_odd_2nd = vecodd[1].first;

	if (max_even_id == max_odd_id){
		cout << min(n - max_odd - max_even_2nd, n - max_even - max_odd_2nd) << endl;
	}else{
		cout << n - max_odd - max_even << endl;
	}

	return 0;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    REP(o, n){
        string a, b; cin >> a >> b;
        int na = 0, nb = 0; 
        REP(i, a.size()){
            if(a[i] == 'm'){
                if(i != 0) na += 1000 * (a[i - 1] - '0');
                else na += 1000;
            } 
            if(a[i] == 'c'){
                if(i != 0 and (a[i - 1] != 'm')) na += 100 * (a[i - 1] - '0');
                else na += 100;
            }
            if(a[i] == 'x') {
                if(i != 0 and (a[i - 1] != 'm' and a[i - 1] != 'c')) na += 10 * (a[i - 1] - '0');
                else na += 10;
            }
            if(a[i] == 'i'){
                if(i != 0 and (a[i - 1] != 'm' and a[i - 1] != 'c' and a[i - 1] != 'x')) na += 1 * (a[i - 1] - '0');
                else na += 1;
            }
        }
        REP(i, b.size()){
            if(b[i] == 'm'){
                if(i != 0) nb += 1000 * (b[i - 1] - '0');
                else nb += 1000;
            } 
            if(b[i] == 'c'){
                if(i != 0 and (b[i - 1] != 'm')) nb += 100 * (b[i - 1] - '0');
                else nb += 100;
            }
            if(b[i] == 'x') {
                if(i != 0 and (b[i - 1] != 'm' and b[i - 1] != 'c')) nb += 10 * (b[i - 1] - '0');
                else nb += 10;
            }
            if(b[i] == 'i'){
                if(i != 0 and (b[i - 1] != 'm' and b[i - 1] != 'c' and b[i - 1] != 'x')) nb += 1 * (b[i - 1] - '0');
                else nb += 1;
            }
        }
        int nans = na + nb;
        string ans;
        if(nans / 1000 >= 2){
            ans += to_string(nans / 1000) + 'm';
            nans %= 1000;
        }
        else if(nans / 1000 == 1){
            ans += 'm';
            nans %= 1000;
        }

        if(nans / 100 >= 2){
            ans += to_string(nans / 100) + 'c';
            nans %= 100;
        }
        else if(nans / 100 == 1){
            ans += 'c';
            nans %= 100;
        }

        if(nans / 10 >= 2){
            ans += to_string(nans/ 10) + 'x';
            nans %= 10;
        }
        else if(nans / 10 == 1){
            ans += 'x';
            nans %= 10;
        }

        if(nans >= 2){
            ans += to_string(nans) + 'i';
        }
        else if(nans == 1) ans += 'i';

        cout << ans << endl;
    }
}


Measured memory_bytes: 3148
#include<iostream>
using namespace std;
typedef long long llong;

int main(){
    llong a, b;
    cin >> a >> b;
    llong x = max(a, b);
    llong y = min(a, b);
    llong z;
    while(x % y){
        z = x % y;
        x = y;
        y = z;
    }
    cout << a / y * b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define LEN 100010
#define STABLE 1
#define NOTSTABLE 0

typedef struct{
  char c;
  int n;
}Card;

void quicksort(Card *A, int p, int r){
  int q;
  if(p<r){
    q = partion(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}

int partion(Card *A, int p, int r){
  int x = A[r].n;
  int i = p-1;
  int j, n;
  Card k;
  
  for(j=p; j<=r-1; j++){
    if(A[j].n<=x){
      i++;
      k=A[i];
      A[i]=A[j];
      A[j]=k;
    }
  }
  
  k=A[i+1];
  A[i+1]=A[r];
  A[r]=k;
  return i+1;
}


void merge(Card *S, int left, int mid, int right){
  int i, j, k;
  int n1=mid-left;
  int n2=right-mid;
  Card L[LEN], R[LEN];
  
  for(i=0; i<n1; i++)L[i]=S[left+i];
  for(i=0; i<n2; i++)R[i]=S[mid+i];

  L[n1].n=1000000001;
  R[n2].n=1000000001;
  i=0;
  j=0;
  for(k=left; k<right; k++){
    if(L[i].n<=R[j].n){
      S[k]=L[i];
      i++;
    }
    else{
	S[k]=R[j];
	j++;
    }
  }
}

void merge_sort(Card *S, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    merge_sort(S, left, mid);
    merge_sort(S, mid, right);
    merge(S, left, mid, right);
  }
}

int main(){
  int n;
  Card A[LEN], M[LEN], card;
  int p, r; 
  int flag=STABLE;
  int i, j, k;
  char c;
  
  scanf("%d", &n);
  scanf("%c", &c);
  for(i=0; i<n; i++){
    scanf("%c %d", &A[i].c, &A[i].n);
    scanf("%c", &c);
    M[i]=A[i];
  }
  
  merge_sort(&M[0], 0, n);
  p=0;
  r=n-1;
  quicksort(&A[0], p, r);
  
  for(i=0; i<n-1; i++){
    if(A[i].c!=M[i].c){
      flag=NOTSTABLE;
      break;
    }
  }
  
  if(flag==STABLE)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0; i<n; i++)printf("%c %d\n", A[i].c, A[i].n);
  
  return 0;
}

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

int main(void){
    int n;
    double sum;
    
    cin >> n;
    
    vector<int> v(n);
    
    rep(i, n){
        cin >> v.at(i);
    }

    sort(v.begin(), v.end());
    sum = (double)v.at(0);
    
    rep(i, n-1){
        sum = (sum + (double)v.at(i+1))/2;
    }

    printf("%.6lf", sum);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test int t; cin>>t; while(t--)
#define loop(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
typedef long long int ll;
#define MAX 100000
#define debug(i) cout<<i<"\n"
#define f(t1,t2) min(max(a[t1],a[t2]) , max(b[t1],b[t2]));

void print_arr(int a[] , int n){
	loop(i,n){
		cout<<a[i]<<" ";
	}
	cout<<"\n";
}

void print_arr(ll a[] , int n){
	loop(i,n){
		cout<<a[i]<<" ";
	}
	cout<<"\n";
}

void init(int a[] , int n){
	loop(i,n) a[i]=0;
}



int main(){
    int n;
    cin>>n;
    loop(i,n) cout<<"ACL";
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<cctype>
#include<stack>
using namespace std;

int main(){

    stack<int> s;
    char c[100];
    while(cin>>c){
        int a,b;
        if(c[0]=='+'){
            a=s.top();s.pop();
            b=s.top();s.pop();
            s.push(b+a);
        }
        else if(c[0]=='-'){
            a=s.top();s.pop();
            b=s.top();s.pop();
            s.push(b-a);
        }
        else if(c[0]=='*'){
            a=s.top();s.pop();
            b=s.top();s.pop();
            s.push(b*a);
        }
        else
            s.push(atoi(c));
    }
    cout<<s.top()<<endl;
    s.pop();
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

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

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

    for (int i = n - 1; i >= 1; i--) cout << a[i] << ' ';
    cout << a[0] << endl;
}


Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int N,sum=0;
  cin >> N;
  int L[N*2];
  for(int i=0; i<2*N; i++){
    cin >> L[i];
  }sort(L,L+2*N,greater<int>());
  for(int i=1; i<2*N; i+=2){
    sum+=L[i];
  }cout << sum << endl;
}

Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#ifndef CONVICTION
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
   /* WARNING : do NOT compile this debug func calls with following flags: // \
    * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
   cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
   err(++it, args...);
}

const int N = (int)1e4 + 10, S = 104;
const int MOD = (int)1e9 + 7;

int dp[N][S][2];
int n, d;
string s;

inline int add (int a, int b) {
   return (a + b)%MOD;
}

void solve() {
   n = (int)s.size();
   s = ' ' + s;

   for (int dg = 0; dg < s[1] - '0'; ++dg)
      dp[1][dg % d][1] += 1;

   dp[1][(s[1] - '0')%d][0] += 1;

   for (int pos = 2; pos <= n; ++pos) {
      for (int rem = 0; rem < d; ++rem) {
         for (bool res_ : {false, true}) {
            int mx_digit = 9;
            if (!res_)
            {
               mx_digit = s[pos] - '0';
            }
            for (int dg = 0; dg <= mx_digit; ++dg) {
               bool res_now = (res_ || (dg < s[pos] - '0'));
               dp[pos][(rem + dg) % d][res_now] =
                  add(dp[pos][(rem + dg) % d][res_now], dp[pos - 1][rem][res_]);
            }
         }
      }
   }
   cout << (dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD << '\n';
}

signed main() {
   IOS; PREC;
   cin >> s >> d;
   solve();

   return EXIT_SUCCESS;
}


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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  if(A<9 && B<9) {
    
    cout << "Yay!" << endl;
    
  } else {
    
    cout << ":(" << endl;
    
  }
  
}

Measured memory_bytes: 256
def bubble_sort(A):
    n = len(A)
    cnt = 0
    for i in range(n-1, 0, -1):
        for j in range(i):
            if A[j] > A[j+1]:
                cnt += 1
                A[j], A[j+1] = A[j+1], A[j]
    return cnt


N = int(input())
A = [int(x) for x in input().split()]
cnt = bubble_sort(A)
print(' '.join(map(str, A)))
print(cnt)



Measured memory_bytes: 5604
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if n == 0:
    print(x)
else:
    under = over = x
    for num in range(x - min(p) + 2):
        if not (x - num in p):
            under = x - num
            break
    for num in range(max(p) - x + 2):
        if not (x + num in p):
            over = x + num
            break
    if x - under <= over - x:
        print(under)
    else:
        print(over)    

Measured memory_bytes: 9220
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
void solve(){
	string s,t; cin >> s >> t;
	int ans = 0;
	for(int i=0;i<s.size();i++){
		ans += (s[i] ^ t[i]) == 0;
	}
	ans = s.size() - ans;
	cout << ans;
}
int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int tst=1; while(tst--){
     solve();
   }
}

Measured memory_bytes: 3792
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
ll n;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    ll ans = 0;
    FOR(i,1,n) {
        ll k = n/i;
        ans += i * (k*(k+1)/2);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
import sys
import itertools


def solve():
    L, R = map(int, input().split())
    lst_mod = [-1]*min((R-L+1), 2019)
    counter = L % 2019
    for i in range(len(lst_mod)):
        lst_mod[i] = counter
        counter += 1
        if counter == 2019:
            print(0)
            sys.exit(0)
    num = 2019
    for comb_lst in itertools.combinations(lst_mod, 2):
        if num > (comb_lst[0]*comb_lst[1]) % 2019:
            num = (comb_lst[0]*comb_lst[1]) % 2019
    print(num)


solve()


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for (size_t i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }

    int sum = b[0];
    for (size_t i = 0; i < n - 2; i++)
    {
        sum += min(b[i], b[i + 1]);
    }
    sum += b.back();

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int a,b,c,temp=0;

  scanf("%d%d%d",&a,&b,&c);

  if(a > b){
    temp =a;
    a = b;
    b = temp;
  }

  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  printf("%d %d %d\n",a,b,c);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#define mod 1000000007
using namespace std;
const int maxn = 1e3;
char m[maxn+2][maxn+2];
int n, m1, dp[maxn+2][maxn+2];
int main()
{
    cin>>n>>m1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m1; j++)
        {
            cin>>m[i][j];
        }
    }
    int x=1;
    while(m[1][x]=='.'&&x<=n)
    {
        dp[1][x]=1;
        x++;
    }
    x=1;
    while(m[x][1]=='.'&&x<=m1)
    {
        dp[x][1]=1;
        x++;
    }
    for(int i=2; i<=n; i++)
    {
        for(int j=2; j<=m1; j++)
        {
            if(m[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=dp[i][j]%mod;
            }
        }
    }
    cout<<dp[n][m1];
    return 0;
}


Measured memory_bytes: 5120
using System;


public class C{
	
	public static void Main(){
	
		string[] args;

		args = Console.ReadLine().Split(' ');
		int n = Int32.Parse(args[0]);
		int x = Int32.Parse(args[1]);

		int[] dis = new int[n];		
		args = Console.ReadLine().Split(' ');
		for( int i = 0; i < n; i++ ){
			dis[i] = Math.Abs( x - Int32.Parse(args[i]) );
		}
	
		int d = dis[0];
		for( int i = 1; i < n; i++ ) d = gcd(d,dis[i]);
		
		Console.WriteLine(d);
		
	}
	
	
	public static int gcd(int x, int y){
		return ( ( y == 0 ) ? x : gcd(y, x % y) );		
	}
	
}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define dbg(x) cerr << #x << ":" << x << " "
#define dbgl(x) cerr << #x << ":" << x << "\n"
#define dbgv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	bool f = false;
	rep(i, N) {
		char c; cin >> c; if (c == 'Y') f = true;
		if (f) break;
	}
	cout << (f ? "Four" : "Three") << endl;
}

Measured memory_bytes: 256
/*
Single Source Shortest Path | Aizu Online Judge http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A

 */
#include <iostream>
#include <vector>
#include <queue>
#include <limits>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;

typedef pair<int,int> Pii;

const int INF = numeric_limits<int>::max();


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

    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<Pii>> edge(V);
    FOR(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        edge[s].push_back(make_pair(t, d));
    }
    vector<int> dist(V, INF);
    dist[r] = 0;
    priority_queue<Pii, vector<Pii>, greater<Pii>> q;
    q.push(Pii(0, r));
    while (!q.empty()) {
        Pii cur = q.top();
        q.pop();
        int cdist = cur.first, cv = cur.second;
        if (dist[cv] < cdist) continue;
        FOR(i, edge[cv].size()) {
            int nd = cdist + edge[cv][i].second,
                nv = edge[cv][i].first;
            if (nd < dist[nv]) {
                dist[nv] = nd;
                q.push(Pii(nd, nv));
            }
        }
    }

    for(auto &d: dist) {
        if (d == INF) cout << "INF";
        else cout << d;
        cout << '\n';
    }

    
    return 0;
}

Measured memory_bytes: 11216
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    CIN(A);CIN(B);CIN(C);
    COUT(A*B/2);
}


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

int main() {
    int s;
    cin >> s;
    int N = 1e9;
    int a;
    int i,idx=0;
    for (int i = 1; i < N; ++i) {
        if (s == 1 || s == 2 || s== 4) {
        cout << i+3 << endl;
        return 0;
        }else if ( s % 2 == 0)
            s = s/2;
        else
            s = 3 * s + 1;

    }
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll mod=1e9+7,MAX=2e3+5;

void fast();
int main()
{
    fast();
    int n;
    cin>>n;
    set<string>v;
    while(n--){
        string s;
        cin>>s;
        v.insert(s);
    }
    cout<<v.size();
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 19196
#include <atcoder/convolution>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<mint> a(n), b(m);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = x;
    }
    for (int i = 0; i < m; i++) {
        int x;
        scanf("%d", &x);
        b[i] = x;
    }

    auto c = convolution(a, b);

    for (int i = 0; i < n + m - 1; i++) {
        printf("%d ", c[i].val());
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 19060
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
A, B, C = map(int, input().split())

if A == B == C :
  print ("Yes")
else :
  print ("No")


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int x;
    cin>>x;
    int ans;
    if(x <= 599) ans = 8;
    else if(x <= 799) ans = 7;
    else if(x <= 999) ans = 6;
    else if(x <= 1199) ans = 5;
    else if(x <= 1399) ans = 4;
    else if(x <= 1599) ans = 3;
    else if(x <= 1799) ans = 2;
    else ans = 1;
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b&&a>=c&&b>=c)
        printf("%d %d %d\n",c,b,a);
    else if(a>=b&&a>=c&&b<=c)
        printf("%d %d %d\n",b,c,a);
        else if(b>=a&&b>=c&&a<=c)
        printf("%d %d %d\n",a,c,b);
        else if(b>=a&&b>=c&&a>=c)
        printf("%d %d %d\n",c,a,b);
        else if(c>=a&&c>=b&&a<=b)
        printf("%d %d %d\n",a,b,c);
        else
            printf("%d %d %d\n",b,a,c);
        return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a,b;
    cin >> a >> b;
    if((a == 1 && b == 2) || (a == 2 && b == 1)) pr(3);
    else if((a == 1 && b == 3) || (a == 3 && b == 1)) pr(2);
    else pr(1);
}

Measured memory_bytes: 256
# min(n-1,k)以下の自然数mに対してnCm*n-1Cn-m-1の和を求める
n, k = map(int, input().split())
p = 10 ** 9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 2 * 10 ** 5 + 1):
    g1.append((g1[-1] * i) % p)
    inverse.append((-inverse[p % i] * (p // i)) % p)
    g2.append((g2[-1] * inverse[-1]) % p)


def cmb(n, r):
    return g1[n] * g2[r] * g2[n - r] % p


ans = 0
for m in range(min(n - 1, k) + 1):
    ans += cmb(n, m) * cmb(n - 1, n - m - 1) % p
print(ans % p)


Measured memory_bytes: 27100
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;

int main(void)
{
	int N, score = 0;
	cin >> N;

	vector<int> S(N);

	for (int i = 0; i < N; i++) {
		cin >> S[i];
		score += S[i];
	}

	sort(S.begin(), S.end());

	if (!(score%10)) {
		for (int i = 0; i < N; i++) {
			if (S[i]%10) {
				cout << score-S[i] << endl;
				return 0;
			}
		}
		score = 0;
	}

	cout << score << endl;

	return 0;
}

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

int main()
{
	int A1, A2, A3,sum;
	cin >> A1 >> A2 >> A3;
	sum = A1 + A2 + A3;
	if (sum < 22)
		cout << "win" << endl;
	else
		cout << "bust" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int A, B, M;
  while (cin >> A >> B >> M) {
    vector<int> a(A), b(B);
    for (auto& x : a) cin >> x;
    for (auto& x : b) cin >> x;
    int res = 1e7;
    for (int i = 0; i < M; i++) {
      int x, y, c;
      cin >> x >> y >> c;
      --x;
      --y;
      chmin(res, a[x] + b[y] - c);
    }
    chmin(res, *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end()));
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 500000

#define MAX_H 100
#define MAX_W 100

int H,W,K;
char mm[50][51];

int memo[50][50][1<<12][4];

int mo[5]={0,-1,0,1,0};

int dfs(int y,int x,int visit,int k,int h=0){
    int ret = -INF;
    bool visit_mm[50][50] = {0};
    
    //cerr << "(" << y << "," << x << ")" << endl;
    
    if(memo[y][x][visit][k] != 0) return memo[y][x][visit][k];
    
    if(y==H-1 && x==W-1 && k==0) return 0;
    
    int after_visit = (visit%(1<<10));
    int after_x = x,after_y = y;
    int calc_visit = visit;
    
    vector<pair<int,int> > vec;
    
    for(int i=0;i<min(h,6);i++){
        after_x -= mo[calc_visit%4];
        after_y -= mo[calc_visit%4+1];
        calc_visit/=4;
        visit_mm[after_y][after_x] = true;
        
        //cerr << "<- (" << after_y << "," << after_x << ")" << endl;
    }
    
    int add = 1;
    
    for(int i=0;i<4;i++){
        if(k>=1 || i>=2){
            int to_x = x+mo[i];
            int to_y = y+mo[i+1];
            
            if(to_x<0 || W<=to_x || to_y<0 || H<=to_y || mm[to_y][to_x]=='#') continue;
            
            if(visit_mm[to_y][to_x]) add = 0;
            else add = mm[to_y][to_x]-'0';
            
            ret = max(ret,dfs(to_y,to_x,after_visit*4+i,k-(i<=1),h+1)+add);
        }
    }
    
    return memo[y][x][visit][k] = ret;
    
}

int main(){
    
    scanf("%d%d%d",&H,&W,&K);
    
    for(int i=0;i<H;i++){
        scanf("%s",mm[i]);
    }
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(mm[i][j]=='.') mm[i][j] = '0';
        }
    }
    
    printf("%d\n",dfs(0,0,0,K));
    
    return 0;
}

Measured memory_bytes: 161424
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = readline().decode('utf-8').strip()
    B = readline().decode('utf-8').strip()
    C = readline().decode('utf-8').strip()
    ans = 0
    for i in range(N):
        if A[i]==B[i]==C[i]:
            continue
        elif A[i]!=B[i] and B[i]!=C[i] and C[i]!=A[i]:
            ans += 2
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PAIR pair<double, double>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
#define PI acos(-1)
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

double operator*(PAIR a, PAIR b){
	return a.first * b.first + a.second * b.second;
}

PAIR operator+(PAIR a, PAIR b){
	return PAIR(a.first + b.first, a.second + b.second);
}

double abs(PAIR d){
	return sqrt(d.first * d.first + d.second * d.second);
}

int main(){
	int N;
	cin >> N;
	vector<PAIR> line(N);
	foreach(i, line)cin>>i.first >> i.second;
	vector<double> anses(100);
	REP(i, 100){
		anses[i] = PI * i / 50;
	}
	auto func = [&](double angle){
		PAIR dir(sin(angle), cos(angle));
		PAIR sum(0, 0);
		foreach(i, line){
			if(i * dir > 0)sum = sum + i;
		}
		return abs(sum);
	};
	REP(i, 10){
		vector<PAIR> nans;
		foreach(j, anses){
			nans.push_back(PAIR(func(j), j));
		}
		sort(ALL(nans));
		double dt = nans.back().second;
		anses.clear();
		for(int j=-50;j<50;++j){
			anses.push_back(dt + j / 10.0 * pow(0.05, (double)i));
		}
	}

	printf("%.15lf\n", func(anses.front()));

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int num = sc.nextInt();
				int count = 0;
				boolean isPrime = true;
				if (num <= 1) {
					System.out.println(count);
				} else if (num == 2) {
					count++;
					System.out.println(count);
				} else if (num == 3) {
					count = 2;
					System.out.println(count);
				} else {
					count=1;
					for (int i = 3; i <= num; i += 2) {
						for (int j = 3; j <= Math.sqrt(i); j += 2) {
							if (i % j == 0) {
								isPrime = false;
								break;
							}
						}
						if (isPrime) {
							count++;
						} else {
							isPrime = true;
						}
					}
					System.out.println(count);
					count = 0;
				}
			}
		} finally {
			sc.close();
		}

	}
}

Measured memory_bytes: 19320
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


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

void solve(){
    int n, m;
    cin >> n >> m;
    int total = (n*(n-1))/2 + (m*(m-1))/2;
    cout << total << endl;
}

signed main(){  
//  freopen("ii.txt", "w", stdin);
    flash;
    int t = 1;
    // cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    //goog(tc);
        solve();
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
	char a[6],b[6];
	int ans=0;
	int x,y;
	cin>>x>>y;
	for(int i=x;i<=y;i++){
		a[0]=i/10000;
		a[1]=(i%10000)/1000;
		a[2]=(i%1000)/100;
		a[3]=(i%100)/10;
		a[4]=i%10;
		if(a[0]==a[4]&&a[1]==a[3])ans++;
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 256
n, k, s = map(int, input().split())

if s == 10 ** 9:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.append('1')
    print(' '.join(ans))
else:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.append(str(s+1))
    print(' '.join(ans))

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] != t[i]) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll N;
    cin >> N;
    vll a(3*N);
    for(auto &x:a) cin >> x;
    DESC(a);
    ll ans = 0;
    REP(i, N) {
        ans += a[2*i+1];
    }
    out(ans);
}

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


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
bool done(string s){
    char c =s[0];
    int n = s.size();
    reps(i,n,1){
        if(c!=s[i]){
            return false;
        }
    }
    return true;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int n = s.size();
int res=0;
while(!done(s)){
    char c = s[0] =='W'?'B':'W';
    int w;
    reps(i,n,1){
        if(s[i]==c){
            w=i;
            break;
        }
    }
    s = s.substr(w,n-w); 
    res++;
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 3732
inp = input().rstrip().split(" ")
N = int(inp[0])
K = int(inp[1])
inp = input().rstrip().split(" ")
HP = [0 for i in range(N)]
for i in range(N):
  HP[i] = int(inp[i])
HP.sort()
HP.reverse()
ans = 0
for i in range(N):
  if i >= K:
    ans += HP[i]
print(ans)

Measured memory_bytes: 28212
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


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


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int a,b,c,temp;
  
  scanf("%d %d %d", &a,&b,&c);
  temp=a;
  a=b;
  b=temp;
  
  temp=a;
  a=c;
  c=temp;
  printf("%d %d %d", a,b,c);
  return 0;
}

Measured memory_bytes: 1728
#include "bits/stdc++.h"

using namespace std;

int dp(int curr, int W, const vector<int>& v, const vector<int>& w, vector<vector<int>>& memo) {
    if (curr >= v.size()) {
        return 0;
    }
    if (memo[curr][W] >= 0) {
        return memo[curr][W];
    }

    int ans = dp(curr + 1, W, v, w, memo);
    if (W >= w[curr]) {
        int take = dp(curr + 1, W - w[curr], v, w, memo) + v[curr];
        ans = max(ans, take);
    }
    memo[curr][W] = ans;
    return ans;
}

int solve1(int N, int W, const vector<int>& v, const vector<int>& w) {
    vector<vector<int>> memo(N + 10, vector<int>(W + 10, -1));
    int ans = dp(0, W, v, w, memo);
    cout << ans << endl;
}

void Main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N, 0), w(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }

    solve1(N, W, v, w);
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 7056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,B,N; cin >> A >> B >> N;
    
    for(ll x = min(B,N); x >= max(1LL,min(B,N)-1000); x--){
        res = max(res,A*x/B-A*(x/B));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int32_t main()
{
    string a, b;
    int n;
    cin >> n >> a >> b;
    
    for(int i = 0; i < a.size(); i++)
        cout << a[i] << b[i];
    puts("");
    
    return 0;
}

Measured memory_bytes: 256
N_1 = int(input())
A = [str(input()) for i in range(N_1)]
N_2 = int(input())
B = [str(input()) for i in range(N_2)]

C = A+B
D = list(set(C))
E=[]
for i in range(len(D)):
    NN = A.count(D[i]) - B.count(D[i])
    E.append(NN)
if max(E)>=0:
    print(max(E))
else:
    print(0)

Measured memory_bytes: 62588
import Data.Char

solve :: Int -> Int -> String -> Bool
solve a b s =
  (all isDigit $ take a s ++ drop (a+1) s)
  && s!!a == '-'
  && length s == a+b+1

main = do
  [a,b] <- map read . words <$> getLine
  s <- getLine
  putStrLn $ if solve a b s then "Yes" else "No"


Measured memory_bytes: 508