akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,n;
    cin>>h>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll dp[100001];
    for(int i=1;i<100001;i++)dp[i]=INF;
    dp[0]=0;
    ll ans=INF;
    for(int i=0;i<n;i++){
        for(int j=a[i];j<n+10001;j++){
            chmin(dp[j],dp[j-a[i]]+b[i]);
            if(j>=h)chmin(ans,dp[j]);
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        Map<String, Integer> map = new HashMap<>();

        int n  = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String word = sc.next();
            int value = map.getOrDefault(word, 0);
            value ++;
            map.put(word, value);
        }

        int m  = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String word = sc.next();
            int value = map.getOrDefault(word, 0);
            value--;
            map.put(word, value);
        }

        int max = 0; //Integer.MIN_VALUE;
        //String maxWord = "";
        for (Map.Entry<String, Integer> entry:  map.entrySet()) {
            int entryVal = entry.getValue();
            if (entryVal > max) {
                max = entryVal;
                //maxWord = entry.getKey();
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
    int n,cu=0;
    scanf("%d ", &n);
	char str[n+3];
    scanf("%s", str);
  	for(int i=0;i<n-2;i++){
      if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C'){ cu++;}
    }
  	printf("%d",cu);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
    return 0;
}

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

int main() {

  int A, B;
  cin >> A >> B;

  int answer = -1;

  for (int i = 1; i <= 1000; i++){
    int a_ = floor((double) i / 100 * 8);
    int b_ = i / 10;
    if (A == a_ && B == b_){
      answer = i;
      break;
    }
  } 
  
  cout << answer << endl;

  return 0;

}

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

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

    int n;
    cin >> n;
    int a = 100000, b;
    int ans = 0;
    for (int i = 1; i < n; i++){
        cin >> b;
        ans += min(a, b);
        a = b;
    }
    ans += a;
    cout << ans << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+4010,-1);
   fill(tableI,tableI+4010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}

int main(){
   modfill(MOD);
   ll K,N;
   cin >> K >> N;
   ll all = modCON(N+K-1,N,MOD);
   FOR(i,2,2*K+1){
      ll res = all;
      ll cnt = 0;
      FOR(j,1,K+1){
         if(j <= K && i - j <= K && j <= i - j)cnt++;
      }
      FOR(j,1,cnt+1){
         if(j * 2 > N) break;
         if(j % 2 == 1){
            res -= modCON(cnt,j,MOD) * modCON(N+K-1-j*2,K-1,MOD);
         }else{
            res += modCON(cnt,j,MOD) * modCON(N+K-1-j*2,K-1,MOD);
         }
         while(res < 0) res += MOD * (ll)1000000000;
         res %= MOD;
      }
      cout << res % MOD << '\n';
   }
}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}


constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}


constexpr long long MOD = 1000000007;

void solve(long long n, long long a, long long b) {
    ll all = pow_mod(2, n, MOD) - 1;
    ll am = nCr_mod(n, a, MOD);
    ll bm = nCr_mod(n, b, MOD);
    ll ans = all + MOD - ((am + bm) % MOD);
    cout << ans % MOD << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long n;
    std::cin >> n;
    long long a;
    std::cin >> a;
    long long b;
    std::cin >> b;
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  int t;

  while (cin >> t, t){
    int n;
    int sum = 0;
    cin >> n;
    REP(i, n){
      int s, f;
      cin >> s >> f;
      sum += f - s;
    }
    sum >= t ? print("OK") : print(t - sum);
  }

  return (0);
}

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

