akhauriyash/Code-Regression huggingface dataset:
import math
h,n=map(int,input().split())
la=[]
lb=[]
for i in range(n):
  a,b=map(int,input().split())
  la.append(a)
  lb.append(b)
dp=[[0]*(h+1) for i in range(n)]
dp[0][0]=0
for i in range(1,h+1):
  a,b=la[0],lb[0]
  dp[0][i]=(math.ceil(i/a)*b)
for i in range(1,n):
  a,b=la[i],lb[i]
  for j in range(h+1):
    if j<a:
      dp[i][j]=min(b,dp[i-1][j])
    else:
      dp[i][j]=min(dp[i][j-a]+b,dp[i-1][j],dp[i-1][j-a]+b)
print(dp[n-1][h])

Measured memory_bytes: 233864
S = gets.chomp
a = []
m = 0
n = 0
answer = 0
if S[0] == ">"
    a.push(0)
end
for i in 0...S.size do
    if S[i] == "<"
        if n > 0
            a.push(n)
            n = 0
        end
        m += 1
    else
        if m > 0
            a.push(m)
            m = 0
        end
        n += 1
    end
end
if S[-1] == "<"
    a.push(m)
    a.push(0)
else
    a.push(n)
end
for i in 0...a.size/2 do
    j = 2*i
    x = a[j]
    y = a[j+1]
    answer += x*(x+1)/2
    answer += y*(y+1)/2
    if x > y
        answer -= y
    else
        answer -= x
    end
end
puts answer

Measured memory_bytes: 4876
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int X;
	cin >> X;
	int y;
	y = X / 200;
	cout << 10 - y;
	return 0;
}

Measured memory_bytes: 3632
n, m, x, y = map(int, input().split())

x_n = []
for part in input().split():
    x_n.append(int(part))
x_n.append(x)

y_n = []
for part in input().split():
    y_n.append(int(part))
y_n.append(y)

x_n.sort()
x_n.reverse()
y_n.sort()

if x_n[0] < y_n[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll X01=(a1-b1)*t1,X02=X01+(a2-b2)*t2;
    if(X02==0){cout<<"infinity";return 0;}
    if(X01<0&&X02<0){cout<<0;return 0;}
    if(X01>0&&X02>0){cout<<0;return 0;}
    cout<<1-(abs(X01)%abs(X02)==0)+abs(X01)/abs(X02)*2;
}

Measured memory_bytes: 256
#include <stdio.h>
int partition(int *, int, int);
  int A[100000];
int main(){
  int i,n,j;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  j=partition(A,0,n-1);
  for(i=0;i<j;i++)
    printf("%d ",A[i]);
    printf("[%d] ",A[j]);
for(i=j+1;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[n-1]);

return 0;


}
int partition(int A[], int p, int r){
  int x,i,j,c;

  x = A[r];
  i = p-1;
  for (j = p ;j<r;j++){
    if (A[j] <= x){
      i = i+1;
      c=A[i]; 
      A[i]=A[j];
      A[j]=c ; 

    }  

}
 
 c=A[i+1]; 
      A[i+1]=A[r];
      A[r]=c ; 




 return i+1;



}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

using P = pair<int,int>;

int N;
i64 K = 0;
vector<P> vec;

