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

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

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main(){
    string x;
    cin>>x;
    stack<char>st;
    for(int i = 0; i < x.size(); i++)
    {   if(!st.empty()){if(st.top()=='S'&&x[i]=='T')st.pop();else st.push(x[i]);}
        else st.push(x[i]);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

string s;
ll k;

int main() {
    cin >> s >> k;
    for (int i = 0; i < min((ll)s.size(), k); i++) {
        if (s[i] == '1') continue;
        else {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 2000* 100 + 5;
int a[maxn], p[maxn];
set < pll > s;

int32_t main(){
    int n;
    cin >>n;
    for(int i = 1; i <= n; i ++){
        cin >>a[i];
    }
    for(int i = 1; i <= n; i ++){
        p[i] = a[i] + p[i - 1];
    }
    int ans = 0;
    s.insert({0, 1});
    for(int i = n; i > 0; i --){
        int x = p[n] - p[i - 1];
        if(s.lower_bound({x, 0}) != s.end() and (*s.lower_bound({x, 0})).F == x){
            ans += (*s.lower_bound({x, 0})).S;
        }
        if(s.lower_bound({x, 0}) != s.end() and (*s.lower_bound({x, 0})).F == x){
            int y = (*s.lower_bound({x, 0})).S + 1;
            s.erase(s.lower_bound({x, 0}));
            s.insert({x, y});
        }
        else{
            s.insert({x, 1});
        }
    }
    cout <<ans <<endl;
    return false;
}


Measured memory_bytes: 15872
from collections import deque
import bisect
N = int(input())
l = [int(input()) for _ in range(N)]

# 各色の最大数を保持
colors = deque()
for n in l:
    # 各色の最大数のどれよりも大きくなかったとき色を増やす
    ind = bisect.bisect_left(colors, n)
    if ind == 0:
        colors.appendleft(n)
    else:
        colors[ind-1] = n
print(len(colors))


Measured memory_bytes: 53592
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

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

int main()
{
	int n, i;
	scanf("%d", &n);
	float v[51];
	lop(i, n){ scanf("%f", &v[i]); }
	
	qsort(v, n, sizeof(int), compare_int);
	
	float sum=v[0];
	for(i=1; i<n; i++){
		sum=(sum+v[i])/2.0;
	}
	
	printf("%f", sum);
	
return 0;
}

Measured memory_bytes: 128
// atcoder/abc135/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> v(n);
    cin >> v;
    vector<int> u = v;
    sort(u.begin(), u.end());
    int cnt = 0;
    for (int i = 0; i < v.size(); ++i) {
      cnt += (u[i] != v[i]);
    }
    cout << (cnt <= 2 ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int K;
	char s[110] = {};
	char res[110] = {};
	
	scanf("%d",&K);
	scanf("%s",&s);
	
	int lon = 0;
	int i = 0;
	for(i = 0;i < 110;i++){
		if(s[i])
			lon++;
	}
	
	if(lon <= K)
		printf("%s",s);
	else{
		for(i = 0;i < K;i++){
			printf("%c",s[i]);
		}
		
		printf("...");
	}
	
	
	
} 

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int top = scan.nextInt();
        int bottom = scan.nextInt();
        int hight = scan.nextInt();
        check_input(top);
        check_input(bottom);
        check_input(hight);
        System.out.println((top + bottom) * hight / 2);
    }
    public static void check_input(int num) {
        if(num < 1 || num > 100) {
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 8788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll a;
  string s;
  cin >> a >> s;
  if(a >= 3200){
    cout << s;
  } else {
    cout << "red";
  }
  
 return 0;
}

Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Thu Apr 02 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        int B = in.nextInt();
        if(A >= 13){
            println(B);
        }
        else if(A >= 6){
            println(B/2);
        }
        else{
            println(0);
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int Mxn = 200005;
int p[Mxn];

int par(int u)
{
	if(p[u]==u) return u;

	return (p[u] = par(p[u]));
}

void  uni(int a,int b)
{
   int p1 = par(a);
   int p2 = par(b);
   p[p2] = p1;
}

int main()
{
	fastio;
    int n,q;
    cin >> n >> q;
    
    for(int i=1;i<=n;i++) p[i] = i;
    while(q--)
    {
    	int t,u,v;
    	cin >> t >> u >> v;
    	if(t==0)
    	{
    		uni(u,v);
    	}else
    	{
    		cout<<(par(u)==par(v)?1:0)<<"\n";
    	}
    }
	return 0;
}

Measured memory_bytes: 4296
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, X = mapint()
Ls = list(mapint())

now = 0
cnt = 0
for l in Ls:
    if now>X:
        break
    now += l
    cnt += 1
else:
    if now<=X:
        cnt += 1
print(cnt)

Measured memory_bytes: 61884
N = int(input())
P = list(map(int,input().split()))

flag = []
for i in range(N-1):
  if P[i] > P[i+1]:
    flag.append(i)

if len(flag) > 2:
  print('NO')
if len(flag) == 2:
  A = P[flag[0]]
  B = P[flag[1]+1]
  P[flag[0]] = B
  P[flag[1]+1] = A
  for i in range(N-1):
    if P[i] > P[i+1]:
      print('NO')
      exit()
  print('YES')
  exit()
if len(flag) == 1:
  A = P[flag[0]]
  B = P[flag[0]+1]
  P[flag[0]] = B
  P[flag[0]+1] = A
  for i in range(N-1):
    if P[i] > P[i+1]:
      print('NO')
      exit()
  print('YES')
  exit()
if len(flag) == 0:
  print('YES')

Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 100005
typedef struct k{
  char name[10];
  int time;
}A;

void enqueue();
A dequeue();

int head=0,tail=0;
A Q[100000];
int main(){
  int i=0,n,q;
  int sum=0;
  A x;
  scanf("%d %d",&n,&q);
  for(i = 0; i < n; i ++){
    scanf("%s %d",Q[i].name,&Q[i].time);
  }
  head = 0;
  tail = n;
  
  while(head != tail){
    x = dequeue();
    if(x.time - q > 0){
      x.time -= q;
      sum += q;
      enqueue(x);
    }
    else if (x.time - q <= 0){
      sum += x.time;
      printf("%s %d\n",x.name,sum);
    }
  }
  return 0;
}
void enqueue(A x){
  Q[tail] = x;
  if(tail + 1 == MAX)tail = 0;
  else tail++;
}

A dequeue(){
  A x;
  x = Q[head];
  if(head + 1 == MAX) head = 0;
  else head++;
  return x;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n; cin >> n;
    string s; cin >> s;
    if(n < 3200) {
        cout << "red";
    }
    else {
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0
for b in range(1 << (n - 1)):
  sm = 0
  a = int(s[0])
  for i in range(n - 1):
    if b & (1 << i) != 0:
      sm += a
      a = 0
    a = a * 10 + int(s[i + 1])
  ans += (sm + a)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{

int n, ab;
cin >> n;
int a[n + 1];
for(int i = 0; i < n; ++i){
	cin>>ab;
	a[ab] = i + 1;
}
for(int i = 1; i < n + 1; ++i){
	cout << a[i] <<' ';
}
}

Measured memory_bytes: 1152
from collections import defaultdict
ri = lambda : list(map(int, input().split(' ')))


def solve():
    n, a, d = ri()

    if d == 0:
        print(1 if a == 0 else n + 1)
        return

    if d < 0:
        a, d = -a, -d

    dic = defaultdict(list)
    for i in range(n + 1):
        l = a * i + i * (i - 1) // 2 * d
        r = a * i + (n-i + n-1)*i // 2 * d
        dic[l % d].append((l // d, r // d + 1))
    
    ans = 0
    for p in dic.values():
        end = -1e18
        p.sort()
        for t in p:
            s, e = t
            if end < s:
                ans += (e-s)
                end = e
            if end < e:
                ans += (e - end)
                end = e

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 83540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(y%2!=0){
    cout<<"No"<<endl;}
  else if (4*x<y){
    cout<<"No"<<endl;}
  else if (y<2*x){
    cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static bool Solve(int H, int W, int N, int r, int c, string S, string T)
    {
        int U = 0, D = H - 1, L = 0, R = W - 1;
        for (int i = N - 1; i >= 0; --i)
        {
            switch (T[i])
            {
            case 'L': R = Math.Min(R + 1, W - 1); break;
            case 'R': L = Math.Max(L - 1, 0); break;
            case 'U': D = Math.Min(D + 1, H - 1); break;
            case 'D': U = Math.Max(U - 1, 0); break;
            }
            switch (S[i])
            {
            case 'L': L = Math.Min(L + 1, W); break;
            case 'R': R = Math.Max(R - 1, -1); break;
            case 'U': U = Math.Min(U + 1, H); break;
            case 'D': D = Math.Max(D - 1, -1); break;
            }
            if (L == W || R == -1 || U == H || D == -1) { return false; }
        }
        return U <= r && r <= D && L <= c && c <= R;
    }

    static void Main(string[] args)
    {
        int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] V2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        Console.WriteLine(Solve(V1[0], V1[1], V1[2], V2[0] - 1, V2[1] - 1, S, T) ? "YES" : "NO");
    }
}


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

int main(){
    int a, b, sum = 0;
	cin >> a >> b;
    int k[100000];
	vector<int>dis;
	for (int i = 0; i < b; ++i) { cin >> k[i]; }
	sort(k, k + b);
	if (a >= b) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < b; ++i) {
		dis.push_back(abs(k[i] - k[i - 1]));
		sum += abs(k[i] - k[i - 1]);
	}
	sort(dis.rbegin(), dis.rend());
	for (int i = 0; i < a - 1; ++i) {
		sum -= dis[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	char n; cin >> n;
	if('A'<=n&&n<='Z') cout << 'A' << endl;
	else cout << 'a' << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define inf (long long)(1e9)
using namespace std;

long long n, cnt = 0;
vector<string> v;
long long memo[205][205] = {0};

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(i == j)
        memo[i][j] = 0;
      else if(v[i][j] == '1')
        memo[i][j] = 1;
      else
        memo[i][j] = inf;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j) {
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
      }
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int k = 0; k < n; ++k)
        if(memo[i][j] != inf &&
           (memo[i][j] % 2) !=
               (memo[i][k] + memo[k][j]) % 2)
          return -1;
  long long ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      ans = max(ans, memo[i][j]);
      for(int k = 0; k < n; ++k) ans = max(ans, memo[i][j]);
    }
  return ans + 1;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
   	
int main() {
	int a, b;

	cin >> a >> b;

	if (a > 12)
	{
		cout << b;
	}
	else if (a < 13 && a > 5)
	{
		cout << b/2;
	}
	else if (a < 6)
	{
		cout << 0;
	}

	return 0;
}



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

vector<vector<int>> vec;
vector<bool> vis;

void dfs(int ind){
    if(vis[ind])
        return;
    vis[ind] = true;
    for(auto d:vec[ind])
        dfs(d);
}

int main(){
    int N,M;
    cin >> N >> M;
    vec.resize(N);
    vis.resize(N, 0);
    for (int i = 0; i < M;i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        vec[a].emplace_back(b);
        vec[b].emplace_back(a);
    }
    int ans = 0;
    for (int i = 0; i < N;i++){
        if(!vis[i]){
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
program main
    implicit none
    integer n,m,number
    read(*,*) n, m
    number = 0
    if (n > 1) then
        number = n*(n-1)/2
    end if
    if (m > 1) then
        number = number + m*(m-1)/2
    end if
    write(*,*) number

end program

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    double T, A;
    cin >> N >> T >> A;
    vector<double> s(N);
    for(int i = 0;i < N;i++){
        double t;
        cin >> t;
        s.at(i) = T - t*0.006;
    }
    
    int ans = 0;
    for(int i = 1;i < N;i++){
        if(abs(A - s.at(i)) < abs(A - s.at(ans))){
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
n = int(input())

d = {}

for i in range(n):
  a = input()
  if a not in d:
    d[a] = 1
  else:
    d[a] += 1

dsorted = sorted(d.items(), key=lambda x:x[1], reverse=True)

name = []
cnt = dsorted[0][1]

for i in dsorted:
  if i[1] == cnt:
    name.append(i[0])
  else:
    break

name.sort()

for i in name:
  print(i)

Measured memory_bytes: 48384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

int N, Q, K;
vector<pii> g[112345];
ll d[112345];

void dfs(int u, int prev, ll cost) {
	chmin(d[u], cost);
	
	REP(i, g[u].size()) {
		int v = g[u][i].fi;
		if (v == prev) continue;
		dfs(v, u, cost + g[u][i].se);
	}
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		g[a].push_back(pii(b, c));
		g[b].push_back(pii(a, c));
	}
	cin >> Q >> K;
	K--;
	
	fill(d, d + 112345, INF);
	
	dfs(K, -1, 0);
	
	
	while (Q--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		
		cout << d[x] + d[y] << endl;
	}
	
	return 0;
}


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

int main()
{
    int count=1;
    int maxh;
    int N;
    cin >> N;
    int H[30];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    maxh=H[0];
    for(int j=1;j<N;j++){
    if(H[j]>=maxh){
    count++;
    maxh=H[j];
    }
    }
    cout << count <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0;
  int x=0;
  int y=0;
  cin >> N;
  x = x + N/100;
  //cout << x << endl;
  N = N - 100*(N/100);
  //cout << N << endl;
  x = x + N/10;
  //cout << x << endl;
  N = N - 10*(N/10);
  //cout << N << endl;
  x = x + N;
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 305
typedef long long ll;
ll dist[maxn][maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        scanf("%lld",&dist[i][j]);
    int flag=1;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int f=1;
            for(int k=1;k<=n;k++)
            {
                if(dist[i][k]+dist[k][j]<dist[i][j])
                {
                    flag=0;
                    break;
                }
                if(k!=i&&k!=j&&i!=j)
                {
                    if(dist[i][k]+dist[k][j]==dist[i][j])
                        f=0;
                }
            }
            if(f)
                sum+=dist[i][j];
            if(!flag)
                break;
        }
        if(!flag)
            break;
    }
    if(!flag)
        printf("-1\n");
    else
        printf("%lld\n",sum/2);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    
    string s,t;ll flag=0;
    cin>>s;
    cin>>t;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            flag=1;
        }
    }
    if(flag==0 && s.size()+1==t.size())
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x, y; cin >> n >> x >> y;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int u, v; cin >> u >> v;
    if(u >= x && v >= y) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

template <int mod = (int)(1e9+7)>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

template <typename T>
struct Combination {
  vector<T> _fact, _rfact, _inv;

  Combination(ll sz=5e6) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if (q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if (n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

int main() {
  Combination<ModInt<>> com(1e6+2);
  int x, y;
  ModInt<> ans=0;
  cin >> x >> y;
  rep(two, x/2+1){
      int one = x - 2LL * two;
      if(y==one*2LL + two){
            int total = one + two;
            ans += com.C(total, one);
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14708
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(a);
    sort(b.begin(), b.end());
    map<int, int> pos;
    for (int i = 0; i < n; i++) {
        pos[b[i]] = i;
    }
    int dist = 0;
    for (int i = 0; i < n; i++) {
        if (abs(i - pos[a[i]]) % 2)
            dist++;
    }
    cout << (dist / 2) << endl;
    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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

const long long INF = 1LL << 60;

int main()
{
    int N, H;
    cin >> N >> H;

    vector<int> a(N), b(N);
    rep(i, N) {
        cin >> a[i] >> b[i];
    }

    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));

    ll cnt = 0;
    bool flag = false;

    rep(i, N) {
        if (b[i] < a[0]) break;
        H -= b[i];
        cnt++;
        if (H <= 0) {
            flag = true;
            break;
        }
    }

    if (!flag) {
        if (H % a[0] != 0) cnt++;
        cnt += H / a[0];
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <cmath> 
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;

    for(int i=0;i<n;i++){
        if(ans<k)ans*=2;
        else ans+=k;
    }
    cout<<ans<<endl;
}

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

bool isYYMM(string s){
    int month = stoi(s.substr(2, 2));
    return month <= 12 && month > 0;
}

bool isMMYY(string s){
    int month = stoi(s.substr(0, 2));
    return month <= 12 && month > 0;
}


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    if(isYYMM(s) && isMMYY(s)){
        cout << "AMBIGUOUS" << '\n';
    }
    else if(isYYMM(s)){
        cout << "YYMM" << '\n';
    }
    else if(isMMYY(s)){
        cout << "MMYY" << '\n';
    }
    else{
        cout << "NA" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	int n, a1 = 0, a4 = 0;
	bool b=true;
	cin >> n;
	rep(i, n) {
		int in;
		cin >> in;
		if (in % 4 == 0)a4++;
		else if (in % 2 == 1)a1++;
		else if (b) {
			a1++;
			b = false;
		}
	}
	if (a1 <= a4 + 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	end;
}


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

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int h,w;
    cin>>h>>w;
    char arr[h+2][w+2];
    memset(arr,0,sizeof(arr));
    queue<pair<int,int>> q;
    int  dist[h+2][w+2];
    memset(dist,-1,sizeof(dist));    
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
      cin>>arr[i][j]; 
        if(arr[i][j]=='#') {
            q.push({i,j}); 
            dist[i][j]=0;
        }
    } 

        int arahx[4]={0,0,-1,1}, arahy[4]={-1,1,0,0},ans=0;
            while(!q.empty()){
                int x=q.front().first;
                int y=q.front().second;
                q.pop();

                for(int j=0;j<4;j++){
                    if(arr[arahx[j]+x][arahy[j]+y]=='.'&&arahx[j]+x>0&&arahx[j]+x<=h&&arahy[j]+y>0&&arahy[j]+y<=w&&(dist[arahx[j]+x][arahy[j]+y]>dist[x][y]+1||dist[arahx[j]+x][arahy[j]+y]==-1)){
                        //cout<<j<<endl;
                        dist[arahx[j]+x][arahy[j]+y]=dist[x][y]+1;
                        q.push({arahx[j]+x,arahy[j]+y});
                        ans=max(ans,dist[x][y]+1);
                    }
                }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13328
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define MOD 1000000007
int h, w, k;
ll g[111], f[111][11];
ll dg(int a){
	if(a < 0) return 1;
	return g[a];
}
int main(){
	scanf("%d %d %d", &h, &w, &k);
	g[0] = 1, g[1] = 1, g[2] = 2;
	f[0][1] = 1;
	for(int i = 3; i <= 10; i++) g[i] = (g[i - 1] + g[i - 2]) % MOD;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++){
			f[i][j] += f[i - 1][j - 1] * dg(j - 2) % MOD * dg(w - j);
			f[i][j] += f[i - 1][j + 1] * dg(j - 1) % MOD * dg(w - j - 1);
			f[i][j] += f[i - 1][j] * dg(j - 1) % MOD * dg(w - j);
			f[i][j] %= MOD;
		//	printf("%d %d %lld\n", i, j, f[i][j]);
		}
	printf("%lld\n", f[h][k]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX_N = 1000, MAX_W = 1000;

int main(){
	int dp[MAX_N+1][MAX_W+1], wdp[MAX_N+1][MAX_W+1];
	int W,N,v[MAX_N],w[MAX_N],C = 1;
	while(cin >> W,W){
		memset(dp,0,sizeof(dp));
		memset(v,0,sizeof(v));
		memset(w,0,sizeof(w));
		std::cin >> N;
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d,%d",&a,&b);
		v[i] = a, w[i] = b;
	}
	for(int i=N-1;i>=0;i--){
		for(int j=0;j<=W;j++){
			if(w[i] > j)
				dp[i][j] = dp[i+1][j];
			else{
				dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]] + v[i]);
			}
		}
	}
	int wmv;
	for(int i=0;i<=W;i++){
		if(dp[0][i] == dp[0][W]){wmv = i;break;}
	}
	cout << "Case " << C++ << ":" << endl << dp[0][W] << endl << wmv << endl;
	}
	return 0;
}

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

int main(void)
{
	int i, N, a[N];
	int counter=0;

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

	for(i=0; i<N; i++)
	{
		while(1)
		{
			if(a[i]%2 == 0)
			{
				a[i] /= 2;
				counter += 1;
			}
			else
			{
				break;
			}
		}
	}
	printf("%d", counter);
	
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader input1 = new BufferedReader(new InputStreamReader(System.in));
        String input2 = input1.readLine();
        String[] fac = input2.split("\\s+");
        int a = Integer.parseInt(fac[0]);
        int b = Integer.parseInt(fac[1]);
        int ab = a * b;
        int syu = 2 * (a + b);
        System.out.println(ab+" "+syu);

        }
    }



Measured memory_bytes: 24292
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

void g(vector<int>&clu)
{
	int zer[2] = {};
	for (int i = 0; i < clu.size(); ++i)
	{
		if (clu[i] == 0)zer[0]++; else zer[1]++;
		clu[i] = clu[i] * 114514 + zer[clu[i]];
	}
}

int f(vector<int>war, vector<int>to, int n)
{
	g(war); g(to);
	int cost = 0;
	for (int i = 0; i < n; ++i)
	{
		int val = war[i];
		int pl = find(to.begin(), to.end(), val) - to.begin();
		if (pl == n)
		{
			return 114514810;
		}
		cost += abs(pl - i);
	}
	return cost / 2;
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int>war, one, two;
	for (int i = 0; i < n; ++i)
	{
		int tmp; cin >> tmp;
		war.push_back(tmp);
	}
	bool flag = false;
	for (int i = 0; i < m; ++i)
	{
		int tmp; cin >> tmp;
		for (int j = 0; j < tmp; ++j)
		{
			one.push_back(flag);
			two.push_back(!flag);
		}
		flag = !flag;
	}
	cout << min(f(war, one, n), f(war, two, n)) << endl;
	return 0;
}

Measured memory_bytes: 3152
import math
k=int(input())
d=0
for i in range(1,k+1):
    for j in range(i+1,k+1):
        for l in range(j+1,k+1):
            c=math.gcd(i,j)
            d+=6*(math.gcd(c,l))
for i in range(1,k+1):
    for j in range(i+1,k+1):
        d+=6*(math.gcd(i,j))
for i in range(1,k+1):
    d+=i
print(d)



Measured memory_bytes: 9116
import java.util.*;
import java.io.*;

public class Main {	
	
	private static void solve(){
		//Implement solution here.
		long X = nl();
		for(int i = -200; i <= 200; i++) {
			for(int j = -200; j <= 200; j++) {
				if((long)Math.pow(i, 5) - (long)Math.pow(j, 5) == X) {
					System.out.println(i + " " + j);
					return;
				}
			}
		}
//		for(int i = 0; i < 1000; i++) {
//			System.out.println(i);
//			System.out.println((long)Math.pow(i + 1, 5) - (long)Math.pow(i, 5));
//		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25800
#include<cstdio>
#include<vector>


using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;


int min_u(int&m, int v)
{
	if(m>v || m==-1)
	{
		m=v;
		return 1;
	}
	return 0;
}


int main(void)
{
	int d, g;

	while(scanf("%d%d", &d, &g)==2)
	{
		vi c(d+1);
		vi p(d+1);
		int ans=0;

		g/=100;
		for(int i=1;i<=d;i++)
		{
			scanf("%d%d", &p[i], &c[i]);
			c[i]/=100;
			ans+=p[i];
		}
		int dp_size=g;
		vvi dp(d+1);

		for(auto&mdp:dp)
		{
			mdp.assign(dp_size+1, -1);
		}
		dp[0][0]=0;

		for(int i=1;i<=d;i++)
		{
			for(int j=0;j<=dp_size;j++)
			{
				if(dp[i-1][j]<0) continue;

				int s=j+i*p[i]+c[i];
				if(s>dp_size) s=dp_size;
				min_u(dp[i][s], dp[i-1][j]+p[i]);

				for(int k=0;k<p[i];k++)
				{
					s=j+i*k;
					if(s>dp_size) s=dp_size;
					min_u(dp[i][s], dp[i-1][j]+k);
				}
			}
		}
/*
		for(int i=1;i<=d;i++)
		{
			for(int j=0;j<=dp_size;j++) printf("%3d ", dp[i][j]);
			printf("\n");
		}
*/
		printf("%d\n", dp[d][dp_size]);
	}
	return 0;
}


Measured memory_bytes: 4864
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst.sort()
lst = lst[::-1]
ans = 0

while m > 0:
    if lst[-1][1] <= m:
        ans += lst[-1][0] * lst[-1][1]
        m -= lst[-1][1]
    else:
        break
    lst.pop()

if m > 0:
    ans += lst[-1][0] * m

print(ans)

Measured memory_bytes: 28264
#include <iostream>
#include <unordered_map>

using namespace std;

int main()
{
  uint64_t n, m;
  cin >> n >> m;
  uint64_t a[n];
  for (auto i = 0; i < n; i++) {
    uint64_t v;
    cin >> v;
    a[i] = v;
  }
  uint64_t b[n + 1];
  b[0] = 0;
  uint64_t sum = 0;
  for (auto i = 0; i < n; i++) {
    sum += a[i];
    b[i + 1] = sum;
  }

  unordered_map<uint64_t, uint64_t> um;
  for (auto i = 0; i < n + 1; i++) {
    auto it = um.find(b[i] % m);
    if (it == end(um)) {
      um.insert(pair<uint64_t, uint64_t>(b[i] % m, 1));
    } else {
      uint64_t v = it->second;
      um.erase(it);
      um.insert(pair<uint64_t, uint64_t>(b[i] % m, v + 1));
    }
  }

  uint64_t ans = 0;
  for (auto&& e : um) {
    uint64_t v = e.second;
    ans += (v * v - v) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5260
def examA():
    A, B, C = LI()
    ans = min(A*B*(C%2),A*C*(B%2),B*C*(A%2))
    print(ans)
    return

def examB():
    class segment_():
        def __init__(self, A, n, segfunc):
            #####単位元######要設定0or1orinf
            self.ide_ele = inf
            ####################
            self.num = 1 << (n - 1).bit_length()
            self.seg = [self.ide_ele] * 2 * self.num
            self.segfunc = segfunc
            # set_val
            for i in range(n):
                self.seg[i + self.num] = A[i]
                # built
            for i in range(self.num - 1, 0, -1):
                self.seg[i] = self.segfunc(self.seg[2 * i], self.seg[2 * i + 1])

        def update(self, k, r):
            k += self.num
            self.seg[k] = r
            while k:
                k >>= 1
                self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

        # 値xに1加算
        def update1(self, k):
            k += self.num
            self.seg[k] += 1
            while k:
                k >>= 1
                self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

        def updateneg1(self, k):
            k += self.num
            self.seg[k] -= 1
            while k:
                k >>= 1
                self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

        def query(self, p, q):
            if q < p:
                return self.ide_ele
            p += self.num;
            q += self.num
            res = self.ide_ele
            while p < q:
                if p & 1 == 1:
                    res = self.segfunc(res, self.seg[p])
                    p += 1
                if q & 1 == 1:
                    q -= 1
                    res = self.segfunc(res, self.seg[q])
                p >>= 1;
                q >>= 1
            return res
    N, x = LI()
    A = LI()
    Seg_min = segment_(A, N, lambda a, b: min(a,b))
    ans = inf
    for k in range(N):
        cur = 0
        for j in range(N):
            if j-k>=0:
                now = Seg_min.query(j-k,j+1)
            else:
                now = min(Seg_min.query(0,j+1),Seg_min.query(N-(k-j),N))
#            print(now,k,j)
            cur += now
        ans = min(ans,cur+k*x)

    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 58844
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1ll < 60;
int main()
{
    ll n, x, d;
    cin >> n >> x >> d;

    if (d == 0){
        if (x == 0){
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
		return 0;
    }

    map<ll, vector<P>> mp;
    // iX + jD
    rep(i, n + 1){
        ll start = i*x;
        ll left = (ll)i*(i-1)/2;
        ll len = (ll)i*(n-i) + 1;
        start += left*d;     // iX + jD(j:min)
        mp[(start%d + d)%d].emplace_back(start, len);      //map
        //printf("%d %lld %lld %lld\n", i,(start%d + d)%d, start, len); 
    }

    ll ans = 0;
    for (auto p: mp){
        
        auto stra = p.second;
        for (auto& i : stra){
            i.first = (i.first - p.first) / d;
        }
        // int m = stra.size();
        // rep(i,m) stra[i].first = (stra[i].first-p.first)/d;

        vector<P> range;
        for (auto i : stra){
            range.emplace_back(i.first, 1);
            range.emplace_back(i.first + i.second, -1);
        }

        sort(range.begin(), range.end());
        ll cnt = 0; 
        ll bef = -INF;
        for (auto i : range){
            //printf("%lld, %lld\n",i.first, i.second);
            if (cnt) ans += i.first - bef;
            bef = i.first;
            cnt += i.second;

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

Measured memory_bytes: 22144
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[510][510];
int dp[310][310];
int t[610][310];
int ABS(int a){
	return max(a,-a);
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	long long ret=0;
	for(int i=0;i<b-1;i++){
		for(int k=0;k<=a;k++){
			for(int j=0;j<=a;j++)dp[k][j]=999999999;
		}
		dp[0][0]=0;
		for(int j=-a;j<=a;j++){
			int cur=0;
			for(int k=0;k+ABS(j)<a;k++){
				if(j>=0&&in[j+k][i]==in[k][i+1])cur++;
				if(j<0&&in[k][i]==in[-j+k][i+1])cur++;
				t[j+300][k]=cur;
			}
		}
		for(int j=0;j<=a;j++){
			for(int k=0;k<=a;k++){
				if(j<a){
					dp[j+1][k]=min(dp[j+1][k],dp[j][k]+t[(j-k)+300][a-1-max(j,k)]);
				}
				if(k<a){
					dp[j][k+1]=min(dp[j][k+1],dp[j][k]+t[(j-k)+300][a-1-max(j,k)]);
				}
			}
		}
	//	printf("%d\n",dp[a][a]);
		ret+=dp[a][a];
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))

shain_dic = {}

for i in range(1,N+1):
    shain_dic[i] = 0

for i in range(N-1):
    shain_dic[A[i]] += 1

for i in shain_dic:
    print(shain_dic.get(i))

Measured memory_bytes: 38804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" <<endl;
    else cout << "ABC" <<endl;
    
}

Measured memory_bytes: 3636
a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(a+2)]
dp[0]=0
for i in range(a+1):
    for j in c:
        if i + j <= a:
            dp[i+j] = min(dp[i+j],dp[i] + 1)
            
print(dp[a])
            
        


Measured memory_bytes: 7392
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    string s; cin >> s;
    ll rs = 0;
    ll ws = 0;
    bool w_nocnt = true;
    ll start = 0;
    ll end = n-1;
    ll ans = 0;
    while(start <= end){
        while(s[start] == 'R'){
            start++;
            if (start == n-1){
                break;
            }
        }
        while(s[end] == 'W'){
            end--;
            if (end == 0){
                break;
            }
        }
        if (start >= end){
            break;
        }
        ans++;
        start++;
        end--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
int main(void){
    int w, a, b, move=0;
    scanf("%d%d%d", &w, &a, &b);
    if(a<b && (a+w)>=b) move=0;
    else if(a<b) move=b-(a+w);
    else if(a>b && (b+w)>=a) move=0;
    else if(a>b) move=a-(b+w);
    printf("%d", move);
    return 0;
}

Measured memory_bytes: 1732
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 17:26:13 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var X, Y string
	fmt.Scan(&X, &Y)
	x, _ := strconv.ParseUint(X, 16, 64)
	y, _ := strconv.ParseUint(Y, 16, 64)
	if x == y {
		fmt.Println("=")
	} else if x < y {
		fmt.Println("<")
	} else {
		fmt.Println(">")
	}
}


Measured memory_bytes: 512