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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector <int> J(B);
    for (int i=0; i<B; i++) {
        J.at(i) = (A*(i+1)) % B;
    }
    for (int j : J) {
        if (j==C) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
}

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


ll solve(ll n, vector<ll> heights) {
	vector<ll> dp(n + 1, 0);
	dp[0] = INT_MAX;
	for (int i = 2; i <= n; ++i) {
		dp[i] = min(dp[i - 1] + abs(heights[i - 1] - heights[i - 2]), dp[i - 2] + abs(heights[i - 1] - heights[i - 3]));
	}
	return dp[n];
}
int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ll n;
	cin >> n;
	vector<ll> heights(n, 0);
	for (int i = 0; i < n; ++i) {cin >> heights[i];}
	cout << solve(n, heights);
}

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

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

  int n;
  cin >> n;

  int G[101][101];
  int u, v, k;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      G[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      G[u][v] = 1;
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j != 1) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,t,k,flag=0;
    cin>>t;
    cin>>n>>k;
    for(int i=n;i<=k;i++)
    if(i%t==0){
        flag=1;
        break;
    }
    if(flag==1)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int cnt1,cnt2;
int main(){
	int x;
	for(int i=1;i<=3;i++){
		x=read();
		if(x==5) cnt1++;
		if(x==7) cnt2++; 
	}
	if(cnt1==2&&cnt2==1) puts("YES");
	else puts("NO");
	return 0;
}

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

int main(){
  constexpr int Ncon= 26;
  int D;
  cin >> D;

  vector<int> mass(Ncon);
  for(int i=0; i<Ncon; i++){
    cin >> mass.at(i);
  }

  vector<vector<int>> reward(Ncon);
  int buf;
  for(int d=1; d<=D; d++){
    for(int i=0; i<Ncon; i++){
      cin >> buf;
      reward.at(i).emplace_back(buf);
    }
  }
  
  vector<int> last(Ncon);

  int val= 0;
  int buf_i;
  for(int d=1; d<=D; d++){
    cin >> buf_i;
    buf_i--; // 1-indexed -> 0-indexed
    last.at(buf_i)= d;

    val+= reward.at(buf_i).at(d-1);
    for(int i=0; i<Ncon; i++){
      val-= mass.at(i)* (d- last.at(i));
    }

    cout << val << endl;
  }
}

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

