akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n,m;
	cin >> n >> m;
	vector< vector<int> > a(n,vector<int>(m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	vector<int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		int res = 0;
		for (int j = 0; j < m; ++j) {
			res += a[i][j]*b[j];
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3168
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b = map(int,input().split())
    s = input().rstrip()
    if len(s)==a+b+1:
        if s[a]=="-" and s.count("-")==1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 9100
from decimal import Decimal
li = input().split()
n = int(li[0])
k = int(li[1])

# n面サイコロ kは得点

# 1/nの確率で1~nが出る
# 勝つためにx回表を出し続ければ良い
# 目 * 2^x >= kとなればよい

answer = 0
for i in range(n):
    dicenum = i + 1
    winline = dicenum
    x = 0
    while winline < k:
        x += 1
        winline = dicenum * (2**x)
    if dicenum == 1:
        first_x = x
        bunbo = n * 2**x #initialize
        bunsi = 1 #initialize
    elif x == 0:
        bunsi += 2**first_x
    else:
        bunsi += 2**(first_x - x)

answer = Decimal(str(bunsi)) / Decimal(str(bunbo))
print("{:.12f}".format(answer))

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

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

bool cmp(P a, P b){
  if(a.second == b.second){
    return a.first < b.first;
  }
  return a.second > b.second;
}

int main(){
  int n;
  string ts;

  while(cin >> n, n){
    getline(cin, ts);

    map<string,int> cnt;

    for(int i = 0; i < n; i++){
      getline(cin, ts);

      stringstream ss(ts);
      string s;

      while(ss >> s){
        cnt[s]++;
        //cout<<":"<<s<<endl;
      }
    }

    char ch;
    cin >> ch;

    vector<P> v;

    for(map<string,int>::iterator iter = cnt.begin(); iter != cnt.end(); iter++){
      if((iter->first)[0] != ch) continue;
      v.push_back(*iter);
    }

    sort(v.begin(), v.end(), cmp);

    bool firstFlg = true;

    for(int i = 0; i < min(5, (int)v.size()); i++){
      if(firstFlg) firstFlg = false;
      else         cout << " ";

      cout << v[i].first;
    }

    if(firstFlg){
      cout << "NA\n";
    }
    else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 952
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void) {

	int count = 0, i;

	char buff1[256];
	char buff2[256];

	scanf("%s", buff1);

	while (1) {
		scanf("%s", buff2);

		if (strcmp(buff2, "END_OF_TEXT") == 0)break;
		for (i = 0; buff2[i] != '\0'; i++) {
			buff2[i] = tolower(buff2[i]);
		}
		if (strcmp(buff2, buff1) == 0) {
			count++;
		}
		else {
			;
		}

	}
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int ori[20],n;

int solve(int ,int );

int main()
{
  int i,j,m,hikaku[200],count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ori[i]);
  }

   scanf("%d",&m);
  for(j=0;j<m;j++){
    count=0;
    scanf("%d",&hikaku[j]);
    count=solve(0,hikaku[j]);
    if(count==1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


int solve(int i,int m)
{
  int result;
  if(m==0) return 1;
  if(i>=n) return 0;
  result=solve(i+1,m) || solve(i+1,m-ori[i]);
  return result;
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

#define lmd [](const vector<ll>& x, const vector<ll>&y) { return x[1] < y[1]; }

struct Edge {
  ll from;
  ll to;
  ll d;
  bool operator<(const Edge &ano) const {
   return d < ano.d;
 };
};

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) { rep(i, N) par[i] = i; }

  int root(int x) { 
    if (par[x]== x) return x;
    else return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx==ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

};

int main() {
  ll N; cin >> N;
  vector<vector<ll>> xd, yd;
  rep(i,N) {
    ll x, y; cin >> x >> y;
    xd.push_back({i,x});
    yd.push_back({i,y});
  }

  sort(xd.begin(), xd.end(),lmd);
  sort(yd.begin(), yd.end(),lmd);
  vector<Edge> e;
  rep(i,xd.size()-1) e.push_back({xd[i+1][0], xd[i][0], xd[i+1][1] - xd[i][1]});
  rep(i,yd.size()-1) e.push_back({yd[i+1][0], yd[i][0], yd[i+1][1] - yd[i][1]});
  sort(e.begin(), e.end());
  // for(auto x: e) cout << x.from << " " << x.to << " " << x.d << endl;

  UnionFind graph(N);
  ll num = 0, result = 0;
  for (auto x: e) {
    if (!graph.same(x.from, x.to)) {
      graph.unite(x.from, x.to);
      num++;
      result += x.d;
    }
    if (num==N-1) break;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int32_t main() {
    $
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 6 && a <= 12) ans = b>>1;
    else if (a > 12) ans = b;
    cout << ans << '\n';
}   



Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve():
    x, n = map(int, input().split())

    if n == 0:
        print(x)
        return

    p_list = list(map(int, input().split()))
    p_list.sort()
    p_list = set(p_list)

    ans = 9999
    work_abs = 9999
    for i in range(110):
        if i in p_list:
            continue

        work_x = max(x, i)
        work_p = min(x, i)
        if work_abs > work_x - work_p:
            work_abs = work_x - work_p
            ans = i

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """6 5
4 7 10 6 5"""
        output = """8"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 5
4 7 10 6 5"""
        output = """9"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100 0"""
        output = """100"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

class DisjointSet {
public:
    vector<int> rank, p;

    DisjointSet();
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) {
            makeset(i);
        }
    }

    void makeset(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    int findset(int x) {
        if (p[x] != x) {
            p[x] = findset(p[x]);
        }
        return p[x];
    }

    bool same(int x, int y) {
        if (findset(x) == findset(y)) {
            return true;
        }
        else {
            return false;
        }
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        }
        else if (rank[x] < rank[y]) {
            p[x] = y;
        }
        else if (rank[x] == rank[y]) {
            p[y] = x;
            rank[x]++;
        }
    }

    void unite(int x, int y) {
        link(findset(x), findset(y));
    }

};


int main() {
    int n, q;
    cin >> n >> q;

    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            ds.unite(x, y);
        }
        else if (c == 1) {
            if (ds.same(x, y) == true) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}



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

int main(void){
	int n;
	int ans = 0;

	cin >> n;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;

		if(x==1) continue;
		if(x==2) {ans++; continue;}
		if(x%2 == 0) continue;
		int j;
		for(j=3; j*j<=x; j+=2){
			if(x%j == 0) break;
		}
		if(j*j > x) {ans++; }
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    int m = 5;
    vll S(m);
    string ls = "MARCH";
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, m) {
            if (s[0] == ls[j]) {
                S[j]++;
                break;
            }
        } 
    }
    ll ans = 0;
    rep(i, m-2) {
        srep(j, m-1, i+1) {
            srep(k, m, j+1) {
                ans += S[i]*S[j]*S[k];
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
    int K, N;
    int A[200001];
    
    scanf("%d %d", &K, &N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

    int L[N];
    for (int i = 0; i < N-1; i++) L[i] = A[i+1] - A[i];
    L[N-1] = (K - A[N-1]) + A[0];

    int maxnum = -1;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (maxnum < L[i]) maxnum = L[i];
        ans += L[i];
    }
    ans -= maxnum;

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

// order(N)

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node
{
  struct node *parent;
  struct node *left;
  struct node *right;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void Tprint(Node);
void find(Node, int);
Node root;

int main()
{
  int m, i, k;
  char str[8];

  scanf("%d", &m);
  for(i=0; i<m; i++)
    {
      scanf("%s", str);
      if(strcmp(str, "insert") == 0)
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(strcmp(str, "print") == 0)
	{
	  Tprint(root);
	}
      else if(strcmp(str, "find") == 0)
	{
	  scanf("%d",&k);
	  find(root,k);
	}
    }
  
  
  return 0;
}

void insert(int key)
{
  Node t, x, y;
  t = (Node)malloc(sizeof(struct node));
  t->key=key;
  t->right = NULL;
  t->left = NULL;
  y = NULL;
  x = root;

  while(x != NULL)
    {
      y = x;
      if(key<x->key)
	x = x->left;
      else
	x = x->right;
    }
  t->parent = y;

  if(y==NULL)
    root = t;
  else if(t->key<y->key)
    y->left = t;
  else
    y->right = t;
}

void preorder(Node T)
{
  if(T == NULL) return;

  printf(" %d", T->key);
  preorder(T->left);
  preorder(T->right);
}
void inorder(Node T)
{
  if(T == NULL) return;

  inorder(T->left);
  printf(" %d", T->key);
  inorder(T->right);
}
void Tprint(Node T)
{
  inorder(T);
  printf("\n");
  preorder(T);
  printf("\n");
}
void find(Node T, int key)
{
  if(T == NULL)
    {
      printf("no\n");
      return;
    }
  else if(key == T->key)
    {
      printf("yes\n");
      return;
    }

  if(key<T->key)
    find(T->left,key);
  else
    find(T->right,key);

  
}

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

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;

    vector<int> aji(n);
    for (int i = 0; i < n; i++)
        aji[i] = l + (i + 1) - 1;
    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += aji[i];
    int dif = 1e9, ans = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp = abs(sum - (sum - aji[i]));
        if (dif > tmp)
        {
            dif = tmp;
            ans = sum - aji[i];
        }
    }

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

Measured memory_bytes: 3532
package main

import "fmt"

func main() {
	var n int
	var s string
	var four bool
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		if s == "Y" {
			four = true
		}
	}
	if four {
		fmt.Println("Four")
		return
	}
	fmt.Println("Three")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n;
	cin >> n;

	int ans = 0;
	vector<int> a;
	for(int i = 1e9; i > 0; i /= 10){
		a.emplace_back(i);
	}
	for(int i = 3; i <= n; i++){
		rep(j, a.size()){
			if(i >= a[j] and  i / a[j] % 2 == 0){
				i += a[j] - 1;
				break;
			}
		}

		vector<bool> res(4, 0);
		for(int j = i; j > 0;){
			int a = j % 10;
			j /= 10;

			res[0] = res[0] or a == 3;
			res[1] = res[1] or a == 5;
			res[2] = res[2] or a == 7;
			res[3] = res[3] or (a != 3 and a != 5 and a != 7);
			if(res[3]) break;
		}
		if(res[0] and res[1] and res[2] and not res[3]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; int m; cin >> n >> m;
  bool graph[9][9];
  rep(i, 9) {
    rep(j, 9) {
      graph[i][j] = false;
    }
  }
  rep(i, m) {
    int a, b; cin >> a >> b;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  vector<int> vec;
  for(int i=2; i<=n; i++) {
    vec.push_back(i);
  }

  //debugln(vec.size());

  int ans = 0;
  do {
    int b = 1;
    bool flag = true;
    for(auto e : vec) {
      //debugln(e);
      if(graph[b][e]) {
        b = e;
      } else {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  } while (next_permutation(vec.begin(), vec.end()));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools


N = int(readline())
S = [x - ord('0') for x in read().rstrip()]
left_index = [[-1] * (N+1) for _ in range(10)]
for i,x in enumerate(S,1):
    for j in range(10):
        left_index[j][i] = left_index[j][i-1]
    left_index[x][i] = i
ans = 0
for a,b,c in itertools.product(range(10),repeat=3):
    i = N
    bl = True
    for x in [a,b,c]:
        i = left_index[x][i] - 1
        if i < -1:
            bl = False
            break
    if bl:
        ans += 1
print(ans)


Measured memory_bytes: 6692
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, x);
    int ans = 0, ang = 0;
    do{
        ans ++, ang += x;
    } while(ang % 360 != 0);
    
    Cout(ans);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define rep(a, b, c, i) for (int i = a; i < b; i += c)
#define ff first
#define ss second
#define newl "\n"

using namespace std;

class AlterAltar{
public:
	int alter(string s){
		vector<int> w, r;
		rep(0, s.size(), 1, i){
			if (s[i] == 'W') w.push_back(i);
			else r.push_back(i);
		}
		int wx = 0, rx = r.size() - 1;
		int count = 0;
		while (wx < w.size() && rx >= 0 && w[wx] < r[rx]){
			count++;
			wx++;
			rx--;
		}
		return count;
	}
};

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	AlterAltar alt;
	cout << alt.alter(s) << newl;
}


Measured memory_bytes: 4896
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*)n,a,b 
    if(mod(n,a)==0)then
        write(*,*)n/a*b
    else
        write(*,*)(n/a+1)*b
    end if
    
    stop
end program sample
  



Measured memory_bytes: 2860
"use strict";

main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  let students_num = parseInt(input.split("\n")[0]); //生徒数
  let arrive_num_order_by_student_num = input.split("\n")[1].split(" "); //学番の順の到着順(配列)

  let result = new Array(students_num); //出力

  for (let i = 0; i < students_num; i++) {
    result[parseInt(arrive_num_order_by_student_num[i]) - 1] = i + 1;
  }

  console.log(result.join(" "));
}


Measured memory_bytes: 34148
#include <iostream>

using namespace std;
#define REP(i, n) for (int i = 0; (i) < (n); ++i)

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int *a = new int[n];
    for (int i = 0; i < n; ++i)
        a[i] = 0;
    for (int i = 1; i < n; ++i)
    {
        int num;
        cin >> num;
        a[num + -1]++;
    }

    for (int i = 0; i < n; ++i)
        cout << a[i] << "\n";
    return 0;
}

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


int main(){
  int K;
  cin >> K;
  int64_t x=0;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        x+=gcd(a,gcd(b,c));
      }
    }
  }
  cout << x << endl;
    
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
n = int(input())
s = []
for _ in range(n):
    s.append(input())
a = []
b = []
c = []
for i in s:
    mi = 0
    tmp = 0
    for j in i:
        if j=='(':
            tmp += 1
        else:
            tmp -= 1
        if tmp<mi:
            mi = tmp
    if tmp>0:
        a.append((mi, tmp))
    elif tmp==0:
        b.append((mi, tmp))
    else:
        c.append((mi, tmp))
a.sort(key=lambda x:-x[0])
c.sort(key=lambda x:x[0]-x[1])
tmp = 0
for i, j in a+b+c:
    if tmp+i<0:
        print('No')
        break
    tmp += j
else:
    if tmp==0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 227392
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key >  A[mid]) left = mid +1;
    else if (key < mid[A]) right = mid;
  }
  return 0;
}

int main()
{
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &k);
    if (binarySearch(k)) sum++;
  }
  printf("%d\n", sum);
  
  return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
#define mod 1000000007
#define inf (1ll<<60)
using namespace std;

int main()
{
    iof;
   ll n; cin>>n;
   double p[n];
   for(ll i=0;i<n;i++)
    cin>>p[i];

   double dp[n+1][n+1];
   for(ll i=0;i<=n;i++)
    for(ll j=0;j<=n;j++)
      dp[i][j]=0;
   dp[0][0]=1;
   for(ll i=1;i<=n;i++)
      dp[0][i]=(1-p[i-1])*dp[0][i-1];
   for(ll i=1;i<=n;i++)
   {
       for(ll j=i;j<=n;j++)
       {
           dp[i][j]= dp[i-1][j-1]*p[j-1]+dp[i][j-1]*(1-p[j-1]);
       }
   }
   ll x;
   if(n&1)
    x= n/2 +n%2;
   else
    x=n/2 +1;

   double ans=0;
   for(ll i=x;i<=n;i++)
      ans+=dp[i][n];
    cout<<setprecision(10)<<ans<<endl;
}


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

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

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);

			 System.out.println(Math.min(b/a, c));
		}
	}
}

Measured memory_bytes: 25340
#include <bits/stdc++.h>
using namespace std;
//ask the right questions.		

int main() 
{
	int n,x;
	cin >> n;
	vector<vector<int>> v;
	for(int i=0;i<n;i++)
	{
		vector<int> p;
		cin >> x;
		p.push_back(x);
		cin >> x;
		p.push_back(x);
		cin >> x;
		p.push_back(x);
		v.push_back(p);
	}

	//max fun on day n obtainable if activity j=0,1,2 is done on that day 
	int dp[n+1][3];
	
	//trivial case:
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;

	//base case:
	dp[1][0]=v[0][0];
	dp[1][1]=v[0][1];
	dp[1][2]=v[0][2];

	for(int i=2; i<=n ; i++)
	{
		//TIP: on ith day you could have done any of the 3 activites only, 
		//this fixes the activity done on prev day
		dp[i][0] = max(dp[i-1][1]+v[i-1][0], dp[i-1][2]+v[i-1][0]);		
		dp[i][1] = max(dp[i-1][2]+v[i-1][1], dp[i-1][0]+v[i-1][1]);
		dp[i][2] = max(dp[i-1][0]+v[i-1][2], dp[i-1][1]+v[i-1][2]);
	}
	
	int ans = max(dp[n][0],dp[n][1]);
	ans = max(ans, dp[n][2]);
	cout << ans <<endl; 
	return 0;
	
}

Measured memory_bytes: 9884
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int d[10][10];


void solve()
{
    int h, w;
    scanf("%d%d", &h, &w);
    int i, j;
    for (i = 0; i < 10; i++) {
        for (j = 0; j < 10; j++) {
            scanf("%d", &d[i][j]);
        }
    }
    int N = 10;
    for(int k = 0; k < N; ++k)
        for(int i = 0; i < N; ++i)
            for(int j = 0; j < N; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    ll sum = 0;
    for (i = 0; i < h*w; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (tmp >= 0) sum += d[tmp][1];
    }
    printf("%lld\n", sum);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a <= b)
        cout << a << endl;
    else
        cout << a - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
CT = [list(map(int, input().split())) for i in range(N)]

ans_c = 10 ** 9
for CTi in CT:
    c, t = CTi
    if t <= T:
        ans_c = c if c < ans_c else ans_c

if ans_c == 10 ** 9:
    print('TLE')
else:
    print(ans_c)


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

int main(){
	long long N,D;
	cin>>N>>D;
	int ans=0;

	for(int i=0;i<N;i++){
		long long X,Y;
		cin>>X>>Y;
		if(X*X + Y*Y<=D*D)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

int main()
{
  int numOfArray;
  cin >> numOfArray; cin.ignore();

  DPRINTF("NUM OF ARRAY %d\n", numOfArray);

  int max = -1;
  int array[numOfArray];
  for (int i = 0; i < numOfArray; i++)
  {
    cin >> array[i];
    if (array[i] > max)
      max = array[i];
  }

#if DEBUG
  for (int i = 0; i < numOfArray; i++)
    if (i == 0) DPRINTF("%d", array[i]);
    else        printf(" %d", array[i]);
  cout << endl;
#endif // DEBUG

  max++; // make array which ranges 0 to max for index
  int counter[max];
  DPRINTF("MAX NUM %d\n", max);

  // init
  for (int i = 0; i < max; i++)
    counter[i] = 0;

  // count
  for (int i = 0; i < numOfArray; i++)
    counter[array[i]]++;

  // to know how many number of less than i exist at i index
  for (int i = 1; i < max; i++)
    counter[i] += counter[i-1];

#if DEBUG
  for (int i = 0; i < max; i++)
    DPRINTF("counter[%d] %d\n", i, counter[i]);
#endif // DEBUG

  int sortedArray[numOfArray + 1]; // ignore index 0

  for (int i = 0; i < numOfArray; i++)
  {
    sortedArray[counter[array[i]]] = array[i];
    counter[array[i]]--;
    DPRINTF("i %d  array %d  counter %d\n", i, array[i], counter[array[i]]);
  }

  for (int i = 1; i < numOfArray + 1; i++)
  {
    if (i == 1) printf("%d", sortedArray[i]);
    else        printf(" %d", sortedArray[i]);
  }
  cout << endl;

  return 0;
}


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

int selectionSort(int a[],int n){
    int c=0;
    for(int i=0;i<n-1;i++){
        int min=i;
        for(int j=i+1;j<n;j++){
            if(a[min]>a[j]) min=j;
        }
        swap(a[i],a[min]);
        if(i!=min) c++;
    }
    return c;
}

int main(void){
    int n;
    cin>>n;
    int a[n];
    string s="";
    for(int i=0;i<n;i++) cin>>a[i];
    int c=selectionSort(a,n);
    for(int i=0;i<n;i++){
        cout<<s<<a[i];
        s=" ";
    }
    cout<<"\n"<<c<<"\n";
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
	int i, t, u;
	double n, a, b, x, y;
	while (cin >> n && n >= 0.0)
	{
		char c[14] = "        .    ";
		b = modf(n, &a);
		t = (int)a;
		for (i = 7; i >= 0; i--)
		{
			c[i] = ((t % 2 == 0) ? '0' : '1');
			t /= 2;
		}
		if (t > 0)
		{
			cout << "NA" << endl;
			continue;
		}
		for (i = 9; i <= 12; i++)
		{
			b *= 2;
			y = modf(b, &x);
			c[i] = ((x == 0.0) ? '0' : '1');
			b = y;
		}
		if (y != 0.0)
			cout << "NA" << endl;
		else
			cout << c << endl;
	}
}

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

typedef long long ll;

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

// chmax, chmin
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() {
    ll N,D;
    cin >> N >> D;
    
    vector<ll> X(N),Y(N);
    REP(i,N){
        cin >> X[i] >> Y[i];
    }
    
    ll count = 0;
    REP(i,N){
        if ( D * D >= ( X[i] * X[i] + Y[i] * Y[i] )) ++count;
    }
    
    cout << count << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  long long int a[N*2] = {};
  long long int A[N*2] ={};
  for (int i = 1; i < N+1; i++) {
    cin >> A[i];
    a[A[i]]++;
  }
  long long int aa[N*2] = {};
  long long int bb[N*2] = {};
  long long int s=0;
  for (int i = 1; i < N+1; i++) {
    if (a[i]!=0) {
    aa[i] = (a[i] - 1)*a[i]/2;
    s += aa[i];
    bb[i] = (a[i]-1)*(a[i]-2)/2;
    }
  }
  for (int i = 1; i < N+1; i++) {
    long long int ss = s;
    printf("%lld\n", ss - aa[A[i]] + bb[A[i]]);
  }
}

Measured memory_bytes: 15104
len_nums = int(input())
nums = input().split()

dic = {}
for num in nums:
	if num in dic:
		dic[num] += 1
	else:
		dic[num] = 1

count_to_be_removed = 0
for key, value in dic.items():
	key = int(key)
	# keyがvalue個あるような数列。key=valueになるように取り除く
	if key <= value:
		count_to_be_removed += value - key
	else:
		count_to_be_removed += value

print(count_to_be_removed)

Measured memory_bytes: 20600
n,k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

h = h.sort.reverse.reverse

if k>=n
    p 0
else
    h = h[0..n-k-1]
    sum = 0
    h.map{|x| sum+=x}
    puts sum
end




Measured memory_bytes: 24560
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
#define LL long long
using namespace std;
int n,ans;
int a[123456];

int main()
{
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&a[i]);
  for(i=1;i<=n;i++) ans+=abs(a[i]-a[i-1]);
  ans+=abs(a[n]);
  for(i=1;i<=n;i++) 
    printf("%d\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
}

Measured memory_bytes: 1664
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ans+=i*(n-i+1)+1;
        //cout << i*(n-i+1) << endl;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

signed main(){
	cout<<fixed<<setprecision(7);
	vector<int> a, b;
	string s, t;
	
	cin>>s>>t;
	
	for(char z: s){
		a.push_back(z);
	}
	for(char z: t){
		b.push_back(z);
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(), greater<char>() );
	s.clear(), t.clear();
	
	for(char z: a){
		s += z;
	}
	for(char z: b){
		t += z;
	}
	
	cout<<yn(s < t)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
q=int(input())
go=0
jisho={}
for x in a:
    go+=x
    if x in jisho:
        jisho[x]+=1
    else:
        jisho[x]=1
for x in range(q):
    b,c=map(int, input().split())
    if b in jisho:
        go=go+(c-b)*jisho[b]
        if c in jisho:
            jisho[c]+=jisho[b]
        else:
            jisho[c]=jisho[b]
        jisho[b]=0
    print(go)

Measured memory_bytes: 20800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int p=a+b+c-k;
    c=c-p;
    int sum=0;
    if(c>0){
     sum=a*1+c*(-1);}
    else{
            c*=-1;
            b=b-c;
            if(b<0){
                b*=-1;
                a=a-b;
            }
      sum=a*1;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3580
S = gets.chomp.split("/").map(&:to_i)
base = [2019,4,30]

if S[0] < base[0]
    puts "Heisei"
elsif S[0] > base[0]
    puts "TBD"
else
    if S[1] < base[1]
        puts "Heisei"
    elsif S[1] > base[1]
        puts "TBD"
    else
        if S[2] < base[2]
            puts "Heisei"
        elsif S[2] > base[2]
            puts "TBD"
        else
            puts "Heisei"
        end
    end
end


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

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

using namespace std;

typedef pair<char,char> cc;
vector<cc> opr;
int ep;

class Parsing{
private:
  string parse;
  int pos;
public:
  bool error;
 
  Parsing(string s){
    parse = s;
    pos = 0;
    error = false;
  }
  int fact(){
    if( error ) return 0;
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p=0;
      while('0' <= parse[pos] && parse[pos] <= '9'){
        p *= 10;
        p += parse[pos]-'0';
        pos++;
      }
      return p;
    }
  }
 
  int term(int depth){

    if( error ) return 0;
    int p; 
    if( depth >= ep ) p = fact();
    else              p = term(depth+1);

    while( depth < ep &&  parse[pos] == opr[depth].second ){

      char c = opr[depth].first;
      if( c == '+' )      { pos++; p += term(depth+1); }
      else if( c == '-' ) { pos++; p -= term(depth+1); } 
      else if( c == '*' ) { pos++; p *= term(depth+1); } 
      else if( c == '/' ) {
        pos++; 
        int denom = term(depth+1); 
        if( denom == 0 ) error = true;
        else p /= denom;
      } 
    }
    return p;
  }
 
  int expression(){
    if( error ) return 0;
    int p = term(1);
    while(!opr.empty() && parse[pos] == opr[0].second ){
      char c = opr[0].first;
      if( c == '+' )      { pos++; p += term(1); }
      else if( c == '-' ) { pos++; p -= term(1); } 
      else if( c == '*' ) { pos++; p *= term(1); } 
      else if( c == '/' ) {
        pos++; 
        int denom = term(1); 
        if( denom == 0 ) error = true;
        else p /= denom;
      } 
    }
    return p;
  } 
 
};

string s;
int main(){
  while( getline(cin,s) ){
    opr.clear();
    if( s == "#" ) break;
    int cnt = 0;
    rep(i,s.size()) if( s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/' ) {
      opr.push_back(cc(s[i],(char)('A'+cnt)));
      s[i] = (char)('A'+cnt);
      cnt++;
    }
    ep = opr.size();
    sort(opr.begin(),opr.end());
    unordered_set<int> ans;
    do{
      Parsing par(s);
      int tmp = par.expression();
      if( par.error ) continue;
      ans.insert(tmp);
    }while(next_permutation(opr.begin(),opr.end()));
    cout << ans.size() << endl;
  }
  return 0;
}

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

strength = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

s_a = strength.index(a)
s_b = strength.index(b)

if s_a > s_b:
    print('Alice')
elif s_a < s_b:
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long S = sc.nextLong() - 1;
		long sum = 0;
		long left = 0;
		long right = 100000000000000000L;
		while (sum < S - 1000) {
			long m = (left + right) / 2;
			long ms = count(m);
			if (ms <= S) {
				sum = ms;
				left = m;
			} else {
				right = m;
			}
		}
		StringBuilder sb = new StringBuilder();
		for (long i = left + 1; sb.length() < S - sum + 20; ++i) {
			boolean d3 = i % 3 == 0;
			boolean d5 = i % 5 == 0;
			if (d3) {
				sb.append(d5 ? "FizzBuzz" : "Fizz");
			} else {
				sb.append(d5 ? "Buzz" : "" + i);
			}
		}
		System.out.println(sb.toString().substring((int) (S - sum), (int) (S - sum + 20)));
	}

	static long count(long max) {
		long sum = 0;
		long base = 10;
		while (base - 1 <= max) {
			sum += count(base / 10, base - 1);
			base *= 10;
		}
		sum += count(base / 10, max);
		return sum;
	}

	static long count(long min, long max) {
		long c3 = max / 3 - (min - 1) / 3;
		long c5 = max / 5 - (min - 1) / 5;
		long c15 = max / 15 - (min - 1) / 15;
		long all = c3 + c5 - c15;
		return ("" + min).length() * (max - min + 1 - all) + (c3 + c5) * 4;
	}

}

Measured memory_bytes: 17440
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	long long H, W, D;
	cin >> H >> W >> D;
	vector<pair<long long, long long>> c(H * W);
	for (auto i = 1ll; i <= H; ++i)
	{
		for (auto j = 1ll; j <= W; ++j)
		{
			int A;
			cin >> A;
			auto& p = c[A - 1];
			p.first = i;
			p.second = j;
		}
	}

	vector<unsigned long long> count(H * W);
	for (auto i = 0; i < H * W; ++i)
	{
		if (count[i] == 0)
		{
			auto sum = 0ull;
			auto index = i;
			for (auto j = i + D; j < H * W; j += D)
			{
				auto& p = c[index];
				auto& q = c[j];
				sum += abs(p.first - q.first) + abs(p.second - q.second);
				index = j;
				count[j] = sum;
			}
		}
	}

	int Q;
	cin >> Q;
	vector<unsigned long long> result(Q);
	for (auto i = 0; i < Q; ++i)
	{
		int L, R;
		cin >> L >> R;
		result[i] = count[R - 1] - count[L - 1];
	}

	for (auto i = 0; i < Q; ++i)
	{
		cout << result[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

ll n, z, w;
ll arr[2010] = {};
ll memo[2010] = {};

ll dp[2][2010] = {};

//手番偶奇で、Xの取ったカード番号、Yのとったカード番号
//更にいけない？
//最後にとったカード番号？どうせ、最終的には片方はn-1になる
ll solve(int turn, int i) {

	if (i == n - 1) {
		if (turn) {
			return 0;
		}
		else {
			return 100000000000;
		}
	}

	if (dp[turn][i] != -1) {
		return dp[turn][i];
	}

	if (turn) {// 1 : min
		ll result = memo[i];

		for (int k = i + 1; k < n; k++) {
			result = min(result, solve(0, k));
		}

		//cout << turn << " " << i << " " << result << endl;

		return dp[turn][i] = result;
	}
	else {// 0 : max
		ll result = memo[i];

		for (int k = i + 1; k < n; k++) {
			result = max(result, solve(1, k));
		}

		//cout << turn << " " << i << " " << result << endl;

		return dp[turn][i] = result;
	}

}

int main() {
	
	cin >> n >> z >> w;
	n += 2;
	for (int i = 2; i < n; i++)
		cin >> arr[i];

	for (int i = 0; i <= n; i++)
		dp[0][i] = dp[1][i] = -1;

	arr[0] = z;
	arr[1] = w;

	for (int i = 0; i <= n; i++)
		memo[i] = abs(arr[i] - arr[n - 1]);

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

	return 0;
}

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

int main() {
  vector<int> dur(5);
  vector<int> hasu(5);
  int time = 0;
  for(int i=0; i<5; i++){
    cin >> dur.at(i);
    hasu.at(i) = dur.at(i) % 10;
    if(hasu.at(i) != 0){
      time += (dur.at(i) / 10 + 1) * 10;
    }else{
      time += (dur.at(i) / 10) * 10;
      hasu.at(i) = 10;
    }
  }
  sort(hasu.begin(), hasu.end());
  time -= (10 - hasu.at(0));
  cout << time << endl;
}


Measured memory_bytes: 256
n,t=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(n)]
ab.sort()
dp=[6007*[0]for _ in range(n)]
ans=0
for i in range(n):
  a,b=ab[i]
  for j in range(6007):
    if i==0:
      if j>=a and j<t:dp[i][j]=b
    elif j>=a and j-a<t:dp[i][j]=max(dp[i-1][j-a]+b,dp[i-1][j])
    else:dp[i][j]=dp[i-1][j]
    ans=max(ans,dp[i][j])
print(ans)

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

int main()
{
    int N, L;
    cin >> N >> L;
    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        sum += L + i - 1;
    }

    if (L <= -N + 1)
    {
        sum -= (N + L - 1);
    }
    else if (L <= -1)
    {
        sum = sum;
    }
    else
    {
        sum -= L;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = True
said = []
for i in range(N):
    word = input()
    if word in said:
        ans = False
        break
    if i != 0:
        if said[i - 1][-1] != word[0]:
            ans = False
            break
    said.append(word)
if ans:
    print("Yes")
else:
    print("No")
        
    


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

int n, q;
int val[1 << 18], weight[1 << 18];

int v[100055], L[100055];
vector<int> query[1 << 18];
vector<int> path;

int res[100055];

vector<pair<int, int>> vec;

int tot;

pair<int, int> on9[1 << 18];

int dp[1 << 9][100001];

void dfs(int v, int par = -1) {
    if (v >= n) return;

    path.push_back(v);

    if (path.size() > 9) {

    } else {
        if (par == -1) {
            for (int i = (int)1e5; i >= weight[v]; i--) {
                dp[v][i] = max(dp[v][i], dp[v][i - weight[v]] + val[v]);
            }
        } else {
            for (int i = (int)1e5; i >= weight[v]; i--) {
                dp[v][i] = max(dp[par][i], dp[par][i - weight[v]] + val[v]);
            }

            for (int i = (int)1e5; i >= 0; i--) {
                dp[v][i] = max(dp[par][i], dp[v][i]);
            }
        }

    }

    for (auto fuck : query[v]) {
        int l = L[fuck];

        if (path.size() <= 9) {
            res[fuck] = max(res[fuck], dp[v][l]);
            continue;
        }

        int left = (int)path.size() - 9;

        for (int mask = 0; mask < (1 << left); mask++) {
            pair<int, int> p = {0, 0};

            for (int i = 0; i < left; i++) {
                if (mask & (1 << i)) {
                    p.first += weight[path[9 + i]];
                    p.second += val[path[9 + i]];
                }
            }

            int need = l - p.first;

            if (need < 0) continue;

            res[fuck] = max(res[fuck], dp[path[8]][need] + p.second);
        }
    }

    dfs(v + v + 1, v);
    dfs(v + v + 2, v);

    path.pop_back();
}
int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &val[i], &weight[i]);
    }

    cin >> q;

    for (int i = 0; i < q; i++) {
        scanf("%d %d", &v[i], &L[i]);
    //    v[i] = i + 1, L[i] = i;
        v[i]--;

        query[v[i]].push_back(i);
    }

    dfs(0);

    for (int i = 0; i < q; i++) printf("%d\n", res[i]);

    return 0;
}


Measured memory_bytes: 215792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
string f(ll n){
  if(n==0) return ""; //再帰関数の終り。何も文字列に付け足さない。
  n--; //'a'=0なのでnも"0から"の基準に合わせる
  return f(n/26)+(char)('a'+n%26); 
  //それぞれ26進数に近いような似たような動きがあるため再帰関数をつくる
  //1の桁はn%26,2桁目以降は26で割ったあとn/26。
  //0番目が'a'であるからこれにn%26を加えると適当なアルファベットが出力される
  //n%26=4のときなら(char)('a'+4)=e。
}
int main()	{
  ll n;
  cin>>n;
  cout<<f(n)<<endl;
}

Measured memory_bytes: 3600