akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<vector<int>> edges;

// return -1 if loop is not found
int find_loop(int cur, vector<bool> &visited, ll &cnt) {
    // printf("cur: %d\n", cur);
    if (visited[cur]) {
        return cur;
    }
    visited[cur] = true;
    cnt++;
    return find_loop(edges[cur][0], visited, cnt);

    // for (auto next : edges[cur]) {
    //     cnt++;
    //     int ans = find_loop(next, visited, cnt, N);
    //     if (ans != -1) {
    //         return ans;
    //     }
    // }
    // return -1;
}

void find_towns_in_loop(int cur, vector<bool> &visited, vector<int> &acc) {
    if (visited[cur]) {
        return;
    }
    acc.push_back(cur);
    visited[cur] = true;
    find_towns_in_loop(edges[cur][0], visited, acc);
}

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    edges.resize(N);
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        t--;
        // printf("%d -> %d\n", i, t);
        edges[i].push_back(t);
    }

    ll cnt_till_loop = 0;
    int loop_start;
    {
        vector<bool> visited(N, false);
        loop_start = find_loop(0, visited, cnt_till_loop);
    }
    assert(loop_start >= 0);

    // printf("loop_start: %d, cnt_till_loop: %lld\n", loop_start, cnt_till_loop);

    if (K < cnt_till_loop) {
        loop_start = 0;
    }

    vector<int> towns_in_loop;
    {
        vector<bool> visited(N, false);
        find_towns_in_loop(loop_start, visited, towns_in_loop);
    }

    // for (auto v : towns_in_loop) {
    //     cout << v << " ";
    // }
    // cout << endl;

    if (K < cnt_till_loop) {
        cout << towns_in_loop[K] + 1 << endl;
    } else {
        K -= cnt_till_loop;
        K = K % ((ll) towns_in_loop.size());
        cout << towns_in_loop[K] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 24152
a, b ,c ,d = map(int, input().split())
def checkWinner(a, b, c, d):
    while(True):
        a = a - d
        c = c - b
        if(c <= 0):
            return('Yes')
        if(a <= 0):
            return('No')
print(checkWinner(a, b, c, d))

Measured memory_bytes: 9120
def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)

def LCM(a, b):
    return a // GCD(a, b) * b

def main():
    A, B = map(int, input().split())
    print(LCM(A, B))

    return 0


if __name__ == '__main__':
    main()

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

#define MAX 100000