typedef long long ll;
ll n, dp[3010][3010], mod = 1e9+7, ans;
string st;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> st;
	for(int i=0; i<n; ++i)
		dp[0][i] = 1;
	for(int i=1; i<n; ++i){
		if(st[i-1] == '<'){
			for(int j=1; j<=n; ++j){
				dp[i][j-1] += dp[i-1][j];
				dp[i][j-1] %= mod;
			}
			for(int j=n-i-2; j>=0; --j){
				dp[i][j] += dp[i][j+1];
				dp[i][j] %= mod;
			}
		}else{
			for(int j=0; j<=n; ++j){
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= mod;
			}
			for(int j=1; j<=n-i-1; ++j){
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<=n; ++j)
//			cout << dp[i][j] << (j == n ? "\n" : " ");
	ans = dp[n-1][0];
	if(ans < 0) ans += mod;
	cout << ans << "\n";
}

Measured memory_bytes: 70784
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

//#define int ll

using edge =struct{int to;ll cost;};
vector <edge> tree[100010];
ll depth[100010];

void dfs(int v,int p,ll d){
    depth[v]=d;
    for(auto &e : tree[v]){
        if(e.to==p)continue;
        dfs(e.to,v,d+e.cost);
    }
}

signed main(){
    int n;
    cin>>n;
    rep(i,0,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        tree[a].pb({b,c});
        tree[b].push_back({a,c});
    }
    
    int q,k;
    cin>>q>>k;
    k--;
    
    dfs(k,-1,0);
    rep(i,0,q){
        int x,y;
        cin>>x>>y;
        x--,y--;
        cout<<depth[x]+depth[y]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 14336
// DPL-DPL_1_A
// Coin Changing Problem
// DP 動的計画法 お釣り問題
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
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;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++)
        cin >> c[i];

    // dp[i][j]: コインi(i=1,...,m)までを使ったときの， j円(0,...,n)を支払うのに必要なコインの最小枚数
    // 一つ前の状態しか使わないから m*n行列ではなくm行列で十分なのだが，値の変化を見やすいのでこうする
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
    {
        // 前の値コピー
        dp[i] = dp[i - 1];
        for (int j = 0; j < n; j++)
        {
            const int coin = c[i - 1];
            // 配るDP する
            // j+coin 円を支払うのに必要なコインの最小枚数を更新する
            // j円の最小枚数を利用する このとき coin円のコインを1枚使った支払額の最小枚数を更新する
            if (j + coin <= n)
                chmin(dp[i][j + coin], dp[i][j] + 1);
        }
    }

    cout << dp[m][n] << endl;
}



Measured memory_bytes: 11580
#include <stdio.h>
int main(){
	int i,n,ans=0,num,j;
	scanf("%d",&n);
	int a,v;
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&v);
		if(ans<v){
			ans=v;
			num=a;
		}else if(ans==v&&num>a)num=a;
	}
	printf("%d %d\n",num,ans);
return 0;
}

Measured memory_bytes: 600
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};

ll n, avg, arr[56];

ll dp[56][56][56 * 56 + 1];


int main(int argc, char const *argv[])
{
	
	cin>>n>>avg;

	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	
	dp[0][0][0] = 1;

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= i; ++j)
		{
			for (int k = 0; k <= 56 * 56; ++k)
			{
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j+1][k+arr[i]]+=dp[i][j][k];
			}
		}
	}
	
	ll ans = 0;

	for (int j = 1; j <= n; ++j)
	{
		ans+=dp[n][j][j*avg];
	}
	cout<<ans;
}	

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

