akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main() {
  cin >> A >> B;
  cout << (A-1)/B+1;
}


Measured memory_bytes: 256
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int n = cin.NextInt();
            int k = cin.NextInt();
            int[] x = new int[n];
            for (int i = 0; i < n;i++)
            {
                x[i] = cin.NextInt();
            }
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                if (x[i] * 2 < (k - x[i]) * 2)
                {
                    sum += x[i] * 2;
                }
                else
                {
                    sum += (k - x[i]) * 2;
                }
            }
            
            Console.WriteLine (sum);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

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

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

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

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

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

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, L, Q;
  cin >> N;
  vl X(N);
  REP(i, N) cin >> X[i];
  cin >> L >> Q;
  vvl r = VVL(20, N + 1, 0);
  REP(i, N) { r[0][i] = upper_bound(ALL(X), X[i] + L) - X.begin() - 1; }
  FOR(j, 1, 20) {
    REP(i, N) { r[j][i] = r[j - 1][r[j - 1][i]]; }
  }
  vl ans(Q);
  REP(q, Q) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    ll s = min(a, b);
    ll e = max(a, b);
    ll least = 0;
    ll add = 0;
    ll an = 0;
    RREP(i, 20) {
      if (e <= r[i][s]) {
        add = POW(2, i);
        an = add + least;
      } else {
        s = r[i][s];
        add = 0;
        least += POW(2, i);
      }
    }
    ans[q] = an;
  }
  REP(i, Q) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 19568
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int a,b;
    cin >> a >>b;
    if(a<9&&b<9)
       cout << "Yay!" <<endl;
    else
    {
       cout <<":(" <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[N];
LL sum[N];
int main(){
	scanf ("%d", &n);
	
	for (int i = 1; i <= n; i++)
	{
		scanf ("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i]; sum[i] %= mod;
	}
	
	LL ans = 0;
	for (int i = 1; i <= n; i++)
	ans = (ans + sum[i - 1] * a[i] % mod) % mod;
	printf ("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 6056
#include<stdio.h>
int main()
{
  int a, n, i;
  double x, y;
  y = 0;
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
  {
    scanf("%d", &a);
    x += 1.0 / a;
  }
  y = 1.0 / x;
  printf("%lf",y);
  return 0;
}

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

const int NIL=-1;
const int MAX=100000;

int n, color[MAX];
vector<int> G[MAX];

void dfs(int v, int id){
    stack<int> s;
    s.push(v);
    color[v]=id;

    while(!s.empty()){
        int u=s.top(); s.pop();
        for(int i=0; i<G[u].size(); i++){
            int v1=G[u][i];
            if(color[v1]==NIL){
                color[v1]=id;
                s.push(v1);
            }    
        }
    }
}

void assignColor(){
    int id=1;

    for(int i=0; i<n; i++) color[i]=NIL;
    for(int i=0; i<n; i++){
        if(color[i]==NIL){
            dfs(i,id); id++;
        }
    }
}

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

    for(int i=0; i<m; i++){
        int s,t; scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    int q; cin >> q;
    for(int i=0; i<q; i++){
        int s,t; scanf("%d %d", &s, &t);
        if(color[s]==color[t]) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


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

int main(){
  int n, d;
  long long a, b, ans, l, c, x, digit[10];
  cin >> n;
  for ( int i = 0; i < 10; i++ ) digit[i] = 0;
  for ( int i = 0; i < n; i++ ) {
    cin >> d >> c;
    digit[d] = digit[d] + c;
    l = l + c;
  }

  x = 0;
  for ( int i = 0; i < 10; i++ ) x = x + i * digit[i];
  a = x / 9;
  b = x % 9;
  if (b == 0) a--;
  
  ans = l - 1 + a;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n, temp, result = 0;
  vector<int> heights;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> temp;
    heights.push_back(temp);
  }
  result = heights[0];
  for (int i=1; i<n; i++) {
    if (heights[i]>heights[i-1]) result+=heights[i]-heights[i-1];
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, K; cin >> N >> K;
    map<int, ll> cnts;
    ll ans = 0;
    cnts.insert({0, 1});
    ll pre = 0;
    ll prefs[N+1]; prefs[0] = 0;
    F0R(i, N) {
        int A; cin >> A; A--;
        pre += A; pre %= K;
        prefs[i+1] = pre;
        if (i >= K-1) {
            cnts[prefs[i-K+1]]--;
        }
        if (cnts.count(pre)) {
            ans += cnts[pre]; cnts[pre]++;
        } else {
            cnts.insert({pre, 1});
        }
    }

    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 14464
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int x;
	cin >> x;
	cout << (x < 1200 ? "ABC" : "ARC") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll n,m,i,j,k,l,t,a,b,c,d,arr[100009];
map<ll,ll>mp;
vector<ll>v;
int main()
{
    scanf("%lld",&n);
    for(i=0;;i++)
    {
        arr[i]=i*i*i*i*i;
       // brr[i]=-arr[i];
       // v.push_back(brr[i]);
        v.push_back(arr[i]);
       // printf("%lld %lld\n",arr[i],i);
        if(arr[i]>=1000000000000000000)
            break;
    }
    for(i=1;i<v.size();i++)
    {
        for(j=i-1;j>=0;j--)
        {
            l=v[i]-v[j];
            if(l==n)
            {
                printf("%lld %lld\n",i,j);
                return 0;
            }
            l=v[i]+v[j];
            if(l==n)
            {
                printf("%lld %lld\n",i,-j);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3924
(let ((a (read))
      (b (read))
      (x (read)))
  (cond ((<= (* 2 x) (* a a b))
         (format t "~F~%" (/ (* 180 (atan (/ (* a b b) (* 2 x)))) pi)))
        ((= x (* a a b))
         (format t "0~%"))
        (t
         (format t "~F~%" (- 90 (/ (* 180 (atan (/ (* a a a) (- (* 2.0d0 a a b) (* 2.0d0 x))))) pi))))))


Measured memory_bytes: 24160
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int, int>;
     
const int MOD = 1e9 + 7;

int main(){
   ll n, k;
   cin >> n >> k;
   ll res = 0;
   if(k == 0){
      cout << n * n << endl;
      return 0;
   }
   REP(b, k + 1, n){
      //cout << (n / b) * (b - k) << " " <<  (n % b + 1 - k) << endl;
      res += (n / b) * (b - k);
      if((n % b + 1 - k) > 0)res += (n % b + 1 - k);
   }
   cout << res << endl;
}


Measured memory_bytes: 3588
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M, D = list(map(int, sys.stdin.readline().split()))


# 数列の 1 つ目の要素が決まれば数も決まりそう
# 差が D となる数が上にだけある・下にだけある・上にも下にもある・どっちにもない
# 1 <= a <= N-D までは上にある
# D < a <= N までは下にある

def solve(n, m, d):
    arr = list(itertools.product(range(n), repeat=m))
    ans = 0
    for a in arr:
        for i in range(m - 1):
            if abs(a[i] - a[i + 1]) == d:
                ans += 1
    return ans


# 隣り合う要素を 2 つ決めたときに差が D となる組み合わせの数
if D == 0:
    c = N
else:
    c = (N - D) * 2

# # 全部の合計
# # pow(N, M - 2): ある 2 つの要素を決めたときにその位置にそれらを使う数列の数
# s = c * pow(N, M - 2) * (M - 1)
# # 個々の美しさがわからなくても合計がわかれば組み合わせ数で割れば平均になる
# ans = s / pow(N, M)

# ans = c * (M - 1) * pow(N, M - 2) / pow(N, M)
ans = c * (M - 1) / N ** 2
print(ans)


Measured memory_bytes: 38384
a,b=map(int,input().split())
#a=input()
li1=list(map(int,input().split()))
li2=li1
li=[1]*a
li3=[list(map(int,input().split())) for i in range(b)]
#print(li2)
#print(li3)
for x,y in li3:
    #print(x)
    if li2[x-1]>li2[y-1]:
        li[y-1]=0
        #print(x,y)
        #print(li2[x-1],li2[y-1])
        #print(li)

    elif li2[x-1]<li2[y-1]:
        li[x-1]=0
        #print(x,y)
        #print(li2[x-1],li2[y-1])
        #print(li)
    else:
        li[x-1]=0
        li[y-1]=0

        pass


#print(li2)
#print(li)
print(li.count(1))


Measured memory_bytes: 93532
#include <cstdio>
#define ll long long
using namespace std;

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const ll MOD = 1e9 + 7;
const int N = 2010;
ll C[N][N];

void init() {
	C[0][0] = 1;
	C[1][0] = C[1][1] = 1;
	for (int i = 2; i < N; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) 
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}
}

int main() {
	init();
	int n = read(), k = read();
	for (int i = 1; i <= k; i++) {
		printf("%lld\n", C[k - 1][i - 1] * C[n - k + 1][i] % MOD);
	}
	return 0;
}

Measured memory_bytes: 30336
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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


    const ll MOD = 1e9 + 7;
    int N;  cin >> N;

    auto dp = vector<map<string, ll>>(N + 1);
    char C[4] = { 'A','G', 'C', 'T' };
    for(char c1 : C) {
        for(char c2 : C) {
            for(char c3 : C) {
                string last3 = { c1,c2,c3 };
                if (last3=="AGC" || last3=="GAC" || last3=="ACG") {
                    dp[3][last3] = 0;
                } else {
                    dp[3][last3] = 1;
                }
            }
        }
    }

    FOR(i, 3, N) {
        for (auto p : dp[i]) {
            string s = p.first;

            for(char c : C) {
                string ns = s.substr(1, 2) + c;
                if (ns == "AGC" || ns == "GAC" || ns == "ACG" 
                    || (s[0]=='A' && s[2]=='G' && c=='C')
                    || (s[0]=='A' && s[1]=='G' && c=='C')) {
                    continue;
                }

                dp[i + 1][ns] += dp[i][s];
                dp[i + 1][ns] %= MOD;
            }
        }
    }

    ll ans = 0;
    for(auto p : dp[N]) {
        ans += p.second;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n ,a[10]={0}, ba=0;
    char card[100];
    
    while(1){
        cin >> n;
        if(n==0) break;
        cin>>card;
        for(int i=0;i<100;i++){
            if(card[i]=='M') a[i%n]++;
            if(card[i]=='S'){
                ba+=a[i%n]++;
                ba++;
                a[i%n]=0;
            }
            if(card[i]=='L'){
                a[i%n]+=ba;
                a[i%n]++;
                ba=0;
            }             
        }
        sort(a,a+n);
        for(int i=0;i<n;i++){
            cout << a[i] << " ";
            a[i]=0;
        }
        cout << ba << endl;
        ba=0;
    }
    
    
    return 0;
}

Measured memory_bytes: 1184
import sys
from io import StringIO
import unittest
import math

def resolve():
    x = int(input())

    a = math.floor(x ** 0.2) + 1

    b5 = a ** 5 - x

    if x == 1:
        a = 0
        b = -1
    elif b5 == 0:
        b = 0
    else:
        right = (10 ** 9)
        left = -1 * (10 ** 9)
        pre_right = (10 ** 9)
        pre_left = -1 * (10 ** 9)

        b = 0
        pre_mid = 10 ** 9
        while 1:
            mid = (right + left) // 2
            ans = mid ** 5
            # print(left, right)

            if ans > b5:
                right = mid - 1
            elif ans < b5:
                left = mid + 1
            else:
                b = mid
                break

            if [pre_right, pre_left] == [right, left]:
                a -= 1
                b5 = a ** 5 - x
                right = (10 ** 9)
                left = -1 * (10 ** 9)

            pre_right = right
            pre_left = left

    print(a, b, sep=' ')


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """33"""
        output = """2 -1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1"""
        output = """0 -1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 16496
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/
ll dp[3100][3100];
string lcs(string a,string b){
	ll m=sz(a);
	ll n=sz(b);
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(a[i-1]==b[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string ans="";
	ll i=m,j=n;
	while(i>0 and j>0){
		if(a[i-1]==b[j-1]){
			ans+=a[i-1];
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1]){
				i--;
			}
			else{
				j--;
			}
		}
	}
	reverse(call(ans));
	re ans;
}
void solve(){
	bhar(dp,0);
	string s,t; cin>>s>>t;
	cout<<lcs(s,t);   
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main()
{
  int n,k; cin >> n >> k;
  vi a(n); rep(i, n) cin >> a[i];
  vi b(n + 1), c(n - k + 1);
  b[0] = 0; rep(i, sz(b) - 1) b[i + 1] = b[i] + max(a[i], 0ll);
  int tmp = 0;
  rep(i, k) tmp += a[i];
  c[0] = max(tmp, 0ll);
  rep(i, sz(c) - 1){
    tmp -= a[i];
    tmp += a[i + k];
    c[i + 1] = max(tmp, 0ll);
  }
  dump(b,c);

  int ans = 0;
  rep(i, sz(c)){
    ans = max(ans, (b[i] - b[0]) + c[i] + (b[sz(b) - 1] - b[i + k]));
  }
  cout << ans << endl;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<int> vote(m, 0);
  
  int k;
  int tmp;
  rep(i, n)
  {
    cin >> k;
    rep(j, k)
    {
      cin >> tmp;
      vote.at(-- tmp) ++;
    }
  }
  
  int count = 0;
  rep(i, m)
  {
    if (vote.at(i) >= n) count ++;
  }
  
  cout << count;
  return 0;
}

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

long long cnt[100100];
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M + 1);
    for (int i = 0; i < M; i++) cin >> A[i];
    A[M] = N + 1;

    cnt[0] = 1;
    long long MOD = 1e9 + 7;
    for (int i = 1; i <= N; i++) {
        if (i == 1) cnt[i] = cnt[i - 1];
        else cnt[i] = cnt[i - 1] + cnt[i - 2];
        cnt[i] %= MOD;
    }

    long long ans = cnt[A[0] - 1];
    ans %= MOD;
    for (int i = 1; i <= M; i++) {
        ans *= cnt[A[i] - A[i - 1] - 2];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

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

    int a, b;

    cin >> a >> b;

    if (a != 1 && b != 1) cout << 1;
    else if (a != 2 && b != 2) cout << 2;
    else cout << 3;

    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 100005;
const int LG = 19;
const int MOD = 1e9 + 7;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int a[N], p[N], s[N];
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        p[i] = __gcd(p[i - 1], a[i]);
    }
    for (int i = n; i >= 1; i--) {
        s[i] = __gcd(s[i + 1], a[i]);
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        res = max(res, __gcd(p[i - 1], s[i + 1]));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
x = sum(A)
ans = 0
 
for i in range(N):
  x -= A[i]
  y = x % MOD
  z = (A[i] * y) % MOD
  ans += z
  ans %= MOD

print(ans)


Measured memory_bytes: 31548
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    long long n,p;
    cin >> n >> p;
    long long P=p,x=sqrt(p);
    vector<long long> a(x+1);
    for(long long i=2; i*i<=P; i++){
        if(p%i==0){
            while(p%i==0){
                p/=i;
                a[i]++;
            }
        }
    }
    long long ans=1;
    for(long long i=2; i<=x; i++){
        if(a[i]/n>=1){
            for(long long j=1; j*n<=a[i]; j++){
                ans*=i;
            }
        }
    }
    if(n==1) ans*=p;
    cout << ans << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int A,B,C;
	cin>>A>>B>>C;
	
	if(A+B>=C){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
		
    return 0;
}


Measured memory_bytes: 256
a,b,k = map(int,input().split())

if a + b <= k:
    print(0,0)
elif a >= k:
    print(a-k,b)
elif a < k:
    print(0,b-(k-a))


"""
while k > 0:
    if a > 0:
        a -= 1
        k -= 1
    else:
        b -= 1
        k -= 1
print(a,b)
"""


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

int main() {
    pair<int, int> a, b;
    cin >> a.first >> a.second >> b.first >> b.second;
    pair<int, int> x, y;
    x = min(a, b);
    y = max(a, b);
    if (x.second < y.first) cout << 0 << endl;
    else if (x.second > y.second) cout << y.second - y.first << endl;
    else cout << x.second - y.first << endl;
}

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

int main() {
	char s[100005];
	scanf("%s", &s);
	int len = strlen(s);
	int l, r;
	int now;
	int ans1 = 0, ans2 = 1;
	l = s[0] - '0';
	r = !l;
	for (int i = 1; i < len; i++) {
		now = s[i] - '0';
		if (l == now) {
			ans1++;
		}
		l = !l;
		if (r == now) {
			ans2++;
		}
		r =( (r == 0) ? 1 : 0);
	}
	int ans = ans1 < ans2 ? ans1 : ans2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
// tmp.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

template<typename T, typename U>
struct Tree {
  Tree<T, U>* r;
  Tree<T, U>* l;
  T key;
  U val;

  Tree() : r(nullptr), l(nullptr) { }

  Tree(T k, U v) : r(nullptr), l(nullptr), key(k), val(v) { }

  U& ref(T k)
  {
    if (key == k) return val;
    if (key < k) {
      if (l == nullptr) l = new Tree<T, U>(k, 0);
      return l->ref(k);
    } else {
      if (r == nullptr) r = new Tree<T, U>(k, 0);
      return r->ref(k);
    }
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    set<string> vis;
    Tree<string, lli>* t = new Tree<string, lli>("@", 0);
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      sort(s.begin(), s.end());
      ++t->ref(s);
      vis.insert(s);
    }

    lli sum = 0;
    each (i, vis) sum += t->ref(i) * (t->ref(i) - 1) / 2;
    cout << sum << endl;
  }



  return 0;
}


Measured memory_bytes: 19072
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]


T = 1 # 高橋くんの最小得票数
A = 1 # 青木くんの最小得票数
ans = 2

for i in range(0, N):
    # m = max(math.ceil(T / TA[i][0]), math.ceil(A / TA[i][1]))
    #m = max(-(-T // TA[i][0]), -(-A // TA[i][1]))
    m = max(T // TA[i][0] + (T % TA[i][0] != 0), A // TA[i][1] + (A % TA[i][1] != 0))
    T = TA[i][0] * m
    A = TA[i][1] * m
    ans = T + A

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>

using ll = long long;
#define rep(i, n) for(int i = 0;i < (n);++i)

constexpr ll mod {1000000007};
constexpr ll INF {-1};

ll answer(const ll& N, const ll& K, const std::vector<ll>& a) {
  std::vector<std::vector<ll>> dp(N+1, std::vector<ll>(K+1, 0));
  dp[0][0] = 1;
  for (auto i = 0;i < N;++i) {
    std::vector<ll> sum(K+2, 0);
    for (auto j = 0;j <= K;++j) {
      (sum[j+1] = (sum[j]+dp[i][j])) %= mod;
    }
    for (auto j = 0;j <= K;++j) {
      (sum[j+1] = (sum[j]+dp[i][j])) %= mod;
      (dp[i+1][j] = (sum[j+1] - sum[std::max(j-a[i], 0LL)] + mod)) %= mod;
    }
  }
  return dp[N][K];
}

int main(int argc, char** argv) {
  ll N, K;
  std::cin >> N >> K;
  std::vector<ll> a(N);
  rep(i, N) std::cin >> a[i];
  std::cout << answer(N, K, a) << '\n';
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    auto n = s.size();
    bool yes = false;
    rep(i,n){
        if(s[i]=='7') yes = true;
    }

    if(yes) cout << "Yes" <<endl;
    else cout << "No" <<endl;

}

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

ll pref[300005][5], suff[300005][5];

int main(){

    int n; cin >> n;
    string s; cin >> s;
    s = "$" + s;

    for(int i = 1; i <= n; i++){
        pref[i][0] = pref[i-1][0];
        pref[i][1] = pref[i-1][1];
        pref[i][s[i] == 'E' ? 1 : 0]++;
    }

    for(int i = n; i >= 1; i--){
        suff[i][0] = suff[i+1][0];
        suff[i][1] = suff[i+1][1];
        suff[i][s[i] == 'E' ? 1 : 0]++;
    }

    ll res = 1e18;
    for(int i = 1; i <= n; i++)
        res = min(res, pref[i-1][0] + suff[i+1][1]);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 24156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

ll f(ll f3,ll f5,ll f7, ll val, ll n){
    ll sum=0;
    if(val>n)return 0;
    if(f3&&f5&&f7)sum++;
    sum+=f(f3+1,f5,f7,val*10+3,n);
     sum+=f(f3,f5+1,f7,val*10+5,n);
      sum+=f(f3,f5,f7+1,val*10+7,n);
      return sum;
}

int main(){
    ll n;cin>>n;
    cout<<f(0,0,0,0,n);
}

Measured memory_bytes: 256
from string import ascii_lowercase

n = int(input())
name = ''

while n != 0:
    name = ascii_lowercase[(26 if n % 26 == 0 else (n % 26)) - 1] + name
    n -= (26 if n % 26 == 0 else (n % 26))
    n //= 26

print(name)

Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N, P;
char S[MAX];

void naive() {
    LL ans = 0;
    unordered_map<LL, LL> dp;
    REP(i, N) {
        unordered_map<LL, LL> nxt;
        FORE(e, dp) {
            nxt[(e.first * 10 + (S[i] - '0')) % P] += e.second;
        }
        nxt[(S[i] - '0') % P]++;
        dp = nxt;

        if (dp.count(0)) {
            ans += dp[0];
        }
    }

    printf("%lld\n", ans);
}

void solve2() {
    LL ans = 0;
    REP(i, N) {
        if ((S[i] - '0') % 2 == 0) {
            ans += i + 1;
        }
    }
    cout << ans << endl;
}

void solve5() {
    LL ans = 0;
    REP(i, N) {
        const int d = (S[i] - '0');
        if (d == 0 || d == 5) {
            ans += i + 1;
        }
    }
    cout << ans << endl;
}

int main(void) {
    scanf("%d%d", &N, &P);
    scanf("%s", S);

    if (P == 2) {
        solve2();
        return 0;
    } else if (P == 5) {
        solve5();
        return 0;
    }

    reverse(S, S + N);

    VL v(N);
    VL v_acc(N + 1);
    {
        LL tmp = 1;
        REP(i, N) {
            v[i] = (S[i] - '0') * tmp % P;
            (tmp *= 10) %= P;
        }

        REP(i, N) {
            v_acc[i + 1] = (v_acc[i] + v[i]) % P;
        }
    }

    map<LL, LL> cnt;
    LL ans = 0;
    RREP(i, N + 1) {
        ans += cnt[v_acc[i]];
        cnt[v_acc[i]]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> student = new List<int[]>();
            int[] score;
            while (true)
            {
                //score = new int[3];
                score = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (score[0] == -1 && score[1] == -1 && score[2] == -1) break;
                else
                    student.Add(score);
            }

            string[] grade = new string[student.Count];
            for (int i = 0; i < student.Count; i++)
            {
                int m = student[i][0];
                int f = student[i][1];
                int r = student[i][2];

                if ((m == -1 || f == -1) || m+f < 30)
                    grade[i] = "F";
                else if (m+f >= 80)
                    grade[i] = "A";
                else if (m+f >= 65 && m+f < 80)
                    grade[i] = "B";
                else if (m+f >= 50 && m+f < 65)
                    grade[i] = "C";
                else if (m+f >= 30 && m+f < 50)
                {
                    if (r >= 50)
                        grade[i] = "C";
                    else
                        grade[i] = "D";
                }
            }

            foreach (string item in grade)
            {
                Console.WriteLine(item);
            }

        }
    }
}



Measured memory_bytes: 18396
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

stringstream ss;

// ([ (([( [ ] ) ( ) (( ))] )) ])
int main(){
    string s;
    while(getline(cin,s) && s != "."){
        string ss;
        stack<char> S;
        bool ok = true;
        for(int i=0;i<s.length();i++){
            switch(s[i]){
                case '(':
                    S.push(')');
                    break;
                case '[':
                    S.push(']');
                    break;
                case ')':
                    if(!S.empty() and S.top() == ')'){
                        S.pop();
                    }else{
                        ok = false;
                    }
                    break;
                case ']':
                    if(!S.empty() and S.top() == ']'){
                        S.pop();
                    }else{
                        ok = false;
                    }
                    break;
            }
        }
        if(ok && S.empty()) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

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

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

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

	int n; cin>>n;
	int sum=0;
	REP(i,n) {
		int l,r; cin>>l>>r; sum+=(r-l+1);
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}


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

    int n; cin >> n;
    map<string, ll> mp;
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        sort(s.begin(), s.end());
        ++mp[s];
    }

    ll ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        ans += (itr->second)*(itr->second-1)/2;
    }

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


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

const int maxn=2e5+10;

int n,tote,FIR[maxn],NEXT[maxn],TO[maxn];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

int dfs(int u,int F)
{
	int Ans=0;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==F) continue;
		Ans^=dfs(v,u)+1;
	}
	return Ans;
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,u,v;
	scanf("%d",&n);
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	puts(dfs(1,0)?"Alice":"Bob");
}


Measured memory_bytes: 6912
N = int(input())
dp = [float('inf') for i in range(N+1)]
dp[0] = 0
if N >= 6:
    dp[6] = 1
def below_power(n,a):
    "n以下になるa**xのxの最大値を求める"
    x = 0
    while n >= a**x:
        x += 1
    return x-1
nine = below_power(N,9)
six = below_power(N,6)
for i in range(six,0,-1):
    for j in range(N+1):
        if j - 6**i >= 0:
            dp[j] = min(dp[j],dp[j-6**i]+1)
        if j - 9**i >= 0:
            dp[j] = min(dp[j],dp[j-9**i]+1)       
ans = dp[N]
for i in range(1,min(N+1,6)):
    ans = min(ans,dp[N-i]+i)
print(ans)

Measured memory_bytes: 6296
a = int(input())# 500
b = int(input())# 100
c = int(input())# 50
x = int(input())# 合計

cou = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 *j+50*k == x:
                cou += 1
print(cou)


Measured memory_bytes: 3060
// Last Change: 07/30/2019 18:00:43.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;

  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256