akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1001;

int lcs(string X, string Y){
    int c[N][N];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i = 0; i <= m; i++) c[i][0] = 0;
    for(int j = 0; j <= n; j++) c[0][j] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(X[i] == Y[j]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i-1][j], c[i][j-1]);
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}
int main(){
    int q;
    cin >> q;
    while(q--){
        string a,b; cin >> a >> b;
        cout << lcs(a,b) << endl;
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	
	int n; cin >> n;
	vector<pair<int, int>> vec(n);
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		vec[i] = {b, a};
	}

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

	int INF = 1000000007;
	vector<vector<int>> dp(n + 1, vector<int> (n + 1, INF));
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(dp[i][j] == INF) continue;

			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			
			if(vec[i].second + dp[i][j] <= vec[i].first) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + vec[i].second);
		}
	}

	int ans = 0;
	for(int i = 0; i <= n; i++){
		if(dp[n][i] != INF) ans = i;
	}
	cout << ans << endl;
	return 0;
}




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

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

  string s,t; cin >> s >> t;
  static int dp[3001][3001] = {};
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < t.size(); j++){
      if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
    }
  }

  string ans;
  int i = s.size(),j = t.size();
  while(dp[i][j] > 0){
    if(dp[i-1][j] == dp[i][j]) i--;
    else if(dp[i][j-1] == dp[i][j]) j--;
    else {
      i--,j--;
      ans += s[i];
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <string>

using namespace std;

#define N_MAX n+1

int main() {
	int n,i,j;
	cin >> n;
	string s;
	cin >> s;
	
	int ans=0,cnt;
	bool X=false,Y=false;
	for(i=0;i<n;++i){
	    
	    cnt=0;
	    
	    for(char c='a';c<='z';++c){
	        
	        X=false,Y=false;
	        
	        for(j=0;j<i;++j){
	            if(s[j]==c) X=true;
	        }
	        
	        for(j=i;j<n;++j){
	            if(s[j]==c) Y=true;
	        }
	        
	        if(X && Y)cnt++;
	        
	    }
	    if(cnt>ans)ans=cnt;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
#define mp make_pair
int n,d,x;
int peo[105];
int main()
{
	cin>>n>>d>>x;
	for(int i=0;i<n;i++){
		cin>>peo[i];
		x+=(d-1)/peo[i]+1;
	}
	cout<<x;
    return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	n-=m;

	cout<<n%k<<endl;



}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<str, ll> msl;
typedef std::map<char, ll> mcl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100000;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))

int main(void){
    ll n;
    str s;
    ll answer =0;
    mcl cnt;
    in2(n,s);
    
    rep(i, n-1){
        ll nt = 0;
        rep(j, n) cnt[s[j]] = 0;
        rep(j, i + 1) cnt[s[j]] = 1;
        For(j, i + 1, n) if (cnt[s[j]] == 1) {nt ++; cnt[s[j]] ++;}
        answer = max(answer, nt);
    }

    prl(answer);
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc140/tasks/abc140_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    // L, Rの境界
    int sum = 0;
    REP(i, N - 1) {
        if (S[i] == S[i + 1]) {
            sum++;
        }
    }
    cout << min(N - 1, 2 * K + sum) << endl;

    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

// 3234566667

vector<int64_t> ans;

void dfs(deque<int8_t>& val) {
  auto insert = [](deque<int8_t> val){
    auto digits = std::accumulate(val.begin(), val.end(), 0ULL, [&val](int64_t acc, int8_t digit){
      return 10 * acc + digit;
    });
    ans.push_back(digits);
  };

  if (val.size() == 9) {
    REP(i, 1, 4) if (abs(val[0] - i) <= 1) {
      val.push_front(i);
      insert(val);
      val.pop_front();
    }
  }
  else {
    rep(i, 10) if (val.empty() || abs(val[0] - i) <= 1) {
      val.push_front(i);
      if (i) {
        insert(val);
      }
      dfs(val);
      val.pop_front();
    }
  }
}

int main() {
  deque<int8_t> val;
  dfs(val);
  sort(ans.begin(), ans.end());
  int K; cin >> K;
  assert(K <= ans.size());
  cout << ans[K - 1] << "\n";
}


Measured memory_bytes: 1404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return 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;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int n, m;

int x[5005], y[5005];
vi compressed_x, compressed_y;

int a[5005][5005];

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

    rep(i, n) {
        cin >> x[i] >> y[i];
        compressed_x.PB(x[i]);
        compressed_y.PB(y[i]);
    }

    sort(all(compressed_x));
    sort(all(compressed_y));

    compressed_x.erase(unique(all(compressed_x)), end(compressed_x));
    compressed_y.erase(unique(all(compressed_y)), end(compressed_y));

    rep(i, n) {
        int xidx = lower_bound(all(compressed_x), x[i]) - begin(compressed_x);
        int yidx = lower_bound(all(compressed_y), y[i]) - begin(compressed_y);

        a[yidx][xidx]++;
    }

    for (int i = 0; i < compressed_y.size()+1; ++i) {
        for (int j = 0; j < compressed_x.size()+1; ++j) {
            if (i - 1 >= 0) a[i][j] += a[i - 1][j];
        }
    }

    for (int i = 0; i < compressed_x.size()+1; ++i) {
        for (int j = 0; j < compressed_y.size()+1; ++j) {
            if (i - 1 >= 0) a[j][i] += a[j][i - 1];
        }
    }

    compressed_x.PB(inf);
    compressed_y.PB(inf);

    rep(i, m) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

        x1 = lower_bound(all(compressed_x), x1) - begin(compressed_x);
        x2 = upper_bound(all(compressed_x), x2) - begin(compressed_x) - 1;
        y1 = lower_bound(all(compressed_y), y1) - begin(compressed_y);
        y2 = upper_bound(all(compressed_y), y2) - begin(compressed_y) - 1;

        if (x2 < 0 || y2 < 0) {
            cout << 0 << endl;
            continue;
        }

        int ans = 0;
        ans += a[y2][x2];
        if (y1 - 1 >= 0) ans -= a[y1 - 1][x2];
        if (x1 - 1 >= 0) ans -= a[y2][x1 - 1];
        if (y1 - 1 >= 0 && x1 - 1 >= 0) ans += a[y1 - 1][x1 - 1];
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 101020
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
    int c[200001]={0};
    int redstorn=0;
    
    int n;
    scanf("%d\n", &n);
    char color;
    for(int i=1;i<=n;i++){
        scanf("%c", &color);
        //printf("%c",color);
        if(color=='R'){
            c[i]=1;
            redstorn++;
        }
    }
    
    int min=0;
    
    int rmin=0;
    for(int i=1;i<=redstorn;i++){
      //  printf("%d",c[i]);
        if(c[i]==0){
        rmin++;
        }
    }

    
    printf("%d",rmin);
}

Measured memory_bytes: 2516
# /usr/bin/python
# coding: UTF-8
import sys

n = raw_input().split()

square = int(n[0]) * int(n[1])
circum = 2 * (int(n[0]) + int(n[1]))

sys.stdout.write(str(square))
sys.stdout.write(" ")
sys.stdout.write(str(circum))
sys.stdout.write("\n")

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t A, B, N, X;
  cin >> A >> B >> N;
  X = (A * min (N, B - 1)) / B;
  cout << X << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    vector<LP> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].S >> v[i].F;
    }
    sort(all(v), greater<LP>());

    int kind[SIZE] = {};
    priority_queue<LP, vector<LP>, greater<LP>> pq;

    LL k = 0;
    LL val = 0;
    int c = 0;
    for(int i = 0; i < N && c < K; ++i) {
        if(kind[v[i].S] == 0) {
            ++k;
            ++c;
            val += v[i].F;
            pq.push(v[i]);
            v[i].F = -1;
            kind[v[i].S]++;
        }
    }

    for(int i = 0; i < N; ++i) {
        if(v[i].F == -1) continue;
        if(c < K) {
            val += v[i].F;
            kind[v[i].S]++;
            ++c;
        } else {
            if(kind[v[i].S] == 0) continue;
            if(pq.empty()) continue;
            LP p = pq.top();
            if(val + k * k < val - p.F + v[i].F + (k - 1) * (k - 1)) {
                pq.pop();
                --k;
                val = val - p.F + v[i].F;
                kind[v[i].S]++;
                kind[p.S]--;
            }
        }
    }
    cout << val + k * k << endl;

    return 0;
}



