akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
  int x;
  cin >> x;
  if(400<=x && x <= 599) cout << 8 << endl;
  else if (600<= x && x <= 799) cout << 7 << endl;
  else if( 800 <= x && x <= 999) cout << 6 <<endl;
  else if(1000<= x && x<=1199) cout << 5 << endl;
  else if(1200<=x && x <= 1399) cout << 4 << endl;
  else if(1400<=x && x<=1599) cout << 3 << endl;
  else if(1600<= x && x <= 1799) cout << 2 << endl;
  else cout << 1 << endl;
}
  
  

Measured memory_bytes: 3632
mod = 10**9+7
N, K = map(int, input().split())
cnt = [0]*(K+1)
ans = 0
for x in range(K, 1, -1):
    c = pow(K//x, N, mod)
    a = 2
    while a*x <= K:
        c -= cnt[a*x]
        a += 1
    ans = (ans+x*c%mod)%mod
    cnt[x] = c
ans = (ans+pow(K, N, mod)-sum(cnt))%mod
print(ans)


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

int main() {
	int n, a;
	string ans="No";
	cin >> n;
	if (n > 81) {
		ans == "No";
	}
	else {
		for (int i = 1; i < 10; i++) {
			a = n % i;
			if (a == 0) {
				a = n / i;
				if (a <= 9)ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    l, r, d = input_to_int_map()
    cnt = 0
    for i in range(l, r + 1):
        if i % d == 0:
            cnt += 1

    return cnt

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9124
w = [[''],['.',',','!','?',' '], ['a','b','c'], ['d','e','f'], ['g','h','i'], ['j','k','l'], ['m','n','o'], ['p','q','r','s'], ['t','u','v'], ['w','x','y','z']]
n = int(input())
for _ in range(n):
    buff = ''
    s = input()
    push = 0
    times = 0
    for c in s:
        if int(c) == 0:
            buff += w[push][times%len(w[push])]
        if int(c) == push:
            times += 1
        else:
            push = int(c)
            times = 0
    print(buff)

Measured memory_bytes: 6724
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int[] a=new int[n];
    Arrays.fill(a,-1);
    for(int i=0;i<m;i++){
      int s=sc.nextInt();
      int c=sc.nextInt();
      if(a[s-1]!=-1&&a[s-1]!=c){
        System.out.println(-1);
        return;
      }else{
        a[s-1]=c;
      }
    }
    if(n==1){
      if(a[0]==-1){
        a[0]=0;
      }
      System.out.println(a[0]);
    }else{
      if(a[0]==0){
        System.out.println(-1);
        return;
      }
      if(a[0]==-1){
        a[0]=1;
      }
      if(n>1&&a[1]==-1){
        a[1]=0;
      }
      if(n>2&&a[2]==-1){
        a[2]=0;
      }
      int ans=0;
      for(int i=0;i<n;i++){
        ans*=10;
        ans+=a[i];
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 23764
n = int(input())
sp = []
for i in range(n):
    s, p = input().split()
    sp.append([s, int(p)])

sorted_sp = sorted(sp, key=lambda x: x[1], reverse=True)
sorted_sp = sorted(sorted_sp, key=lambda x: x[0])

for i in range(n):
    print(sp.index(sorted_sp[i]) + 1)


Measured memory_bytes: 3060
n = int(input())
dp = [False] * (n + 1)
dp[-1] = True

for i in list(range(n + 1))[::-1]:
  if (i + 4) <= n:
    if dp[i + 4] == True:
      dp[i] = True
  if (i + 7) <= n:
    if dp[i + 7] == True:
      dp[i] = True

if dp[0] == True:
  print('Yes')
else: 
  print('No')

Measured memory_bytes: 3064
N, T = map(int, input().split())
A = list(map(int, input().split()))
mi, ma = float("inf"), 0
d = 0
cnt = 0
for a in A:
    mi = min(mi, a)
    if mi+d < a:
        d = a-mi
        cnt = 1
    elif mi+d == a:
        cnt += 1
print(cnt)


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

int main() {

  int a, b, c;
  cin >> a >> b >> c;

  string ret = "No";
  if ((a == b && b != c) || (a == c && a != b) || (b == c && a != b)) {
    ret = "Yes";
  }

  cout << ret << endl;
}

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

int main(void) {
    int a, b, c; cin >> a >> b >> c;
    int ans;
    if (a > b) {
        if (a > c) {
            ans = 10 * a + b + c;
        }
        else {
            ans = 10 * c + b + a;
        }
    }
    else {
        if (b > c) {
            ans = 10 * b + a + c;
        }
        else {
            ans = 10 * c + b + a;
        }
    }
    cout << ans;
    return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int h, n;
	cin >> h >> n;
	int a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	int sum = 0;
	for(int i = 0; i < n; ++i)
		sum += a[i];
	if(sum >= h) cout << "Yes";
	else cout << "No";

	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ull sum = 1;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        sum *= i;
    }
    OP(sum)
    return 0;
}


Measured memory_bytes: 3008
import math
from math import gcd

K = int(input())
result = 0

for i in range(1, K+1):
    result += i

for i in range(1, K):
    for j in range(i+1, K+1):
        result += gcd(i,j) * 6

if K >= 3:
    for i in range(1, K-1):
        for j in range(i+1, K):
            for k in range(j+1, K+1):
                result += gcd(gcd(i,j),k) * 6

print(result)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;

//=============================================================
//=============================================================

/*
 */

int L, R;
const int mod = 2019;
void solve()
{
    //prime.
    int dr = (R - L);
    while (dr > mod*2) dr -= mod; 
    int l = L;
    int r = R % mod;
    l = L % mod;

    int ans = 2025;
    // debug(dr);
    // debug(l);
    // debug(r);
    for (int i = l; i < l+dr; ++i)
    {
       // debug(i);
        int ii = i;
        ii %= mod; 
        for (int j = i+1; j <= l+dr; ++j)
        {
           // debug(j);
            int jj = j;
            jj %= mod;
            ans = min(ans, (ii * jj) % mod);
        }
    }
    cout << ans << endl;

    // L to r
}
signed main()
{
    cin >> L >> R;

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    vvi vx(n),vy(n);
    ll x,y;
    rep(i,n){
        cin >> a.at(i);
        rep(j,a.at(i)){
            cin >> x >> y;
            vx.at(i).push_back(x);
            vy.at(i).push_back(y);
        }
    }
    // i番目の人が本当として、矛盾がないかを確かめる
    ll res = 0;
    rep(i,1<<n){
        vi ass(n);
        bool tres = true;
        rep(j,n) ass.at(j) = i>>j&1;
        rep(k,n){
            if(!ass.at(k)) continue;
            rep(l,a.at(k)){
                if(vy.at(k).at(l)){
                    if(!ass.at(vx.at(k).at(l)-1)) tres = false;
                }else{
                    if(ass.at(vx.at(k).at(l)-1)) tres = false;
                }
            }
        }
        if(tres) {
            rep(j,n) cerr << ass.at(j) << " ";
            cerr << endl;
        }
        ll countTrue = 0;
        if(tres) rep(j,n) if(ass.at(j)) countTrue++;
        res = max(res, countTrue);
    }
    cout << res << endl;
}

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

class Cell{
    Cell prev;
    Cell next;
    int value;

    Cell(){ // head生成用のコンストラクタ
        this.prev = this;
        this.next = this;
    }

    Cell(int val){
        value = val;
        this.prev = null;
        this.next = null;
    }
}

class Main{
    static Cell head = new Cell();

    static void insert(int value){
        Cell newone = new Cell(value);
        newone.next = head.next;
        newone.prev = head;
        newone.next.prev = newone;
        head.next = newone;
    }

    static void delete(int value){
        Cell run = head.next;
        while(run != head){
            if(run.value == value){
                run.prev.next = run.next;
                run.next.prev = run.prev;
                run.prev = null;
                run.next = null;
                return;
            }
            run = run.next;
        }
    }

    static void deleteFirst(){
        delete(head.next.value);
    }

    static void deleteLast(){
        Cell del = head.prev;
        head.prev = del.prev;
        del.prev.next = head;

        del.prev = null;
        del.next = null;
    }

    static void show(){
        Cell run = head.next;
        if(run == head){
            System.out.println();
            return;
        }
        StringBuilder sb = new StringBuilder();
        boolean format = true;
        while(run != head){
            if(format){
                sb.append(run.value);
                format = false;
            }else{
                sb.append(" " + run.value);
            }
            run = run.next;
        }
        System.out.println(sb);
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        for(int i = 0; i < n; i++){
            String[] input = br.readLine().split(" ");

            switch(input[0]){
                case "insert":
                    insert(Integer.parseInt(input[1]));
                    break;
                case "delete":
                    delete(Integer.parseInt(input[1]));
                    break;
                case "deleteFirst":
                    deleteFirst();
                    break;
                case "deleteLast":
                    deleteLast();
                    break;
            }
        }
        show();
    }
}





Measured memory_bytes: 186500
#include<iostream>

using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0; i<m; i++){
        cin>>a[i];
    }
    int s=0;
    for(int i=0;i<m;i++){
        s += a[i];
    }
    if(s > n){
        cout<<-1<<endl;
    }
    else{
        cout<< n - s <<endl;
    }

    return 0;
}

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

int main(){
    long double x1, y1, x2, y2, distance;
    scanf("%Lf %Lf %Lf %Lf", &x1, &y1, &x2, &y2);

    distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

    printf("%Lf\n", distance);
    return 0;
}


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

using namespace std;

int q_sort(int d[],int left,int right){
	if(left >= right) return 0;
	int pipot = d[(left+right)/2], l = left, r = right, tmp;
	while(l<r){
		while(d[l] < pipot) l++;
		while(d[r] > pipot) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}

int main(void)
{
	int n; cin>>n;
	int w = 2 * n;
	int L[w];
	for(int i = 0; i < 2*n; i++) cin>>L[i];
	q_sort(L,0,2*n-1);
	for(int i = 0; i < 2*n; i++){
		//cout<<" i = "<<i<<", L[i] = "<<L[i]<<endl;
	}
	long long ans = 0;
	for(int i = 0; i < 2*n; i+=2){
		ans+=L[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL INF = 1E18;
constexpr int N = 1E5;
int n, m;
struct Node {
    int cnt;
    LL mn, lazy;
    vector<tuple<int, int, int>> e;
} t[4 * N];
void build(int p, int l, int r) {
    t[p].cnt = r - l;
    t[p].lazy = INF;
    if (r - l == 1) {
        t[p].mn = l == 0 ? 0 : INF;
        return;
    }
    int mid = (l + r) / 2;
    build(2 * p, l, mid);
    build(2 * p + 1, mid, r);
    t[p].mn = min(t[2 * p].mn, t[2 * p + 1].mn);
}
void addEdge(int p, int l, int r, int x, int y, int c) {
    if (l >= y || r <= x)
        return;
    if (l >= x && r <= y) {
        t[p].e.emplace_back(x, y, c);
        return;
    }
    int mid = (l + r) / 2;
    addEdge(2 * p, l, mid, x, y, c);
    addEdge(2 * p + 1, mid, r, x, y, c);
}
void pushdown(int p) {
    if (t[2 * p].cnt != 0) {
        t[2 * p].lazy = min(t[2 * p].lazy, t[p].lazy);
        t[2 * p].mn = min(t[2 * p].mn, t[p].lazy);
    }
    if (t[2 * p + 1].cnt != 0) {
        t[2 * p + 1].lazy = min(t[2 * p + 1].lazy, t[p].lazy);
        t[2 * p + 1].mn = min(t[2 * p + 1].mn, t[p].lazy);
    }
}
pair<int, LL> getMin(int p, int l, int r) {
    --t[p].cnt;
    if (r - l == 1) {
        LL tmp = t[p].mn;
        t[p].mn = INF + 1;
        return {l, tmp};
    }
    int mid = (l + r) / 2;
    pushdown(p);
    pair<int, LL> result;
    if (t[2 * p].mn == t[p].mn) {
        result = getMin(2 * p, l, mid);
    } else {
        result = getMin(2 * p + 1, mid, r);
    }
    t[p].mn = min(t[2 * p].mn, t[2 * p + 1].mn);
    return result;
}
void rangeCover(int p, int l, int r, int x, int y, LL d) {
    if (t[p].cnt == 0)
        return;
    if (l >= y || r <= x)
        return;
    if (l >= x && r <= y) {
        t[p].lazy = min(t[p].lazy, d);
        t[p].mn = min(t[p].mn, d);
        return;
    }
    int mid = (l + r) / 2;
    pushdown(p);
    rangeCover(2 * p, l, mid, x, y, d);
    rangeCover(2 * p + 1, mid, r, x, y, d);
    t[p].mn = min(t[2 * p].mn, t[2 * p + 1].mn);
}
void expand(int p, int l, int r, int u, LL d) {
    for (auto _e : t[p].e) {
        int l, r, c;
        tie(l, r, c) = _e;
        rangeCover(1, 0, n, l, r, c + d);
    }
    t[p].e.clear();
    if (r - l == 1)
        return;
    int mid = (l + r) / 2;
    if (u < mid)
        expand(2 * p, l, mid, u, d);
    else
        expand(2 * p + 1, mid, r, u, d);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    build(1, 0, n);
    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        addEdge(1, 0, n, --l, r, c);
    }
    for (int i = 0; i < n; ++i) {
        int u;
        LL d;
        tie(u, d) = getMin(1, 0, n);
        if (u == n - 1) {
            cout << (d == INF ? -1 : d) << endl;
            return 0;
        }
        expand(1, 0, n, u, d);
    }
    return 0;
} 

Measured memory_bytes: 42480
#include <iostream>
#include <array>
#include <cmath>

using namespace std;

bool IsPrime(int n) {
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int len;
    cin >> len;
    array<int, 10000> src;

    for (int i = 0; i < len; i++) {
        cin >> src[i];
    }
    
    int primeNumCount = 0;
    for (int i = 0; i < len; i++) {
        if (IsPrime(src[i])) primeNumCount++;
    }

    cout << primeNumCount << endl;

    return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
#include<stdlib.h>

int main(){
    int n;
    int a[20+5];
    int b[20+5];
    int c[20+5];
    int score=0;

    scanf("%d", &n);
    
    for(int i=1; i<=n; i++){
        scanf("%d", &a[i]);
    }
    for(int i=1; i<=n; i++){
        scanf("%d", &b[i]);
    }
    for(int i=1; i<n; i++){
        scanf("%d", &c[i]);
    }

    for(int i=1; i<=n; i++){
        score+=b[a[i]];
        // printf("%d\n", score);
        if(a[i]-a[i-1]==1){
            score+=c[a[i-1]];
            // printf("%d %d\n", i, score);
        }
    }

    printf("%d\n", score);
    return 0;
}

Measured memory_bytes: 128
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	int a, b;

	cin >> a >> b;

	if (a == 1) { a = 14; }
	if (b == 1) { b = 14; }

	if (a == b) {
		cout << "Draw" << endl;
	}
	else {
		if (a > b) { cout << "Alice" << endl; }
		if (b > a) { cout << "Bob" << endl; }
	}


	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];



signed main(){
    string s;cin>>s;
    N=s.size();
    rep(i,N)A[i]=s[i]-'0';

    int ans=9;

    chmin(ans,*max_element(A,A+N)-*min_element(A,A+N));

    int ma=0,mi=INT_MAX;
    for(int i=0;i<N;i++){
        if(A[i]==1&&i+1<N){
            chmax(ma,A[i+1]+10);
            i++;
        }
        else{
            chmin(mi,A[i]);
        }
    }

    if(ma!=0&&mi!=INT_MAX)chmin(ans,ma-mi);


    for(int i=2;i<N;i++){
        if(N%i)continue;
        string mi(1,'9'+1);
        string ma(1,'0'-1);

        for(int j=0;j<N;j+=i){
            string s;
            for(int k=0;k<i;k++)s+=(char)(A[j+k]+'0');
            if(mi>s)mi=s;
            if(ma<s)ma=s;
        }

        if(mi.substr(0,i-2)!=ma.substr(0,i-2))continue;
        int x=(mi[i-2]-'0')*10+mi[i-1]-'0';
        int y=(ma[i-2]-'0')*10+ma[i-1]-'0';
        chmin(ans,y-x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4040
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer x;
   
  x = nil->next;
   
  while(x != nil && x->key != key){
    x = x->next;
  }
  return x;
   
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
 
}
 
void deleteFirst(){
  deleteNode(nil->next);
}
 
void deleteLast(){
  deleteNode(nil->prev);
}
 
void delete(int key){
  NodePointer x;
 
  if((x = listSearch(key))!=NULL){
 
    deleteNode(x);
  }
  
}
 
 
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
 
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
   
}
 
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
 
  printList();
  return 0;
}

Measured memory_bytes: 34976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,k,h[200001];
    cin>>n>>k;
    rep(i,n) cin>>h[i];
    int ans=0;
    rep(i,n) if(h[i]>=k) ans++;
    cout<<ans;
}

Measured memory_bytes: 640
n,w=map(int,input().split())
weight=[]
value=[]
for _ in range(n):
    ww,vv=map(int,input().split())
    weight.append(ww)
    value.append(vv)
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(0,n):
    for w_sum in range(w+1):
        if w_sum >= weight[i]:
            dp[i+1][w_sum]=max(dp[i+1][w_sum],dp[i][w_sum-weight[i]]+value[i])
        dp[i+1][w_sum]=max(dp[i+1][w_sum],dp[i][w_sum])
print(dp[n][w])


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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int N = 100005;
int n, m, height[N];
vector<int> graph[N];
bool shorter[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
        cin >> height[i];
    }
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(height[a] > height[b])
        {
            shorter[b] = true;
        }
        else if(height[b] > height[a])
        {
            shorter[a] = true;
        }
        else if(height[a] == height[b])
        {
            shorter[a] = shorter[b] = true;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        //cout << i << " " << height[i]  << " " << shorter[i] << "\n";
        ans += !shorter[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6484
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<vector<ll> >dp(n+1,vector<ll>(k+1));
    dp[0][0]=1;
    dp[0][1]=-1;
    rep(i,n){
        REP(j,1,k+1){
            dp[i][j]=dp[i][j-1]+dp[i][j];
            dp[i][j]%=inf;
        }
        rep(j,k+1){
            if(dp[i][j]<0)dp[i][j]+=inf;
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=inf;
            if(j+a[i]+1<=k){
                dp[i+1][j+a[i]+1]-=dp[i][j];
                dp[i+1][j+a[i]+1]%=inf;
            }
        }
    }
    REP(i,1,k+1){
        dp[n][i]=dp[n][i-1]+dp[n][i];
        dp[n][i]%=inf;
    }
    ll ans=dp[n][k];
    if(ans<0)ans+=inf;
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		sc.nextLine();
		String S = sc.nextLine();

		String ans = S.substring(0, K-1) + S.substring(K-1,K).toLowerCase() + S.substring(K, N);
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	if(n%2)
	ans=n/2+1;
	else
	ans=n/2;
	cout<<ans;
    return 0;
}

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

ans = 0
cnt = sum(a)
node = 1

for i in range(n + 1):
    ans += node
    cnt -= a[i]
    node = min(cnt, (node - a[i]) * 2)

    if node < 0:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 20136
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


struct BinaryIndexed {
  ll num;
  vll bit;

  BinaryIndexed(ll x = MAX) {
    num = x;
    bit.resize(x + 1, 0);
  }

  ll sum(ll i) {
    ll ret = 0;
    while (i > 0) {
      ret += bit[i];
      i -= i & -i;
    }
    return ret;
  }

  void add(ll i, ll x) {
    if (i == 0) cout << "access 0 index" << endl;
    while (i <= num) {
      bit[i] += x;
      i += i & -i;
    }
  }
};

ll mod_pow(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1) ret = (x*ret) % mod;
    x = (x*x) % mod;
    y >>= 1;
  }
  return ret;
}


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


  cin >> n;
  vll x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vpll v;
  rep(i, n) v.pb(pll(x[i], y[i]));
  sort(all(v));
  sort(all(y));
  unordered_map<ll, ll> cmp;
  rep(i, n) cmp[y[i]] = i + 1;
  BinaryIndexed le(MAX), ri(MAX);
  FOR(i, 0, n) ri.add(cmp[v[i].second], 1);
  (ans = n * mod_pow(2, n - 1)) %= mod;
  FOR(i, 0, n) {
    ll a, b, c, d;
    ll aa, bb, cc, dd;
    ll pos = cmp[v[i].second];
    ri.add(pos, -1);

    a = ri.sum(MAX - 1) - ri.sum(pos);
    b = ri.sum(pos);
    c = le.sum(pos);
    d = le.sum(MAX - 1) - le.sum(pos);

    aa = mod_pow(2, a) - 1;
    bb = mod_pow(2, b) - 1;
    cc = mod_pow(2, c) - 1;
    dd = mod_pow(2, d) - 1;

    (ans += aa * cc % mod * mod_pow(2, n - a - c - 1)) %= mod;
    (ans += bb * dd % mod * mod_pow(2, n - b - d - 1)) %= mod;

    tmp = aa * bb % mod * cc % mod * dd % mod;
    (ans += mod - tmp) %= mod;

    le.add(pos, 1);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 19052
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int a[n];
  int count =0;
  long long sum =0;


  for(int i=0; i<n; i++){
    cin >> a[i];
    sum += a[i];
  }
  double ans = (double)sum/(4*m);
  for(int i=0; i<n; i++){
    if(a[i] >= ans) count++;
  }
  if(count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
using namespace std;

//long long A[100000];
//int stand_bit_num[40];

//int t[1000000];
//long long d[100000];

int p[100];
int c[100];

int main(){
    int D, G;
    cin >> D >> G;
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int ans = accumulate(p, p + D, 0);
    for(int comp_set = 0; comp_set < (1 << 10); comp_set ++){
        int cur_score = 0;
        int ans_num = 0;
        for(int i = 0; i < 10; i++){
            if(((comp_set >> i) & 1) == 1){
                cur_score += (i + 1) * p[i] + c[i] / 100;
                ans_num += p[i];
            }
        }
        if(cur_score >= G / 100){
            ans = min(ans, ans_num);
            continue;
        }

        int left_score = G / 100- cur_score;
        for(int i = D - 1; i >= 0; i--){
            if(((comp_set >> i) & 1) == 0){
                if(left_score <= (p[i] - 1) * (i + 1)){
                    if(left_score % (i + 1) == 0){
                        ans_num += left_score / (i + 1);
                    } else {
                        ans_num += left_score / (i + 1) + 1;
                    }
                    ans = min(ans, ans_num);
                    break;
                } else {
                    left_score -= (p[i] - 1) * (i + 1);
                    ans_num += p[i] - 1;
                }
            }
        }

    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int N;
ll a[3000];
ll dp[3000][3000];

// [l, N-1-r] が残っている状態で渡ってきた
ll solve(int l, int r){
    if(l<0 || r<0 || l>=N || r>=N) return INT64_MAX/2;
    if(dp[l][r] != INT64_MAX) return dp[l][r];
    ll ret;
    ret = max(a[l] - solve(l+1, r), a[N-1-r] - solve(l, r+1));
    dp[l][r] = ret;
    return ret;
}

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

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dp[i][j] = INT64_MAX;
        }
    }
    for(int i=0;i<N;i++){
        dp[i][N-1-i] = a[i];
    }

    cout << solve(0,0) << endl;    

    return 0;
}

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

int main(){
	int W,H,x,y,r;

	cin >> W >> H >> x >> y >> r;
	if(y + r <= H && x + r <= W && y >= r && x >= r)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
char s[20];
scanf("%s",s);
printf("%c%c%c%c%c %c%c%c%c%c%c%c %c%c%c%c%c\n",s[0],s[1],s[2],s[3],s[4],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[14],s[15],s[16],s[17],s[18]);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 int main(){
	long long X;
	cin>>X;
	long long  tyokin = 100;
	int t = 0;
	while (tyokin<X){
		tyokin = tyokin*(1.01);
		t+=1;
	}
	cout<<t<<endl;
}


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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

void solve(){
    scanf("%d %d" , &n , &m);
    m *= 2;
    m ++;
    printf("%d\n" , (n+m-1)/m);

}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int n;cin>>n;
  int ce[100000];
  int cod[100000];
  rep(i,100000){
    ce[i]=0;
    cod[i]=0;
  }
  rep(i,n/2){
    int even,odd;cin>>even>>odd;
    even--;odd--;
    ce[even]++;cod[odd]++;
  }
  
  auto eitr = max_element(ce,ce+100000);
  auto oitr = max_element(cod,cod+100000);
  int eind1 = distance(ce,eitr),
      oind1 = distance(cod,oitr),
      enum1 = *eitr,
      onum1 = *oitr;
  if(eind1==oind1){
    ce[eind1] = cod[oind1] = 0;
    int enum2 = *max_element(ce,ce+100000),
        onum2 = *max_element(cod,cod+100000);
    cout << min(n-enum1-onum2,n-enum2-onum1) << endl;
  }else{
    cout << n-enum1-onum1 << endl;
  }
}


Measured memory_bytes: 1024
n1 = int(input())

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

n3 = []
n4 = []
for i1 in range(n1):
    if i1 % 2 == 0:
        n3.append(n2[i1])
    else:
        n4.append(n2[i1])

n3.sort()
n4.sort()

t1 = 0
c1 = 0
n5 = []

for i2 in range(len(n3)):
    if n3[i2] == t1:
        c1 += 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])
    else:
        if i2 != 0:
            n5.append([t1, c1])
        t1 = n3[i2]
        c1 = 1
        if i2 == len(n3) - 1:
            n5.append([t1, c1])

t1 = 0
c1 = 0
n6 = []
for i3 in range(len(n4)):
    if n4[i3] == t1:
        c1 += 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])
    else:
        if i3 != 0:
            n6.append([t1, c1])
        t1 = n4[i3]
        c1 = 1
        if  i3 == len(n4) - 1:
            n6.append([t1, c1])

n5.sort(key=lambda x:(x[1],x[0]), reverse=True)
n6.sort(key=lambda x:(x[1],x[0]), reverse=True)

r1 = 0

if len(n5) == 1 and len(n6) == 1 and n5[0][0] == n6[0][0]:
     r1 = n1 // 2
else:
    if n5[0][0] != n6[0][0]:
        r1 = n1 - n5[0][1] - n6[0][1]
    else:
        if len(n5) == 1:
            r1 = n1 - n5[0][1] - n6[1][1]
        elif len(n6) == 1:
            r1 = n1 - n5[1][1] - n6[0][1]
        else:
            if (n1 - n5[0][1] - n6[1][1]) >= (n1 - n5[1][1] - n6[0][1]):
                r1 = r1 = n1 - n5[1][1] - n6[0][1]
            else:
                r1 = n1 - n5[0][1] - n6[1][1]

print(r1)

Measured memory_bytes: 21572
#include <stdio.h>
#include <stdlib.h>
#include <math.h> //-lmをつけてコンパイルする

//２点の距離を求める関数
double dist(int point1, int point2){
    int zettaichi = abs(point1 - point2);
    double distance = pow((double)zettaichi, 2.0);
    //printf("distance:%f\n", distance);
    return distance;
    }

//整数判別関数
int intDiscrimination(double d){
    if(ceil(d) != floor(d)){ //切り上げ関数と切り下げ関数
        return 0; //整数ではない
    }else{
        return 1; //整数
    }   
}

int main(void) {
    int N, D;
    scanf("%d %d", &N, &D);
    //printf("%d行 %d列\n", D, N);
    int a[D][N];
    if( N<2 || N>10 || D<1 || D>10){
        //printf("The number is inappropriate\n");
        exit(0);
    }

    for(int i = 0; i < N; i++) { //登録
        for(int j = 0; j < D; j++){
            scanf("%d", &a[j][i]);
            //printf("%d\n", a[j][i]);
            if( a[j][i]<-20 || a[j][i]>20){
                //printf("The number is inappropriate\n");
                exit(0);
            }
        }
    }

 

    int seisu = 0;
    for(int j = 0; j < N; j++){
        for(int i = 0; i < N; i++){
            double sum = 0;
            if(i >= j) break;  
            for (int k = 0; k < D; k++){
                //printf("%d %d\n", a[k][j],a[k][i]);
                sum += dist(a[k][j],a[k][i]);
                //printf("sum:%f\n", sum);
                }
            double root = pow(sum, 0.5);
            //printf("root:%f\n", root);
            int hanbetusi = intDiscrimination(root);
            int hambetsu = intDiscrimination(root);
            //printf("hambetsu:%d\n",hambetsu);

            if(hambetsu == 1){
                seisu++;
                hambetsu = 0;
            }
        //printf("seisu:%d\n", seisu);   
        }    
    }

    printf("%d\n", seisu);
    
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[2010000];
int fail[2010000];
int n;
map<pair<long long,long long>,long long>M;
long long calc(long long a,long long b,long long c,int d){
	if(M.count(make_pair(a,b)))return M[make_pair(a,b)];
	//printf("%lld %lld %lld %d\n",a,b,c,d);
	long long ret=0;
	if(n>=b){
		for(int i=0;i<a;i++){
			if('a'+d==in[i])ret++;
		}
		return M[make_pair(a,b)]=ret;
	}
	long long to=b-c;
	long long to2=c-to;
	ret+=calc(min(a,c),c,to,d);
	if(a>c){
		ret+=calc(a-c,to,to2,d);
	}
	return M[make_pair(a,b)]=ret;
}
int main(){
	scanf("%s",in);
 
	n=strlen(in)/2;
 
	for(int i=1;i<n;i++){
		int at=fail[i];
		while(1){
			if(in[at]==in[i]){
				fail[i+1]=at+1;
				break;
			}
			if(at==0)break;
			at=fail[at];
		}
	}
	long long L,R;
	scanf("%lld%lld",&L,&R);
	L--;
	int sh=n-fail[n];
	long long f1=n;
	long long f2=sh;
	while(f1<R){
		long long tmp=f1+f2;
		f2=f1;f1=tmp;
	}
	for(int i=0;i<26;i++){
		M.clear();
		printf("%lld ",calc(R,f1,f2,i)-calc(L,f1,f2,i));
	}
	printf("\n");
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    ll n=s.size();
    ll ans = 15-n;
    for(ll i=0;i<n;i++)ans+=(s[i]=='o');
    cout<<(ans>=8?"YES\n":"NO\n");
}




Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int n,m,a,b,count=0,temp;
    scanf("%d %d",&n,&m);
    int h[n+1],good[n+1];
    memset(good,0,(n+1)*sizeof(good[0]));
    for(int i=1;i<=n;i++)
    scanf("%d",&h[i]);
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&a,&b);
        if(h[a]>h[b]&&good[a]>=0)
        good[a]++;
        if(h[b]>h[a]&&good[b]>=0)
        good[b]++;
        if(good[a]>=0&&h[a]<h[b])
        good[a]=-1;
        if(h[b]>=0&&h[b]<h[a])
        good[b]=-1;
        if(h[a]==h[b])
        {
            good[a]=-1;
            good[b]=-1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(good[i]>=0)
        count++;
    }
    printf("%d",count);
}


Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
map<long long,long long>mp;
long long o;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++)
    {
        cin>>o;
        v.push_back(i-o);
        mp[i+o]++;
    }
    long long sum=0;
    for(long long i=1;i<=n;i++)
    {
        sum+=mp[v[i-1]];

    }
    cout<<sum<<endl;
}