int main(){
  cin >> N >> K;
  rep(i,0,N - 1){
    int a,b;
    cin >> a >> b;
    vec.push_back({a,b});
  }

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

  rep(i,0,N - 1){
    int a = vec[i].first;
    int b = vec[i].second;

    if(K - b > 0){
      K -= b;
    }
    else{
      cout << a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fastio;
  	int n;
  	cin>>n;
  	LL a[n],sum=0;
  	int count[100000+7]={0};
    
 // memset(count,0,sizeof(count));
  for(int i=0;i<n;i++){
    cin>>a[i];
    count[a[i]]++;
    sum+=a[i];
  }
  

  int q;
  cin>>q;
  while(q--){
   
   LL b,c;
   cin>>b>>c;
   if(count[b]>0){
     sum = sum-(b*count[b])+(c*count[b]);
     count[c]+= count[b];
     count[b]=0;

   }
     cout<<sum<<"\n";
  }
   
}

Measured memory_bytes: 4820
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char c;
    cin>>c;
    
    if(c>='A' && c<='Z') cout<<'A'<<endl;
    else cout<<'a'<<endl;

  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){
	double a,b,c,d,e,f;
	double x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
	x=(c*e-f*b)/(a*e-d*b);
	y=(a*f-d*c)/(a*e-b*d);
	x=x*1000;
	if(x>0) x=(double)(int)(x+0.5);
	else  x=(double)(int)(x-0.5);
	x=x/1000;
	y= y*1000;
	if(y>0) y=(double)(int)(y+0.5);
	else y=(double)(int)(y-0.5);
	y=y/1000;
	printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 2600
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = parseInt(input.trim());
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var Q = parseInt(input[0].split(" ")[2]);
  input.shift();
  input = input.map((a)=>Number(a));
  var pointList = new Array(N);
  pointList.fill(0);
  for(var i = 0; i < input.length; i++){
    pointList[input[i] - 1]++;
  }
  for(var i = 0; i < pointList.length; i++){
    if(Q - pointList[i] < K){
       myout("Yes");
       }else{
       myout("No");
       }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main(){
    int n,y;
    cin >> n >> y;
    int a=-1, b=-1, c=-1;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=(n-i); j++){
            int k=n-i-j;
            if((10*i+5*j+k) == y/1000){
                a=i;
                b=j;
                c=k;
                break;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int find(vector<int>& grp, int x) {
    if (grp[x] == x)
        return x;
    return grp[x] = find(grp, grp[x]);
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> grp(n, 0);
    for(int i = 0; i < n; i++)
        grp[i] = i;
    int a, b, dummy;
    for(int i = 0; i < m; i++) {
        cin >> a >> b >> dummy;
        int r1 = find(grp, a-1);
        int r2 = find(grp, b-1);
        if (r1 != r2) {
            grp[r1] = grp[r2] = min(r1, r2);
        }
    }
    unordered_set<int> cnt;
    for(int i = 0; i < n; i++)
        cnt.insert(find(grp, i));
    cout << cnt.size() << endl;
    return 0;
}




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

int main() {
  vector<int> a;
  a = {1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,121,144,169,196,225,289,324,361,400,441,484,529,576,676,784,841,900,961};
  sort(a.begin(),a.end());
  int x;
  cin >> x;
  
  int max=0;
  
  for(int i=0; i<a.size(); i++){
    if(a.at(i)>x){
      break;
    }
    else{
      max=a.at(i);
    }
  }
   cout << max << endl;
	return 0;
}


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

int main() {
  int n, k, q, a;
  cin >> n >> k >> q;
  int s[n];
  REP(i, n) s[i] = 0;

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

  REP(i, n) {
    if (s[i] + k - q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        String[] line = ReadLine().Split(' ');
        int H = int.Parse(line[0]);
        int W = int.Parse(line[1]);

        var listS = new List<char[]>();
        listS.Add(new char[W + 2]);
        for (int i = 0; i < H; i++)
        {
            listS.Add((" " + ReadLine() + " ").ToCharArray());
        }
        listS.Add(new char[W + 2]);

        for (int i = 1; i <= H; i++)
        {
            var result = new List<String>();

            for (int j = 1; j <= W; j++)
            {
                if (listS[i][j] == '#') {
                    result.Add("#");
                    continue;
                }

                int count = 0;
                if (listS[i][j + 1] == '#') { count++; }
                if (listS[i][j - 1] == '#') { count++; }
                if (listS[i + 1][j] == '#') { count++; }
                if (listS[i + 1][j + 1] == '#') { count++; }
                if (listS[i + 1][j - 1] == '#') { count++; }
                if (listS[i - 1][j] == '#') { count++; }
                if (listS[i - 1][j + 1] == '#') { count++; }
                if (listS[i - 1][j - 1] == '#') { count++; }

                result.Add(count.ToString());
            }

            WriteLine(String.Join("", result));
        }
    }

}

Measured memory_bytes: 13268
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int n,a[110];

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		if(a[i]%2==0&&a[i]%3>0&&a[i]%5>0)
		{
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}

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

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

  int flag = 0;
  int len = 0, ans = 0;
  for (int i = 0; i < s.size(); i++) {
    len++;

    if (flag == 0 && s[i] == 'A') {
      len = 1;
      flag++;
    }

    if (flag == 1 && s[i] == 'Z') {
      ans = len;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  for(auto& i: A) cin >> i;


  auto ok = [&](auto a, auto x) {
    auto n = 0;
    auto p = 0;
    for(auto i=0; i<N+1; ++i) if(A[i] < a || i==N) {
      auto d = i - p;
      auto ng = 0;
      for(auto j=p; j<i; ++j) if(a + x < A[j]) ++ng;
      if(K <= d) {
        auto add = d - K + 1;
        n += min(add, d - ng);
      }
      p = i + 1;
    }
    return Q <= n;
  };

  int res = 1e9;
  for(auto a: A) {
    int l=-1, h=1e9;
    while(l+1 < h) {
      auto m = (l + h) / 2;
      if(ok(a, m)) h = m;
      else         l = m;
    }
    res = min(res, h);
  }
  cout << res << endl;
}


Measured memory_bytes: 384
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int dp[105][4][4][4];

int solve(){
  int N;cin>>N;

  // 'A', 'G', 'C', 'T'
  rep(i, 4)rep(j, 4)rep(k,4){
    dp[3][i][j][k] = 1;
  }
  dp[3][1][0][2]--;  //GAC
  dp[3][0][2][1]--;  //ACG
  dp[3][0][1][2]--;  //AGC

  rep(n, 4, 101){
    // T
    rep(i, 4){
      rep(j, 4){
        rep(k, 4){
          dp[n][j][k][3] += dp[n-1][i][j][k];
          dp[n][j][k][3] %= MOD;
        }
      }
    }

    // A
    rep(i, 4){
      rep(j, 4){
        rep(k, 4){
          dp[n][j][k][0] += dp[n-1][i][j][k];
          dp[n][j][k][0] %= MOD;
        }
      }
    }

    // G
    rep(i, 4){
      rep(j, 4){
        rep(k, 4){
          if(j==0 and k==2) continue;
          dp[n][j][k][1] += dp[n-1][i][j][k];
          dp[n][j][k][1] %= MOD;
        }
      }
    }

    // C
    rep(i, 4){
      rep(j, 4){
        rep(k, 4){
          if(j==0 and k==1) continue;
          if(j==1 and k==0) continue;
          if(i==0 and k==1) continue;
          if(i==0 and j==1) continue;
          dp[n][j][k][2] += dp[n-1][i][j][k];
          dp[n][j][k][2] %= MOD;
        }
      }
    }
  }
  int res = 0;
  rep(i, 4)rep(j, 4)rep(k, 4) res+=dp[N][i][j][k];
  cout << res%MOD << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string NO = "Impossible";

class UnionFindTree {
private:
  vector<int> par;
  vector<int> rnk;
  vector<int> siz;

public:
  UnionFindTree(int n) {
    par.assign(n, -1);
    rnk.assign(n, -1);
    siz.assign(n, -1);

    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
      siz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  bool same(int x, int y) { return find(x) == find(y); }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (rnk[x] < rnk[y]) {
      par[x] = y;
      siz[y] += siz[x];
    } else {
      par[y] = x;
      siz[x] += siz[y];
      if (rnk[x] == rnk[y])
        ++rnk[x];
    }
  }

  int size(int x) {
    x = find(x);
    return siz[x];
  }
};

void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> x, std::vector<long long> y) {
  UnionFindTree uf(N + 1);
  rep(m, M) { uf.unite(x[m], y[m]); }

  map<ll, priority_queue<ll, vl, greater<ll>>> costs;
  rep(n, N) { costs[uf.find(n)].push(a[n]); }

  // 全グループから一つづつ取る。それ以外はコストが低いものからとればいい
  if (costs.size() == 1) {
    print(0);
    return;
  }

  ll ans = 0;
  priority_queue<ll, vl, greater<ll>> restCosts;
  for (auto iter = costs.begin(); iter != costs.end(); iter++) {
    auto pq = iter->second;
    ans += pq.top();
    pq.pop();

    while (!pq.empty()) {
      restCosts.push(pq.top());
      pq.pop();
    }
  }

  ll needPoints = (costs.size() - 1) * 2 - costs.size();
  while (needPoints > 0 && !restCosts.empty()) {
    ans += restCosts.top();
    restCosts.pop();
    needPoints--;
  }

  if (needPoints > 0) {
    print(NO);
  } else {
    print(ans);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(N - 1 - 0 + 1);
  for (int i = 0; i < N - 1 - 0 + 1; i++) {
    scanf("%lld", &a[i]);
  }
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, M, std::move(a), std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 13184
A, B, C, D, E, F = map(int, input().split())

w_list = []
s_list = []
d_list = []

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = (100 * A) * a + (100 * B) * b
                s = C * c + D * d
                if w == 0 or w + s > F:
                    break
                else:
                    if w // 100 * E >= s:
                        d = s / (w + s)
                        w_list.append(w)
                        s_list.append(s)
                        d_list.append(d)

print(w_list[d_list.index(max(d_list))] + s_list[d_list.index(max(d_list))], s_list[d_list.index(max(d_list))])


Measured memory_bytes: 21172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 10001
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int inf = 1e9;
const ll INF = 1e18;
#define B 100

struct edge{int to, cost;};
vector<edge> G[3001];
priority_queue<P, vector<P>, greater<P> > q;
int v[3001];
int main(){
	int n, m, k, a, b, l;
	scanf("%d%d%d", &n, &m, &k);
	fill(v, v+3001, inf);
	rep(i,m){
		scanf("%d%d%d", &a, &b, &l);
		G[a].push_back((edge){b, l});
		G[b].push_back((edge){a, l});
	}
	rep(i,k){
		scanf("%d", &a);
		v[a] = 0;
		q.push(dmp(0, a));
	}
	
	while(!q.empty()){
		P x = q.top();q.pop();
		if(v[x.se] < x.fi)continue;
		for(int i = 0;i < G[x.se].size();i++){
			int t1 = G[x.se][i].to, t2 = G[x.se][i].cost;
			if(v[t1] > v[x.se]+t2){
				v[t1] = v[x.se]+t2;
				q.push(dmp(v[t1], t1));
			}
		}
	}
	
	int ans = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < G[i].size();j++){
			int x = v[i], y = v[G[i][j].to];
			ans = max(ans, (x+y+G[i][j].cost+1)/2);
		}
	}
	
	/*for(int i = 1;i <= n;i++){
		printf("%d ", v[i]);
	}*/
	printf("%d\n", ans);
	/*rrep(i,n){
		rep(j,G[i].size())printf("%d %d\n", G[i][j].to, G[i][j].cost);
	}*/
	return 0;
}

Measured memory_bytes: 6008
#!/usr/bin/env python3
import sys


def solve(C: str):
    print(chr(ord(C)+1))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)

if __name__ == '__main__':
    main()


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    int res = 0;
    for (int i = 0; i < n; i++) {
        int k = i;
        for (int j = i + 1; j < n; j++) {
            // a[k] < a[i] + a[j];
            while (k < n && a[k] < a[i] + a[j]) k++;
            res += k - (j + 1);
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
	int a[100010]={};
	int n,t,max=0, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &t);
      if(t>100000){
        ans++;
      }
      else{
        a[t]++;
      }
	}
	for (int i = 1; i <= 100000; i++)
	{
      if(a[i]<i){
        ans+=a[i];
      }
      else if(a[i]>i){
        ans+=a[i]-i;
      }
	}
	printf("%d",ans);
	return 0;
}


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

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

  if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
  int N;
  scanf("%d",&N);
  int a,b,c,temp;
  int i;
  for(i=0; i<N; i++){
    scanf("%d %d %d",&a,&b,&c);
    a = pow(a,2);
    b = pow(b,2);
    c = pow(c,2);

    if(a<b){
      temp = a;
      a = b;
      b = temp;
    }
    if(a<c){
      temp = a;
      a = c;
      c = temp;
    }
    if(a==b+c) printf("YES\n");
    else printf("NO\n");
    
  }

  return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr int INF = 2e9;

int main() {
  char x;
  cin >> x;
  if ('A' <= x && x <='Z') cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
} 

Measured memory_bytes: 3584
# -*- coding:utf-8 -*-
import re

s = input()
f = True
while(f):
    if(re.search('dreameraser', s)):
        s = re.sub('dreameraser', '', s)
    elif(re.search('dreamerase', s)):
        s = re.sub('dreamerase', '', s)
    elif(re.search('dreamer', s)):
        s = re.sub('dreamer', '', s)
    elif(re.search('dream', s)):
        s = re.sub('dream', '', s)
    elif(re.search('eraser', s)):
        s = re.sub('eraser', '', s)
    elif(re.search('erase', s)):
        s = re.sub('erase', '', s)
    else:
        f = False
print("NO" if len(s) > 0 else "YES")


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,k;
    cin>>a>>b>>k;
    int i = a;
    for(;i<a+k && i<=b;i++){
        cout<<i<<"\n";
    }
    i = max(i,b-k+1);
    for(;i<=b;i++){
        cout<<i<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
using System;
class Program {
  static void Main(string[] args) {
    int N = int.Parse(Console.ReadLine());
    bool ok = false;
    int part, total;
    for (int i = 0; (part = i * 4) <= N; ++i) {
      for (int j = 0; (total = part + j * 7) <= N; ++j) {
        if (total == N) {
          ok = true;
          goto LOOP_END;
        }
      }
    }
    LOOP_END:
      if (ok) {
        Console.WriteLine("Yes");
      } else {
        Console.WriteLine("No");
      }
  }
}


Measured memory_bytes: 11092
n, m, l = map(int, input().split())
ma = []
mb = []
mc = [[0 for i in range(l)] for i in range(n)]
for i in range(n):
    ma.append(list(map(int, input().split())))
for i in range(m):
    mb.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        for k in range(m):
            mc[i][j] += ma[i][k] * mb[k][j]

for row in mc:
    print(" ".join(map(str, row)))



Measured memory_bytes: 6892
n, k = map(int, input().split())
l = list(map(int, input().split()))
datas = {}
for i in l:
    if i in datas:
        datas[i] += 1
    else:
        datas[i] = 1

a = sorted(datas.items(), key=lambda x: x[1], reverse=True)
if len(a) < k + 1:
    print(0)
else:
    ans = 0
    for i in a[k:]:
        ans += i[1]
    print(ans)

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K;
  IN(K);
  ll A, B;
  IN(A,B);

  for(ll i=A; i<=B; ++i){
    if(i%K==0){
      OUT("OK");
      return 0;
    }
  }

  OUT("NG\n");

  return 0;
}

Measured memory_bytes: 3612
S = input()
T = input()
def checkstr(ss):
    for (s,t) in zip(ss,T):
        check = True
        if s=="?":
            continue
        elif s!=t:
            check = False
            break
    return check
ans = ""
for i in range(len(S)-len(T)+1):
    strs = S[i:i+len(T)]
    if checkstr(strs):
        ans = S[:i].replace("?","a")+T+S[i+len(T):].replace("?","a")
if ans=="":
    print("UNRESTORABLE")
else:
    print(ans)


Measured memory_bytes: 3064
n, l = gets.split.map(&:to_i)


absdif = 1000000000
taste = 0

orig = 0
n.times do |i|
  orig += l + i
end

n.times do |donteat|
  sum = 0
  n.times do |i|
    sum += l + i if i != donteat
  end

  if absdif > (orig - sum).abs
    taste = sum
    absdif = (orig - sum).abs
  end
end

p taste


Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
vvl v;
vl vis,d;

int main() {
    IOS;
    cin>>n>>k;
    fo(i,n){
        vl d(k);cin>>d;
        v.pb(d);
    }
    fo(i,n){
        for(int j=i+1;j<n;j++){
            p=0;
            fo(l,k)p+=(v[i][l]-v[j][l])*(v[i][l]-v[j][l]);
            ld f=sqrt(p);
            ll g=f;
            if(g==f)kv++;
        }
    }
    cout<<kv;
    return 0;
}


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  long long N, M;
  cin >> N >> M;

  if(abs(N - M) >= 2) {
    cout << 0 << endl;
  }
  else {
    long long pow_N = N % MOD, pow_M = M % MOD;
    for(int i = 1; i < N; i++) {
      pow_N *= i;
      pow_N %= MOD;
    }
    for(int i = 1; i < M; i++) {
      pow_M *= i;
      pow_M %= MOD;
    }
    if (abs(N - M) == 1) {
      cout << (pow_N * pow_M) % MOD << endl;
    }
    else {
      cout << 2 * (pow_N * pow_M) % MOD << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3624
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

int insu[100];

void soinsu(int n, int i = 2) {
    if (n == 1) return;
    
    if (n % i == 0) {
        insu[i]++;
        soinsu(n / i, i);
    } else {
        soinsu(n, ++i);
    }
}

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

    for (int i = 2; i <= n; i++) soinsu(i);
    
    int more3 = 0;
    int more5 = 0;
    int more15 = 0;
    int more25 = 0;
    int more75 = 0;
    for (int i = 0; i < n; i++) {
        if (insu[i] + 1 >= 75) ++more3, ++more5, ++more15, ++more25, ++more75;
        else if (insu[i] + 1 >= 25) ++more3, ++more5, ++more15, ++more25;
        else if (insu[i] + 1 >= 15) ++more3, ++more5, ++more15;
        else if (insu[i] + 1 >= 5) ++more3, ++more5;
        else if (insu[i] + 1 >= 3) ++more3;
    }

    cout << more75 + more25 * (more3 - 1) + more15 * (more5 - 1) + more5 * (more5 - 1) * (more3 - 2) / 2 << endl;
}


Measured memory_bytes: 256
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct

  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    if t.size <= 0 then failwith "out of size" else
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m = i then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(m);
        t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      let p = parent i in
      if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(p);
        t.node.(p) <- tmp;
        doit p
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size

end

module H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)

let dijkstra g n =
  let reached_p = Array.make n false in
  let min_costs = Array.make n max_int in
  min_costs.(0) <- 0;
  let h = H.make 100000 (0, 0) in
  H.push (0, 0) h;
  while not (H.empty_p h) do
    let (u, x) = H.pop h in
    reached_p.(u) <- true;
    if x > min_costs.(u) then ()
    else
      List.iter (fun (v, c) ->
        let x = min_costs.(u) + c in
        if not reached_p.(v) && x < min_costs.(v) then begin
          min_costs.(v) <- x;
          H.push (v, x) h;
        end) g.(u);
  done;
  min_costs

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> assert false

let make_pair lst = make_pair [] lst

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let g = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> g.(u) <- make_pair l
    | _ -> assert false
  done;
  dijkstra g n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" i e)

Measured memory_bytes: 30604
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>

using namespace std;
using namespace boost::multiprecision;

//重み付きグラフ
//距離の部分をテンプレートに
template<class T>
class wGraph {
public:
	int N;
	vector<multimap<int, T> >* E;
	wGraph(int n, T i) {
		N = n;
		E = new vector<multimap<int, T> >;
		E->resize(N);
		INF = i;
	}
	wGraph() {
	}
	void constructor(int n, T i) {
		N = n;
		E = new vector<multimap<int, T> >;
		E->resize(N);
		INF = i;
	}
	~wGraph() {
		delete E;
	}
	void addEdge(int a, int b, T c) {
		E->at(a).emplace(b, c);
	}
	bool isConnected(int a, int b) {
		return (E->at(a).find(b) != E->at(a).end());
	}
	T INF;
};

//ダイクストラする
//グラフ本体、始点、保存用vector
//到達不可能はg.INF
//O(ElogV)
template<class T>
void  dijkstra(wGraph<T>& g, int s, vector<T>& v) {
	v.resize(g.N);
	for (int i = 0; i < g.N; i++) {
		v[i] = g.INF;
	}
	typedef pair<T, int> t;
	priority_queue<t, vector<t>, greater<t>> q;
	q.push(t(0, s));
	while (!q.empty()) {
		t e = q.top();
		q.pop();
		if (v[e.second] != g.INF && v[e.second] <= e.first)continue;
		v[e.second] = e.first;
		for (auto itr = g.E->at(e.second).begin(); itr != g.E->at(e.second).end(); itr++) {
			q.push(t(e.first + (*itr).second, (*itr).first));
		}
	}
	return;
}

int N, M, R;
vector<int> r;
wGraph<long long> G;
vector<long long> V;
long long arr[8][8];   //ri-rj

void solve() {
	cin >> N >> M >> R;
	r.resize(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}
	G.constructor(N, LLONG_MAX);
	for (int m = 0; m < M; m++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G.addEdge(a, b, c);
		G.addEdge(b, a, c);
	}
	for (int i = 0; i < R; i++) {
		V.clear();
		dijkstra(G, r[i], V);
		for (int j = 0; j < R; j++) {
			arr[i][j] = V[r[j]];
		}
	}
	long long ans = LLONG_MAX;
	for (int i = 0; i < R; i++)r[i] = i;
	do {
		long long temp = 0;
		for (int i = 0; i < R - 1; i++)temp += arr[r[i]][r[i + 1]];
		ans = min(ans,temp);
	} while (next_permutation(r.begin(), r.end()));
	cout << ans << endl;
	return;
}

Measured memory_bytes: 4440
#include <stdio.h>

#define LIMIT 1000000

char ifnprime[LIMIT];
int numofprime[LIMIT];

void eratosthenes(void){
    int x, y;
    ifnprime[0] = ifnprime[1] = 1;
    for(x = 2; x * x < LIMIT; x++){
        if(!ifnprime[x]){
            for(y = x * x; y < LIMIT; y += x){
                ifnprime[y] = 1;
            }
        }
    }
    numofprime[0] = 0;
    for(x = 1; x < LIMIT; x++){
        numofprime[x] = numofprime[x-1] + !ifnprime[x];
    }
}

int main(void){
    int n, x, ans;
    eratosthenes();
    while(scanf("%d", &n) != EOF){
        printf("%d\n", numofprime[n]);
    }
    return 0;
}

Measured memory_bytes: 5476
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){\
cout << it.fi << " " << it.se << endl;}


#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double pi=3.141592653;
    int r;
    cin>>r;
    double ans=2*pi*r;
    cout << fixed << setprecision(9) << ans;
}


Measured memory_bytes: 3780
#include <stdio.h>
 
int main(void){
     
    int i,n,max,min,a;
    long long int sum=0;
     
    max=-1000000;
    min=1000000;
     
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a>max) max=a;
        if(a<min) min=a;
        sum+=a;
    }
     
    printf("%d %d %lld\n",min,max,sum);
     
    return 0;
}


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


int main(){
    int n;
    int l;
    cin >> n >> l;
    int a[n];
    int sum = 0;
    rep(i,n){
        a[i] = l + i;
        sum += a[i];
    }
    int rem;
    if(a[n-1] > 0 && a[0] > 0) rem = a[0];
    if(a[n-1] < 0 && a[0] < 0) rem = a[n-1];
    if(a[n-1] > 0 && a[0] < 0) rem = 0;
    if(a[n-1] == 0 || a[0] == 0) rem = 0;
    int ans = sum - rem;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string Sa, Sb, Sc;
	cin >> Sa >> Sb >> Sc;

	map<char, string> hands;
	hands['a'] = Sa;
	hands['b'] = Sb;
	hands['c'] = Sc;

	char turn_player = 'a';
	while (!hands[turn_player].empty()) {
		char next_turn_player = hands[turn_player][0];
		hands[turn_player].erase(hands[turn_player].begin());
		turn_player = next_turn_player;
	}
	cout << char(turn_player - ('a' - 'A')) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

h, w, k = map(int, input().split())
rows = [input() for _ in range(h)]
for i in range(2**h):
    for j in range(2**w):
        chk = 0
        for ii in range(h):
            for jj in range(w):
                if (i >> ii) & 1:
                    if (j >>jj) & 1:
                        if rows[ii][jj] == "#":
                            chk += 1
        if chk == k:
            ans += 1
print(ans)

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

#define N 50

long long K;
long long a[N];

int main()
{
	cin >> K;

	long long rest = K % N;
	long long mul = K / N;
	for( int i = 0; i < N; i++ ) {
		a[i] = N - 1;
	}
	for( int i = 0; i < N; i++ ) {
		if( i < rest ) {
			a[i] += mul + N - rest;
		}
		else {
			a[i] += mul - rest;
		}
	}

	cout << N << endl;
	for( int i = 0; i < N; i++ ) {
		cout << a[i];
		if( i < N - 1 ) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

const int maxn = 1e5;

vector<int> adj[maxn];

int get_leaf(int v, int p) {
  for (int u : adj[v])
    if (u != p)
      return get_leaf(u, v);
  return v;
}

int get_first_ant(int v, int p) {
  int nc = 0;
  for (int u : adj[v])
    if (u != p) {
      ++nc;
      int res = get_first_ant(u, v);
      if (res != -1)
        return res;
    }
  if (nc >= 2)
    return get_leaf((adj[v][0] != p ? adj[v][0] : adj[v][1]), v);
  return -1;
}

int solve(int v, int p) {
  int result = 0;
  int nc_without_ant = 0;
  for (int u : adj[v])
    if (u != p) {
      int res = solve(u, v);
      result += res;
      if (res == 0) ++nc_without_ant;
    }
  if (nc_without_ant >= 2)
    result += nc_without_ant - 1;
  return result;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int first_ant = get_first_ant(0, -1);
  if (first_ant == -1) first_ant = 0;
  int result = 1 + solve(first_ant, -1);
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 11904
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
j = 0
for i in range(m):
    while j < len(a) and bc[i][0] > 0:
        if a[j] < bc[i][1]:
            a[j] = bc[i][1]
            bc[i][0] -= 1
        j += 1
print(sum(a))

Measured memory_bytes: 32964
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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

int main()
{
    optimize();

    int a;
    cin >> a;

    cout << ( a + ( a * a ) + ( a * a * a ) ) << endl;

    return 0;
}


















Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, x;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        bool f = 1;
        for (int j = 0; j < v.size(); j++) {
            if (v[j] == x) f = 0;
        }
        if (f)v.push_back(x);
    }
    cout << v.size() << endl;
}


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

/*文字数字の変換*/
int change(char s){
	return s - '0';
}

int main(){
	/*input*/
	char s[11];	cin >> s;  
	int year = change(s[0])*1000 + change(s[1])*100 + change(s[2])*10 + change(s[3]);
	int month = change(s[5])*10 + change(s[6]);
	int day = change(s[8])*10 + change(s[9]);
	/*calculation*/
	bool heisei = false;	//true:平成
	if(year < 2019){
		heisei =true;
	}else if(year == 2019){
		if(month < 3){
			heisei = true;
		}else if(month == 4){
			if(day <= 30){
				heisei = true;
			}
		}
	}
	/*output*/
	(heisei)?cout << "Heisei" << endl:cout << "TBD" << endl;
	return 0;
}


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

using namespace std;

typedef long ll;

long a[100001];
long mod = 998244353;
int main(int, char**)
{
	ll r, g, b, n, ans = 0;
	cin >> r >> g >> b >> n;

	for (ll i = 0; i <= n / r; ++i) {
		ll x = n - i * r;
		for (ll j = 0; j <= x / g; ++j) {
			ll y = x - j * g;
			if (y % b == 0) ++ans;
		}
	}

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


Measured memory_bytes: 256
function LD(a, b){
    var ar = new Array();
    for(var i = 0; i < a.length + 1; i++){
        var subar = new Array();
        for(var j = 0; j < b.length + 1; j++){
            subar.push(0);
        }
        ar.push(subar);
    }

    for(var i = 0; i < a.length + 1; i++){
        ar[i][0] = i;
    }

    for(var i = 0; i < b.length + 1; i++){
        ar[0][i] = i;
    }

    for(var i = 1; i < a.length + 1; i++){
        for(var j = 1; j < b.length + 1; j++){
            if(a.charAt(i - 1) == b.charAt(j - 1)){
                ar[i][j] = Math.min(ar[i - 1][j] + 1, ar[i][j - 1] + 1, ar[i - 1][j - 1]);
            }else{
                ar[i][j] = Math.min(ar[i - 1][j] + 1, ar[i][j - 1] + 1, ar[i - 1][j - 1] + 1);
            }
        }
    }
    return ar[a.length][b.length];
} 

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var strings = input.split('\n');

console.log(LD(strings[0], strings[1]));

Measured memory_bytes: 29792