int main(){
        ll n; scanf("%lld", &n);
        ll a[n];
        for(ll i=0; i<n; i++) scanf("%lld", &a[i]);

        ll I=1, ans=0;
        for(ll i=0; i<n; i++){
                if(a[i]==I) I++;
                else ans++;
        }
        if(I==1) ans=-1;
        printf("%lld\n", ans);
        return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    while (cin >> N, N) {
        set<string> check;
        map<string, vs> group;
        REP(i, N) {
            string s;
            cin >> s;
            s.erase(s.length()-1);
            replace(ALL(s), ':', ' ');
            replace(ALL(s), ',', ' ');
            stringstream ss(s);
            string g;
            ss >> g;
            string member;
            while (ss >> member) {
                if (i == 0) check.insert(member);
                group[g].push_back(member);
            }
        }
        set<string> a, b;
        while (check.size() > 0) {
            for (string m : check) {
                if (EXIST(group, m)) {
                    for (string mm : group[m]) {
                        a.insert(mm);
                    }
                } else {
                    b.insert(m);
                }
            }
            check = a;
            a.clear();
        }
        cout << b.size() << endl;
    }
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	int R, G, B, N;
  	cin >> R >> G >> B >> N;
  	int Rmax = N / R;
  	int Gmax = N / G;
  	int cnt = 0;
  	for (int r = 0; r <= Rmax; r++){
    	for (int g = 0; g <= Gmax; g++){
    		int rest = N - r * R - g * G;
          	if (rest >= 0 && rest % B == 0){
            	cnt++;
            }
    	}
    }
  	cout << cnt << endl;
}

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