Measured memory_bytes: 27284
N = int(input())

if N % 2 == 0:
    G = []
    G_append = G.append
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            if i + j != (1 + N):
                G_append((i, j))
    print (len(G))
    for g in G:
        print (*g, sep = ' ')
    
else:
    G = []
    G_append = G.append
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            if i + j != N:
                G_append((i, j))
    print (len(G))
    for g in G:
        print (*g, sep = ' ')




Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int x[90005],y[90005],dp[90005];
int main()
{
int h,w,d;
cin>>h>>w>>d;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
    int p;
    cin>>p;
    x[p]=i;
    y[p]=j;

}
for(int i=0;i<=h*w;i++)
if(i>=d)
{
    dp[i]+=dp[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
}
int q;
cin>>q;
for(int i=0;i<q;i++)
{
    int a,b;
    cin>>a>>b;
    cout<<dp[b]-dp[a]<<endl;
}
return 0;
}
 


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    ll ans = 1;
    if (S <= 2) {
        cout << 0 << endl;
        return 0;
    }
    COMinit();

    for (ll i = 6; i <= S; i += 3) {
        ll diff = S - i;
        ll c = i / 3;
        c--;
        ans += COM(diff + c, c);
        ans %= MOD;
    }

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

Measured memory_bytes: 27060
#include<stdio.h>