Measured memory_bytes: 3704
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	add := a + b
	sub := a - b
	mul := a * b

	fmt.Println(max(add, sub, mul))
}

func max(args ...int) int {
	max := -100000000
	for _, v := range args {
		if max < v {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 512
#[int(i) for i in input().split()]
import collections
n = int(input())
dic = collections.defaultdict(int)
for i in range(n):
  dic[input()] += 1
print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))


Measured memory_bytes: 74652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const int INF = 1e9;

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    vector<vector<int>> edge(N, vector<int>(N, -1));
    REP(i, N) dist[i][i] = 0;
    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
        edge[a][b] = edge[b][a] = c;
    }

    REP(k, N) REP(i, N) REP(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    vector<vector<bool>> used(N, vector<bool>(N));

    REP(i, N) {
        REP(j, N) {
            queue<int> q;
            q.push(j);
            while (!q.empty()) {
                int v = q.front(); q.pop();
                REP(u, N) {
                    if (edge[u][v] != -1 && dist[i][u] + edge[u][v] == dist[i][v]) {
                        used[u][v] = used[v][u] = true;
                        q.push(u);
                    }
                }
            }
        }
    }

    int ans = 0;
    REP(i, N) REP(j, N) if (edge[i][j] != -1 && !used[i][j]) ans++;
    cout << ans / 2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
      if(b<c){
          cout<<"Yes"<<endl;
      }else{
          cout<<"No"<<endl;
      }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import sys
st=[]
for a in sys.stdin:
    s=a.split()
    del st[:]
    for i in range(len(s)):
        if s[i] in ['+','-','*','/']:
            a=st.pop(-1)
            b=st.pop(-1)
            if s[i]=='+':c=b+a
            elif s[i]=='-':c=b-a
            elif s[i]=='*':c=b*a
            else: c=1.*b/a
            st.append(c)
        else:
            st.append(float(s[i]))
    print st[0]

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

int main() {
    ll x;
    cin >> x;

    ll ans = (x / 11) * 2;
	int rem = x % 11;

    if (rem != 0) {
        if (rem > 6) {
            ans += 2;
        } else {
            ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: usize = scan(tokens);
    let b: usize = scan(tokens);
    if (a + b) % 2 == 0 {
        println!("{}", (a + b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstdio>
using namespace std;



int main() {
	long long x,y;
	cin >> x >> y;
	//cout << count << endl;

	if(abs(x-y)>1){
		cout << "Alice" << endl;
	}else{
		cout << "Brown" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int main(){

string r[105];
int n,g;
cin>>n>>g;
for(int i=0;i<n;i++)
	cin>>r[i];
sort(r,r+n);
for(int i=0;i<n;i++)
	cout<<r[i];
cout<<endl;
	return 0;
}



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

int main(){
    string s,t,u;
    int a,b;
    cin >>s>>t>>a>>b>>u;
    if(u==s){
        cout << a-1 << " " << b <<endl;
    }
    else{
        cout << a<< " " << b-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int N, T, c[2000], t[2000], ans=10000;
  bool f=false;
  cin >> N >> T;
  for(int i=0;i<N;i++){
    cin >> c[i] >> t[i];
    if(T>=t[i]){
      f=true;
      ans=min(ans,c[i]);
    }
  }
  if(f)cout << ans << endl;
  else puts("TLE");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<ctype.h>
int main(){
    int n, i, j;
    scanf("%d", &n);
    char c1[n+1], c2[n+1];
    scanf("%s%s", &c1, &c2);
    for(i=0,j=0;i<n,j<n;i++,j++){
            printf("%c%c", c1[i], c2[j]);
    }

return 0;
}


Measured memory_bytes: 128
using namespace std;
#include<bits/stdc++.h>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define st first
#define nd second
#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)
#define FORD(i,a,b) for(int i=(a),b_=(b);i>=b_;--i)
#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())))
 
const int N = 5e3 + 100;
const int MOD = 1e9 + 7; 
int dp[N][N]; 

 
int main() {
    #define TASK "TASK"	
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s, t;
	cin >> s >> t; 
	int n =  s.size(), m = t.size(); 
	s = " " + s; 
	t = " " + t; 
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1; 
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); 
			}
		}
	}
	string ans = ""; 
	int x = n, y = m; 
	while(x > 0 && y > 0){
		if (s[x] == t[y] and dp[x][y] > dp[x - 1][y] and dp[x][y] > dp[x][y - 1]) {
			ans = ans + s[x]; 
			x--;
			y--; 
		}
		else {
			if (dp[x - 1][y] > dp[x][y - 1]){
				x--; 
			}
			else {
				y--; 
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans; 
	
	
     
  	return 0;
}

Measured memory_bytes: 61312
## coding: UTF-8
N = int(input())
h = list(map(int,input().split()))
dp = [1000000000] * N

dp[0] = 0
#dp[1] = abs(h[1]-h[0])

'''
for i in range(2, N):
    #print('i:{}, h[i]:{}'.format(i, h[i]))
    #print('dp[i-2]+abs(h[i-2]-h[i]):{}, dp[i-1]+abs(h[i-1]-h[i]):{}'.format(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i])))
    dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]))
    #print(dp)
'''
for i in range(N-2):
    #print('i:{}, i+2:{}, h[i+2]:{}'.format(i, i+2, h[i+2]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    #print(dp)

dp[N-1] = min(dp[N-1], dp[N-2] + abs(h[N-1] - h[N-2]))

print(dp[-1])


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

signed main () {
    int n, m, ans = 0;
    cin >> n >> m;
    vector < vector < int > > s(m);
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; ++j) 
            cin >> s[i][j];
    }
    vector < bool > p(m);
    for (int i = 0; i < m; ++i) {
        int t;
        cin >> t;
        p[i] = bool(t);
    }
    for (int i = 0; i < (1 << n); ++i) {
        vector < bool > cur(m, 0);
        for (int j = 0; j < m; ++j) {
            for (int w: s[j]) {
                if (i & (1 << (w - 1))) 
                    cur[j] = cur[j] ^ 1;
            }
        }
        ans += (cur == p);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
int main(void)
{
	int a, b, c;
	int max, min, total = 0;
    scanf("%d %d %d", &a, &b, &c);
    total = a + b + c ;
    
    if(a >= b && a >= c)
    {
    	max = a;
	}
	else if(b >= a && b >= c)
	{
		max = b;
	}
    else
    {
    	max = c;
	}
	if(a <= b && a <= c)
	{
		min = a;
	}
	else if(b <= a && b <= c)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, (total)-max-min, max);
	return 0;
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    if(n==1)
    {
        cout<<1000000000;
    }
    ll dp1[n+1];
    ll dp2[n+1];
    dp1[1]=a[0];
    dp2[n]=a[n-1];
    for(i=2;i<=n;i++)
    {
        dp1[i]=__gcd(dp1[i-1],a[i-1]);
    }
    for(i=n-1;i>=1;i--)
    {
        dp2[i]=__gcd(dp2[i+1],a[i-1]);
    }
    ll maxi=0;
    for(i=2;i<=n-1;i++)
    {
        maxi=max(maxi,__gcd(dp1[i-1],dp2[i+1]));
    }
    maxi=max(maxi,max(dp1[n-1],dp2[2]));
    cout<<maxi;
    return 0;
}


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

int main()
{
	unordered_map<int,ll>mp;

	int n;
	cin>>n;

	int arr[n+5];
	for(int i=1;i<n;i++)
	{
		cin>>arr[i];
		mp[arr[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<mp[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 12144
#include<cstdio>
#include<list>
#include<algorithm>

using namespace std;

list<int> myList;

int main()
{
    int n, num;
    char command[15];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", command);
        if ('i' == command[0]) {
            scanf("%d", &num);
            myList.push_front(num);
        }
        else if ('F' == command[6]) {
            myList.pop_front();
        }
        else if ('L' == command[6]) {
            myList.pop_back();
        }
        else {
            scanf("%d", &num);
            for (list<int>::iterator iter = myList.begin(); iter != myList.end(); iter++) {
                if (num == *iter) {
                    myList.erase(iter);
                    break;
                }
            }
        }
    }
    for (list<int>::iterator iter = myList.begin(); iter != myList.end(); iter++) {
        if (iter != myList.begin()) printf(" ");
        printf("%d", (*iter));
    }
    printf("\n");
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	bool flg=(a[0]!=0);
	for(int i=1; i<=n; i++){
		flg|=(a[i]>a[i-1]+1);
	}
	if(flg){
		cout << -1 << endl;
		return 0;
	}

	ll ans=0;
	map<ll, ll> cnt;
	for(int i=1; i<=n; i++){
		if(a[i]<a[i-1]){
			ans+=a[i-1];
			for(int j=a[i-1]; cnt[j]!=0; j--){
				ans+=(cnt[j]-1)*j;
			}
			cnt.clear();
		}
		cnt[a[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
al = list(map(int, input().split()))
al = [-a for a in al]
heapify(al)

while m != 0:
    tmp = heappop(al)
    tmp = int(tmp/2)
    m -= 1
    heappush(al, tmp)

al = list(al)
al = [-a for a in al]
print(sum(al))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1<<29;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int N, C, K; cin >> N >> C >> K;
    vint T(N);
    rep(i, N) cin >> T[i];
    sort(ALL(T));
    int ans = 1;
    for(int i = 0; i < N;){
        int human = 1;
        for(int j = i + 1; j < N; j++){
            if(human < C && T[j] <= T[i] + K){
                human++;
            } else {
                ans++;
                break;
            }
        }
        i += human;
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 640
import collections
q = collections.deque()
N,Q = map(int,input().strip().split(" "))
for _ in range(N):
    n,p = input().strip().split(" ")
    q.append([n,int(p)])
t = 0
while len(q) > 0:
    processing = q.popleft()
    lstt = processing.pop()
    if lstt <= Q:
        t += lstt
        name = processing.pop()
        print(name,t)
    else:
        t += Q
        lstt -= Q
        processing.append(lstt)
        q.append(processing)


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a,b;
    int tmp;
    for (int i=0;i<n;i++) {
        cin >> tmp;
        b.push_back(tmp);
    }
    while(b.size()) {
        int len = b.size();
        for (int i=len-1;i>=0;i--) {
            if (b[i] == i+1) {
                a.push_back(b[i]);
                b.erase(b.begin() + i);
                break;
            }
        }
        if (len == b.size()) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i=n-1;i>=0;i--) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define sz(a)			a.size()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD1			998244353
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	const int MOD = 1e9+7;
	const double EPS = 1e-9;

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		int n;
		cin>>n;
		int ar[2][n];
		fore(i, 0, 2) fore(j, 0, n) cin>>ar[i][j];
		int res = 0, ax;
		fore(i, 0, n)
		{
			ax = 0;
			fore(j, 0, i+1)
				ax += ar[0][j];
			fore(j, i, n) 
				ax += ar[1][j];
				res = max(res, ax);
		}
		cout<<res<<'\n';
		return 0;
	}

	// read the question correctly (is y a vowel? what are the exact constraints?)
	// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    double tempDouble;
    scanf("%d",&n);
    vector<double> p;
    p.push_back(0.0);
    for(i=1;i<=n;i++)
    {
        //scanf("%c",&tempChar);
        //printf("tempChar:%c\n",tempChar);
        scanf("%lf",&tempDouble);
        //printf("tempDouble:%f\n",tempDouble);
        p.push_back(tempDouble);
    }
    vector<vector<double> > dp(n+1,vector<double>(n+1,0.0));
    double probNone=1.0,probAll=1.0,res=0.0;
    for(i=1;i<=n;i++)
    {
        probNone*=(1.0-p[i]);
        dp[i][0]=probNone;
        probAll*=p[i];
        dp[i][i]=probAll;
    }
    for(i=1;i<=n;i++)
        for(j=1;j<i;j++)
            dp[i][j]=dp[i-1][j-1]*p[i] + dp[i-1][j]*(1.0-p[i]);
    /*
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=i;j++)
            printf("%f ",dp[i][j]);
        printf("\n");
    }
    */
    for(j=n/2+1;j<=n;j++)
        res+=dp[n][j];
    printf("%.10f\n",res);
    return 0;
}


Measured memory_bytes: 73784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 
int main(){
   ll n;cin >> n; 
   vl v(n);rep(i,n)cin  >> v[i];
   sort(all(v));rev(all(v));
   ll t=0;
   ll cnt=1;
   ll i=0;
   n--;
   while(n--){
       t+=v[i];
       cnt++;
       if(cnt==2){
           cnt=0;
           i++;
       }
   }
   cout << t <<endl;
}

Measured memory_bytes: 4844
def eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

N = int(input())
N2 = N + 336

A = eratosthenes(N2)

ans = 0
for i in range(len(A)):
    if A[i] == N:
        ans = A[i]
        break
    elif A[i] < N and A[i+1] > N:
        ans = A[i+1]
        break
print(ans)

Measured memory_bytes: 45164
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

constexpr int mod = 1000000007;
struct ModCalc {
    vector<int> fact;
    
    ModCalc(int N) : fact(N + 1) {
        fact[0] = 1;
        rep(i, N) fact[i + 1] = (long long)(i + 1) * fact[i] % mod;
    }
    
    int ModPow(int x, int y) {
        if (y == 0) return 1;
        long long a = ModPow(x, y / 2);
        if (y & 1) return a * a % mod * x % mod;
        else return a * a % mod;
    }
    
    int ModCom(int x, int y) {
        if (x < y) return 0;
        int res = fact[x];
        res = (long long)ModPow(y, mod - 2) * res % mod;
        res = (long long)ModPow(x - y, mod - 2) * res % mod;
        return res;
    }
};

int main() {
    int m, n;
    cin >> m >> n;
    ModCalc MC(1);
    cout << MC.ModPow(m, n) << endl;
    return 0;
}



Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		final int E = sc.nextInt();
		final int S = sc.nextInt();
		final int T = sc.nextInt();
		final int R = sc.nextInt();
		
		int[] as = new int[M];
		int[] bs = new int[M];
		boolean[][] adj = new boolean[N + 300][N + 300];
		for(int i = 0; i < M; i++){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			as[i] = a;
			bs[i] = b;
			adj[a][b] = adj[b][a] = true;
		}
		
		int[] cs = new int[E];
		int[] cas = new int[E];
		int[] cbs = new int[E];
		for(int i = 0; i < E; i++){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int c = sc.nextInt();
			
			cs[i] = c;
			cas[i] = a;
			cbs[i] = b;
		}
		
		boolean[][][] already = new boolean[N][R + 1][1 << E];
		LinkedList<Integer> time_queue = new LinkedList<Integer>();
		LinkedList<Integer> move_queue = new LinkedList<Integer>();
		LinkedList<Integer> bits_queue = new LinkedList<Integer>();
		LinkedList<Integer> city_queue= new LinkedList<Integer>();
		
		bits_queue.add(0);
		city_queue.add(S);
		time_queue.add(0);
		move_queue.add(0);
		already[S][0][0] = true;
		
		while(!city_queue.isEmpty()){
			final int city = city_queue.poll();
			final int time = time_queue.poll();
			int bits = bits_queue.poll();
			final int move = move_queue.poll();
			
			if(city == T){
				System.out.println(move);
				return;
			}
			
			// check event
			for(int i = 0; i < E; i++){
				if(city == cs[i]){
					bits |= (1 << i);
				}
			}
			//System.out.println(city + " " + time + " "  + Integer.toBinaryString(bits) + " " + move);
			
			if(!already[S][0][bits]){ // teleport
				already[S][0][bits] = true;
				city_queue.add(S);
				time_queue.add(0);
				bits_queue.add(bits);
				move_queue.add(move + 1);
			}
			
			if(time < R){
				for(int i = 0; i < E; i++){
					if((bits & (1 << i)) != 0){
						adj[cas[i]][cbs[i]] = adj[cbs[i]][cas[i]] = true;
					}
				}
				
				for(int next = 0; next < N; next++){
					if(!adj[city][next]){
						continue;
					}else if(already[next][time + 1][bits]){
						continue;
					}
					
					already[next][time + 1][bits] = true;
					city_queue.add(next);
					time_queue.add(time + 1);
					bits_queue.add(bits);
					move_queue.add(move + 1);
				}
				
				for(int i = 0; i < E; i++){
					if((bits & (1 << i)) != 0){
						adj[cas[i]][cbs[i]] = adj[cbs[i]][cas[i]] = false;
					}
				}
			}
		}
		
		System.out.println(-1);
	}
	
} 

Measured memory_bytes: 30964
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,k;
int main(){
	cin>>a>>b>>k; //2 3 3
	if(a>=k){
		a-=k;
		printf("%lld %lld",a,b);
		return 0;
	}
	else{
		k-=a;
		a=0;
		if(b>=k) b-=k;
		else b=0;
		printf("%lld %lld",a,b);
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int flag = 1;
   for (int j = 1; j <= 2; j++){
        flag = 0;
        for(int i = -200; i <= 200; i++) {
            if (c[0][0] == c[j][0] + i && c[0][1] == c[j][1] + i && c[0][2] == c[j][2] + i) {
                flag = 1;
            }
        }
        if (flag == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX(a,b) (((a)>(b))?(a):(b))
using namespace std;
typedef long long LL;

int main(){
    int n, m, i, j;
    cin >> n >> m;
    LL w[n], v[n];
    for(i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    LL dp[n+1][m+1] = {};
    for(i = 0; i < n; i++){
        for(j = 0; j <= m; j++){
            if(j >= w[i]){
                dp[i+1][j] = MAX(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[n][m] << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  vector<int> d(5);
  int ans = 0;
  int x = 0;
  int y = 0;
  rep(i,5)cin >> d[i];
  rep(i,5){
    rep(j,66){
      if(j*10>=d[i]){
        ans += j*10;
        y = j*10-d[i];
        break;
      }
    }
    x = max(x,y);
  }
  cout << ans-x << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  n--;
  
  ll money=1000;
  ll kabu=0;
  
  for(int i=0;i<n;i++){
    if(a[i]<a[i+1]){
      kabu+=money/a[i];
      money%=a[i];
    }
    else if(a[i]>a[i+1]){
      money+=kabu*a[i];
      kabu=0;
    }
  }
  
  cout << money+kabu*a[n] << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int unsigned long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 51;
int n,m,q;

int pts[N][N][N];

int solve(int x,int y,vector<int> value){
	if(x>=n) return 0;
	int ans = 0;
	for(int i=0;i<value.size();i++){
		ans += pts[x][i][y-value[i]];
	}
	value.push_back(y);
	int res = 0;
	for(int i=y;i<=m;i++){
		res = max(res,solve(x+1,i,value));
	}
	return ans + res;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>q;
	memset(pts,0,sizeof(pts));
	for(int i=0;i<q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		cin>>pts[b][a][c];
	}
	int ans = 0;
	for(int i=1;i<=m;i++){
		vector<int> temp;
		ans = max(ans,solve(0,i,temp));
	}
	cout<<ans<<endl;
	return 0;
}



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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, x, y;
    cin>>n>>x>>y;
    vi ans(n);
    for(int i=1; i<=n-1; i++) {
        for(int j=i+1; j<=n; j++) {
            if(i<=x) {
                if(j<y) {
                    int dis = min(j-i, x-i + 1 + y-j);
                    ans[dis]++;
                }
                else {
                    ans[x-i + 1 + j-y]++;
                }
            }
            else {
                if(j <= y) {
                    int dis = min(j-i, i-x + 1 + y-j);
                    ans[dis]++;
                }
                else {
                    int dis = min(j-i, i-x+1+j-y);
                    ans[dis]++;
                }
            }
        }
    }
    for(int i=1; i<=n-1; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int ans = 0;
        
        for (int i = 0; i < N; i++) {
            int a= scanner.nextInt();
            while (a % 2 == 0) {
                a /= 2;
                ans += 1;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 34652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
const ll MOD = 1e9;

int main(){
  ll n,a,b;
  string s;
  cin>>n>>a>>b>>s;
  int cnt=0;
  int cnb=0;
  for(int i=0;i<n;i++){
	if(cnt>=a+b||s[i]=='c'){
	  cout<<"No"<<endl;
	  continue;
	}
	if(s[i]=='a'){
	  if(cnt<a+b){
		cout<<"Yes"<<endl;
		cnt++;
	  }else cout<<"No"<<endl;
	}else{
	  cnb++;
	  if(cnt<a+b&&cnb<=b){
		cout<<"Yes"<<endl;
		cnt++;
	  }else cout<<"No"<<endl;
	}
  }
  return 0; 
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		if (i - 1 >= 0) {
			dp[i] = min(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]));
		}
		if (i - 2 >= 0) {
			dp[i] = min(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]));
		}
	}
	cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))

now=1000
kabu=0
for i in range(n):
    ud=-1
    for j in range(i+1,n):
        if a[i]<a[j]:
            ud=1
            break
        elif a[i]>a[j]:
            ud=0
            break
    if ud==1:
        kabu+=now//a[i]
        now-=now//a[i]*a[i]
    elif ud==0:
        now+=kabu*a[i]
        kabu=0
    # print(now,kabu,ud)
print(now+kabu*a[-1])

Measured memory_bytes: 68132
#include<iostream>
using namespace std;
int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if ((b-a <= k) &&
        (c-a <= k) &&
        (d-a <= k) &&
        (e-a <= k) &&
        (c-b <= k) &&
        (d-b <= k) &&
        (e-b <= k) &&
        (d-c <= k) &&
        (e-c <= k) &&
        (e-d <= k)) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    X = list(map(int, input().split()))
    ans = 10**11
    for i in range(0,101):
        temp = 0
        for x in X:
            temp += (x-i)**2
        ans = min(temp,ans)

    print (ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 63548