akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int h, w;
char mp[30][30];
int score[30][30];
int v[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int main() {
    Fill(mp, '#');
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> mp[i + 1][j + 1];
    int ans = 0;
    for(int si = 1; si <= h; si++)
        for(int sj = 1; sj <= w; sj++)
            for(int gi = 1; gi <= h; gi++)
                for(int gj = 1; gj <= w; gj ++) {
                    if(mp[si][sj] == '#' || mp[gi][gj] == '#') continue;
                    Fill(score, inf);
                    queue<pair<int, int>> q;
                    score[si][sj] = 0;
                    q.push({si, sj});
                    while(!q.empty()) {
                        int x, y;
                        tie(x, y) = q.front();
                        q.pop();
                        rep(i, 4) {
                            int X = x + v[i][0], Y = y + v[i][1];
                            if(mp[X][Y] == '#') continue;
                            if(chmin(score[X][Y], score[x][y] + 1)) q.push({X, Y});
                        }
                    }
                    chmax(ans, score[gi][gj]);
                }
    cout << ans << endl;
}

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

using ll = long long;
constexpr ll MOD = 998244353;

ll a[3030], dp[3030][3][3030];

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

	dp[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= s; ++j) {
			(dp[i + 1][0][j] += dp[i][0][j]) %= MOD;
			(dp[i + 1][1][j] += dp[i][0][j] + dp[i][1][j]) %= MOD;
			(dp[i + 1][2][j] += dp[i][0][j] + dp[i][1][j] + dp[i][2][j]) %= MOD;
          if (j + a[i] <= s) {
			(dp[i + 1][1][j + a[i]] += dp[i][0][j] + dp[i][1][j]) %= MOD;
			(dp[i + 1][2][j + a[i]] += dp[i][0][j] + dp[i][1][j]) %= MOD;
          }
		}
	}
	printf("%d", dp[n][2][s]);
	return 0;
}


Measured memory_bytes: 215296
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

L = []
for i in range(n):
    L += [i+1]*A[i]
#print(L)

for i in range(h):
    l = L[i*w:(i+1)*w]
    if i%2 == 1:
        l.reverse()
    print(*l)

Measured memory_bytes: 41584
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll ok=false;
    rep(i,N) if(A[i]%2) ok=true;
    cout<< ( ok ? "first" : "second" )<<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1024
#include<stdio.h>
#define INF 1000000
void genericMST(int,int);
int ming=0,count[100],c=0;
int g[100][100];
int main(){
  int i,j,n,min;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    count[i]=0;
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
  genericMST(0,n);
  printf("%d\n",ming);

  return 0;
}


void genericMST(int x,int n){
  int min=INF,minj=1000,i,j,f=0;
  for(i=0;i<n;i++){
    if(count[i]!=1)f++;
  }if(f==1)return;
  count[x]=1;

  
  for(i=0;i<n;i++){
    if(count[i]==1){
      for(j=0;j<n;j++){
	if(g[i][j]!=-1&&count[j]!=1){
	  if(g[i][j]<min){
	    min=g[i][j];
	    minj=j;
	  }
	}
      }
    }
  }
  ming+=min;
  
  if(count[minj]!=1){
    genericMST(minj,n);
  }
}

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

