akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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() {
  ll N; cin >> N;
  ll kinds = 0;
  map<ll, ll> cards;
  rep(i,N) {
    int X; cin >> X;
    if(cards.count(X)) {
      cards.at(X)++;
    } else {
      ++kinds;
      cards.insert(make_pair(X,1));
    }
  }
  if(kinds != N) {
    vector<ll> eat;
    for(auto i:cards) {
      if(i.second > 1) {
        int r = i.second;
        while(r >= 3) { r -= 2; }
        rep(n, r-1) eat.push_back(i.first);
      }
    }
    ll l=0, r=eat.size()-1;
    for(;;) {
      if(l >= r) { break; }
      if(eat[l] < eat[r]) { l++; r--; }
      else { break; }
    }
    if(l <= r) kinds -= (r-l+1);
  }
  cout << kinds << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int r;
    cin >> r;
    
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int cards[4][13]={{0},{0}};
  char str;
  int n,num,i,j;
  scanf("%d",&n);
  for(i=0;i<2*n;i++){
    scanf("%c",&str);
    scanf("%d",&num);
    if(str=='S')
      cards[0][num-1]=1;
    else if(str=='H')
      cards[1][num-1]=1;
    else if(str=='C')
      cards[2][num-1]=1;
    else if(str=='D')
      cards[3][num-1]=1;
  }
  for(j=0;j<4;j++)
    for(i=0;i<13;i++)
      if(cards[j][i]==0)
	switch(j){
	case 0:
	  printf("S %d\n",i+1);
	  break;
	case 1:
	  printf("H %d\n",i+1);
	  break;
	case 2:
	  printf("C %d\n",i+1);
	  break;
	case 3:
	  printf("D %d\n",i+1);
	  break;
	}
  return 0;
}

Measured memory_bytes: 596
//
// Created by Huang,Zhiqiang on 2018/8/15.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

ll N, M;
map<ll, ll> m;