int main(void) 
{
	int N, M, A[10000],i,sum=0;
	scanf("%d%d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &A[i]);
	}
	for(i=0;i<M;i++){
		sum += A[i];
	}
	if (N >= sum) {
		printf("%d", N - sum);
	}
	else {
		printf("%d", -1);
	}
	return 0;
}

Measured memory_bytes: 2192
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        long cnt = Stream.of(a).distinct().count();
        if (cnt == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26580
#include <iostream>
using namespace std;
const int MAX_N = 25;
int A[MAX_N],B[MAX_N],C[MAX_N];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	for (int i = 1; i <= N; ++i)
	{
		cin >> B[i];
	}

	for (int i = 1; i <= N-1; ++i)
	{
		cin >> C[i];
	}

	int ans = 0;

	for (int i = 0; i < N; ++i)
	{
		ans += B[A[i]];

		if (i != 0)
		{
			if (A[i-1] + 1 == A[i])
			{
				ans += C[A[i-1]];
			}
		}
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main (String[] arg) {
    	try (Scanner sc = new Scanner(System.in)) {
    		/*
    		 * 頭文字にBを含むもの
    		 * 末尾にAを含むもの
    		 * 頭文字にB　&& 末尾にAを含むもの
    		 * 上記以外
    		 */
    		int lineSize = sc.nextInt();
    		int countAB = 0;
    		int countInialB = 0 ;
    		int countEndA = 0;
    		int countIniBEndA = 0;
    		
    		for (int lineNum = 1; lineNum <= lineSize; lineNum++) {
    			String readStr = sc.next();
    			if (readStr.contains("AB")) {
    				countAB += readStr.split("AB").length - 1;
    			}
    			if (readStr.startsWith("B")) {
    				if (readStr.endsWith("A")) {
    					countIniBEndA++;
    					
    				} else {
    					countInialB++;
    				}
    				
    			} else if (readStr.endsWith("A")) {
    				countEndA++;
    			}
    		}
    		if (countIniBEndA == 0) {
    			countAB += Math.min(countEndA, countInialB);
    		} else if (countEndA + countInialB == 0) {
    			
    			/*
    			 * BA * 3 
    			 *  BA,BA,BA
    			 *  
    			 */
    			countAB += countIniBEndA - 1;
    		} else {
    			/*
    			 * BA * 3, B * 1
    			 *  BA,BA,BA,B : 4
    			 * BA * 3, A * 1
    			 *  A,BA,BA,BA : 4
    			 * BA * 3, A * 1, B * 1
    			 *  A,BA,BA,BA,B : 4
    			 * BA * 3, A * 1, B * 2
    			 *  A,BA,BA,BA,B,(B) : 4
    			 *  BA,BA,BA,B,A,B  : 4
    			 *  
    			 */
    			countAB += (Math.min(countEndA, countInialB) + countIniBEndA);
    			
    			
    		}
    		System.out.println(countAB);
    	} catch (Exception e) {
			// TODO: handle exception
		}
    } 
}

Measured memory_bytes: 33464
#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;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int n,k; cin >> n >> k;
  if(k == n) cout << 1 << endl;
  else if(n <= k + k-1) cout << 2 << endl;
  else{
    if((n-k)%(k-1) == 0) cout << (n-k)/(k-1)+1 << endl;
    else cout << (n-k)/(k-1)+2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e2+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
			continue;
		ans += i;
	}
	cout << ans;
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x3 - dx;
  int y4 = y3 - dy;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n;
int main(){
    scanf("%d",&n);
    printf("%d\n",n*n*n);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)

pL= 0
pR = sumA
cost = abs(pR - pL)
for i in range(N):
    pL += A[i]
    pR -= A[i]
    cost = min(cost, abs(pR - pL))
print(cost)



Measured memory_bytes: 105376
#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> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll ans = 0;
	int n; cin >> n;
	rep(i, n) {
		int x; cin >> x;
		ans += ll(x - 1);
	}
	cout << ans << '\n';



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define all(v) v.begin(),v.end()

int32_t main() {
	int n,k;
	cin>>n>>k;
	int a[n],dp[n]={0};
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
	    dp[i]=INT_MAX;
	    for(int j=i-1;j>=max(0ll,i-k);j--)
	    {
	        dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);
	    }
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
#include<utility>
using namespace std;
int num[200005],cnt[1000005]={0};
bool used[1000005]={0},right;
vector<pair<int,int>> vec;
void DFS(int index,int v){
	if(right)
		return;
	if(index==(int)vec.size()){
		if(used[v])
			right=1;	
		return;
	}
	int i,ans=1;
	for(i=0;i<=vec[index].second;i++){
		DFS(index+1,v*ans);
		ans*=vec[index].first;
	}
}
int main(){
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		cnt[num[i]]++;
	}
	sort(num,num+n);
	used[num[0]]=1;
	int j,ans=(cnt[num[0]]==1);
	for(i=1;i<n;i++){
		if(cnt[num[i]]>1){
			used[num[i]]=1;
			continue;
		}
		vec.clear();
		int temp=num[i];
		for(j=2;j*j<=num[i];j++){
			int cnt=0;
			while(num[i]%j==0){
				num[i]/=j;
				cnt++;
			}
			if(cnt)
				vec.emplace_back(j,cnt);
		}
		if(num[i]!=1)
			vec.emplace_back(num[i],1);
	//	printf("%d\n",num[i]);
	//	for(auto x:vec)
	//		printf("%d %d\n",x.first,x.second);
		right=0;
		DFS(0,1);
		ans+=(right==0);
	//	if(!right)
	//		printf("%d\n",temp);
		used[temp]=1;
	}
	printf("%d\n",ans);
}


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

int main(){
 int n,d,count=0;
 scanf("%d %d", &n,&d);
 int p[n][d];
 int f;
 for(int i=0;i<n;i++){	
   for(int j=0;j<d;j++){
   	 scanf("%d ", &f);
     p[i][j] = f;
   }
 }
  int s,m;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        m = 0;
      	// printf("%d %d\n", i,j);
    	for(int k=0;k<d;k++){
        	s = (p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
          	m += s;
        }
      	double un = (double)m;
      	un=sqrt(un);
      	int nn = (int)un;
      	(double)nn;
      	if(un-nn==0){ count++ ;}
      	
    }
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 128