akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

int N;
char str[101];
int main()
{
    scanf("%d", &N);
    scanf("%s", &str);
    int x = 0, ans = 0;
    for(int i=0;i<N;i++)
    {
        if(str[i]=='I') x++;
        else x--;
        ans = ans>x?ans:x;
    }
    printf("%d\n", ans);
}

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


int main(){
  ll N, T, A;
  cin >> N >> T >> A;
  vector<ll> H(N);

  rep(i, N) cin >> H[i];

  rep(i, N) H[i] = abs(T*1000 - H[i]*6 - A*1000);

  // Hがソートされていない時はdistanceを利用する
  auto index = min_element(H.begin(), H.end());
  int ans = index - H.begin();
  cout << ans + 1 << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
 
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  int ans;
  ans = a[0]+a[1]+a[2]*10;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int A, B, x, y, z;
	scanf("%d%d", &A, &B);
	
	x=A+B;
	y=A-B;
	z=A*B;
	
	if(x>=y && x>=z)
	{
		printf("%d", x);
	}
	else if(y>=x && y>=z)
	{
		printf("%d", y);
	}
	else if(z>=x && z>=y)
	{
		printf("%d", z);
	}
	return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
    register T1 __ = 0, ___ = 1;
    register char ch;
    while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
    do{
        __ = (__ << 1) + (__ << 3) + (ch ^ 48);
    }while(isdigit(ch = getchar()));
    __ *= ___;
    IEE = __;
    qread(ls...);
    return ;
}
ll a, b;
int main(){
    cin >> a >> b;
    cout << a * b;
    return 0;
}

Measured memory_bytes: 3584
A,B,K =  map(int,input().split())
if K==0:
    print("{} {}".format(A, B))
elif A==0&B==0:
    A=0
    B=0
    print("{} {}".format(A, B))
elif A<K:
    B=B-(K-A)
    if B<0:
        B=0
    A=0
    print("{} {}".format(A, B))
elif A==K:
    A=0
    print("{} {}".format(A, B))
else :
    A = A-K
    print("{} {}".format(A, B))


    

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{   
    char a[20];
    char b[20];
    scanf("%s", a);
    int i = 0;
    int j = 0;
    while (strcmp(&a[i], "\0") != 0) {
        i += 1;
    }
    i -= 1;
    strcpy(&b[i], &a[i]);
    for (; i >=  0; i--) {
        b[j] = a[i];
        j += 1;
    } 
    printf("%s\n", b);
    return 0;
}

Measured memory_bytes: 952
#include <iostream>
#include <complex>
#include <utility>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;

#define X real()
#define Y imag()

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

string ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return "COUNTER_CLOCKWISE";
    if(cross(a, b) < -EPS) return "CLOCKWISE";
    if(dot(a, b) < -EPS) return "ONLINE_BACK";
    if(norm(a) < norm(b)) return "ONLINE_FRONT";

    return "ON_SEGMENT";
}

int main(){
    double x0, y0, x1, y1; cin>>x0>>y0>>x1>>y1;
    Point p0 = {x0, y0};
    Point p1 = {x1, y1};
    int q; cin>>q;
    while(q--){
        double x2, y2; cin>>x2>>y2;
        Point p2 = {x2, y2};

        cout << ccw(p0, p1, p2) << endl;
    }
}


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