int main()
{
  string s;
  long long k;
  cin >> s >> k;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(s[i] != '1' && i < k){
      cout << s[i] << endl;
      return(0);
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
template<class C, size_t Y> struct TP {
    void operator()(Dbg& os, const C &t) { TP<C, Y-1>()(os, t); os << ", " << get<Y-1>(t); }
};
template<class C> struct TP<C, 1> { void operator()(Dbg& os, const C &t) { os << get<0>(t); } };
template<class... C> Dbg& operator<<(const tuple<C...> &t) {
    os << '{', TP<decltype(t), sizeof...(C)>()(*this, t); return *this << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args ...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(string(#args)), args), dbg << endl
#define ASSERT(a, o, b) { if (!((a) o (b))) bug(a, b), assert((a) o (b)); }
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 100005;

char s[mxn];
bool a[mxn];

signed main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.precision(11);
    cin >> s;
    int n = sl(s);
    for (int i = 1; i <= n; i++) {
        a[i] = s[i-1]-'0';
    }
    for (int i = 1; i <= n-1; i++) {
        if (a[i]!=a[n-i]) return cout << "-1\n", 0;
    }
    if (a[n] or !a[1]) return cout << "-1\n", 0;
    int cur = 1;
    for (int i = 2; i <= n; i++) {
        if (!a[i] and i!=n) continue;
        for (int j = cur; j < i; j++) {
            cout << j << ' ' << i << '\n';
        }
        cur = i;
    }
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vector<int> A(N), B(N), C(N), dpA(N), dpB(N), dpC(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }

    dpA[0] = A[0];
    dpB[0] = B[0];
    dpC[0] = C[0];
    for (int i = 1; i < N; i++) {
        dpA[i] = A[i] + max(dpC[i - 1], dpB[i - 1]);
        dpB[i] = B[i] + max(dpA[i - 1], dpC[i - 1]);
        dpC[i] = C[i] + max(dpB[i - 1], dpA[i - 1]);
    }

    int ans = max({dpA[N - 1], dpB[N - 1], dpC[N - 1]});

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


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int H, W;
        
        sscanf(input.c_str(), "%d %d\n", &H, &W);
        
        if((H | W) == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(j == 0 || j == (W - 1) || i == 0 || i == (H - 1)){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return(0);
}



Measured memory_bytes: 3200
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

pint get(pint a,pint b){
    if(a.first>b.first)swap(a,b);
    if(b.first==inf)return a;
    if(a.first==-inf)return a;
    if(a.second<b.first)return {-inf,-inf};
    if((a.first-b.first)%2)return {-inf,-inf};
    return {b.first,min(a.second,b.second)};
}

pint p[101010];
int ans[101010];
vector<int> v[101010];
pint dfs(int x,int par){
    pint& ret=p[x];
    for(auto to:v[x]){
        if(to==par)continue;
        ret=get(ret,dfs(to,x));    
    }
    if(ret.first==inf||ret.first==-inf)return ret;
    return {ret.first-1,ret.second+1};
}

void build(int x,int par,int res=0){
    if(x==0)ans[x]=p[x].first;
    else{
        if(p[x].first<=res+1&&res+1<=p[x].second)ans[x]=res+1;
        else ans[x]=res-1;
    }
    for(auto to:v[x]){
        if(to==par)continue;
        build(to,x,ans[x]);
    }
}
int main(){
    int n;cin>>n;
    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        --x;--y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    rep(i,n)p[i]={inf,inf};
    int k;cin>>k;
    rep(i,k){
        int x,y;
        cin>>x>>y;
        p[--x]={y,y};
    }
    dfs(0,-1);
    if(p[0].first==-inf){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    build(0,-1);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	long long ans = 0;
	int acc = 0;
	unordered_map<int, int> h;

	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		acc = (0LL + acc + A) % M;
		if (acc == 0) {
			++ans;
		}
		ans += h[acc];
		++h[acc];
	}
	cout << ans << endl;
}


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

ll com(ll n){
  ll res = n*(n-1)/2;
  return res;
}

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n);
  rep(i,n){
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll tot = 0;
  rep(i,n+1) tot += com(cnt[i]);
  rep(i,n){
    ll ans = tot;
    ans -= com(cnt[a[i]]);
    ans += com(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4824
A = [int(input()) for i in range(5)]
mod_list = [a % 10 for a in A]
mod_list = [10 if a == 0 else a for a in mod_list]

comb_list = [[a, b] for a, b in zip(A, mod_list)]
sort_list = sorted(comb_list, key=lambda x: -x[1])

res = 0

for i, a in enumerate(sort_list):
    if i < 4:
        res += a[0] + (10-a[1])
    else:
        res += a[0]

print(res)


Measured memory_bytes: 3064
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
ans = 0
import collections
from collections import deque
d1 = deque()
count = 0
for i in range(N-1) :
    if A[i] == A[i+1] :
        count += 1
    else :
        if count == 0 :
            count = 0
            continue
        elif count < 3 :
            d1.append(A[i])
        else :
            d1.append(A[i])
            d1.append(A[i])
        count = 0
    if i == N-2 :
        if 0 < count < 3 :
            d1.append(A[i])
        elif count >= 3 :
            d1.append(A[i])
            d1.append(A[i])
if len(d1) < 2 :
    print(ans)
else :
    print(d1[-1] * d1[-2])

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

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	pair<int,int> a[105];
	for(int i=0;i<n;i++)
	{
		cin >> a[i].first;
		a[i].second=i+1;
	}
	
	int ans[1000005];
	int count=0;
	int before=-1;
	int last;

	for(int i=0;i<k+1;i++)
	{
		sort(a,a+n);
		reverse(a,a+n);
		for(int j=0;j<n;j++)
		{
//			cout << i << ":" << j << " " << a[j].second << ":" << before << endl;
			if(a[j].second==before)
			{
				continue;
			}
			if(a[j].first<=0)
			{
				cout << -1 << endl;
				return 0;
			}
			ans[count]=a[j].second;
			a[j].first--;
			count++;
			if(j==n-1 or (j==n-1-1 and a[n-1].second==before))last=a[j].second;
		}
		before=last;
	}

	cout << count << endl;

	for(int i=0;i<count;i++)
		cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl H(N);
  REP(i, N) cin >> H[i];
  ll ans = 0;
  ll ma = 0;
  REP(i, N) {
    if (ma <= H[i])
      ans++;
    ma = max(ma, H[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
o=input()
e=input()
moji=""

if len(o)==len(e):
    for i in range(len(o)):
        moji+=o[i]
        moji+=e[i]
else:
    for i in range(len(e)):
        moji+=o[i]
        moji+=e[i]
    moji+=o[-1]

print(moji)

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define F first
#define S second
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 60;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int k; cin >> k;
  string s; cin >> s;
  if(sz(s) <= k)cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;
  return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      StringBuilder sb = new StringBuilder();
      if(n == 0) {
        System.out.println(0);
        return;
      }
      while(n != 0) {
        if(n % -2 == 0) 
            sb.append("0");
        else {
            sb.append("1");
            n--;
        }
        n /= -2;
      }
      System.out.println(sb.reverse().toString());
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,M,a,Asum=0;
    vector<int> A,B;
    cin >> N >> M;
    REP(i,N){
        cin >> a;
        Asum+=a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    B=A;
    RREP(i,N-1){
        B[i]+=B[i+1];
    }
    B.push_back(0);
    
    int ng=300000,ok=0,mid;
    
    while(abs(ok-ng)>1){
        mid=(ok+ng)/2;
        
        int num=0;
        REP(i,N){
            decltype(A)::iterator it = std::lower_bound(A.begin(), A.end(), mid-A[i]);
            int d=A.end()-it;
            num+=d;
        }
        //cout << mid << " " << num << endl;
        
        if(num>=M){
            ok=mid;
        }else{
            ng=mid;
        }
        
    }
    
    //cout << ok << endl;
    
    int Ans=0;
    int now=0;
    RREP(i,N){
        decltype(A)::iterator it = std::lower_bound(A.begin(), A.end(), ok-A[i]);
        int d=it-A.begin();
        Ans+=(N-d)*A[i];
        Ans+=B[d];
        now+=(N-d);
        //cout << i MM d MM now<< "  ";
        //cout << Ans << endl;
    }
    Ans-=max(0ll,now-M)*ok;
    cout << Ans << endl;
    
    return 0;
}



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

using namespace std;
const int MAXN = 3 * 1e5 + 15;
int cntx[MAXN], cnty[MAXN], x[MAXN], y[MAXN];
int main() {

    int h, w, m;
    scanf("%d %d %d", &h, &w, &m);

    for(int i = 1; i <= m; i++) {
        scanf("%d %d", &x[i], &y[i]);

        cntx[x[i]]++; cnty[y[i]]++;
    }

    int fx = 0, fy = 0, sumx = 0, sumy = 0;

    for(int i = 1; i <= h; i++) {
        fx = max(fx, cntx[i]);
    }
    for(int i = 1; i <= h; i++) {
        if(cntx[i] == fx) sumx++;
    }

    for(int i = 1; i <= w; i++) {
        fy = max(fy, cnty[i]);
    }
    for(int i = 1; i <= w; i++) {
        if(cnty[i] == fy) sumy++;
    }

    int cnt = 0;
    for(int i = 1; i <= m; i++) {
        if(cntx[x[i]] == fx && cnty[y[i]] == fy) cnt++;
    }

    printf("%d\n", fx + fy - (cnt == 1ll * sumx * sumy ? 1 : 0));

    return 0;
}


Measured memory_bytes: 8452
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000

char a[1005][1005];
ll dp[1005][1005];
int main()
{
	ios
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<m;i++)
	{
		if(a[0][i]=='.')
			dp[0][i]=dp[0][i-1];
		else	break;
	}
	for(int i=1;i<n;i++)
	{
		if(a[i][0]=='.')
			dp[i][0]=dp[i-1][0];
		else	break;
	}
	
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(a[i][j]=='.')
				dp[i][j]=add(dp[i-1][j],dp[i][j-1]);
		}
	}
	cout<<dp[n-1][m-1];		
}



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

int main(){
  int64_t X,Y;
  cin >> X >> Y;
  int64_t ans=1;
  while(1){
    X+=X;
    if(X<=Y){
      ans++;
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#get input
n = input()
S = map(lambda x: int(x), input().split(' '))
q = input()
T = list(map(lambda x: int(x), input().split(' ')))

#create T set
T_set = set(T)

#iterate S and counting
count = 0
for i in S:
    if i in T_set:
        count += 1
        T_set.remove(i)

print(count)


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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	rep(i,n) cin >> v[i];
	rep(i,n) cin >> c[i];
	
	int res = 0;
	
	rep(i,n){
		int benefit = v[i] - c[i];
		if(benefit >= 0) res += benefit;
	}

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

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

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

    cout << (a + b) % 24 << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    ll k, n;
    cin >> k >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    ll mx = 0;

    mx = a[0]-0;
    rep(i, 1, n){
        mx = max(mx, a[i]-a[i-1]);
    }
    mx = max(mx, a[0]+(k-a[n-1]));
    ll ans = k - mx; //uターンしない

    cout << ans << endl;
}


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

    solve();
    return 0;
}


Measured memory_bytes: 1792
import collections

def judge(card, cnt):
    nmax = cnt[0][1]
    if nmax == 4: return "four card"
    if nmax == 3: return "full house" if cnt[1][1] == 2 else "three card"
    if nmax == 2: return "two pair" if cnt[1][1] == 2 else "one pair"
    if (card[0] == 1 and list(range(10, 14)) == card[1:]) or list(range(card[0], card[0] + 5)) == card : return "straight"

    return "null"
while True:
    try:
        card = list(map(int, input().split(",")))
    except:
        break
    cnt = collections.Counter(card)
    print(judge(sorted(card), sorted(cnt.items(), key = lambda x:-x[1])))


Measured memory_bytes: 5992
#include<stdio.h>
int main(){
int n,a[100],i,j;
 
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(j=0;j<n;j++){
if(j==n-1)printf("%d\n",a[0]);
else printf("%d ",a[n-1-j]);
}
 
return 0;
}

Measured memory_bytes: 596
import itertools
n,m,x = map(int, input().split())
argo = list()
for i in range(n):
    argo.append(list(map(int, input().split())))
least = float("inf")
test = [x] * m
for i in range(1,n+1):
    tmp = list(itertools.combinations(argo, i))
    for j in range(len(tmp)):
        boolean = True
        money = 0
        check = [0] * m
        for k in range(i):
            money += tmp[j][k][0]
            for l in range(m):
                check[l] += tmp[j][k][l+1]
        for k in range(m):
            if check[k] < x:
                boolean = False
                break
        if boolean:
            if money <= least:
                least = money
if least == float("inf"):
    print(-1)
else:
    print(least)
            

Measured memory_bytes: 9376
#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cctype>
#include <cassert>

using namespace std;
string str;

struct Tree {
  int num;
  vector<char> op;
  vector<Tree> child;
  Tree() :num(-1), op(), child() {}
};

typedef pair<Tree ,int> P;

P num(int idx) {
  int num = 0;
  while (isdigit(str[idx])) {
    num = num * 10 + (str[idx] - '0');
    idx++;
  }
  Tree t;
  t.num = num;
  // printf("%d\n", num);
  return P(t, idx);
}

P expr(int idx) {
  Tree e;
   do {
    if (str[idx] == '(') {
      P t = expr(idx + 1);
      e.child.push_back(t.first);
      idx = t.second;
      assert(str[idx] == ')');
      idx++;
    } else {
      P t = num(idx);
      // printf("%d\n", t.first.num);
      e.child.push_back(t.first);
      idx = t.second;
    }
    if (idx == str.size() || str[idx] == ')') {
      return P(e, idx);
    }
    e.op.push_back(str[idx]);
    idx++;
  } while (idx < str.size());
}

typedef pair<bool, int> Res;

Res eval(int a, int b, char op) {
  switch (op) {
  case '+':
    return Res(true, a+b);
  case '-':
    return Res(true, a-b);
  case '*':
    return Res(true, a*b);
  case '/':
    if (b == 0) {
      return Res(false, 0);
    } else {
      return Res(true, a / b);
    }
  }
}

set<int> merge_res(set<int> l, set<int> r, char op) {
  set<int> res;
  for (set<int>::iterator lit = l.begin(); lit != l.end(); lit++) {
    for (set<int>::iterator rit = r.begin(); rit != r.end(); rit++) {
      Res t = eval(*lit, *rit, op);
      if (t.first) {
        res.insert(t.second);
      }
    } 
  }
  return res;
}

set<int> evaluate(Tree e, int l, int r) {
  // printf("%d, %d\n", l, r);
  if (e.child.size() == 0) {
    set<int> s;
    s.insert(e.num);
    return s;
  }
  if (r == l + 1) {
    //printf("down\n");
    set<int> s = evaluate(e.child[l], 0, e.child[l].child.size());
    // printf("ret\n");
    return s;
  }

  // printf("op = %d\n", e.op.size());
  set<int> result;
  for (int nextr = l + 1; nextr < r; nextr++) {
    set<int> resl = evaluate(e, l, nextr);
    set<int> resr = evaluate(e, nextr, r);
    set<int> res = merge_res(resl, resr, e.op[nextr - 1]);
    //printf("out\n");
    result.insert(res.begin(), res.end());
    // printf("safe\n");
  }

  return result;
}

void testTree(Tree e) {
  if (e.child.size() == 0) {
    printf("%d", e.num);
    return;
  }
  printf("(");
  testTree(e.child[0]);
  for (int i = 0; i < e.op.size(); i++) {
    printf("%c", e.op[i]);
    testTree(e.child[i + 1]);
  }
  printf(")");
}

void solve() {
  P e1 = expr(0);
  Tree e = e1.first;
  //testTree(e);
  //printf("\n");
  set<int> res = evaluate(e, 0, e.child.size());
  printf("%d\n", res.size());
}

int main() {
  while (true) {
    getline(cin, str);
    if (str == "#") {
      return 0;
    }
    //cout << str << endl;
    solve();
  }
}

Measured memory_bytes: 988
N = int(input())
x = [list(map(int,input().split())) for i in range(N)]
x[0:0] =[[0,0,0]]
can = True
for i in range(N):
    max_dis = x[i+1][0]-x[i][0]
    dis = abs(x[i+1][1]-x[i][1])+abs(x[i+1][2]-x[i][2])
    if(dis>max_dis or dis%2 != max_dis%2):
        can = False
        break
print("Yes" if can == True else "No")


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

int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    rep(i,ty-sy) cout<<"U";
    rep(i,tx-sx+1) cout<<"R";
    rep(i,ty-sy+1) cout<<"D";
    rep(i,tx-sx+1) cout<<"L";
    cout<<"U";
    cout<<"L";
    rep(i,ty-sy+1) cout<<"U";
    rep(i,tx-sx+1) cout<<"R";
    rep(i,ty-sy+1) cout<<"D";
    rep(i,tx-sx) cout<<"L";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int x,y,a,b,c,total,ans=0;
    vector <int> v;
    cin>>x>>y>>a>>b>>c;
    int r[a],g[b],n[c];
    for(int i=0;i<a;i++)
    cin>>r[i];
    for(int i=0;i<b;i++)
    cin>>g[i];
    for(int i=0;i<c;i++)
    cin>>n[i];
    sort(r, r+a);
    sort(g, g+b);
    sort(n, n+c);
    for(int i=a-1;i>=a-(min(x, a));i--)
    v.pb(r[i]);
    for(int i=b-1;i>=b-(min(y, b));i--)
    v.pb(g[i]);
    for(int i=c-1;i>=0;i--)
    v.pb(n[i]);
    int l=v.size(),blah=0;
    sort(v.begin(), v.end());
    for(int i=l-1;i>=0;i--)
    {
        ans+=v[i];
        blah++;
        if(blah==x+y)
        break;
    }
    cout<<ans;
}

Measured memory_bytes: 8816