int main() {
    cin >> N >> M;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        ll x;
        cin >> x;
        sum += x;
        m[sum % M]++;
    }
    map<ll, ll>::iterator iter = m.begin();
    ll ans = 0;
    while (iter != m.end()) {
        if (iter->first == 0) ans += iter->second;
        ans += (iter->second) * ((iter->second) - 1) / 2;
        iter++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
from sys import stdin, stdout  
  
def main(): 
	T = (stdin.readline().rstrip())
	#for tc in range(N):
	#h1, m1, h2, m2, k  = [int(x) for x in stdin.readline().split()]
	T = T.replace('?', 'D')
	stdout.write(str(T)+'\n')

if __name__ == "__main__": 
	main()

Measured memory_bytes: 9316
n = int(input())
for i in range(1,n+1):
    x = i
    if x % 3 == 0:
        print(f" {i}",end='')
    else:
        while True:
            if x % 10 == 3:
                print(f" {i}",end='')
                break
            x = int(x / 10)
            if x == 0:
                break
print("")



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

using namespace std;

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

    int k;
    cin >> k;
    int cnt = 0;
    for (int i=0; i<5; i++)
        for (int j=0; j<5; j++)
            if (i != j && abs(a[i]-a[j]) > k)
                cnt++;

    cout << (cnt?":(":"Yay!") << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    for (int i = 0; i < n; ++i){
        x -= a[i];
        if (x < 0){
            cout << i << endl;
            break;
        }
    }
    if (x >= 0) cout << (x == 0 ? n : n - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y, S;

ll func(ll n)
{
    if (n >= 0)
        return n / X + 1;
    else
        return 0;
}

int main()
{
    cin >> A >> B >> X;
    cout << func(B) - func(A-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  char s[1001] = { 0 };
  scanf("%s", s);
  if(s[strlen(s)-1] == 's') {
    printf("%ses\n", s);
  } else {
    printf("%ss\n", s);
  }
  return 0;
}


Measured memory_bytes: 2156
N = int(input())
b = list(map(int, input().split()))
b.reverse()
ans = []
for i in range(N):
    for j in range(len(b)):
        if b[j] == len(b)-j:
            ans.insert(0, b.pop(j))
            break

if not len(ans)==N:
    ans = [-1]

for a in ans:
    print(a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
 
int main() {
  string s;
  cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
n,c,k = map(int, input().split())
k *= 2
t = []
for _ in range(n):
    t.append(int(input())*2)
t.sort()
# print(t)
res = 0
s = []
for x in t:
    if len(s)==0:
        s.append(x)
    else:
        # print(x,s,x-s[0])
        if x-s[0]>k:
            while len(s)>0 and x-s[0]>k:
                res += 1
                s = s[c:]
            s.append(x)
        elif len(s)+1>c:
            res += 1
            s = s[c:]
            s.append(x)
        else:
            s.append(x)
# print(s)
if len(s)>0:
    res += 1
print(res)


Measured memory_bytes: 7444
def to_int(t)
  if t[0]==?0
    t[1].to_i
  else
    t.to_i
  end
end

def is_monthly(n)
  1<=n && n<=12
end

s=gets.chomp
n1=to_int(s[0,2])
n2=to_int(s[2,2])
m1=is_monthly(n1)
m2=is_monthly(n2)
ans=""

if m1 && m2
  ans="AMBIGUOUS"
elsif m1 && !m2
  ans="MMYY"
elsif !m1 && m2
  ans="YYMM"
else
  ans="NA"
end

puts ans

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=new int[s[0]];
		for(int i=0;i<s[0];i++){a[i]=int.Parse(Console.ReadLine());}
		Array.Sort(a);
		int ans=int.MaxValue;
		for(int i=s[1]-1;i<s[0];i++){ans=Math.Min(ans,a[i]-a[i-s[1]+1]);}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 15452
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(len(p)):
    if i + 1 == p[i]:
        if i + 1 != len(p):
            tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            count += 1
        else:
            tmp = p[i]
            p[i] = p[i - 1]
            p[i - 1] = tmp
            count += 1

print(count)


Measured memory_bytes: 52332
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


int main(){
    ll n;
    cin>>n;
    cout<<fixed<<setprecision(12)<<2*n*M_PI;
    
}


Measured memory_bytes: 3784
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n)
    cin>>v[i];
  sort(v.begin(), v.end());
  int t = 0; 
  while(t+1<n){
    for(int i=0; i<n; i++) {
      if(i==t) continue;
      int x = v[i]/v[t];
      v[i]-=v[t]*x;
    }
    sort(v.begin(), v.end());
    while(t<n and v[t]==0)
      t++;
  }
  std::cout << v[t] << std::endl;
  return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer> a = new ArrayList<>();
		for(int i = 0; i < k; i++){
			int d = sc.nextInt();
			for(int j = 0; j < d; j++){
				a.add(sc.nextInt());
			}
		}
		List<Integer> result = new ArrayList<Integer>(new HashSet<>(a));
		System.out.println(n - result.size());


	}
}


Measured memory_bytes: 46364
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <bitset>
using namespace std;

int main() {
	int N; cin >> N;
	int sum = 0;
	int s = N;
	while (s > 0)sum += s % 10, s /= 10;
	if (N % sum == 0)cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

int main() {
    int n, a, b; cin >> n >> a >> b;
    cout << (n * a < b ? n * a : b) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double n = sc.nextDouble();
        int a = (int)n;
        int b = (int)Math.sqrt(a);
        int i,j,k;
        int v;
        int ans = 0;
        int last[] = new int[a];
      
      
        for(i = 1;i<=b; i++){
         
          for(j = 1; j <=b; j++){
          	for(k = 1; k <= b; k++){
              if(i*i + j*j + k*k + i*k + j*k + i*j <= a){
                v = i*i + j*j + k*k + i*k + j*k + i*j;
                last[v - 1] += 1;
              }
            }
          }
        }
        
        for(i = 0;i < a; i++){
          System.out.println(last[i]); 
        }
      
 
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, T; cin >> N >> T;
	int ans = INF;
	rep(i, N) {
		int c, t; cin >> c >> t;
		if (t <= T) ans = min(ans, c);
	}
	if (ans == INF) cout << "TLE" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; //10^19 < 9223372036854775807
#define REP(i,n) for(ll i=0;i<ll(n);i++)


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

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

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

    ll ans = lcm(A, B);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  int ans=0;
  while(N>0){
    N/=K;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    print(YES if N % sum(map(int,list(str(N)))) == 0 else NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//
//  main.cpp
//  A
//
//  Created by Sultan.
//  Copyright © 2017 Sultan. All rights reserved.
//
//  CF Handle : 2017_Scayre_TBIL_777
//
//  ARSEN TOKSYN ZVER UUUU!!!!                BIZ SAGAN SENEMIZ!!!                   TaldykBIL,ALGA!!!
//

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>

#define ll long long
#define ull unsigned ll
#define ioi exit(0);

#define f first
#define s second

#define inf 1e9 + 7;

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define mp make_pair

#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)

#define pb(x) push_back(x)
#define ppb(x) pop_back(x)

#define endl "\n"

#define in(x) insert(x)

#define rep(x,y,z) for(int x=y;x<=z;x++)
#define per(x,y,z) for(int x=y;x>=z;x--)

#define all(x) x.begin(),x.end()

using namespace std;

int n;

ll ch;

int main() {
    
    cin >> n;
    
    while(ch*ch<=n){
        ch++;
    }
    
    ch--;
    
    cout << ch*ch << endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
(__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    int a = N % 10;

    if (a == 3) {
        cout << "bon";
        return;
    }

    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
        cout << "hon";
        return;
    }

    cout << "pon";
    return;
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3648
N = int(input())
d = [0 for _ in range(N)]
for i in range(N):
    d[i] = int(input())

d = sorted(d)

cnt = 0
max = 0
for i in range(len(d)):
    if max < d[i]:
        max = d[i]
        cnt += 1
print(cnt)


Measured memory_bytes: 62472
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H, reverse=True)
    sum_H = 0
    for h in H:
        if K > 0:
            K -= 1
            continue
        sum_H += h
    print(sum_H)

if __name__ == "__main__":
    main()

Measured memory_bytes: 26020
n = int(input())
s = input()
cnt = 0
pre = 0
for i in range(n):
    if s[i] == "(":
        cnt += 1
    else:
        cnt -= 1
        if cnt < 0:
            pre = max(pre, -cnt)
s = "(" * pre + s
s = s + ")" * (cnt + pre)
print(s)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long LL;

const int N = 4e5 + 100;

char a[N], b[N], c[N];
int h_max[N], h_min[N], v_max[N], v_min[N];
int h_max_suf[N], h_min_suf[N], v_max_suf[N], v_min_suf[N];
int main() {
	int n, m, Q;
	cin >> n >> m >> Q;
	int x, y;
	cin >> x >> y;
	Q *= 2;
	scanf("%s", c + 1);
	scanf("%s", b + 1);
	for(int i = 1; i <= Q; i ++) {
		if(i % 2 == 0) a[i] = b[(i + 1) / 2];
		else a[i] = c[(i + 1) / 2];
	}
	h_max[0] = h_min[0] = y;
	v_max[0] = v_min[0] = x;
	for(int i = 1; i <= Q; i ++) {
		h_max[i] = h_max[i - 1], h_min[i] = h_min[i - 1];
		v_max[i] = v_max[i - 1], v_min[i] = v_min[i - 1];
		if(i % 2 == 0) {
			if(a[i] == 'R') h_min[i] ++;
			if(a[i] == 'L') h_max[i] --;
			if(a[i] == 'U') v_max[i] --;
			if(a[i] == 'D') v_min[i] ++;
		}
		if(i % 2 == 1) {
			if(a[i] == 'R') h_max[i] ++;
 			if(a[i] == 'L') h_min[i] --;
			if(a[i] == 'D') v_max[i] ++;
			if(a[i] == 'U') v_min[i] --;
		}
	}	
	
	v_max[Q + 1] = h_max[Q + 1] = -0x3f3f3f3f;
	v_min[Q + 1] = h_min[Q + 1] = 0x3f3f3f3f;
	for(int i = Q; i >= 1; i --) {
		h_max[i] = max(h_max[i], h_max[i + 1]);
		h_min[i] = min(h_min[i], h_min[i + 1]);
		v_max[i] = max(v_max[i], v_max[i + 1]);
		v_min[i] = min(v_min[i], v_min[i + 1]);
		h_max_suf[i] = h_max[i] - h_max[i - 1];
		h_min_suf[i] = h_min[i] - h_min[i - 1];
		v_max_suf[i] = v_max[i] - v_max[i - 1];
		v_min_suf[i] = v_min[i] - v_min[i - 1];
	}
	bool flag = true;
	for(int i = 1; i <= Q; i ++) {
		h_max[i] = h_max[i - 1], h_min[i] = h_min[i - 1];
		v_max[i] = v_max[i - 1], v_min[i] = v_min[i - 1];
		if(i % 2 == 0) {
			if(a[i] == 'R') h_min[i] ++;
			if(a[i] == 'L') h_max[i] --;
			if(a[i] == 'U') v_max[i] --;
			if(a[i] == 'D') v_min[i] ++;
		}
		if(i % 2 == 1) {
			if(a[i] == 'R') h_max[i] ++;
 			if(a[i] == 'L') h_min[i] --;
			if(a[i] == 'D') v_max[i] ++;
			if(a[i] == 'U') v_min[i] --;
		}
		if(i != Q) {
			h_max[i] = max(h_max[i], 1 - h_min_suf[i + 1]); 
			h_min[i] = min(h_min[i], m - h_max_suf[i + 1]);
			v_max[i] = max(v_max[i], 1 - v_min_suf[i + 1]);
			v_min[i] = min(v_min[i], n - v_max_suf[i + 1]);
		}
		if (h_max[i] > m || h_min[i] < 1 || v_max[i] > n || v_min[i] < 1) flag = false;
	}

	if(flag) puts("YES");
	else puts("NO");



	
}


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

using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std ;
const int N = 9000 ;
vector<char> v[N] ;
string s[N][N] ;
string a[27] = {"a" , "b" , "c" , "d" , "e" , "f" , "g" ,  "h" , "i" , "j" , "k"} ;
int b[N] ;
int main()
{
  int n ;
  cin >> n ;
  s[1][1] = "a" ;
  int cnt = 1 , ans = 0 ;
  if(n == 1) cout << "a" << endl ;
  else
  for(int i = 2 ;i <= n ;i ++)
   {
     for(int j = 1 ;j <= cnt ;j ++)
      {
        int t = 0 ;

        for(int h = 0 ;h < s[i - 1][j].size() ;h ++)
         {
           int x = s[i - 1][j][h] - 'a' ;
           if(b[x] ) continue ;b[x] = 1;
           if(i == 10)
            {
              cout << s[i - 1][j] + a[x] << endl ;
            }
            else
           s[i][++ ans] = s[i - 1][j] + a[x] ;
           t = max(t , x) ;
           b[x] = 1;
         }
         for(int i = 0 ;i <= 11 ;i ++) b[i] = 0 ;
            if(i == 10)
             cout << s[i - 1][j] + a[t + 1] << endl ;
             else
           s[i][++ ans] = s[i - 1][j] + a[t + 1] ;
      }
     cnt = ans ;
     if(i == n &&i != 103
     )
      {
        // cout << ans << endl ;

        for(int j = 1 ;j <= ans ;j ++)
         cout << s[i][j] << endl ;
        break ;
      }
     ans = 0 ;
   }

  return 0 ;
}


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

using namespace std;

typedef long long ll;

const int MAX = 1e5+7;

vector<int> g[MAX];
int d[MAX], l[MAX];

int main()
{
	int n,m;scanf("%d%d", &n, &m);
	for(int i = 0; i<m; ++i)
	{
		int u, v;scanf("%d%d", &u, &v);
		g[u].emplace_back(v);
		++d[v];
	}	
	queue<int> q;
	for(int i = 1; i<=n; ++i)if(d[i]==0)
		q.emplace(i);
	while(!q.empty())
	{
		int u = q.front();q.pop();
		for(int v : g[u])
		{
			--d[v];l[v] = max(l[v],l[u]+1);
			if(d[v]==0)q.emplace(v);
		}
	}
	int ans = *max_element(l+1,l+n+1);
	printf("%d\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

namespace Mylib{
    using namespace std;
    
    int changeDigit(int N,int K){
        int ans=0;
        while(N%K!=0||N/K!=0){
            ans++;
            N=N/K;
            
        }
        return ans;
    }
}

int main(void){
    using namespace std;
    int N,K;
    int ans=0;
    cin >> N >> K;
    ans=Mylib::changeDigit(N,K);
    
    cout << ans << endl;
    return 0;
}


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

int main(){
int N, A, B, C, i; cin >> N >> A >> B >> C;
vector<string> S(N), ans(N); map<char, int> F;
for(i=0; i<N; i++){ cin >> S[i]; }
for(i=0; i<N; i++){ 
  string s=S[i];
  if(s=="AB"){ 
    if(A==0&&B==0){ cout << "No\n"; return 0; }
    if(B==0){ ans[i]="B"; B++; A--; continue; }
    if(A==0){ ans[i]="A"; A++; B--; continue; }
    if(A==1&&B==1&&C==0){ 
      if(i==N-1||S[i+1]=="BC"){ ans[i]="B"; B++; A--; }
      else{ ans[i]="A"; A++; B--; } continue;
    }
    if(A<=B){ ans[i]="A"; A++; B--; }else{ ans[i]="B"; A--; B++; }
  }
  if(s=="BC"){ 
    if(C==0&&B==0){ cout << "No\n"; return 0; }
    if(B==0){ ans[i]="B"; B++; C--; continue; }
    if(C==0){ ans[i]="C"; C++; B--; continue; }
    if(C==1&&B==1&&A==0){ 
      if(i==N-1||S[i+1]=="AB"){ ans[i]="B"; B++; C--; }
      else{ ans[i]="C"; C++; B--; } continue;
    }
    if(C<=B){ ans[i]="C"; C++; B--; }else{ ans[i]="B"; C--; B++; }
  }
  if(s=="AC"){ 
    if(A==0&&C==0){ cout << "No\n"; return 0; }
    if(C==0){ ans[i]="C"; C++; A--; continue; }
    if(A==0){ ans[i]="A"; A++; C--; continue; }
    if(A==1&&B==0&&C==1){ 
      if(i==N-1||S[i+1]=="BC"){ ans[i]="C"; C++; A--; }
      else{ ans[i]="A"; A++; C--; } continue;
    }
    if(A<=C){ ans[i]="A"; A++; C--; }else{ ans[i]="C"; A--; C++; }
  }
}
cout << "Yes\n";
for(i=0; i<N; i++){ cout << ans[i] << "\n"; }
}

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

void solve(){
  int n; cin >> n;
  vector<int> a(n), g;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  g.push_back(1);
  while(g[g.size() - 1] < n){
    g.push_back(g[g.size() - 1] * 3 + 1);
  }
  if(g.size() > 1) g.pop_back();
  int m = g.size();
  long long cnt = 0;
  for(int i = m - 1; i >= 0; i--){
    int x = g[i];
    for(int i = x; i < n; i++){
      int y = a[i];
      int j;
      for(j = i - x; j >= 0 && a[j] > y; j -= x){
        a[j + x] = a[j];
        cnt++;
      }
      a[j + x] = y;
    }
  }
  cout << m << endl;
  for(int i = m - 1; i >= 1; i--) cout << g[i] << " "; cout << g[0] << endl;
  cout << cnt << endl;
  for(int i = 0; i < n; i++) cout << a[i] << endl;
  return;
}

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



Measured memory_bytes: 6784
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		int c=n.nextInt();
		
		if (a<b && b<c) { System.out.println("Yes");
		} else {	 System.out.println("No");
		}
	}

}

Measured memory_bytes: 17172
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string iti,ni,san,si,go,ro,mo,to;
    cin>>mo>>to;
    if(mo<to){
        cout<<"<"<<endl;
    }
    else if(mo==to){
        cout<<"="<<endl;
    }
    else{
        cout<<">"<<endl;
    }
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(s:#));
    let mut list1 = s.clone()
        .chars()
        .map(|x| if x == 'W' { 1 } else { 0 })
        .scan(0, |state, x| {
            *state = *state + x;
            Some(*state)
        })
        .collect::<Vec<_>>();

    let mut list2 = s.chars()
        .map(|x| if x == 'E' { 1 } else { 0 })
        .collect::<Vec<_>>();
    list2.reverse();
    list2 = list2
        .into_iter()
        .scan(0, |state, x| {
            *state = *state + x;
            Some(*state)
        })
        .collect::<Vec<_>>();
    list2.reverse();

    (list1
        .into_iter()
        .zip(list2.into_iter())
        .map(|(a, b)| a + b)
        .fold(10000000, |a, b| std::cmp::min(a, b)) - 1)
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "5\nWEEWW" => "1",
    test2: "12\nWEWEWEEEWWWE" => "4",
    test3: "8\nWWWWWEEE" => "3",
}


Measured memory_bytes: 12024
#include <stdio.h>

int main()
{
	char enki;

	scanf("%c", &enki);
	switch (enki)
	{
	case 'A':	printf("T\n");	break;
	case 'T':	printf("A\n");	break;
	case 'G':	printf("C\n");	break;
	case 'C':	printf("G\n");	break;
	}

	return 0;
}

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

bool flag = 0;
string arr;
vector<char> v;

int main() {
	
	cin >> arr;
	
	if (arr[0] == arr[1]){
		if(arr[2] == arr[3] && arr[2] != arr[0])	cout << "Yes";
		else	cout << "No";
	}
	else if (arr[0] == arr[2]){
		if(arr[1] == arr[3] && arr[1] != arr[0])	cout << "Yes";
		else	cout << "No";
	}
	else if (arr[0] == arr[3]){
		if(arr[2] == arr[1] && arr[2] != arr[0])	cout << "Yes";
		else	cout << "No";
	}
	else cout << "No";
	
	return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<string>
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<queue>
#include<set>
//#define IORD
#define eps 1e-8
#define inf 0x3f3f3f3f
#define mod (1000000007)

using namespace std;
typedef long long LL;
typedef pair<int,int> pp;

char s[20];

void Sol()
{
    int fg=1,cnt=0,len=strlen(s);
    if(s[0]!='A') fg=0;
    else
    {
        for(int i=2;i<len-1;i++)
           if(s[i]=='C') cnt++;
        if(cnt!=1) fg=0;



        if(s[1]=='C' || s[len-1]=='C') fg=0;

    }



    for(int i=0;i<len;i++)
        if((s[i]!='A' && s[i]!='C') && !(s[i]>='a' && s[i]<='z')) fg=0;


    if(fg) printf("AC\n");else printf("WA\n");
}
int main()
{

    #ifdef IORD
    freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif // IORD

    while(scanf("%s",&s)!=EOF)
        Sol();
        //cout<<s[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
jishin, funshin, hji, mfun = map(int, input().split())

jiDegree = hji * 360 / 12 + mfun * 360 /(12*60)
funDegree = mfun * 360 / 60

deg = max(jiDegree, funDegree) - min(jiDegree, funDegree)
if deg > 180:
    deg = 360 - deg

from math import cos, radians, sqrt

len2 = jishin**2 + funshin**2 - 2*jishin*funshin*cos(radians(deg))

print(sqrt(len2))

Measured memory_bytes: 9452
N = int(input())
p=0
if N < 105:
    print(0)
else:
    for n in range(1,  N+1, 2):
        ans = []
        for i in range(2, int(n**0.5)+1):
            while n % i == 0:
                ans.append(i)
                n //= i
        if n!=1:ans.append(n)

        A = 1
        sp = list(set(ans))
        for s in sp:
            A *= ans.count(s)+1
        if A == 8:
            p+=1

    print(p)

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  int x, y;
  x = y = 0;
  x = 800*n;
  y = n/15;
  y *= 200;
  dump(x-y);
  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 ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
   ll a,b,k;cin>>a>>b>>k;
   int count = 0;
   map<int,int>m;
for(int i = a;count<k&&i<=b;i++ ){
    m[i]++;
    count++;
}
count=0;
for(int i = b;count<k&&i>=a;i-- ){
    m[i]++;
    count++;
}
for(auto i:m){
    cout<<i.first<<endl;
}
    
    return 0;
}


Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
N,T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
sum = 0
for i in range(N-1) :
    if t[i+1] - t[i] <= T :
        sum += t[i+1] - t[i]
    else :
        sum += T
sum += T
print(sum)

Measured memory_bytes: 77520
use proconio::{input, marker::Chars};
use std::collections::HashMap;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut dict = HashMap::new();
    let mut dict_inv = HashMap::new();

    for (c_s, c_t) in s.into_iter().zip(t.into_iter()) {
        if let Some(&val) = dict.get(&c_s) {
            if val != c_t {
                println!("No");
                return;
            }
        } else {
            dict.insert(c_s, c_t);
        }
        if let Some(&val) = dict_inv.get(&c_t) {
            if val != c_s {
                println!("No");
                return;
            }
        } else {
            dict_inv.insert(c_t, c_s);
        }
    }

    println!("Yes");
}


Measured memory_bytes: 4080
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	int a[50];

	cin >> n;
	rep(i, n){
		cin >> a[i];
	}
	int idx, mabs = 0;
	rep(i, n){
		if (mabs < abs(a[i])){
			mabs = abs(a[i]);
			idx = i + 1;
		}
	}
	if (mabs == 0){
		cout << 0 << endl;
		return 0;
	}
	cout << 2 * n << endl;
	if (a[idx - 1] < 0){
		cout << idx << ' ' << n << endl;
		cout << idx << ' ' << n << endl;
		for (int i = n - 1; i >= 1; i--){
			cout << i + 1 << ' ' << i << endl;
			cout << i + 1 << ' ' << i << endl;
		}
	}
	else{
		cout << idx << ' ' << 1 << endl;
		cout << idx << ' ' << 1 << endl;
		for (int i = 2; i <= n; i++){
			cout << i - 1 << ' ' << i << endl;
			cout << i - 1 << ' ' << i << endl;
		}
	}



	return 0;
}

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

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

  int int1000, int100, int10, int1;
  
  int1000 = intN / 1000;
  int100 = (intN % 1000) / 100;
  int10 = (intN % 100) / 10;
  int1 = intN % 10;
  
  if (int100 == int10){
    if (int1000 == int100){
	    cout << "Yes" << endl;
    }
    else if (int10 == int1){
	    cout << "Yes" << endl;
    }
    else{
	    cout << "No" << endl;
    }
    
  }
  else{
    cout << "No" << endl;
  }
  
}
  
 

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int nextInt() { int d; cin >> d; return d;}

bool fall(int field[][5], int H) {
  bool isFalledRet = false;
  
  for (int y = H - 1; y >= 0; y--) {
    for (int x = 0; x < 5; x++) {
      if (field[y][x] != 0) {
        int i;
        bool isFalled = false;
        for (i = y + 1; i < H; i++) {
          if (field[i][x] != 0) {
            break;
          }
          isFalled = true;
        }
        if (isFalled) {
          field[i - 1][x] = field[y][x];
          field[y][x] = 0;
          isFalledRet = true;
        }
      }
    }
  }
  
  return isFalledRet;
}

int dfs(int field[][5], int H) {
  // テヲツーツエテ・ツケツウテ」ツ?ォ3テ」ツ?、テゥツ?」テァツカツ堙」ツ?療」ツ?ヲテ」ツつ凝」ツつづ」ツ?ョテ」ツつ津ヲツ篠「テ」ツ??
  int score = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < 3; x++) {
      if (x < 1) {
        if (field[y][0] != 0 && field[y][0] == field[y][1] && field[y][1] == field[y][2] &&
              field[y][2] == field[y][3] && field[y][3] == field[y][4]) {
          score += 5 * field[y][0];
          field[y][0] = 0;
          field[y][1] = 0;
          field[y][2] = 0;
          field[y][3] = 0;
          field[y][4] = 0;        
        }  
      }
      if (x < 2) {
        if (field[y][x] != 0 && field[y][x] == field[y][x + 1] && field[y][x + 1] == field[y][x + 2] && field[y][x + 2] == field[y][x + 3]) {
          score += 4 * field[y][x];
          field[y][x]     = 0;
          field[y][x + 1] = 0;
          field[y][x + 2] = 0;
          field[y][x + 3] = 0;
        }
      }     
      if (field[y][x] != 0 && field[y][x] == field[y][x + 1] && field[y][x + 1] == field[y][x + 2]) {
        score += 3 * field[y][x];
        field[y][x]     = 0;
        field[y][x + 1] = 0;
        field[y][x + 2] = 0;
      }
    }  
  }
  
  bool isFalled = fall(field, H);
  if (!isFalled) {
    return score;
  }
  
  int dfsScore = dfs(field, H);
  score += dfsScore;
  return score;
}

int main() {
  while (true) {
    int H = nextInt();
    if (H == 0) {
      break;
    }
    
    int field[H][5];
    memset(field, 0, sizeof(field));
    
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < 5; x++) {
        int d = nextInt();
        field[y][x] = d;
      }
    }
    int ans = dfs(field, H);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  FOR(i,0,d-b)cout<<'U';
  FOR(i,0,c-a)cout<<'R';
  FOR(i,0,d-b)cout<<'D';
  FOR(i,0,c-a)cout<<'L';
  cout<<'L';
  FOR(i,0,d-b+1)cout<<'U';
  FOR(i,0,c-a+1)cout<<'R';
  cout<<'D';
  cout<<'R';
  FOR(i,0,d-b+1)cout<<'D';
  FOR(i,0,c-a+1)cout<<'L';
  cout<<'U'<<endl;
  return 0;
}

Measured memory_bytes: 384
X,Y = map(int,input().split())

r = 0

if X == 1:
    r = r + 300000
elif X == 2:
    r = r + 200000
elif X == 3:
    r = r + 100000
else:
    pass


if Y == 1:
    r = r + 300000
elif Y == 2:
    r = r + 200000
elif Y == 3:
    r = r + 100000
else:
    pass

if X == 1 and Y == 1:
    r = r + 400000
else:
    pass

print(r)

Measured memory_bytes: 3060
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab.sort()

ans = 0
drink = 0
i = 0

while drink < M:
    if ab[i][1] == 0:
        i += 1

    ans += ab[i][0]
    ab[i][1] -= 1
    drink += 1

print(ans)


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


def f(S):
    X = {}
    for c in S:
        X[c] = X.get(c, 0) + 1

    if len(X) != 2:
        return False

    for key, value in X.items():
        if value != 2:
            return False

    return True


def main():
    S = input()
    
    print('Yes' if f(S) else 'No')




if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    string s;
    cin >> n >> s >> k;
    char t = s[k - 1];
    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] != t ) cout << '*';
        else cout << s[i];

    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll n;cin >> n;
    ll k;cin >> k;
    ll ans = 0;
    if(k == 0){
        ans = n*n;
    }
    else{
        for(int i=k+1;i<=n;i++){
            ans += (i-k)*(n/i)+max((n%i-k+1),(ll)0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

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

// check a cycle in a directed graph: source codeforces;

// void dfs(int v, int p){
//   color[v] = 1; // GREY
//   for(int w : g[v]){
//     if(color[w] == 1){
//       // you found a cycle, it's easy to recover it now.
//     }
//     if(color[w] == 0) dfs(w, v);
//   }
//   color[v] = 2; // BLACK
// }


///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);

string s;
cin>>s;
ll sum=0;
for(auto K : s)
{
	sum+=K-'0';
}
if(sum%9==0)
{
	cout<<"Yes"<<endl;
}
else
{
	cout<<"No"<<endl;
}
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 3932
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
string arr[1000005];
char str[1000005];

int main() {
    //freopen("test.in", "r", stdin);
    //  freopen("ac.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
        scanf("%s", str);
        arr[i] = string(str);
        vec.push_back(i);
    }
    sort(vec.begin(), vec.end(), [](int x, int y) {
        return arr[x].size() < arr[y].size();
    });
    long long ans = 0;
    map<size_t, int> hash;
    for (int i = 0; i < n; ++i) {
        string &S = arr[vec[i]];
        int vis = 0, sz = S.size();
        size_t h = 0;
        for (int i = 0; i < sz; ++i) {
            int id = S[i] - 'a' + 1;
            if ((vis >> id) & 1) continue;
            vis |= (1 << id);
            h = 1;
            if (hash.find((h * 31) + id) != hash.end()) ans += hash[(h * 31) + id];
            for (int j = sz - 1; j > i; --j) {
                h *= 31;
                h += (S[j] - 'a' + 1);
                if (hash.find((h * 31) + id) != hash.end()) ans += hash[(h * 31) + id];
            }
        }
        h = 1;
        for (int j = sz - 1; ~j; --j) {
            h *= 31;
            h += (S[j] - 'a' + 1);
        }
        ++hash[h];
    }
    cout << ans;
}


Measured memory_bytes: 47716
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5+5, lg = 20;
int n, mod, dp[N], sol[N];

vector<int> adj[N], prefix[N], suffix[N];

int add(int a, int b)
{
    a = (a + mod)%mod;
    b = (b + mod)%mod;
    return (a + b)%mod;
}

int mul(int a, int b)
{
    a = (a + mod)%mod;
    b = (b + mod)%mod;
    return (1ll*a*b)%mod;
}

void dfs(int node, int par)
{
    prefix[node] = vector<int>(adj[node].size());
    suffix[node] = vector<int>(adj[node].size());
    int cur = 1;
    for(int i=0; i < adj[node].size(); i++)
    {
        int child = adj[node][i];
        if(child != par)
        {
            dfs(child, node);
            cur = mul(cur, dp[child]);
        }
        prefix[node][i] = cur;
    }
    dp[node] = add(1, cur);
    cur = 1;
    for(int i = (int)adj[node].size() - 1; i>=0; i--)
    {
        int child = adj[node][i];
        if(child != par)
            cur = mul(cur, dp[child]);
        suffix[node][i] = cur;
    }
}

void solve(int node, int par)
{
    sol[node] = dp[node];
    for(int i = 0; i < adj[node].size(); i++)
    {
        int child = adj[node][i];
        if(child == par) continue;
        int dp1 = dp[node], dp_child = dp[child];
        dp[node] = dp[par];
        if(i)
            dp[node] = mul(dp[node], prefix[node][i-1]);
        if(i + 1 < adj[node].size())
            dp[node] = mul(dp[node], suffix[node][i+1]);

        dp[node] = add(1, dp[node]);

        dp[child] = add(-1, dp[child]);
        dp[child] = mul(dp[child], dp[node]);
        dp[child] = add(1, dp[child]);

        solve(child, node);

        dp[node] = dp1;
        dp[child] = dp_child;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> mod;
    for(int i=1; i<n; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dp[0] = 1;
    dfs(1, 0);
    solve(1, 0);
    for(int i = 1; i<= n; i++)
        cout << add(-1, sol[i]) << '\n';
    return 0;
}


Measured memory_bytes: 26240
/**
1 から n までの数の中から、重複無しで３つの数を選びそれらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。

例えば、1 から 5 までの数から３つを選んでそれらの合計が 9 となる組み合わせは、
?1 + 3 + 5 = 9
?2 + 3 + 4 = 9

の２通りがあります。

 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 点数を受け取る変数を宣言
		int intN = 0;
		int intX = 0;
		int intKekka = 0;

		// breakされるまで処理をくりかえす
		while (true) {

			// 数字を二つ受け取る
			intN = sc.nextInt();
			intX = sc.nextInt();
			//結果を表示する変数
			intKekka = 0;
			//二つの数値が０だった場合処理を狩猟する
			if (intN == 0 && intX == 0) {
				break;
			}
			
			//受け取った数字N*N*N回処理を実行する
			for (int i = 1; i <= intN; i++) {
				for (int j = 1; j <= intN; j++) {
					for (int k = 1; k <= intN; k++) {
						//ijkが同じ数字だったときなにもしない
						if(i == j || j == k || i == k){
						//Nの数字を３つ足していって合計がXだった場合結果に１プラスする。
						}else if ( i + j + k == intX){
							intKekka ++;
							}
						}
					}
				}
			// 
			System.out.println(intKekka/6);
			}

		}
	}

Measured memory_bytes: 19672
cards = [[False for i in range(13)] for j in range(4)]
pattern = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    a,b = input().split()
    cards[pattern.index(a)][int(b)-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(f'{pattern[i]} {j+1}')


Measured memory_bytes: 5612
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2, ceil
from fractions import Fraction

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if w == v:
    print('NO')
elif w > v:
    print('NO')
else:
    # w < v
    if a > b:
        ans = (a-b)/(v-w)
        print('YES' if ceil(ans) <= t else 'NO')
    else:
        ans = (a-b)/(w-v)
        print('YES' if ceil(ans) <= t else 'NO')




Measured memory_bytes: 10412