int bgr(int idx) {}

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

  int n;
  cin >> n;

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

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

  int ans = 0;
  for (int b = 0; b < n; b++) {
    for (int a = 0; a < b; a++) {
      int ab = l[a] + l[b];

      auto it = lower_bound(l.begin(), l.end(), ab);

      int ri = distance(l.begin(), it);
      int li = b + 1;

      ans += ri - li;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
int n, a[MAXN], x;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    FOR(i, 0, n)
        cin >> a[i], x ^= a[i];
    FOR(i, 0, n)
        cout << (x ^ a[i]) << ' ';
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

int main(){
    int A;
    int B;
    int C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W; cin >> H >> W;
	vector<VI> A(H, VI(W));
	vector<VI> dp(H, VI(W, 0));
	REP(i, H)REP(j, W)cin >> A[i][j];
	REP(i, H)if (A[i][0] == 0)dp[i][0] = 1;
	REP(i, W)if (A[0][i] == 0)dp[0][i] = 1;

	REP(i, H - 1) {
		REP(j, W - 1) {
			if (A[i + 1][j + 1] == 0) {
				//cout << i << " " << j << endl;
				dp[i + 1][j + 1] = min({ dp[i][j],dp[i + 1][j],dp[i][j + 1] }) + 1;
			}
		}
	}
	
	int ans = 0;
	REP(i, H)REP(j, W)chmax(ans, dp[i][j]);
	cout << ans * ans << endl;
	return 0;
}




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

    int     main() {
            int N, M, X, Y;
            cin >>N >>M >>X >>Y;
            string S="No War";
            string W="War";
            int x=X, xx;
            int y=Y, yy;
            for (int i=0; i<N; i++) {
                    cin >>xx;
                    x=max(x, xx);
            }
            for (int i=0; i<M; i++) {
                    cin >>yy;
                    y=min(y, yy);
            }
            if (x>=y) S=W;
            cout <<S << endl;
            return 0;
    }


Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(n):
    s = sorted(list(input()))   
    s = ''.join(s)
    d[s] = d.get(s, 0) + 1

cnt = 0
for k,v in d.items():
    if v >= 2:
        cnt += v * (v - 1) // 2 # 組の個数

print(cnt)

Measured memory_bytes: 17808
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int N,K;
    cin >> N >> K;
    int ans;
    if(K == 1)
      ans = 0;
    else
      ans = N - K;
    // 出力
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,base;
    cin >> n >> base;
    int dig = (int)(floor( log(n) / log(base)) + 1);  
    cout<<dig<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int a[105];
int _max=0;
int main() {
    int sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        _max=max(_max,a[i]);
    }
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            a[i+1]=++_max;
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int H, W;
int INF = 100000000;
int main(){
  cin >> H >> W;
  char maze[H][W];
  int dp[H][W];
  rep(i, H)rep(j, W) cin >> maze[i][j];
  rep(i, H)rep(j, W) dp[i][j] = INF;
  rep(i, H)rep(j, W){
    if (i == 0 && j == 0){
      if (maze[i][j] == '#') dp[0][0] = 1;
      else dp[0][0] = 0;}
    else if (i == 0){
      if (maze[i][j-1] == '.' && maze[i][j] == '#')dp[i][j] = dp[i][j-1]+1;
      else dp[i][j] = dp[i][j-1];
    }
    else if (j == 0){
      if (maze[i-1][j] == '.'  && maze[i][j] == '#')dp[i][j] = dp[i-1][j] + 1;
      else dp[i][j] = dp[i-1][j];
    }
    else{
      int a, b;
      if (maze[i][j-1] == '.' && maze[i][j] == '#')a = 1;
      else a = 0;
      if (maze[i-1][j] == '.' && maze[i][j] == '#')b = 1;
      else b = 0;
      dp[i][j] = min(dp[i][j-1] + a, dp[i-1][j] + b);
    }
  }
  cout << dp[H-1][W-1] << endl;
}  

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

const int N = 1e5+5;

int n;
int a[N];
bool vis[N];

int main(){
	int ans = 0;
	scanf("%d" , &n);
	for(int i = 0;i < n;i++){
		scanf("%d" , a + i);
		if(a[i] == i + 1)vis[i] = 1;
	}
	for(int i = 0;i < n;i++){
		if(i == n-1){
			if(vis[i])ans++;
		}
		else if(vis[i]){
			ans++;
			i++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 768
// Copyright 2015 KanatoNagayama
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;

int main() {
  int a, b;
  cin >> a;
  cin >> b;
  if (a < b) 
    cout << "a < b" << endl;
  else if (a > b) 
    cout << "a > b" << endl;
  else
    cout << "a == b" << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;
#define mod 1000000007
typedef long long ll;

int main()
{
  int n,w; scanf("%d %d",&n,&w);
  ll weight[n],val[n];
  for(int i=0;i<n;i++) scanf("%lld %lld",&weight[i],&val[i]);
 
 ll dp[w+1];
 memset(dp,0,sizeof(dp));
   for(int i=0;i<n;i++){
     for(int j=w;j>=weight[i];j--){
       dp[j] = max(dp[j], val[i]+dp[j-weight[i]]);
     }
   }
   printf("%lld",dp[w]);
}

Measured memory_bytes: 1024
/* 
   AOJ 1155
   How can I satisfy thee? Let me count the ways...
   
*/

#include<stdio.h>
#define MAX_STR 100
char not[3] = {'2', '1', '0'};
char and[3][3] = {{'0', '0', '0'}, {'0', '1', '1'}, {'0', '1', '2'}};
char or[3][3] = {{'0', '1', '2'}, {'1', '1', '2'}, {'2', '2', '2'}};

char instr[MAX_STR];
int pp;

  

char interpreter(int p, int q, int r)
{
  char c = instr[pp];
  switch(c)
    {
    case '0':
    case '1':
    case '2':
      return instr[pp++];
    case 'P':
      pp++;
      return p + '0';
    case 'Q':
      pp++;
      return q + '0';
    case 'R':
      pp++;
      return r + '0';
    case '-':
      pp++;
      return not[interpreter(p, q, r) - '0'];
    case '(':
      pp++;
      char f0 = interpreter(p, q, r);
      char op = instr[pp++];
      char f1 = interpreter(p, q, r);
      pp++;
      if(op == '*')
	return and[f0 - '0'][f1 - '0'];
      else
	return or[f0 - '0'][f1 - '0'];
    }
}

int main(void)
{
  int p, q, r, ans = 0;
  while(scanf("%s", instr), instr[0] != '.')
    {
      for(p = 0; p < 3; p++)
	for(q = 0; q < 3; q++)
	  for(r = 0; r < 3; r++)
	    {
	      if(interpreter(p, q, r) == '2')
		ans++;
	      pp = 0;
	    }
      printf("%d\n", ans);
      ans = 0;
      pp = 0;
      for(p = 0; p < MAX_STR; p++)
	instr[p] = '\0';
    }
  return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
int N, K;
vi X, Y;
vector<vi> C;

void input_data(void) {
	cin >> N >> K;
	X.resize(N);
	Y.resize(N);
	C.resize(2 * K + 1, vi(2 * K + 1, 0));
	for (int i = 0; i < N; ++i) {
		int x, y; char c;
		cin >> x >> y >> c;
		X[i] = (c == 'B') ? x : x + K;
		Y[i] = y;
		++C[(Y[i] % (2 * K)) + 1][(X[i] % (2 * K)) + 1];
	}
}

int solve(void) {
	for (int j = 1; j <= 2 * K; ++j) {
		for (int i = 1; i <= 2 * K; ++i)
			C[j][i] += C[j][i - 1];
	}
	for (int i = 1; i <= 2 * K; ++i) {
		for (int j = 1; j <= 2 * K; ++j)
			C[j][i] += C[j - 1][i];
	}
	int max_cnt1 = -1;
	int max_cnt2 = -1;
	for (int y = 1; y <= K; ++y) {
		for (int x = 1; x <= K; ++x) {
			int s1 = C[y + K][x] - C[y][x];
			int s2 = C[2 * K][x + K] - C[y + K][x + K] - (C[2 * K][x] - C[y + K][x]);
			int s3 = C[y][x + K] - C[y][x];
			int s4 = C[y + K][2 * K] - C[y + K][x + K] - (C[y][2 * K] - C[y][x + K]);
			int cnt1 = s1 + s2 + s3 + s4;
			int cnt2 = N - cnt1;
			max_cnt1 = max(cnt1, max_cnt1);
			max_cnt2 = max(cnt2, max_cnt2);
		}
	}
	return max(max_cnt1, max_cnt2);
}

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

	input_data();
	int ans = solve();

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


Measured memory_bytes: 16768
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
using namespace std;
#define INF (2147483647)
#define mod (1000000007)

int main(void){
  string S;
  cin >> S;
  for (size_t i = 0; i < S.size(); i++) {
    if (S[i]==','){
      S[i] = ' ';
    }
  }
  cout << S;
}


Measured memory_bytes: 256
#include<stdio.h>
#define	bmi(a,b) a/b/b
main(){
  int id;
  double w,h;
  while(~scanf("%d,%lf,%lf",&id,&w,&h)){
    if(bmi(w,h)>=25)
      printf("%d\n",id);
  }
  return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long long dp[3002][3002][4];
int main() {
    int R,C,K;
    cin >> R >> C >> K;
    vector<vector<int>>cnt(R,vector<int>(C));
    for(int i = 0; i < K; i++) {
        int r,c,v;
        cin >> r >> c >> v;
        r--;c--;
        cnt[r][c] = v;
    }
    long long ans = 0;
    for(int i = 0; i < R; i++) {
        for(int j = 0; j < C; j++) {
            for(int k = 0; k <= 3; k++) {
                if(k <= 2) {
                    dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]+cnt[i][j]);
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1],dp[i][j][k]+cnt[i][j]);
                }
                dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
                dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
                if(i+1 == R && j+1 == C) {
                    ans = max(ans,dp[i][j][k]+((k <= 2)?cnt[i][j]:0));
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 319800
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret);
  if(n%2)((ret *= a));
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}

vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}


////////////////////////////////////////////////////////////////////

int n,m;vector<P> g[110000];
int dist[110000];bool c;
int dfs(int x){
  rep(i,g[x].size()){
    int to = g[x][i].first, cost = g[x][i].second;
    if(dist[to] == INF){
      dist[to] = dist[x]+cost;
      dfs(to);
    }else if(dist[to] != dist[x]+cost){
      c = false;
    }
  }
}
signed main(){
  cin>>n>>m;
  rep(i,m){
    int l,r,d;cin>>l>>r>>d;l--;r--;
    g[l].push_back(P(r,d));
    g[r].push_back(P(l,-d));
  }
  c = true;
  rep(i,110000)dist[i] = INF;
  rep(i,n)if(dist[i] == INF){
    dist[i] = 0;dfs(i);
  }
  cout << (c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 16768
N, M = map(int, input().split())

A = [int(i) for i in input().split()]

A_sum = 0
for i in A:
    A_sum += i

A.sort(reverse = True)

YN = True
for i in range(M):
    if A[i] < A_sum / (4 * M):
        YN = False
        break

if YN == True:
    print("Yes")
else:
    print("No")

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  const int MOD = 1e9 + 7;

  int n;
  cin >> n;
  long long ans = 1;
  rep(i, n) {
    ans *= (i + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}


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

int main(){
  string s;
  cin >> s;
  string ans="";
  for(int i=0;i<s.length();i++){
    if(s[i]=='B'){
        if(ans.length()) ans.erase(ans.begin()+ans.length()-1);
    }else{
        ans+=s[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
A,B,C,D = map(int,input().split())
C_div = B//C - (A-1)//C
D_div = B//D - (A-1)//D
CD = (C * D) // gcd(C, D)
CD_div = B//CD - (A-1)//CD
print(B-A+1 - C_div - D_div + CD_div)


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

static const int M_SIZE = 100;

int main() 
{
    int adj_M[M_SIZE][M_SIZE];
    int n, v_id, v_degree, adj_v;
    cin >> n;

    // init
    for (int i = 0; i < n; ++i) 
    {
        for (int j = 0; j < n; ++j) 
        {
            adj_M[i][j] = 0;
        }
    }


    for (int i = 0; i < n; ++i) 
    {
        cin >> v_id >> v_degree;
        v_id--;
        for (int j = 0; j < v_degree; ++j) 
        {
            cin >> adj_v;
            adj_v--;
            adj_M[v_id][adj_v] = 1;
        }
    }

    for (int i = 0; i < n; ++i) 
    {
        for (int j = 0; j < n; ++j) 
        {
            if (j) cout << " ";
            cout << adj_M[i][j];
        }
        cout << endl;
    }
}


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

int main(){
  int  N;
  int  A;
  int  B;
  int sum=0;
  
  int s=0;
  cin>>N>>A>>B;
  for(int i=1;i<=N;i++){
    s=0;
    int c=i;
    
    while(c>0){
     int b=c%10;
     c/=10;
     s+=b;
    }
  if(A<=s&&s<=B){
    sum+=i;
   }
  }
 cout<<sum<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
li=[input().split() for i in range(m)]
 
ac=set()
wa=0
 
q=[[0,-1] for i in range(n+1)]
 
for x,y in li:
  if y=="AC" and q[int(x)][1]==-1: #AC出したらこれまでのwaを答えに足して、それ以降はカウントされないようにする
    wa+=q[int(x)][0]
    q[int(x)][1]=0
    ac.add(x)
  elif y=="WA" and q[int(x)][1]==-1:
    q[int(x)][0]+=1
 
print(len(ac),wa)

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

using namespace std;

map<char, string> mcs;
map<string, char> msc;
int p[] = {1, 2, 4, 8, 16};

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

    msc["11010"] = ' ';
    msc["11011"] = '.';
    msc["11100"] = ',';
    msc["11101"] = '-';
    msc["11110"] = '\'';
    msc["11111"] = '?';
}

int main() {
    init();

    string s;
    while (getline(cin, s)) {
        string ns = "";
        for (int i = 0; i < s.size(); i++) ns += mcs[s[i]];
        while (ns.size() % 5) ns += "0";

        string ans = "";
        while (ns.size()) {
            string ss = ns.substr(0, 5);
            if (msc.find(ss) != msc.end()) ans += msc[ss];
            else {
                int sum = 0;
                reverse(ss.begin(), ss.end());
                for (int i = 0; i < 5; i++)
                    sum += p[i] * (ss[i] - '0');
                ans += (sum + 'A');
            }
            ns = ns.substr(5, ns.size() - 5);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3192
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
a2 = 0
for i in range(1, n, 2):
    a2 += a[i]

ans = [0] * n
ans[0] = sum_a - 2*a2
for i in range(1, n):
    ans[i] = 2*a[i-1] - ans[i-1]
print(*ans)

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k){
        cout << a - k << ' ' << b << '\n';
    }
    else{
        cout << 0 << ' ' << max(0LL, b - k + a) << '\n';
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,K;cin>>N>>K;
    int a[110];
    for(int i=0;i<N;i++)cin>>a[i];
    int dp[100010][2];
    dp[0][0]=1;dp[0][1]=0;
    for(int i=1;i<=K;i++){
        bool b0=false;
        for(int n=0;n<N;n++){
            if(i>=a[n] && dp[i-a[n]][1]==0){
                b0=true;
                break;
            }
        }
        if(b0)dp[i][0]=0;
        else  dp[i][0]=1;

        bool b1=false;
        for(int n=0;n<N;n++){
            if(i>=a[n] && dp[i-a[n]][0]==1){
                b1=true;
                break;
            }
        }
        if(b1)dp[i][1]=1;
        else  dp[i][1]=0;
    }
    if(dp[K][0]==0)cout<<"First"<<endl;
    else           cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t p=1000000007;
  int64_t sum=0;
  int64_t cnt=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(A[i]>A[j]){cnt++;}
    }
  }
  sum+=(cnt*K%p);
  cnt=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i]>A[j]){cnt++;}
    }
  }
  sum+=K*(K-1)/2%p*cnt%p;
  cout<<sum%p<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int n,k;
    cin>>n>>k;
    int ans=0;
    VL gcd(k+1);
    rep(i,1,k+1)gcd[i]=powmod(k/i,n);
    per(i,1,k/2+1){
        for(int j=2*i;j<=k;j+=i)gcd[i]=(gcd[i]-gcd[j])%mod;
    }
    rep(i,1,k+1)gcd[i]=(1ll*gcd[i]*i)%mod;
    cout<<(((accumulate(gcd.begin(),gcd.end(),0ll)))%mod+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
int Ma=0,Mi=0;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.push_back(a);
        Ma = max(Ma,a);
        Mi = min(Mi,a);
    }
}

int solve(){
    int ans = INT_INF;
    for (int x = Mi; x <= Ma; x++)
    {
        int tmp = 0;
        for (int i = 0; i < N; i++)
        {
            tmp += (A[i]-x)*(A[i]-x);
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    
    return 0;
}   

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

Measured memory_bytes: 256
//
//  main.cpp
//  ABC169F
//
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using P=pair<int,int>;
using ll = long long;
const ll INF=1e18;
const int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(int argc, const char * argv[]) {
    int n,s;
    cin>>n>>s;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    vector<mint> dp(s+1);
    dp.at(0)=1;
    rep(i,n){
        vector<mint> p(s+1);
        swap(dp,p);
        rep(j,s+1){
            dp.at(j)+=p.at(j)*2;
            if (j+a.at(i)<=s) {
                dp.at(j+a.at(i))+=p.at(j);
            }
        }
    }
    cout << dp.at(s)<<endl;
    return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int m, f, r;
    int sum;
    char s;

    while (true)
    {
        cin >> m >> f >> r;
        if (m + f + r == -3)
            break;

        if (m == -1 || f == -1)
        {
            s = 'F';
        }
        else
        {
            sum = m + f;
            if (sum >= 80)
            {
                s = 'A';
            }
            else if (sum >= 65)
            {
                s = 'B';
            }
            else if (sum >= 50)
            {
                s = 'C';
            }
            else if (sum >= 30)
            {
                if (r >= 50)
                {
                    s = 'C';
                }
                else
                {
                    s = 'D';
                }
            }
            else
            {
                s = 'F';
            }
        }

        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;

    cin >> N;

    int A[N];
    REP(i, N){
        cin >> A[i];
    }

    map<int, int> map;

    REP(i, N){
        map[A[i]] += 1;
    }

    int res = 0;
    for (auto p : map) {
        auto key = p.first;
        auto value = p.second;
        if (value%2 == 1){
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 5376
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			String[] input = str.split(" ");
			int alt = 0;
			int a = Integer.parseInt(input[0]);
			int b = Integer.parseInt(input[1]);
			int c = Integer.parseInt(input[2]);
			while(true){
				if(a > b){
					alt = a;
					a = b;
					b = alt;
				}else if(b > c){
					alt = b;
					b = c;
					c = alt;
				}else{
					break;
				}
			}
			System.out.println(a + " " + b + " " + c);
		}catch(IOException e){

		}
	}
}


Measured memory_bytes: 24348
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

map<int, string> t;

enum NodeType{ROOT = 0, INTERNALNODE = 1, LEAF = 2};
enum ChildZero{CHILDZERO = -1};

struct type_name{
 map<int, string> type_map;
 type_name(){
  type_map[ROOT] = "root";
  type_map[INTERNALNODE] = "internal node";
  type_map[LEAF] = "leaf";
 }
};

struct Tree{
 int n;
 int root;
 struct type_name t;
 vector<int> parent;
 vector<int> depth;
 vector<int> type;
 vector<int> sibling;
 vector<int> degree;
 vector<int> height;
 vector< vector<int> > child;
 vector<int> leaf;

 Tree(int n) : n(n){
  parent.reserve(n); parent.assign(n,-1);
  depth.reserve(n); depth.assign(n,0);
  type.reserve(n); type.assign(n,INTERNALNODE);
  sibling.reserve(n); sibling.assign(n,-1);
  degree.reserve(n); degree.assign(n,0);
  height.reserve(n); height.assign(n,0);
  child.reserve(n);

  
  init();
  SearchRoot();
  ComputeDepth();
  ComputeHeight();
  
 }

 void init(){
  for(int i = 0; i < n; i++){
   int node_num;
   vector<int> buf(2);
   cin >> node_num >> buf[0] >> buf[1];

   for(int i = 0; i < buf.size();i++){   

    if(buf[i] != CHILDZERO) {
     degree[node_num]++;
     parent[buf[i]] = node_num;
     int sib_num = (i == 0 ? 1 : 0);
     if(buf[sib_num] != -1) sibling[buf[i]] = buf[sib_num];
     child[node_num].push_back(buf[i]);
    }
 
   }
   if(degree[node_num] == 0) type[node_num] = LEAF;
  }
 }
 
 void SearchRoot(){
  for(int i = 0; i < parent.size(); i++){
   if(parent[i] == -1){
    root = i;
    type[i] = ROOT;
   }
  }  
 }

 void ComputeDepth(){

   queue<int> queue;

   queue.push(root);
   while( !queue.empty()){
    int key = queue.front();queue.pop();
    for(int i = 0; i < child[key].size(); i++){
     int buf = child[key][i];
     queue.push(buf);
     depth[buf] = depth[key] + 1;
    }
   }
 }
 
 void ComputeHeight(){
  for(int i = 0; i < n; i++){
   if(type[i] == LEAF){
    int node = i;
    int buf = 0;
    while(node != root){
     buf++;
     node = parent[node];
     if(height[node] < buf)height[node] = buf;
    }
   }
  }
 }

 void output(){
  for(int i = 0; i < n; i++){
   cout << "node " << i;
   cout << ": parent = " << parent[i];
   cout << ", sibling = " << sibling[i];
   cout << ", degree = " << degree[i];
   cout << ", depth = " << depth[i];
   cout << ", height = " << height[i];
   cout << ", " << t.type_map[type[i]] << '\n';
  }
 }
};

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

 int n = 0;
 cin >> n;
 
 Tree tree(n);
 tree.output(); 

 return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	VI a(5);

	rep(i,5) cin >> a[i];
	sort(all(a));
	int ans = 1<<28;
	do {
		int nw=0;
		rep(i,5){
			nw += a[i];
			if(i!=4)
			nw = (nw + 9 )/10 * 10;
		}
		ans = min(ans, nw);
	} while ( next_permutation(all(a)) );

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

Measured memory_bytes: 256
n,c,k = map(int,input().split())
li = []
for _ in range(n):
    li.append(int(input()))
li.sort()

all_count = 0
kazu = 0
start = 0
if c == 1:
    print(n)
    exit()
for l in li:
    if kazu == 0 and start == 0:
        all_count += 1
        kazu += 1
        start = l
        continue
    if kazu < c and l - start <= k:
        kazu += 1
    if kazu == c:
        kazu = 0
        start = 0
        continue
    if l - start > k:
        all_count += 1
        kazu = 1
        start = l
print(all_count)

Measured memory_bytes: 50648
package main

import (
	"fmt"
)

func main() {
	var S string
	K := "keyence"
	fmt.Scan(&S)
	for i := 0; i < len(K)-1; i++ {
		if K[i] != S[i] {
			if i < len(S) && S[i+1] == K[i] {
				i++
			}
			if S[len(S)-len(K[i+1:])-1:] == K[i:] {
				fmt.Println("YES")
				return
			} else {
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}


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

int main() {
	int N;
  	cin >> N;
  	vector<int> A(N);
  
  	int total = 0;
  	for(int i= 0; i < N; i++){
      cin >> A.at(i);
      total += A.at(i);
    }
  
  sort(A.begin(), A.end());
  
  if(A.at(N-1) < (total - A.at(N-1))) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    int d;
    cin >>n>> d;
    d*=d;
    
    int ans = 0;
    for(int i = 0; i<n; ++i){
        int x, y;
        cin >> x >> y;

        if(x*x + y*y <= d) ans++;
    }
    cout<< ans << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S; cin>>S;
  int N=S.size();
  int count=1;
  vi ans(N);
  int memoL,memoR;
  rep(i,1,N){
    if(S[i]=='L'){
      if(S[i-1]=='L')
        count++;
      else{
        ans[i]+=count/2;
        ans[i-1]+=count-count/2;
        count=1;
        memoR=i;
        memoL=i-1;
      }
    }
    else{
      if(S[i-1]=='R')
        count++;
      else{
        ans[memoL]+=count/2;
        ans[memoR]+=count-count/2;
        count=1;
      }
    }
  }
  ans[memoL]+=count/2;
  ans[memoR]+=count-count/2;
  rep(i,0,N) cout<<ans[i]<<" ";
  cout<<endl;
  }



Measured memory_bytes: 1408
N = int(input())
t, x, y = [], [], []

for i in range(N) :
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

cur_x, cur_y = 0, 0
cur_t = 0
flg_impossible = "Yes"

for i in range(N) :
    dloc = (x[i] - cur_x) + (y[i] - cur_y)
    dt = t[i] - cur_t
    
    if ((dloc % 2 == 0 and dt % 2 == 0) or (dloc % 2 != 0 and dt % 2 != 0)) and dloc <= dt :
        cur_x, cur_y, cur_t = x[i], y[i], t[i]
    else :
        flg_impossible = "No"
        
print(flg_impossible)

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s;
  cin >> s;

  int ret = 700;
  REP(i, 3) if(s[i] == 'o') ret += 100;
  cout << ret << endl;

  return 0;
}


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

struct Number {
	int a, c;
};

bool cmp(Number a, Number b) {
	return a.a < b.a;
}

int main() {
	long long n, k;
	cin >> n >> k;
	
	Number N[n];
	
	for(int i = 0; i < n; i++) {
		cin >> N[i].a >> N[i].c;
	}
	
	sort(N, N + n, cmp);
	
	long long count = 0;
	for(int i = 0; i < n; i++) {
		count += N[i].c;
		if(count >= k) {
			cout << N[i].a << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import accumulate

n = int(readline())
a = list(map(int, readline().split()))
cumsum = list(accumulate(a[::-1]))
ans = 0
check = 1
for aa, v in zip(a, cumsum[::-1]):
    if aa > check:
        print(-1)
        exit()
    else:
        ans += min(check, v)
        check -= aa
        check *= 2
print(ans)


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

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

    std::vector<int> d(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> d[i];
    }

    int sum = 0;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = i; j < n; j++ ) {
            if ( i != j ) {
                sum += d[i] * d[j]; 
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N, A[100000], B[100000],tmp;
  long long count = 0;
  scanf("%d\n", &N);
  for(int i = 0;i < N; i++){
    scanf("%d %d", &A[i], &B[i]);
  }

  for(int k = N - 1; k >= 0; k--){
    if((A[k] + count)%B[k] != 0){
    tmp = B[k] - ((A[k] + count)%B[k]);
    count += tmp;
  }
  }

  printf("%lld\n", count);

  return 0;
}

Measured memory_bytes: 896
def f(b, K, N):
    i = N // b
    ans = N - ((K-1) + (i - 1) * K + min((N%b) + 1, K))
    return ans

N, K = map(int, input().split(' '))
if K == 0:
    ans = int(N * N)
    print(ans)
else:
    ans = 0
    for b in range(K+1, N+1):
        ans += f(b, K, N)
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;


int main()
{
    long int x;
    cin>>x;
    long int c500 = x/500, c5, ans;
    x = x%500;
    c5 = x/5;
    ans = c500*1000 + c5*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector <bool> used(n + 1);
	vector <int> count(n + 1);
	vector <pair <int, string>> a(m);
	int cor = 0;
	int wro = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		if (used[a[i].first])
			continue;
		if (a[i].second == "WA")
			count[a[i].first]++;
		if (a[i].second == "AC") {
			cor++;
			used[a[i].first] = true;
		}
	}
	for (int i = 0; i < n + 1; i++)
		if (used[i])
			wro += count[i];
	cout << cor << " " << wro;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main(){
  string s, t;
  std::cin >> s >> t;
  bool ans = false;
  for(int i=0; i<s.size(); i++){
    t = t.at(t.size()-1) + t.substr(0, t.size()-1);
    if( t == s ) ans = true;
  }
  if( ans ) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256