int N;
int A[MAX];
int AA[MAX];

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

	sort( A, A + N );
	int cnt = N;
	while( cnt > 1 ) {
		AA[0] = A[0];
		int cnt1 = 1;
		for( int i = 1; i < cnt; i++ ) {
			A[i] %= A[0];
			if( A[i] ) {
				cnt1++;
				AA[i] = A[i];
			}
			else if( i < cnt - 1 ) {
				AA[i] = A[i + 1];
			}
		}
		cnt = cnt1;
		sort( AA, AA + cnt );
		swap( A, AA );
	}
	int ans = A[0];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
	char s[257],t[257];
	int i,j,k,n;
	for(scanf("%d\n",&n);n--;)
	{
		gets(s);
		for(i=1;i<=26;i+=2)
			for(j=0;j<=26;j++)
			{
				for(k=0,strcpy(t,s);s[k];k++)
					if(s[k]>='a'&&s[k]<='z')
						t[k]=((s[k]-'a')*i+j)%26+'a';
				if(strstr(t,"this")||strstr(t,"that"))
					goto e;
			}
e:		puts(t);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
	int N;
	int i,j,v;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
			A[j+1]=v;
		}
		for(j=0;j<N-1;j++){
			printf("%d ",A[j]);
		}
		for(j=N-1;j<N;j++){
			printf("%d",A[j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

void dfs(int num,int ar[10]);
int Pe[1 * 2 * 3 * 4 * 5 * 6 * 7 * 8];
int f[10] = {};
int c = 0;
int N;

int main() {
	cin >> N;
	dfs(0, f);
	
	int a, P, Q;
	P = Q = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		P *= 10;
		P += a;
	}
	for (int i = 0; i < N; i++) {
		cin >> a;
		Q *= 10;
		Q += a;
	}
	bool f_p = false;
	bool f_q = false;
	int p, q;
	for (int i = 0; !f_p || !f_q; i++) {
		if (Pe[i] == P) {
			f_p = true;
			p = i;
		}
		if (Pe[i] == Q) {
			f_q = true;
			q = i;
		}
	}

	if (p - q > 0) {
		cout << p - q << endl;
	}
	else {
		cout << q - p << endl;
	}

	return 0;
}

void dfs(int num, int ar[10]) {
	bool flag = false;
	int local_f[10] = {};
	copy(ar, ar + 10, local_f);
	for (int i = 1; i <= N; i++) {
		if (local_f[i] == 0) {
			local_f[i] = 1;
			flag = true;
			dfs(num * 10 + i, local_f);
			local_f[i] = 0;
		}
	}
	if (!flag) {
		Pe[c] = num;
		c++;
	}

	return;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = Integer.parseInt(scanner.nextLine());
        int[] array = new int[N];

        for (int i = 0; i < N; ++i) {
            array[i] = Integer.parseInt(scanner.nextLine());
        }

        long count = 0;
        int prep = 0;

        for (int i = N - 1; i >= 0; --i) {
            int current = array[i];
            if (current >= prep) {
                count += current;
            } else if (current < prep - 1) {
                break;
            }
            prep = current;
        }
        if (prep > 0) {
            count = -1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 158268
import sys

readline = sys.stdin.readline

def main():
    sx, sy, tx, ty = map(int, input().split())
    first = 'R'*(tx-sx) + 'U'*(ty-sy)
    second = 'L'*(tx-sx) + 'D'*(ty-sy)
    third = 'D' + 'R'*(tx-sx+1) + 'U'*(ty-sy+1) + 'L'
    forth = 'U' + 'L'*(tx-sx+1) + 'D'*(ty-sy+1) + 'R'
    ans = first + second + third + forth
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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 argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    double ans = 0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        }
        else {
            ans += x*380000.0;
        }
    }

    cout << ans;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
int main(void){
    int n, m;
    int town[50] = {0};
    int i;
    
    n = num();
    m = num();
    for(i=0; i<m*2; i++){
        town[num()-1]++;
    }
    
    for(i=0; i<n; i++){
        printf("%d\n", town[i]);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n,i;
    cin>>n;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        if(i%15==0)
        {
            continue;
        }
        else if(i%15!=0 && i%3==0)
        {
            continue;
        }
        else if(i%15!=0 && i%5==0)
        {
            continue;
        }
        else
        {
            ans+=i;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second

#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

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

    int n;
    cin>>n;
    lli a[n];
    f1(i,n) {
        cin>>a[i];
    }
    lli sum=0;
    lli x=a[0];
    for(int i=1;i<n;++i) {
        if(a[i]<x) {
            sum+=x-a[i];
        }
        else {
            x=a[i];
        }
    }

    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 5184
n=int(input())
a=list(map(int,input().split()))

odd=0
even=0

for aa in a:
    if aa%2==0:
        even+=1
    else:
        odd+=1

#odd+odd=even
#even+even=even

#もし奇数がペアが作れない場合,NO
if odd%2==1 and ( odd>2 or even>0):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 62448
#include<iostream>
using namespace std;
int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int i=A;i<=B;i++)
    if((0<=i-A && i-A<=K-1)||(0<=B-i && B-i<=K-1))cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
import math

while True:
    result = 0
    sums = 0
    num = int(input())
    if num == 0:
        break
    results = input().split(' ')
    for i in results:
        sums += int(i)
    average = sums / len(results)
    for i in results:
        result += (int(i) - average) ** 2
    
    result = result / len(results)
    
    print('{:.8f}'.format(math.sqrt(result)))


Measured memory_bytes: 5768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int n;
  cin >>n;
 
  string s = to_string (n);
  
  int ans = 0;
  if(s.size()==1) ans = n;
  if(s.size()==2) ans = 9;
  if(s.size()==3) ans = n-90;
  if(s.size()==4) ans = 909;
  if(s.size()==5) ans = n-9090;
  if(s.size()==6) ans = 90909;
  
  cout << ans << endl;
  
}


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

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

	map<ll,ll> am,bm;
	for(ll i=0; i<N; i++){
		am[a[i]]++;
		bm[b[i]]++;
	}
	for(auto&& pr:am){
		if(pr.second + bm[pr.first]> N){
			cout << "No\n";
			return 0;
		}
	}
	
	map<ll,pair<ll,ll>> arange, brange;
	ll i=0;
	while(i<N){
		ll beginindex=i;
		while(i<N && a[beginindex]==a[i])i++;
		arange[a[beginindex]]={beginindex, i};
	}
	i=0;
	while(i<N){
		ll beginindex=i;
		while(i<N && b[beginindex]==b[i])i++;
		brange[b[beginindex]]={beginindex, i};
	}

	ll diff=0;
	for(auto&& pr:arange){
		if(brange.find(pr.first)==brange.end())continue;
		ll t=pr.second.second - brange[pr.first].first;
		if(diff<t)diff=t;
	}

	cout << "Yes\n";
	for(ll i=0; i<N; i++) cout << b[(i-diff+N)%N] << " \n"[i==N-1];

	return 0;
}


Measured memory_bytes: 56260
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int H, W;
char s[100][100];
bool flg[100][100];

signed main()
{
	cin >> H >> W;
	REP(y, H)
	{
		char str[256];
		cin >> str;
		REP(x, W)
		{
			s[x][y] = str[x];
		}
	}

	queue<int> q;
	q.push(0);
	q.push(0);
	flg[0][0] = true;

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

	int size = 0;
	REP(y, H)
	{
		REP(x, W)
		{
			if (s[x][y] == '.')
			{
				size++;
			}
		}
	}

	int cnt = 0;
	while (q.size() > 0)
	{
		int q_size = q.size();
		for (int i = 0; i < q_size / 2; i++)
		{
			int x = q.front();
			q.pop();
			int y = q.front();
			q.pop();

			for (int d = 0; d < 4; d++)
			{
				int nx = x + dx[d];
				int ny = y + dy[d];

				if (nx == W - 1 && ny == H - 1)
				{
					cout << (size - cnt - 2) << endl;
					return 0;
				}

				if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
				if (flg[nx][ny]) continue;
				if (s[nx][ny] == '#') continue;

				flg[nx][ny] = true;
				q.push(nx);
				q.push(ny);
			}
		}
		cnt++;
	}

	cout << "-1" << endl;
}








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

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    
    int res = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(x%2 && i%2){
            res += 1;
        }
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 3624
H,W,D=map(int,input().split())
A=[]
for _ in range(H):
   row=list(map(int,input().split())) 
   A.append(row)
Q=int(input())
LR=[]
for _ in range(Q):
    l,r=map(int,input().split())
    LR.append((l,r))

ACCUM = [0] * (H*W+1)
POS = [None] * (H*W+1)

for i in range(H):
    for j in range(W):
        num=A[i][j]
        POS[num]=(i,j)

for start in range(1,D+1):
    i=start
    cost=0
    while i <= H*W:
        pos0 = POS[i]
        i += D
        if i > H*W: break
        pos1 = POS[i]
        cost += abs(pos0[0]-pos1[0]) + abs(pos0[1]-pos1[1])
        ACCUM[i] = cost

for q in range(Q):
    l,r = LR[q]
    print(ACCUM[r]-ACCUM[l])

Measured memory_bytes: 67160
open Printf
open Scanf

let input_int () =
  scanf "%d\n" (fun k -> k)

let f () = 
  let n = input_int () in
  let rec loop tot a =
    if a=n then
      printf "%d\n" tot
    else
      loop (tot + ((n-1)/a)) (a+1)
  in
  loop 0 1

let () = f ()


Measured memory_bytes: 3848
#include <iostream>
#include <string>

bool dp[100010];

using namespace std;

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

  string divide[] = { "dream", "dreamer", "erase", "eraser" };
  dp[0] = true;
  for (int i = 0; i < s.length(); i++) {
    if (!dp[i]) { continue; }
    for (int j = 0; j < 4; j++) {
      string t = divide[j];
      if (s.substr(i, t.length()) == t) {
        dp[i+t.length()] = true;
      }
    }
  }
  cout << (dp[s.length()] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 10000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll dp[2005][2005];

int main() 
{ 
    fastio
    int n, x, y;
    cin>>n>>x>>y;

    x -= 1; y -= 1;
    for(int i = 0; i<n; ++i) for(int j = 0; j<n; ++j) dp[i][j] = 1000000;
    for(int i = 0; i<n-1; ++i)
    {
        dp[i][i+1] = 1;
        dp[i][i] = 0;
    }
    dp[n-1][n-1] = 0;
    dp[x][y] = 1;

    for(int i = 0; i<n; ++i)
        for(int j = 2; j+i<n; ++j)
            dp[i][i+j] = j;

    for(int i = 0; i<n; ++i)
    {
        for(int j = i+1; j<n; ++j)
        {
            ll a1 = (i<x?dp[i][x]:dp[x][i]);
            ll a2 = (j<y?dp[j][y]:dp[y][j]);
            dp[i][j] = min(dp[i][j], a1 + a2 + 1);
        }
    }
        

    map<int, int> imap;
    for(int i = 0; i<n; ++i)
    {
        for(int j = i+1; j<n; ++j) 
        {
            imap[dp[i][j]]++;
        }
    }
    
    for(int i = 1; i<=n-1; ++i)
    {
        cout<<imap[i]<<endl;
    }
} 

Measured memory_bytes: 31744
/*
 #pragma GCC target ("avx2")
 #pragma GCC optimize ("Ofast")
 #pragma GCC optimize ("unroll-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#define F first
#define S second
#define pb push_back
using namespace std;
const long long N = 2e5 + 10;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
				Scanner scan = new Scanner(System.in);
				int X = scan.nextInt();
			
				int Y = scan.nextInt();
				
				int Z = scan.nextInt();
				
				int result = 0;
				
				result = (X - Z)/(Y+Z);
				System.out.println(result);
	}

}

Measured memory_bytes: 22996
#include<iostream>
#include<sstream>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;

double INF = 1000.0;

int main(){
    string s;
    while(getline(cin, s)){
        stringstream ss(s);
        int w;
        ss >> w;

        vector<double> rad;
        double next; 
        int n = 0;
        
        while(ss >> next){
            rad.push_back(next);
            n++;
        }

        double dp[n][1<<n];

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

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

        for(int s = 1; s < 1<<n; s++){
            for(int i = 0; i < n; i++){
                if(!((1<<i) & s)) continue;
                for(int j = 0; j < n; j++){
                    if((1<<j) & s)  continue;
                    double tmp = dp[i][s] + 2*sqrt(rad[i]*rad[j]);
                    if(tmp < dp[j][s | (1<<j)]){
                        dp[j][s | (1<<j)] = tmp;
                    }
                }
            }
        }

        double ans = INF;
        for(int i = 0; i < n; i++){
            ans = min(ans, dp[i][(1<<n)-1] + rad[i]);
        }

        cout << (ans <= w ? "OK" : "NA") << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  int N, M;
  cin >> N >> M;
  vector<ll> cnt(N, 0);
  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--, b--;
    cnt[a]++;
    cnt[b]++;
  }
  bool l = 1;
  for(int i = 0; i < N; i++){
    if(cnt[i] % 2) l = 0;
  }
  if(l) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1024
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
x,y=reada(N,2)
function d(x1,y1,x2,y2)return math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))end

s=0
dt={}
for i=1,N do
dt[i]={}
for j=1,i-1 do
dt[i][j]=d(x[i],y[i],x[j],y[j])
s=s+dt[i][j]
dt[j][i]=dt[i][j]
end
end
print(s/N*2)

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        divs.sort(reverse=True)
        return divs
    divs = trial_division(M)
    for d in divs:
        if d*N <= M:
            return print(d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		//Input
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());

		ArrayList<Denkyu> denkyu = new ArrayList<>();
		for(int j = 0; j < M; j++) {
			Denkyu d = new Denkyu(j+1);
			int k = Integer.parseInt(sc.next());
			ArrayList<Integer> inputList = new ArrayList<>();
			for(int i = 0; i < k; i++) {
				inputList.add(Integer.parseInt(sc.next()));
			}
			d.setS(inputList, N);
			denkyu.add(d);
		}
		for(int i = 0; i < M; i++) {
			denkyu.get(i).p = Integer.parseInt(sc.next());
			//denkyu.get(i).output();
		}

		sc.close();

		int answer= 0;
		int gudge = 0;
		int kaisu = (int) Math.pow(2, N);
		for(int i = 0; i < kaisu; i++) {
			String fmt = "%0"+N+"d";
			String a = Integer.toBinaryString(i);
			String b = String.format(fmt, Integer.parseInt(a));

			String[] input = b.split("");
			int[] inputSwitch = new int[N];
			for(int j = 0 ; j < N ; j++) {
				inputSwitch[j] = Integer.parseInt(input[j]);
			}

			gudge = 0;
			for(Denkyu d : denkyu) {
				gudge += d.check(inputSwitch);
			}

			if(gudge == M) {
				answer += 1;
			}

		}

		System.out.println(answer);
	}
}

class Denkyu {
	int no=0;
	ArrayList<Integer> s;
	int p;

	Denkyu(int no){
		this.no = no;
	}

	void setS(ArrayList<Integer> list, int N) {
		s = new ArrayList<Integer>();

		for(int i = 0; i < N; i++) {
			if(list.contains(i+1)) {
				s.add(1);
			}else {
				s.add(0);
			}
		}
	}

	int check(int[] switchInput){
		int ret = 0;
		for(int i = 0; i < s.size(); i++) {
			ret += s.get(i) * switchInput[i];
		}
		if((ret % 2) == p) {
			return 1;
		}else {
			return 0;
		}
	}

	void output() {
		System.out.println("No: " + this.no);
		System.out.println("s: " + s);
		System.out.println("p: " + this.p);
	}

}

Measured memory_bytes: 25940
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!

n,k,q= map(int,input().split())
point_list = [0 for i in range(n)]

for i in range(q):
    a=int(input())
    point_list[a-1] += 1

for i in point_list:
    if k - (q - i) >= 1:
        print("Yes")
    else:
        print("No")
        

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

int main() {
  int N, MA, MB;
  cin >> N >> MA >> MB;
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  int ret = 987654321;
  map<pair<int, int>, int> comb;
  comb[make_pair(0, 0)] = 0;
  if (N >= 21) {
    for (int i = 0; i < (1 << (N - 20)); i++) {
      int sa = 0, sb = 0, sc = 0;
      for (int j = 0; j < (N - 20); j++) {
        if (i & (1 << j)) {
          sa += a[20 + j];
          sb += b[20 + j];
          sc += c[20 + j];
        }
      }
      if (comb.count(make_pair(sa, sb)) == 0 ||
          (comb.count(make_pair(sa, sb)) > 0 && comb[make_pair(sa, sb)] > sc)) {
        comb[make_pair(sa, sb)] = sc;
      }
    }
  }

  for (int i = 0; i < (1 << min(N, 20)); i++) {
    int sa = 0, sb = 0, sc = 0;
    for (int j = 0; j < min(N, 20); j++) {
      if (i & (1 << j)) {
        sa += a[j];
        sb += b[j];
        sc += c[j];
      }
    }
    if (sa * MB == sb * MA && (sa + sb > 0)) {
      ret = min(ret, sc);
    } else {
      for (int k = 1; k <= 40; k++) {
        int ta = k * MA - sa, tb = k * MB - sb;
        if (ta >= 0 && tb >= 0 && comb.count(make_pair(ta, tb)) > 0) {
          ret = min(ret, sc + comb[make_pair(ta, tb)]);
        }
      }
    }
  }

  if (ret == 987654321) {
    cout << -1 << endl;
  } else {
    cout << ret << endl;
  }
}

Measured memory_bytes: 512
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-1):
    if i+1==p[i]:
        p[i],p[i+1]=p[i+1],p[i]
        cnt+=1
if p[n-1]==n:
    cnt+=1
print(cnt)

Measured memory_bytes: 14004
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N=200005;
int h,w,n,x,y,L,R,U,D;
char s[N],t[N];

int main(){
	cin>>h>>w>>n>>x>>y;
	scanf("%s",s+1);
	scanf("%s",t+1);
	L=1,R=w,U=1,D=h;
	per(i,n,1){
		if(t[i]=='R')L--;
		if(t[i]=='L')R++;
		if(t[i]=='D')U--;
		if(t[i]=='U')D++;
		L=max(min(L,w),1);
		R=max(min(R,w),1);
		U=max(min(U,h),1);
		D=max(min(D,h),1);
		if(s[i]=='L')L++;
		if(s[i]=='R')R--;
		if(s[i]=='U')U++;
		if(s[i]=='D')D--;
		if(L>R||U>D)return puts("NO"),0;
		if(R<1||L>w)return puts("NO"),0;
		if(D<1||U>h)return puts("NO"),0;
		//printf("%d %d %d %d\n",U,D,L,R);
	}
	if(U<=x&&x<=D&&L<=y&&y<=R)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 640
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    double N = 0, D =0;
    cin(N);
    cin(D);

    vvll X(N, vll(2));
    REP(i,N){
        cin(X.at(i).at(0));
        cin(X.at(i).at(1));
    }

    ll c =0;
    REP(i,N){
        double p = X.at(i).at(0);
        double q = X.at(i).at(1);
        double r = sqrt(p*p + q*q);
        if(r <= D){ c ++;}
    }








    //出力
    cout << c << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

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

int main() {
	string s[3];
	rep(i,3) cin >> s[i];
	int idx[3]={};
	int curr = 0;
	while(idx[curr] < s[curr].length()) {
		int next = s[curr][idx[curr]] - 'a';
		idx[curr]++;
		curr = next;
	}
	cout << (char)('A'+curr) << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);



int main(){
  faster();
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  bool flag = true;
  rep(i,n){
    if(i!=n && a[i]==a[i+1]) flag = false;
  }
  if(flag) cout << "YES";
  else cout << "NO";
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



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

#define MAX_N 100010
 
class UnionFind {
private:
  // 親と木の深さ
  int par[MAX_N];
  int rank[MAX_N];
public:
  void init(int n);
  int find(int x);
  void unite(int x, int y);
};
 
// 要素数nで初期化
void UnionFind::init (int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}
 
// 要素xの親を求める
int UnionFind::find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}
 
// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
  // xとyの親
  x = find(x);
  y = find(y);
  if(x == y) return;
 
  // yのほうが深さが深い　xの親はyの親
  if(rank[x] < rank[y]) par[x] = y;
  else {
    par[y] = x;
    if( rank[x] == rank[y] ) rank[x]++;
  }
}

UnionFind uf;

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

	int N, M; cin >> N >> M;
	vector<int> p(N); uf.init(N);
	REP(i, N) cin >> p[i];
	REP(i, M){
		int x, y; cin >> x >> y;
		uf.unite(x-1, y-1);
	}
	int ans = 0;
	REP(i, N){
		if(uf.find(i) == uf.find(p[i]-1)) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "T" : "F");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  string s, t; cin >> s >> t;
  int n = s.length(), m = t.length();
  int a[n][256], d[n][256];
  fill(all(a[0]), n);
  fill(all(d[0]), 0);
  for(int j=0; j<2; j++)
    for(int i=n-1; i>=0; i--) {
      copy(all(a[(i+1) % n]), a[i]);
      for(char c='a'; c<='z'; c++) d[i][c] = d[(i+1) % n][c] + 1;
      a[i][s[i]] = i, d[i][s[i]] = 0;
    }
  // for(int i=0; i<n; i++) dbr(a[i]+'a', a[i]+'z');

  ll ans = 0, cur = 0;
  for(;;) {
    for(; cur<m and t[cur] == s[ans%n]; cur++, ans++);
    if( cur == m ) break;
    if( a[ans%n][t[cur]] == n ) {
      return cout << -1, 0;
    }
    ans += d[ans%n][t[cur]];
  }
  cout << ans << endl;

}


Measured memory_bytes: 200656
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	for i := 0; i <= 7; i++ {
		if s[:i] == "keyence"[:i] && s[len(s)-(7-i):] == "keyence"[i:] {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


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

int main()
{
  int N;
  char day[4];

  scanf("%s",&day);
  if( (day[0]=='S')&&(day[1]=='U')) printf("7\n");
  if( day[0]=='M' ) printf("6\n");
  if( (day[0]=='T')&(day[1]=='U')) printf("5\n");
  if( day[0]=='W' ) printf("4\n");
  if( (day[0]=='T')&(day[1]=='H')) printf("3\n");
  if( day[0]=='F' ) printf("2\n");
  if( (day[0]=='S')&(day[1]=='A')) printf("1\n");

  return 0;
}


Measured memory_bytes: 128
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if(a>b) swap(a,b);
  if(v<=w){
      cout << "NO" << endl;
      return 0;
  }
  cout << ((b-a)<=t*(v-w) ? "YES" : "NO") << endl; 
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
vector<P> prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; 
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }
    if (N != 1) res.push_back({ N, 1 });
    return res;
}
int main() {
    ll n;
    cin >> n;
    vector<P>x;
    x = prime_factorize(n);
    ll ans = 0;
    for (auto id : x) {
        ll index = 2;
        while (id.second > 0) {
            id.second -= index;
            index++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> S(h, vector<char>(w));
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> S[i][j];
        }
    }
    vector<vector<int>> dis(h, vector<int>(w, -1));
    int max=0;
    int Sy,Sx,Gy,Gx;
    for (int sy = 0; sy < h; sy++)
    {
        for (int sx = 0; sx < w; sx++)
        { //それぞれのスタート地点ごとに
            if(S[sy][sx]=='#'){
                continue;
            }
            rep(i,h){
                rep(j,w){
                    dis[i][j]=-1;
                }
            }
            dis[sy][sx] = 0;
            queue<pair<int, int>> q;
            q.push(make_pair(sy, sx));
            int dx[4] = {0, 1, 0, -1};
            int dy[4] = {1, 0, -1, 0};
            while (!q.empty())
            {
                pair<int, int> p = q.front();
                q.pop();
                //先頭の今決まってる座標を取り出す
                for (int i = 0; i < 4; i++)
                {
                    int ny = p.first + dy[i];
                    int nx = p.second + dx[i];
                    if (nx < 0 || ny < 0 || nx >= w || ny >= h)
                    {
                        continue;
                    }
                    else if (S[ny][nx] == '#')
                    {
                        continue;
                        //探索しようと思ったら壁
                    }
                    else if (dis[ny][nx] != -1)
                    {
                        continue;
                    }
                    else
                    {
                        dis[ny][nx] = dis[p.first][p.second] + 1;
                        if(dis[ny][nx]>max){
                            max = dis[ny][nx];
                            Sy = sy,Sx=sx,Gy=ny,Gx=nx;

                        }
                        //cout <<"dis["<<ny<<"]["<<nx<<"]="<<dis[ny][nx]<<endl;
                        q.push(make_pair(ny, nx));
                        //新しく確定マスをキューに入れる
                    }
                }
            }
        }
    }
    cout<<max<<endl;
    //cout <<"Start=("<<Sy<<","<<Sx<<")"<<endl;
    //cout <<"Goal=("<<Gy<<","<<Gx<<")"<<endl;
}

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


int main(){

int x,y;
cin >> x >> y;
string ans = "No";

rep1(a,x){
int b = x-a;
if(b<0) break;

int leg = 4*x-2*a;
if(leg == y){
    ans = "Yes";
    break;
}


}


cout << ans << endl;


    
}

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

int dsc(const void *a, const void *b){
    return *(int *)b - *(int *)a;
}

int main(){
    int N, K, l[50], i, sum=0;

    scanf("%d %d", &N, &K);

    for(i=0; i<N; i++){
        scanf("%d", &l[i]);
    }

    qsort(l, N, sizeof(int), dsc);

    for(i=0; i<K; i++){
        sum += l[i];
    }

    printf("%d\n", sum);

    return 0;
}

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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000][3] = {}, B[1000000] = {}, weight[1000] = {}, value[1000] = {};
ll dp[10002][3] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
pair<str, ll> S[1000];
bool an = true, bn = false;
long long mod = 1e9 + 7;

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;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> A[i][0] >> A[i][1] >> A[i][2];

	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1] + A[i][0], dp[i - 1][2] + A[i][0]);
		dp[i][1] = max(dp[i - 1][0] + A[i][1], dp[i - 1][2] + A[i][1]);
		dp[i][2] = max(dp[i - 1][0] + A[i][2], dp[i - 1][1] + A[i][2]);

	}
	cout << max({ dp[n][0],dp[n][1],dp[n][2] });
	cin >> n;
	return 0;
}


Measured memory_bytes: 10496
out = []
cnt = 0
while True:
    W = int(input())
    if W == 0:
        break
    N = int(input())
    v = []
    w = []
    C = list([0 for i in range(W + 1)] for j in range(N + 1))
    for i in range(N):
        n, m = list(map(int,input().split(",")))
        v.append(n)
        w.append(m)
    for i in range(1, N + 1):
        for j in range(1, W + 1):
            if j - w[i - 1] < 0:
                C[i][j] = C[i-1][j]
            else:
                C[i][j] = max(int(C[i-1][j]),int(C[i-1][j-w[i - 1]]+v[i - 1]))
    for i in range(1,W+1):
            if C[N][i] == C[N][W]:
                min_wt = i
                break
    out.append([C[N][W] , min_wt])
    cnt += 1

for cs in range(cnt):
    print("Case "+str(cs+1)+":")
    print(out[cs][0])
    print(out[cs][1])

Measured memory_bytes: 20172
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<int> result;

  while (cin >> n) {
    if (n > 36 || n < 0) {
      result.push_back(0);
    } else {
      int tmp = 0;
      for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
          for (int k = 0; k < 10; k++)
            for (int l = 0; l < 10; l++)
              if (i + j + k + l == n)
                tmp++;
      result.push_back(tmp);
    }
  }
  for (int i = 0; i < result.size(); i++) 
    cout << result[i] << endl;
  return 0;
}
    

Measured memory_bytes: 1216