int main() {
  ll n, d;
  cin >> n >> d;
  int cnt = 0;
  for (ll i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define INF 2000000000
#define MOD 1000000007

using namespace std;

int main() {
	int n;
	int arr[200];
	cin >> n;
	for (int i = 0; i < n * 2; i++) 
		cin >> arr[i];
	sort(arr, arr + n * 2);
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2) {
		ans += arr[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split(" "))
coord = {}

for i in range(H):
    for j, A in enumerate(map(int, input().split(" "))):
        coord[A] = (i, j)

magic = [0 for i in range(H * W + 1)]
for i in range(H * W + 1):
    if i + D <= H * W:
        magic[i + D] += magic[i]
        if i != 0:
            magic[i + D] += abs(coord[i][0] - coord[i + D][0]) + abs(coord[i][1] - coord[i + D][1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split(" "))
    print(magic[R] - magic[L])

Measured memory_bytes: 66812
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1000000007
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

int solve(){
    int n;
    cin>>n;
	ll a[n];
	ll sum[n+1];
	sum[0]=0;
	rep(i,0,n){
		cin>>a[i];
		sum[i+1]=(sum[i]+a[i])%mod;
	}
	ll mul=0;
	rep(i,0,n){
		ll val=(sum[n]-sum[i+1]);
		val+=mod;
		val%=mod;
		val*=a[i];
		val%=mod;
		mul+=val;
		mul%=mod;
	}
	cout<<mul<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool f, string yes, string no) {
	if (f)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

int num;
string s[100];
int vote[100];

int main() {

	int n; cin >> n;
	rep(n) {
		string t;
		cin >> t;
		if (i == 1) {
			s[1] = t;
			vote[1]++;
			num++;
			continue;
		}
		bool flag = true;
		for (int j = 1; j <= num; j++) {
			if (t == s[j]) {
				flag = false;
				vote[j]++;
			}
		}
		if (flag) {
			num++;
			s[num] = t;
			vote[num]++;
		}
	}
	int m; cin >> m;
	rep(m) {
		string t;
		cin >> t;
		for (int j = 1; j <= num; j++) {
			if (t == s[j])vote[j]--;
		}
	}
	int ans = 0;
	rep(num) {
		ans = max(ans, vote[i]);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n, m) for (int i = n; i < (int) m; i++)

int y, x, s;

bool init()
{
	cin >> x >> y >> s;
	if (s == 0) return false;
	return true;
}

int calc(int a, int b) {
	return a * (b + 100) / 100;
}

void solve()
{
	int ans = 0;
	reps(a, 1, s+1) {
		reps(b, 1, s+1) {
			if (calc(a, x) + calc(b, x) == s) {
				ans = max(ans, calc(a, y) + calc(b, y));
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	while (init()) {
		solve();
	}
}


Measured memory_bytes: 2992
# Your code here!
def pin(type=int):
    return map(type,input().split())
"""    
入力は以下の形式で標準入力から与えられる。

N  #これいるかなぁ
x1　y1 N=0として。
xN　yN
"""
N,M= pin()
if N==M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#ifdef __cplusplus
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

#define rep(l, end) for(ll l = 0; l < (end); ++l)
#define rep4(l, start, end, step) for (ll l = (start); l < (end); l += (step))
 
#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF_SHORT (1 << 30)
#define INF_SHORT_NEG (INF * -1)
#define INF (1LL << 62)
#define INF_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
ll StrLen(char *s) { for(ll ptr = 0;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, ll n) { ll l = StrLen(s); s[l - n + 1] = '\0'; return l - n; }

ll NumDigits(ll l){ char s[32]; return sprintf(s, "%lld", l); }

ll is1stAns = 1;
#ifdef __cplusplus
template <class T> 
void print(T t) { if (is1stAns) cout << t, is1stAns = 0; else cout << " " << t; }
#else
void printI(int    i) { if (is1stAns) printf(  "%d", i), is1stAns = 0; else printf(  " %d", i); }
void printL(ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void print (ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void printD(double d) { if (is1stAns) printf("%.9f", d), is1stAns = 0; else printf(" %.9f", d); }
void printC(char   c) { if (is1stAns) printf(  "%c", c), is1stAns = 0; else printf(  " %c", c); }
void printS(char  *s) { if (is1stAns) printf(  "%s", s), is1stAns = 0; else printf(  " %s", s); }
#endif

signed main()
{
#ifdef __cplusplus
    cout << fixed << setprecision(9);
#endif

    ll N; cin >> N;
    vector<ll> h(N + 9); rep(i, N) cin >> h[i];
    vector<ll> dp(N + 9, INF); // 大きな値での初期化は不要な気もするけど、まずは基本に忠実に……
    
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    rep4(i, 2, N, 1){
        ll next1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        ll next2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(next1, next2);
    }

    cout << dp[N - 1] << endl;

    return 0;
}


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

int const N=3e2+5, M=1e5+5, OO = 0x3f3f3f3f;


int n,a;
int cnt[5];
double ans;

double mem[N][N][N];
double solve(int cnt1, int cnt2, int cnt3)
{
    if((cnt1==0 && cnt2==0 && cnt3==0)||(cnt1+cnt2+cnt3>n))
        return 0;
    if(mem[cnt1][cnt2][cnt3]>=0)
        return mem[cnt1][cnt2][cnt3];
    double ret= 1.0*n/(cnt1+cnt2+cnt3);
    ret+=(cnt1>0) ? solve(cnt1-1,cnt2,cnt3)*(1.0*cnt1/(cnt1+cnt2+cnt3)) : 0;
    ret+=(cnt2>0) ? solve(cnt1+1,cnt2-1,cnt3)*(1.0*cnt2/(cnt1+cnt2+cnt3)) : 0;
    ret+=(cnt3>0) ? solve(cnt1,cnt2+1,cnt3-1)*(1.0*cnt3/(cnt1+cnt2+cnt3)) : 0;
    return mem[cnt1][cnt2][cnt3]=ret;
}






int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a);
        cnt[a]++;
    }
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            for(int k=0; k<=n; k++)
                mem[i][j][k]=-1.0;
    ans=solve(cnt[1],cnt[2],cnt[3]);
    cout<<fixed<<setprecision(15)<<ans<<endl;
    return 0;

}


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

int main(){
    int n;
    cin >> n;
    int apart[4][3][10] = {};
    for(int i = 0; i < n; i++){
        int p,q,r,s;
        cin >> p >> q >> r >> s;
        apart[p-1][q-1][r-1] += s;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << apart[i][j][k];
            }
            cout << endl;
        }
        if(i < 3){
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int n;
int h[1000005], memo[1000005];
int f(int n) {
    if(n == 1) {                        // bisa juga base case nya n = 0, f(0) harus tinggi, misal 1e9;
        return 0;
    }
    if(n == 2) {
        return abs(h[1] - h[2]);
    } 
    else if(memo[n] != -1) {
        return memo[n];
    }
    memo[n] = min(f(n - 1) + abs(h[n] - h[n - 1]), f(n - 2) + abs(h[n] - h[n - 2]));
    return memo[n];
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &h[i]);
    }
    memset(memo, -1, sizeof(memo));
    f(n);
    printf("%d\n", f(n));
}

Measured memory_bytes: 7936
#include <iostream>

int main()
{
    long large, small;
    long a, b, tmp;
    while (std::cin >> a >> b) {
        if (a < b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        large = a;
        small = b;
        while (small != 0) {
            tmp = small;
            small = large - (large / small) * small;
            large = tmp;
        }
        std::cout << large << " " << a * b / large << std::endl;
    }
    return 0;
}

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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 998244353;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;

int main(void){
    ll N,A,B,K;
    cin>>N>>A>>B>>K;
    modint res = 0;
    rep(a,N+1){
        if(A*a > K) break;
        if((K-A*a)%B == 0){
            ll b = (K-A*a)/B;
            res += modint::com(N,a) * modint::com(N,b);
        }
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N, P;

signed main()
{
  cin >> N >> P;

  vector<int> pp;

  for(int i = 2; i*i <= P; i++) {
    if(P%i == 0) {
      pp.push_back(i);
      pp.push_back(P/i);
    }
  }
  pp.push_back(P);

  reverse(begin(pp), end(pp));

  for(int p : pp) {
    int PP = P;
    bool flag = true;
    for(int n = 0; n < N; n++) {
      if(PP%p != 0) {
        flag = false;
        break;
      }
      PP /= p;
    }
    if(flag) {
      cout << p << endl;
      return 0;
    }
  }

  cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = list(in_all())

    if N == 0:
        if A[0] == 0:
            print(0)
            exit()
        else:
            print(-1)
            exit()

    if A[0] != 0:
        print(-1)
        exit()

    ans = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            if A[i + 1] - A[i] == 1:
                ans += 1
            else:
                print(-1)
                exit()
        elif A[i] >= A[i + 1]:
            ans += A[i + 1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29340
N = int(input())
A = [int(x) for x in input().split()]
x = sum(A)-A[0]
y = A[0]
ans = abs(x - y)
for i in range(1,N-1):
    x -= A[i]
    y += A[i]
    ans = min(ans, abs(x - y))
print(ans)

Measured memory_bytes: 24832
import sys
import math
import bisect
import heapq
import collections

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

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

int main (){
    string a, b, c;
    cin >> a >> b >> c;
    if(b[0]==a[(int)(a.length())-1] && b[(int)(b.length())-1]==c[0]){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter
n=input()
a=list(map(int,input().split()))
a=Counter(a)

f,t=[],[]
for k in a:
    if a[k]>=4:
        f.append(k)
    if a[k]>=2:
        t.append(k)
# print('f:',f)
# print('t:',t)
ans1=0
for ff in f:
    ans1=max(ans1,ff**2)
ans2=0
t.sort(reverse=True)
if len(t)>=2:
    ans2=t[0]*t[1]
print(max(ans1,ans2))



Measured memory_bytes: 18600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = INF, sub = INF;

  for (int i = -110; i < 110; i++) {
    int a = abs(i-x);
    bool ok = true;
    rep(j,n) {
        if (i == p[j]) ok = false;
    }
    if (ok) {
        if (sub > a) ans = i;
        sub = min(sub, a);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF
/*てんぷれぞーんしゅーりょー！*/
 
signed main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=c&&c<=b) puts("Yes\n");
    else puts("No\n");
}

Measured memory_bytes: 256
N = input()

K = int(input())

lis =  [ [ [0,0] for i in range(K+1) ] for j in range(len(N) + 1) ]

#桁/0以外が出た個数/密着フラグ

lis[0][0][0] = 1

for i in range(len(N)):

    nketa = int(N[i])

    for num in range(K):

        for flag in range(2):


            if num == 0 and flag == 0:

                lis[i+1][num+1][0] += lis[i][num][flag]
                lis[i+1][num+1][1] += (nketa - 1) * lis[i][num][flag]
                lis[i+1][num][1] += lis[i][num][flag]

            if num != K and flag == 0:

                if nketa == 0:
                    lis[i+1][num][0] += lis[i][num][flag]
                else:
                    lis[i+1][num+1][0] += lis[i][num][flag]
                    lis[i+1][num][1] += lis[i][num][flag]
                    lis[i+1][num+1][1] += lis[i][num][flag] * (nketa - 1)
                

            if num != K and flag == 1:

                lis[i+1][num+1][1] += 9 * lis[i][num][flag]
                lis[i+1][num][1] += lis[i][num][flag]

ans = 0

#print (lis)

for i in range(len(N) + 1):

    for j in range(2):

        ans += lis[i][K][j]

print (ans //2 )

Measured memory_bytes: 38384
def main():
  sum=0
  N,D=map(int,input().split())
  box=[]
  for i in range(N):
    box.append(list(map(int,input().split())))
  for i in range(N):
    for j in range(i+1,N):
    	sum+=check(box[i],box[j])
  print(sum)

def check(a,b):
  sum=0
  for i in range(len(a)):
    sum+=(a[i]-b[i])**2
  sum=sum**(1/2)
  if sum%1==0:
    return 1
  else:
    return 0
main()

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (ll)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

void solve(ll t) {
	ll n; cin >> n ;
	ll sm =0 ;
	for(ll i=1;i<=n;++i){
		if((i%3) && (i%5)) sm += i;
	}
	cout << sm ;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif 

    fast;
	ll t=1;
	// cin>>t;
	rep(t) {
		solve(i+1) ;
	}
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

}


Measured memory_bytes: 59660
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;

const ll INF = 100000000000;

int main() {FIN

	ll n, k, i, j;
	cin >> n >> k;
	vll hs(n), dp(n, INF);
	
	for (i = 0; i < n; i++)
		cin >> hs[i];

	dp[0] = 0;
	for (i = 0; i < n; i++) {
		for (j = 1; j <= k; j++) {
			if (j <= i)
				dp[i] = min(dp[i], dp[i - j] + abs(hs[i] - hs[i - j]));
			else
				break;
		}
	}

	cout << dp[n - 1] << "\n";

	return 0;
}

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

int main(){

  int hoge;

  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      hoge = i * j;
      cout<<i<<"x"<<j<<"="<<hoge<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1116
def nCk(_n,_k):
  return fact[_n]*pow(fact[_k],m-2,m)*pow(fact[_n-_k],m-2,m)%m

def main():
  for i in range(1,2001):
    fact[i]=fact[i-1]*i
  n,k=map(int,input().split())
  for i in range(1,k+1):
    print(nCk(n-k+1,i)*nCk(k-1,i-1)%m if n-k>=i-1 else 0)

if __name__=='__main__':
  fact,m=[1]*2005,10**9+7
  main()

Measured memory_bytes: 11456
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll n;cin>>n;
	ll u_mid = (int)sqrt(n);
	ll l_mid = u_mid;
	ll ans = 0LL;
	while(true){
		if(n%u_mid==0LL){ans = u_mid+n/u_mid; break;}
		if(n%l_mid==0LL){ans = l_mid+n/l_mid; break;}
		++u_mid; --l_mid;
	}
	cout<<ans-2LL<<endl; return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    long N, K;
    cin >> N >> K;

    vl counts(100000 + 1, 0);

    long a, b;
    for (long i = 0; i < N; ++i) {
        cin >> a >> b;
        counts[a] += b;
    }

    long count = 0;
    for (long i = 0; i < counts.size(); ++i) {
        count += counts[i];
        if (K <= count) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

bool dp[1001][1001];
int dp2[1001];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint c(n), w(n);
  rep(i, n) cin >> c[i] >> w[i];
  vint sum(n+1, 0);
  rep(i, n) sum[i+1] = sum[i]+w[i];

  auto get = [&](int i, int j) {
    return sum[j]-sum[i];
  };

  rep(i, n) dp[i][i+1] = true;

  reps(len, 2, n+1) {
    rep(i, n) {
      int j = i+len;
      if(j > n) continue;
      //cout<<i<<" "<<j<<" "<<get(i, j)<<" "<<get(i+1, j)<<endl;
      if(dp[i][j-1] && c[j-1] >= get(i, j-1)) dp[i][j] = true;
      if(dp[i+1][j] && c[i] >= get(i+1, j)) dp[i][j] = true;
    }
  }

  fill(dp2, dp2+1001, inf);
  dp2[0] = 0;
  rep(i, n) {
    reps(j, i+1, n+1) {
      if(dp[i][j]) chmin(dp2[j], dp2[i]+1);
    }
  }
  cout << dp2[n] << endl;

  return 0;
}



Measured memory_bytes: 4236
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string s;
int n;

int main()
{
    cin >> s;
    n = s.size();
    int nog = 0;
    int nop = 0;
    rrep(i,n-1){
        if(s[i] == 'g') nog++;
        else nop++;
    }
    int nog_m = (n-1)/2;
    int nop_m = (n-1) - nog_m;
    int ans = min(nog, nop_m) - min(nop, nog_m);
    if(s[0] == 'p') ans--;
    cout << ans << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll x;
  cin >> x;
  
  cout << x/3 << endl;
}

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

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

  int n, k;
  cin >> n >> k;
  
  vector<int> x(n);
  for(int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  
  int ans = 0;
  for(int xi: x){
    int d1 = xi * 2;
    int d2 = abs(xi - k) * 2;
    
    ans += min(d1, d2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	a := make(map[int]struct{}, n)

	for i := 0; i < n; i++ {
		k := nextInt()
		if _, ok := a[k]; !ok {
			a[k] = struct{}{}
		} else {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}


Measured memory_bytes: 7680
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long remove_set(int from, int diff){
    return from ^ (from & diff);
}
int dp[4500];
int a[1000];
int bit_sets[1000];
int main(){ 
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int b;
        cin >> a[i] >> b;
        for(int j = 0; j < b; j++){
            int c;
            cin >> c;
            bit_sets[i] = bit_sets[i] | (1 << (c - 1));
        }
    }
    for(int i = 0; i < (1 << N); i++){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int bit_set = 0; bit_set < (1 << N); bit_set++){
        for(int i = 0; i < M; i++){
            int before = remove_set(bit_set, bit_sets[i]);
            if(dp[before] != INT_MAX){
                dp[bit_set] = min(dp[bit_set], a[i] + dp[before]);
            }
        }
    }

    if(dp[(1 << N) - 1] == INT_MAX){
        cout << -1 << endl;
    } else {
        cout << dp[(1 << N) - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char stdin[] = br.readLine().toCharArray();
		for (int i=0; i<stdin.length; i++){
			if(stdin[i] > 'C'){
				stdin[i] -= 3;
			}else{
				stdin[i] += 23;
			}
		}
		System.out.println(String.valueOf(stdin));
	}
}

Measured memory_bytes: 24264
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int h,w,k;
    string s[10];
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int ans=mod;
    for(int S=0;S<1<<h-1;S++){
        int tmp[10];
        tmp[0]=0;
        for(int i=0;i<h-1;i++)
            tmp[i+1]=tmp[i]+(S>>i&1);
        int ans2=tmp[h-1];
        int tmp2[10]={};
        for(int i=0;i<w;i++){
            for(int j=0;j<h;j++)
                if(s[j][i]=='1')
                    tmp2[tmp[j]]++;
            bool ok=1;
            for(int j=0;j<=tmp[h-1];j++)
                if(tmp2[j]>k)
                    ok=0;
            if(ok)
                continue;
            ans2++;
            for(int j=0;j<=tmp[h-1];j++)
                tmp2[j]=0;
            for(int j=0;j<h;j++)
                if(s[j][i]=='1')
                    tmp2[tmp[j]]++;
            ok=1;
            for(int j=0;j<=tmp[h-1];j++)
                if(tmp2[j]>k)
                    ok=0;
            if(!ok){
                ans2=mod;
                break;
            }
        }
        ans=min(ans,ans2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
int L[100000];
int R[100000];
int main() {
	int N;
	cin >> N;
	int maxL = 0, minR = 1 << 30;
	int maxLen = 0;
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
		R[i]++;
		maxL = max(maxL, L[i]);
		minR = min(minR, R[i]);
		maxLen = max(maxLen, R[i] - L[i]);
	}
	int ans = maxLen + max(minR - maxL, 0);
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		int a = max(R[i] - maxL, 0);
		int b = max(minR - L[i], 0);
		vec.emplace_back(-a, b);
	}
	sort(vec.begin(), vec.end());
	int minB = vec.back().second;
	for (int i = vec.size() - 2; i >= 0; i--) {
		ans = max(ans, -vec[i].first + minB);
		minB = min(minB, vec[i].second);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2168
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut a:i64=2;
    let mut b:i64=1;
    let mut c:i64;
    for i in 0..read::<i32>(){
        c=b;
        b=a+b;
        a=c;
    }
    println!("{}",a)
}


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

int main()
{

	int n;
	while (cin >> n) {
		int C = 0;
		bool prime[1000000] = { 0 };
		// 0????´???°
		prime[1] = 1;
		prime[2] = 0;

		for (int j = 2; j * j <= n; j++) {
			if (prime[j] ==0) {
				for (int k = 2; k*j <= n; k++) {
					prime[j*k] = 1;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			if (prime[i] == 0)
				C++;
		}
		cout << C << endl;
	}
	return 0;
}

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

const int N = 200005;
int arr[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    int bg = 1, en = 1000000001;
    while (bg < en) {
        int mid = (bg + en) / 2;
        long long kk = 0;
        for (int i = 0; i < n; i++) {
            kk += (arr[i] + mid - 1) / mid;
        }
        if (kk <= k + n) en = mid;
        else bg = mid + 1;
    }
    cout << bg << '\n';
}

Measured memory_bytes: 4280
S = input()
time = list(map(int, S.split('/')))

if time[0] < 2019:
    print('Heisei')
elif time[0] > 2019:
    print('TBD')
else:
    if time[1] < 4:
        print('Heisei')
    elif time[1] > 4:
        print('TBD')
    else:
        if time[2] <= 30:
            print('Heisei')
        else:
            print('TBD')


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n; std::cin >> n;
	int cur = 1;
	rep(i, n) {
		int ai; std::cin >> ai;
		if (ai == cur)
			cur++;
	}
	if (cur == 1)
		std::cout << -1 << "\n";
	else
		std::cout << n - (cur - 1) << "\n";
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(a+b > c+d)
        cout << "Left" << endl;
    else if(a+b < c+d)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    p=m+f
    if m+f+r==-3:
        break
    if m==-1 or f==-1:
        print("F")
    elif p>=80:
        print("A")
    elif 65<=p and p<80:
        print("B")
    elif 50<=p and p<65:
        print("C")
    elif 30<=p and p<50:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7596
#include<cstdio>
#include<iostream>

using namespace std;

main(){

  int w[10],k[10],temp;

  for(int i=0;i<10;i++){
    cin >> w[i];
  }

  for(int i=0;i<10;i++){
    cin >> k[i];
  }

  for(int i=0;i<9;i++){
    for(int j=9;j>i;j--){
      if(w[j]>w[j-1]){
	temp=w[j];
	w[j]=w[j-1];
	w[j-1]=temp;
      }
      if(k[j]>k[j-1]){
	temp=k[j];
	k[j]=k[j-1];
	k[j-1]=temp;
      }
    }
  }

  cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;

  return 0;
}

Measured memory_bytes: 1164
s = input()

lis = ['dream', 'dreamer', 'erase', 'eraser']
rev_lis = []

for e in lis:
	rev_lis.append(e[::-1])

rev_s = s[::-1]

while True:
	if rev_s == '':
		print('YES')
		exit()
	tmp1 = rev_s[0:5]
	tmp2 = rev_s[0:6]
	tmp3 = rev_s[0:7]
	if tmp1 in rev_lis:
		rev_s = rev_s[5:]
	elif tmp2 in rev_lis:
		rev_s = rev_s[6:]
	elif tmp3 in rev_lis:
		rev_s = rev_s[7:]
	else:
		print('NO')
		exit()



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

int n, m, p;
int x[100];

int main() {
	while (cin >> n >> m >> p) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> x[i];
		m--;
		
		int sumX = 0;
		for (int i = 0; i < n; i++) sumX += x[i];
		
		if (x[m] == 0) {
			cout << 0 << endl;
		}
		else {
			cout << sumX * (100 - p) * 100 / (100 * x[m]) << endl;
		}
	}
	return 0;
}

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

int main(){
  long long n;
  cin>>n;
  vector<long long>x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  reverse(x.begin(),x.end());
  long long ans=0;
  for(int j=0;j<n-1;j++){
    int t=(j+1)/2;
    ans+=x[t];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4816
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void) {
	cin.tie(0);
	//ブルー不可法?
	llint n,D,ans=0,i;cin>>n>>D;
	vector<llint>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	vector<int>uni(n);
	for(i=0;i<n;i++){uni[i]=i;}
	vector<int>ran(n,1);
	while(-1){
		pair<llint,int>saf=mp(a[0],uni[0]);
		pair<llint,int>sac=mp(big,-1);
		vector<tuple<llint,int,int>>go(n,mt(big,-1,-1));
		for(i=1;i<n;i++){
			pair<llint,int>ter=saf;
			if(saf.sec==uni[i]){ter=sac;}
			mineq(go[uni[i]],mt(ter.fir+a[i]+D*i,ter.sec,uni[i]));
			if(uni[i]==saf.sec){mineq(saf,mp(a[i]-D*i,uni[i]));}
			else{mineq(sac,mp(a[i]-D*i,uni[i]));if(saf>sac){swap(saf,sac);}}
		}
		saf=mp(a[n-1]+D*(n-1),uni[n-1]);
		sac=mp(big,-1);
		for(i=n-2;i>=0;i--){
			pair<llint,int>ter=saf;
			if(saf.sec==uni[i]){ter=sac;}
			mineq(go[uni[i]],mt(ter.fir+a[i]-D*i,ter.sec,uni[i]));
			//if(i==n-2){cerr<<"de"<<ter.fir+a[i]-D*i<<endl;}
			if(uni[i]==saf.sec){mineq(saf,mp(a[i]+D*i,uni[i]));}
			else{mineq(sac,mp(a[i]+D*i,uni[i]));if(saf>sac){swap(saf,sac);}}
		}
		
		for(auto it:go){
			llint cost,x,y;tie(cost,x,y)=it;
			if(cost>=big){continue;}
			while(x!=uni[x]){x=uni[x];}
			while(y!=uni[y]){y=uni[y];}
			
			if(x==y){continue;}
			//cerr<<"c,x,y"<<cost<<","<<x<<","<<y<<endl;
			if(ran[x]<ran[y]){swap(x,y);}
			uni[y]=x;ran[x]+=ran[y];ans+=cost;
		}
		for(i=0;i<n;i++){
			int x=i;
			while(x!=uni[x]){x=uni[x];}
			uni[i]=x;
		}
		bool can=1;
		for(i=1;i<n;i++){
			if(uni[i]!=uni[0]){can=0;break;}}
		if(can){break;}
		//cerr<<"d";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6616
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    // System.out.println(S);
    if(s.equals("ABC")){
    System.out.println("ARC");  
    }else{
    System.out.println("ABC");  
    }

  }
}





Measured memory_bytes: 35688
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int64 ret = 1LL << 60;
  // ABC
  int L = m / 3, R = (m + 2) / 3;
  ret = min((int64)(R - L) * n, ret);
  // A
  // B
  // C
  L = n / 3, R = (n + 2) / 3;
  ret = min((int64)(R - L) * m, ret);

  // AB
  // CC
  int t = n / 3;
  for (int k = 0; k < 2; ++k) {
    int L = m / 2, R = (m + 1) / 2;
    vector<int64> a = {(int64)L * (n - k - t), (int64)R * (n - k - t), (int64)(k + t) * m};
    sort(a.begin(), a.end());
    ret = min(ret, a[2] - a[0]);
  }

  // AC
  // BC
  t = m / 3;
  for (int k = 0; k < 2; ++k) {
    int L = n / 2, R = (n + 1) / 2;
    vector<int64> a = {(int64)L * (m - k - t), (int64)R * (m - k - t), (int64)(k + t) * n};
    sort(a.begin(), a.end());
    ret = min(ret, a[2] - a[0]);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
# from scipy.special import comb
# from math import factorial
# from operator import mul
# from functools import reduce

# def combination(n, r):
#     r = min(n - r, r)
#     if r == 0:
#         return 1
#     over = reduce(mul, range(n, n - r, -1))
#     under = reduce(mul, range(1, r + 1))
#     return over // under


def combination(n, r, mod=10 ** 9 + 7):
    n1, r = n + 1, min(r, n - r)
    numerator = denominator = 1
    for i in range(1, r + 1):
        numerator = numerator * (n1 - i) % mod
        denominator = denominator * i % mod

    return numerator * pow(denominator, mod - 2, mod) % mod


x, y = map(int, input().split())

if (x + y) % 3 != 0 or (x > 2 * y or y > 2 * x):
    print(0)
else:
    # (+1, +2) n
    # (+2, +1) m
    # n + 2m = x
    # 2n + m = y
    m = (2 * x - y) // 3
    n = (2 * y - x) // 3
    # score = factorial(n + m) // factorial(n) // factorial(m)
    # score = comb(n + m, n, exact=True)
    score = combination(n + m, n)
    print(score)

Measured memory_bytes: 3064
n = int(input())
h = list(map(int,input().split()))
ans = 0
maxi = 0
for i in range(1,n):
    if h[i-1] >= h[i]:
        ans += 1
    else:
        maxi = max(ans,maxi)
        ans = 0
print(max(maxi,ans))

Measured memory_bytes: 15020