using namespace std;
string name;
int signnum;
int ans = 0;
int main() {
	cin >> signnum;
	cin >> name;
	vector<string> oldsign(signnum);
	for (int i = 0; i < signnum; i++) {
		cin >> oldsign[i];
	}

	for (int i = 0; i < signnum; i++) {
		for (int j = 0; j < (oldsign[i].length() - name.length()) / (name.length() - 1) + 1; j++) {
			int flag = 0;
			for (int k = 0; k + (j * (name.length() - 1)) + name.length() < oldsign[i].length() + 1; k++) {
				string temp;
				for (int n = 0; n < name.length(); n++) {
					temp.push_back(oldsign[i][n*j + n + k]);
				}
				if (temp == name) {
					ans++;
					flag++;
					break;
				}
			}
			if (flag) {
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[1000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
    int n;
    int a,b,c,ans;
    while(cin>>n){
        if(n==-1) break;
        a=b=c=ans=0;
        if(n>30) a=n-30;
        if(n>20) b=n-20;
        if(n>10) c=n-10;
        if(b>10) b=10;
        if(c>10) c=10;
        ans=1150+c*125+b*140+a*160;
        ans=4280-ans;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5452
input()
xs=list(map(int, input().split()))
 
f,t,z=0,0,0
for x in xs:
  if x % 4 == 0:
    f+=1
  elif x % 2 == 0:
    t += 1
  else:
    z += 1
z += 0<t
print('Yes' if z - 2 < f else'No')

Measured memory_bytes: 14252
<?php
list($s) = strs();
$prev = array_fill(0, 26, PHP_INT_MIN);
for ($i = 0; $i < strlen($s); ++$i) {
    if (4 > $i - $prev[ord($s[$i]) - 97] + 1)
        exit(($prev[ord($s[$i]) - 97] + 1) . ' ' . ($i + 1));
    $prev[ord($s[$i]) - 97] = $i;
}
echo '-1 -1';
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16272
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    string S; cin >> S;

    int ans = 753;

    REP(i, S.size() - 2){
        int tmp = 100 * (S.at(i) - '0') + 10 * (S.at(i+1) - '0') + S.at(i+2) - '0';
        ans = min(abs(753 - tmp), ans);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

pub struct UnionFind {
    pub root: Vec<usize>,
}
impl UnionFind {
    pub fn new(nodes: usize) -> Self {
        Self {
            root: (0..=nodes).collect(),
        }
    }
    pub fn merge(&mut self, a: usize, b: usize) {
        let a = self.root_of(a);
        let b = self.root_of(b);

        if a < b {
            self.root[a] = b;
        } else {
            self.root[b] = a;
        }
    }
    pub fn same_root(&mut self, a: usize, b: usize) -> bool {
        self.root_of(a) == self.root_of(b)
    }
    pub fn root_of(&mut self, a: usize) -> usize {
        if self.root[a] == a {
            return a;
        }
        self.root[a] = self.root_of(self.root[a]);
        self.root[a]
    }
}

fn main() {
    input! {
        n: usize,
        rel: [(Usize1, Usize1)]
    }

    let mut uf = UnionFind::new(n);

    for &(a, b) in &rel {
        uf.merge(a, b);
    }

    let mut map = std::collections::HashMap::new();

    for i in 0..n {
        map.entry(uf.root_of(i)).and_modify(|x| *x += 1).or_insert(1);
    }

    let mut ans = 0;
    for (&k, &v) in &map {
        ans = std::cmp::max(ans, v);
    }

    println!("{}", ans);
}


Measured memory_bytes: 15516
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	ps <- uncurry zip . ( id &&& drop ( k - 1 ) ) <$> readInts
	print $ minimum $ map solve ps

solve ( l, r )
	| r < 0 = -l
	| 0 < l = r
	| otherwise = min (-l) r + ( r - l )

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

int main(void){
    int N; cin >> N;
    VI A(N,0); REP(i,N-1) cin >> A[i+1];
    VI ans(N,0);
    REP(i,N-1) ans[A[i+1]-1]++;
    REP(i,N) cout << ans[i] << en;
    return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double n,m,x,y,mx,my;
	cin>>n>>m>>x>>y;
	printf("%lf ",n*m/2);
	mx=n/2;my=m/2;
	if(x==mx && y==my) cout<<1;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;
  int a[26];
  int b[26];
  for(int i = 0; i < 26; i++){
      a[i] = 1e9;
      b[i] = 0;
  }
  for(int i = 0; i < n; i++){
      string s;
      cin >> s;
      for(int i = 0; i < s.size(); i++){
          b[s[i] - 'a']++;
      }
      for(int i = 0; i < 26; i++){
          a[i] = min(a[i],b[i]);
      }
      for(int i = 0; i < 26; i++){
          b[i] = 0;
      }
  }
  for(int i = 0; i < 26; i++){
      for(int j = 0; j < a[i]; j++){
          cout << static_cast<char>('a' + i);
      }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

const ll INF = 1 << 30;

int main() {
  ll N, M;
  string str;
  cin >> N >> M >> str;

  vll dp(N + 1, INF);
  ll cur = N;
  dp[N] = 0;
  for (ll i = N - 1; i >= 0; i--) {
    if (str[i] == '1') continue;
    while (1) {
      if (i >= cur) {
        puts("-1");
        return 0;
      } else if (dp[cur] != INF && cur - i <= M) {
        dp[i] = dp[cur] + 1;
        // cerr << i << " " << dp[i] << endl;
        break;
      }
      cur--;
    }  // while
  }    // i

  vll ans;
  ll x = 0;
  ll nxt = dp[0] - 1;
  while (x < N) {
    ll i = 1;
    while (dp[x+i] != nxt) {
      i++;
    }
    ans.push_back(i);
    nxt--;
    x += i;
  }

  for (size_t i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main(){
    int n;
    cin>>n;
    ll card[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>card[i];
        sum+=card[i];
    }
    ll min=2*MAX;
    ll tmpsum=0;
    for(int i=0;i<n-1;i++){
        tmpsum+=card[i];
       ll tmp=abs(sum-2*tmpsum);
       if(min>tmp) min=tmp;
    }
    cout<<min<<endl;
}

Measured memory_bytes: 1792
/*
abc 158 c
*/
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
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; }

int main() {
    string N, ans;
    cin >> N;
    REP(i, 3) {
        if (N[i] == '7') {
            ans = "Yes";
            break;
        }
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, A;

  cin >> N >> A;
  
  if ( N % 500 == 0 ) {
    
    cout << "Yes" << endl;   
  }
  else if ( N % 500 <= A ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 256
#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>;

const int INF = 1001001001;

int main() {
  int n, ans = 0, tmp = 0;
  cin >> n;
  vector<int> h(n);
  rep(i,n) {
    cin>>h[i];
    if(h[i] >= tmp) {
      tmp = h[i];
      ans++;
    }
  }

  cout<<ans<<endl;


  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    bool ans = true;
    if (S.length() != A + B + 1) ans = false;
    REP(i, S.length()) {
        if (i == A) {
            if (S[i] != '-') ans = false;
        } else {
            int num = S[i] - '0';
            if (num < 0 || num > 9) ans = false;
        }
    }
    
    if (ans) print("Yes");
    else print("No");
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <iostream>

int main() {

	for (int i = 0; i < 5;  ++i) {

		int temp = 0;
		std::cin >> temp;

		if (temp == 0) {

			std::cout << i + 1 << std::endl;

			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    map<char, string> mp1;
    mp1[' '] = "101";
    mp1['\''] = "000000";
    mp1[','] = "000011";
    mp1['-'] = "10010001";
    mp1['.'] = "010001";
    mp1['?'] = "000001";
    mp1['A'] = "100101";
    mp1['B'] = "10011010";
    mp1['C'] = "0101";
    mp1['D'] = "0001";
    mp1['E'] = "110";
    mp1['F'] = "01001";
    mp1['G'] = "10011011";
    mp1['H'] = "010000";
    mp1['I'] = "0111";
    mp1['J'] = "10011000";
    mp1['K'] = "0110";
    mp1['L'] = "00100";
    mp1['M'] = "10011001";
    mp1['N'] = "10011110";
    mp1['O'] = "00101";
    mp1['P'] = "111";
    mp1['Q'] = "10011111";
    mp1['R'] = "1000";
    mp1['S'] = "00110";
    mp1['T'] = "00111";
    mp1['U'] = "10011100";
    mp1['V'] = "10011101";
    mp1['W'] = "000010";
    mp1['X'] = "10010010";
    mp1['Y'] = "10010011";
    mp1['Z'] = "10010000";

    map<string, char> mp2;
    mp2["00000"] = 'A';
    mp2["00001"] = 'B';
    mp2["00010"] = 'C';
    mp2["00011"] = 'D';
    mp2["00100"] = 'E';
    mp2["00101"] = 'F';
    mp2["00110"] = 'G';
    mp2["00111"] = 'H';
    mp2["01000"] = 'I';
    mp2["01001"] = 'J';
    mp2["01010"] = 'K';
    mp2["01011"] = 'L';
    mp2["01100"] = 'M';
    mp2["01101"] = 'N';
    mp2["01110"] = 'O';
    mp2["01111"] = 'P';
    mp2["10000"] = 'Q';
    mp2["10001"] = 'R';
    mp2["10010"] = 'S';
    mp2["10011"] = 'T';
    mp2["10100"] = 'U';
    mp2["10101"] = 'V';
    mp2["10110"] = 'W';
    mp2["10111"] = 'X';
    mp2["11000"] = 'Y';
    mp2["11001"] = 'Z';
    mp2["11010"] = ' ';
    mp2["11011"] = '.';
    mp2["11100"] = ',';
    mp2["11101"] = '-';
    mp2["11110"] = '\'';
    mp2["11111"] = '?';

    string s;
    while (getline(cin, s))
    {
        string en = "";
        for (int i = 0; i < (int)s.size(); ++i)
        {
            en += mp1[s[i]];
        }
        //cout << en << endl;

        string ans = "";
        for (int i = 0; i < (int)en.size(); i += 5)
        {
            string p = "";
            if (i + 5 < (int)en.size())
            {
                p = en.substr(i, 5);
            }
            else
            {
                int w = (int)en.size() - 1 - i;
                for (int j = 0; j <= w; ++j)
                    p += en[i + j];

                for (int j = 1; j < 5 - w; ++j)
                    p += '0';
            }

            ans += mp2[p];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=4*1e18;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> x(n),y(n),xx(n),yy(n);
    vector<vector<ll>> sum(n+1,vector<ll>(n+1));
    rep(i,n){
        cin >> x[i] >> y[i];
        xx[i]=x[i];
        yy[i]=y[i];
    }
    sort(xx.begin(),xx.end());
    sort(yy.begin(),yy.end());
    map<ll,ll> mx,my;
    rep(i,n){
        mx[xx[i]]=i+1;
        my[yy[i]]=i+1;
    }
    rep(i,n){
        ll nx=mx[x[i]];
        ll ny=my[y[i]];
        sum[nx][ny]++;
    }
    rep(i,n+1){
        rep(j,n){
            sum[i][j+1]+=sum[i][j];
        }
    }
    rep(i,n+1){
        rep(j,n){
            sum[j+1][i]+=sum[j][i];
        }
    }
    /*rep(i,n+1){
        rep(j,n+1){
            if(j) cout << " ";
            cout << sum[i][j];
        }
        cout << endl;
    }*/
    ll ans=INF;
    rep(a,n){
        for(ll b=a;b<n;b++){
            for(ll c=b;c<n;c++){
                for(ll d=c;d<n;d++){
                    vector<ll> p(4);
                    p[0]=a;
                    p[1]=b;
                    p[2]=c;
                    p[3]=d;
                    for(ll i=0;i<(1<<4);i++){
                        set<ll> s,t,u,v;
                        rep(j,4){
                            if((i>>j)%2==1){
                                s.insert(x[p[j]]);
                                t.insert(y[p[j]]);
                                u.insert(mx[x[p[j]]]);
                                v.insert(my[y[p[j]]]);
                            }
                            
                        }
                        if(s.size()<=1 || t.size()<=1) continue;
                        ll up=*v.rbegin();
                        ll dw=*v.begin();
                        ll ri=*u.rbegin();
                        ll le=*u.begin();
                        ll h=*t.rbegin()-*t.begin();
                        ll w=*s.rbegin()-*s.begin();
                        ll cnt=sum[ri][up]-sum[ri][dw-1]-sum[le-1][up]+sum[le-1][dw-1];
                        if(cnt>=k && h*w>0){
                            ans=min(ans,h*w);
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}



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

typedef unsigned long long ull;

int main()
{
	ull n;
	std::cin >> n;
	ull ans = 0;
	for (ull i = 1; i <= n; i++)
	{
		ull top = n / i;
		ans += (top * (top + 1)) * i / 2;
	}
	std::cout << ans << '\n';
	return 0;
	
}

Measured memory_bytes: 3572
N,K=map(int,input().split())
res=0
for b in range(1,N+1):
    if(b<=K):
        continue
    res+=(N//b)*(b-K)
    if(K!=0):
        res+=max(0,N%b-(K-1))
    else:
        res+=N%b
print(res)

Measured memory_bytes: 3060
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
std::vector<ll> v[200002];
ll dp[200003][3];
void mul(ll &a,ll b)
{
	a=(a*b)%M;
}
void dfs(ll x,ll parent)
{
	for(auto i:v[x])
	{
		if(i!=parent)
		{
			dfs(i,x);
		}
	}
	ll fl=0;
	dp[x][0]=1;
	dp[x][1]=1;
	for(auto i:v[x])
	{
		if(i==parent)
		{
			continue;
		}
		mul(dp[x][0],dp[i][1]);
		mul(dp[x][1],(dp[i][1]+dp[i][0])%M);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for (int i = 0; i < n-1; ++i)
    {
    	ll a,b;
    	cin>>a>>b;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    dfs(1,-1);
    cout<<(dp[1][0]+dp[1][1])%M<<'\n';
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
int ksum(int A){
    int ans=0;
    while(A >= 1){
        ans += A%10;
        A /= 10;
    }
    return ans;
}
int main(){
    int N,ans=0;
    cin >> N;
    while(N >= 100){
        ans += N%10;
        N /= 10;
    }
    int min = 20,tmp;
    for(int i=1;i<N;i++){
        tmp = i +ksum(N - 1);
        if(min > tmp) min = tmp;
    }
    ans += min;
    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
h2*w2内の総和がどこを見ても-1になるようにする
*/


int main(void){
	bool ok=true;
	ll h,w,h2,w2,ans[510][510];//オーバーフローする？
	cin>>h>>w>>h2>>w2;
	if(h%h2==0 && w%w2==0)ok=false;
	rep(i,h)rep(j,w)ans[i][j]=-1000;
	//どちらに余りが出るかで作り方を変える
	if(h%h2!=0){
		rep(i,h/h2+1)rep(j,w)ans[i*h2][j]=(h2-1)*1000;
		rep(i,h/h2+1)reg(j,1,w/w2)ans[i*h2][j*w2-1]-=1;
	}else{//w%w2!=0
		rep(i,h)rep(j,w/w2+1)ans[i][j*w2]=(w2-1)*1000;
		reg(i,1,h/h2)rep(j,w/w2+1)ans[i*h2-1][j*w2]-=1;
	}
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,h){
			rep(j,w)cout<<ans[i][j]<<" ";
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
  int a[3];
  std::cin >> a[0] >> a[1] >> a[2];
  
  std::sort(a, a+3);
  if(a[2] == a[0]+a[1]){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int MX = 2000100;
ll f[MX],inv[MX],fi[MX];
constexpr ll mod = 1000000007;
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    }
    f[0] = fi[0] = 1;
    for(int i=1;i<MX;i++){
        f[i] = f[i-1]*i%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}

ll nck(ll n, ll k){
    if(n<0 || k<0 || n<k) return 0;
    return f[n]*fi[k]%mod*fi[n-k]%mod;
}

ll pw(ll a, ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

string s;
int main(){
    int i,j,n,k;
    cin >> k >> s;
    n = s.size(); solve();
    ll ans2 = 0;
    for(i=n;i<=n + k;i++){
        (ans2 += pw(26,n + k - i)*pw(25,i - n)%mod*nck(i - 1,n - 1)%mod) %= mod;
    }
    cout << ans2 << endl;
}

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

long long n, ans = 0;

int main() {
  cin >> n;
  ans += (n / 11) * 2;
  n %= 11;
  if(n != 0) ans += n / 7 + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		long total = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (x >= d) {
		        total += x - d;
		    }
		}
		if (total <= 0) {
		    System.out.println("kusoge");
		} else {
		    System.out.println(total);
		}
	}
}



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

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

int main(void) {
    int a, b, ans = 0;

    cin >> a >> b;
    FOR(i, a, b + 1) {
        if ((i / 10000) % 10 == i % 10
            && (i / 1000) % 10 == (i / 10) % 10) {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110000
int N;
ll A[Max];

void attack(int remain) {
    sort(A, A+N);
    repd(i, 0, N) {
        if (i == N-remain) continue;
        A[i] = A[i] % A[N-remain];
    }
}

int remain() {
    int ans = 0;
    rep(i, N) {
        if (A[i] != 0) ans+=1;
    }
    return ans;
}

int is_end(int base) {
    int is_end = 1;
    rep(i, N) {
        // いきてるやつ全員体力同じ
        if (A[i] != A[base] && A[i] != 0) is_end = 0;
    }
    if (is_end) return 1;
    if (remain() == 1) is_end = 1;
    return is_end;
}

int main(int argc, const char * argv[]) {
    N = inputValue();
    inputArray(A, N);
    sort(A, A+N);
    while(!is_end(0)) {
        int rem = remain();
        attack(rem);
        // rep(i, N) {
        //     printf("%lld", A[i]);
        // }
        // output("");
    }

    sort(A, A+N);
    output(A[N-remain()]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
const int mod = 1e9 + 7;
string s;
int f[4];
 
void add(int &a, int b) {
    a += b;
    while (a >= mod) a -= mod;
}
 
int main(void) {
    cin >> s;
    f[0] = 1;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 3; j >= 0; --j) {
            if (s[i] == '?') f[j] = f[j] * 3LL % mod;
            if (j) add(f[j], f[j-1] * (s[i] == '?' || s[i] == 'A' + j - 1));
        }
    }
    cout << f[3] << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<p> stu, check;
    for(int i = 0; i < n; i++){
        ll a,b;
        cin >> a >> b;
        stu.push_back(p(a, b));
    }
    for(int i = 0; i < m; i++){
        ll c,d;
        cin >> c >> d;
        check.push_back(p(c, d));
    }
    for(int i = 0; i < n; i++){
        int ans = 0;
        ll norm = pow(10, 9);
        for(int j = 0; j < m; j++){
            if(abs(stu.at(i).first - check.at(j).first) 
                + abs(stu.at(i).second - check.at(j).second) < norm){
                    norm = abs(stu.at(i).first - check.at(j).first) 
                            + abs(stu.at(i).second - check.at(j).second);
                    ans = j;
                }
        }
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 3576
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define MAX 200002
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define CLEAR(a) memset(a,0,sizeof a)
#define pii pair< int , int >
#define fr freopen("input.txt", "r", stdin)
#define fw freopen("output.txt", "w", stdout)
using namespace std;
int a[111], n;

int f(int m){
    int ret = 0;
    for(int i=0;i<n;i++){
        ret += (m-a[i])*(m-a[i]);
    }
    return ret;
}


int main()
{
    //fr;fw;
    cin >> n;
    REP(i,n) cin >> a[i];

    int ret = 1e9;

    for(int i=-100;i<=100;i++){
        ret = min(ret,f(i));
    }
    cout << ret;
}


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

int main() {
    int n;
    cin >> n;
    if (n == 3) cout << 180 << endl;
    else  cout << 180 + 180 * (n - 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[n-1]-a[0] << endl;
}

Measured memory_bytes: 256
class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.size_ = 1
        self.rank_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, size: {}, rank: {})"
        return template.format(self.group_id_, self.parent_, self.size_,
                               self.rank_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def get_size(self):
        root = self.root()
        return root.size_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()

        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
                root.size_ += unite_root.size_

            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)
                unite_root.size_ += root.size_

N,M,K = map(int,input().split())

node_list = [UnionFindNode(i) for i in range(N)]

friend_num = [0] * N
for i in range(M):
    A,B = map(int,input().split())
    friend_num[A-1] += 1
    friend_num[B-1] += 1
    node_list[A-1].unite(node_list[B-1])

ans_array = [node.get_size() - friend - 1 for friend,node in zip(friend_num,node_list)]

for _ in range(K):
    C,D = map(int,input().split())
    if node_list[C-1].root() == node_list[D-1].root():
        ans_array[C-1] -= 1
        ans_array[D-1] -= 1

print(" ".join(map(str,ans_array)))

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

int main() {
  int N,A,B;
  cin >>N >>A >>B;
  if(A>B){
    cout <<B <<endl;
  }
  else{
    cout <<A <<endl;
  }
  
  if(A+B>N){
    cout <<(A+B-N) <<endl;
  }
  else{
    cout <<0 <<endl;
  }
}


Measured memory_bytes: 256
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        else:
            ans[i] = ans[i]+x
    return ans

ab = input()

a = get(ab,2)[0]
b = get(ab,2)[1]

t1 = a * int(b)
t2 = b * int(a)

dic = [t1,t2]
dic.sort()
print(dic[0])

Measured memory_bytes: 3064
#!/usr/bin/env python

def main():
    N = int(input())
    S = input()

    if N % 2 == 1:
        print("No")
    else:
        for i in range(N // 2):
            if S[i] != S[i + N // 2]:
                print("No")
                exit()
        print("Yes")

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using mint = modint<1000000007>;
int main() {
	int N;
	cin >> N;
	int bits = 20;
	vector<int> c(1 << bits);
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		c[x] += 1;
	}
	for (int i = 0; i < bits; ++i) {
		for (int j = 0; j < 1 << bits; ++j) {
			if ((j >> i) & 1) {
				c[j - (1 << i)] += c[j];
			}
		}
	}
	mint ans = 0;
	for (int i = 0; i < 1 << bits; ++i) {
		int cnt = 0;
		for (int j = 0; j < bits; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		if (cnt % 2 == 0) {
			ans += mint(2).pow(c[i]);
		}
		else {
			ans -= mint(2).pow(c[i]);
		}
	}
	cout << ans.get() << endl;
	return 0;
}


Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int digitSum(int n) {
    int tmp = n;
    int ret = 0;
    while (tmp > 0) {
        ret += tmp % 10;
        tmp /= 10;
    }
    return ret;
}
/* main */
int main(){
    int N;
    cin >> N;
    int div = digitSum(N);
    if (N % div == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b;
    cin >> a >> b;
    REP(i,1001){
        if(floor((double)i*0.08)==a && floor((double)i*0.1)==b){
            cout << i;
            return 0;
        }
    }
    cout << -1;

    return 0;
}

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

int N, M, A[100001], B[100001], C[100001];
 
int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++)    cin >> A[i];
    for(int i=0;i<M;i++)    cin >> B[i] >> C[i];

    sort(A, A+N);

    vector< pair<int, int> > CB(M);
    for(int i=0;i<M;i++)    CB[i] = make_pair(C[i], B[i]);
    sort(CB.begin(), CB.end(), greater< pair<int, int> >());

    int k = 0;
    for(int i=0;i<M;i++){
        for(int j=0;j<CB[i].second;j++){
            if( N <= k )    break;
            if( A[k] < CB[i].first ){
                A[k] = CB[i].first;
                k++;
            } else  break;
        }
        if( N <= k )    break;
    }

    int64_t ans = 0;
    for(int i=0;i<N;i++)    ans += A[i];

    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;
#define NUMBER 200000

int main(){

	int ary[NUMBER];
	int min_register[NUMBER];

	/*
	for(int i = 0; i < NUMBER; i++){
		ary[i] = -1;
		min_register[i] = -1;
	}
	*/

	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> ary[i];
	}
	int min = ary[0];
	min_register[0] = min;
	for(int i = 1; i < n; i++){
		if(min > ary[i]){
			min = ary[i];
		}
		min_register[i] = min;
	}

	int max = -1000000001;
	for(int i = n-1; i > 0; i--){
		max = (max > ary[i] - min_register[i-1])? max:ary[i] - min_register[i-1];
	}
	cout << max << endl;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
int main() {
        string s;
        cin>>s;

        string s1 = s;

        reverse(s1.begin(), s1.end());

        if(s !=s1)
        {
            cout<<"No"<<endl;
            return 0;
        }

        int n = s.length();

        int n1 = (n-1)/2;
        int n2 = (n+3)/2;




        string s2(s.begin(), s.begin()+n1);

         string s3(s.begin()+n2-1, s.end());

         string s4(s2.begin(),s2.end());
         string s5(s3.begin(),s3.end());

          reverse(s4.begin(), s4.end());
           reverse(s5.begin(), s5.end());


       // cout<<s2<<" "<<s3<<" "<<s4<<" "<<s5<<endl;

           if(s2 == s4 && s3 == s5)
           cout<<"Yes"<<endl;
           else
           cout<<"No"<<endl;







    }


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> path(10, vector<bool>(10, false));
  rep(i, M){
    int a, b;
    cin >> a >> b;
    path.at(a).at(b) = true;
    path.at(b).at(a) = true;
  }
  
  vector<int> p(10);
  rep(i, N - 1) p.at(i) = i + 2;
  int ans = 0;
  
  do{
    bool flag = true;
    rep(i, N-1){
      int a, b;
      if(i == 0){
        a = 1;
        b = p.at(0);
      } else {
        a = p.at(i-1);
        b = p.at(i);
      }
      
      if(!path.at(a).at(b)){
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  } while (next_permutation(p.begin(), p.end()));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int k, a, b;
    cin >> k;
    cin >> a;
    cin >> b;
    bool judge = false;
    
    for (int i = a; i <= b; i++){
        if (i % k == 0){
            judge = true;
            break;
        }
    }
    if (judge) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
int main(){
    string s, t; cin >> s >> t;
    int n = s.size();
    int ans = 0;
    rep(i, n){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3856
<?php
/**
 * ABC121
 * B - Can you solve this?
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d", $N, $M, $C);
$B = array_map('intval', explode(' ', trim(fgets(STDIN))));

$count = 0;

for ($i = 0; $i < $N; $i++) {
    $A = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $sum = $C;
    for ($j = 0; $j < $M; $j++) {
        $sum += $A[$j] * $B[$j];
    }
    if ($sum > 0) $count++;
}

echo $count, PHP_EOL;


Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	static int[][] dp;
	static char[] in1, in2;
	final static int BIG_PRIME = 1000000007;
	
	public static void main(String[] args) throws IOException {
		BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
		
		in1 = br.readLine().toCharArray();
		in2 = br.readLine().toCharArray();
		
		dp = new int[in1.length][in2.length];
		for(int[] i : dp){
		    Arrays.fill(i, -1);
		}
		  
		System.out.println(search(0, 0) % BIG_PRIME);
	}
	static int search(int i, int j){
		  int count = 0;
		  
		  if(j == in2.length)return 1;
		  if(i == in1.length)return 0;
		  
		  if(dp[i][j] != -1){
		    return dp[i][j];
		  } else if(in1[i] == in2[j]){
		    count = search(i + 1, j + 1)% BIG_PRIME + search(i + 1, j)% BIG_PRIME;
		  } else {
		    count = search(i + 1, j)% BIG_PRIME;
		  }
		  
		  return dp[i][j] = count;
		}
}



Measured memory_bytes: 29376
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
long long kk;
char s[1000];
int main(){
        scanf("%s",s);
        scanf("%lld",&kk);
        n=strlen(s);
        for(int i=0;i<n;i++){
                if(s[i]>'1') return printf("%c",s[i]),0;
                else kk--;
                if(kk==0) return printf("%c",s[i]),0;
        }
}

Measured memory_bytes: 888
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nk = readInts()
    // let n = nk[0]
    let k = nk[1]
    var s = Array(readLine()!)
    
    if s[k - 1] == "A" {
        s[k - 1] = "a"
    } else if s[k - 1] == "B" {
        s[k - 1] = "b"
    } else {
        s[k - 1] = "c"
    }
    
    print(s.reduce("") { $0 + String($1) })
}

main()


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e3 + 10;

int N, K, M;
int Ix[MAX_N], Cnt[MAX_N], Nr[MAX_N];
bool Vis[MAX_N];
vector<pi> Co;
int main() {
	cin >> N >> K >> M;
	for(int i=0; i<N; i++) {
		int x; scanf("%d", &x);
		Nr[i] = x;
		Co.emplace_back(x, i);
	}
	sort(ALL(Co));
	int ans = INF;
	for(int s=0, e=0; s<N; s=e) {
		int ix = 0;
		for(int a=0, b=0; a<N; a=b) {
			if(Vis[a]) {b = a+1; continue;}
			ix++;
			int cnt = 0;
			while(b < N && !Vis[b]) {
				Ix[b] = ix;
				cnt++;
				b++;
			}
			Cnt[ix] = max(0, cnt - K + 1);
		}
		int nowv = 0;
		for(int i=s; i<N; i++) {
			if(Cnt[Ix[Co[i].two]] > 0) {
				nowv++;
				Cnt[Ix[Co[i].two]]--;
			}
			if(nowv == M) {
				ans = min(ans, Co[i].one - Co[s].one); 
				break;
			}
		}
		while(e < N && Co[s].one == Co[e].one) {
			int x, ix; tie(x, ix) = Co[e];
			Vis[ix] = true;
			e++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256