akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in); 
		int n = as.nextInt();
		int[] a;
		a = new int[3*n];
		for(int i=0;i<3*n;i++){
			a[i] = Integer.parseInt(as.next());
		}
		Arrays.sort(a);
		long l = 0;
		for(int i=3*n-2;i>=n;i--){
			l+=a[i];
			i--;
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 64728
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=len(set(a))
if s<=k:
    print(0)
else:
    l=[0]*(max(a)+1)
    for i in range(n):
        l[a[i]]+=1
    l.sort()
    l=l[::-1]
    print(sum(l[k:]))


Measured memory_bytes: 25276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n); rank.resize(n);
    fill(par.begin(), par.end(), 1); fill(rank.begin(), rank.end(), 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};

ll a[1000],b[1000];

int main(void){
    ll n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    ll ans=0;
    for(int i=0;i<m;i++){
        UnionFind uf;
        uf.init(n);
        for(int j=0;j<m;j++){
            if(i==j) continue;
            uf.merge(a[j],b[j]);
        }
        if(uf.getSize(0)!=n) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
import sys
input=sys.stdin.readline
from collections import defaultdict,deque
def conv(n,a,b):
    return a*(2*n-a-1)//2+b-a-1

n=int(input())
v=n*(n-1)//2
A=[list(map(lambda x: int(x)-1,input().split())) for _ in range(n)]
Edges=[]
for i in range(n):
    l=len(A[i])
    for j in range(l-1):
        a=A[i][j]
        b=A[i][j+1]
        fr_i,fr_j=min(i,a),max(i,a)
        to_i,to_j=min(i,b),max(i,b)
        Edges.append((conv(n,fr_i,fr_j),conv(n,to_i,to_j)))
Outs=defaultdict(list)
In_cnt=defaultdict(int)
for v1,v2 in Edges:
    Outs[v1].append(v2)
    In_cnt[v2]+=1
q=deque((v0,1) for v0 in range(v) if In_cnt[v0]==0)
TopologicalSort=[]
while q:
    v1,d=q.popleft()
    TopologicalSort.append((v1,d))
    for v2 in Outs[v1]:
        In_cnt[v2]-=1
        if In_cnt[v2]==0:
            q.append((v2,d+1))
print(TopologicalSort[-1][1] if len(TopologicalSort)==n*(n-1)//2 else -1)

Measured memory_bytes: 238016
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
Y = []
if N>=M:
    print(0)
else:
    for i in range(M-1):
        Y.append(X[i+1]-X[i])
    Y=sorted(Y)[::-1]
    print(sum(Y[N-1:]))

Measured memory_bytes: 92484
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var kx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var k = kx[0];
        var x = kx[1];
        Console.WriteLine(k * 500 >= x ?  "Yes" : "No");
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

int  main() {
	ll n; cin >> n;
	cout << (n - 1)*n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 50030; 

bool prime[MAX_N];
vector<int> p;

void make_prime (void )
{
	fill (prime, prime+MAX_N, true );
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i < MAX_N; i++ ){
		if (prime[i] ){
			for (int j = 2*i; j < MAX_N; j += i ){
				prime[j] = false;
			} // end for
		} // end if
	} // end for

	p.clear();
	rep (i, MAX_N ){
		if (prime[i] ) p.push_back (i );
	} // end rep

//	cerr << "last_prime: " << p[p.size() - 1] << endl;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.PNII", "r", stdin );
	make_prime ();

	int n;
	while (~scanf ("%d", &n ) ){
		int max_p, min_p;
		vector<int>::iterator it = upper_bound (ALL (p ), n );
		int i = (int)(it-p.begin());
		min_p = p[i];
		for (; i >= 0; i-- ){
			if (p[i] < n ){
				max_p = p[i];
				break;
			} // end if
		} // end for
		printf ("%d %d\n", max_p, min_p );
	} // end while	

	return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

void solve(int n) {
	int ans = INF;
	string s;
	vector<string> ss,vs;
	vvi vv(n, vi(n, 0));
	rep(i, n) {
		cin >> s;
		ss.push_back(s);
	}
	rep(i, n) {
		rep(j, n) {
			if (i != j) {
				if (ss[i].find(ss[j]) != std::string::npos) {
					bool sw = true;
					rep(k, vs.size()) {
						if (vs[k] == ss[j])sw = false;
					}
					if (sw)vs.push_back(ss[j]);
				}
			}
		}
	}
	rep(i, vs.size()) {
		rep(j, ss.size()) {
			if (vs[i] == ss[j]) {
				ss.erase(ss.begin() + j);
				n--;
				break;
			}
		}
	}

	rep(i, n) {
		rep(j, n) {
			if (i != j) {
				int t = 0;
				rep(k, min(ss[i].size(), ss[j].size())) {
					if (ss[i].substr(ss[i].size() - k - 1, k + 1) == ss[j].substr(0, k + 1))t = k + 1;
				}
				vv[i][j] = ss[j].size() - t;
			}
		}
	}
	//bitdp
	vvi dp(pow(2, n), vi(n, INF));
	rep(i, n) {
		dp[1 << i][i] = ss[i].size();
	}
	rep(i, pow(2, n)) {
		rep(j, n){
			if(dp[i][j]!=INF){
				rep(k, n) {
					if (!((1 << k) & i)) {
						dp[(1 << k) + i][k] = min(dp[(1 << k) + i][k], dp[i][j] + vv[j][k]);
					}
				}
			}
		}
	}
	cout << *min_element(all(dp.back())) << endl;
}

int main() {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
}



Measured memory_bytes: 4424
N = int(input())
n = round(N**0.5)
counter = [0]*N
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      f = i**2+j**2+k**2+i*j+j*k+k*i
      if f <= N:
        counter[f-1] += 1
for i in range(N):
  print(counter[i])

Measured memory_bytes: 9464
/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	5000

int compare(const void *a, const void *b) {
	char *s = *(char **) a;
	char *t = *(char **) b;

	return strcmp(s, t);
}

int main() {
	static char cc[N + 1], *ss[N * 5];
	int n, k, h, i, j, cnt;

	scanf("%s%d", cc, &k);
	n = strlen(cc);
	cnt = 0;
	for (i = 0; i < n; i++)
		for (j = i; j < n && j < i + k; j++)
			ss[cnt++] = strndup(cc + i, j - i + 1);
	qsort(ss, cnt, sizeof *ss, compare);
	for (h = 0; h < cnt; h++)
		if (h == 0 || strcmp(ss[h], ss[h - 1]) != 0)
			if (--k == 0) {
				printf("%s\n", ss[h]);
				return 0;
			}
	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define maxn 100005
#define inf (1<<30)
#define mod 1000000007
using namespace std;
typedef long long LL;
int main()
{
    int x1,x2,x3,x4,y1,y2,y3,y4;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    x3=x2-(y2-y1);
    y3=y2+(x2-x1);
    x4=x3-(y3-y2);
    y4=y3+(x3-x2);
    printf("%d %d %d %d\n",x3,y3,x4,y4);
}


Measured memory_bytes: 256
class Node
  attr_accessor :p, :num, :left, :right
  def initialize(p, num)
    @p = p
    @num = num
    @left = nil
    @right = nil
  end
end

def addnode(tree, p, num, axis)
  if tree == nil then
    tree = Node.new(p, num)
    return tree
  end
  axis ^= 1 # swap axis

  if tree.p[axis] > p[axis]
    tree.left = addnode(tree.left, p, num, axis)
  else
    tree.right = addnode(tree.right, p, num, axis)
  end
  return tree
end

def range_search(tree, r, axis)
  axis ^= 1 # swap asis
  ans = []
  unless r[0] > tree.p[0] || tree.p[0] > r[1] || r[2] > tree.p[1] || tree.p[1] > r[3]
    ans << tree.num
  end
  if tree.left && r[2*axis] <= tree.p[axis]
    ans += range_search(tree.left, r, axis)
  end
  if tree.right && tree.p[axis] <= r[2*axis+1]
    ans += range_search(tree.right, r, axis)
  end
  return ans
end

n = gets.to_i
arr = Array.new(n){[]}

tree = nil
n.times{|i|
  arr[i] = gets.split.map(&:to_i)
  arr[i] << i
}
# to make semi-balanced tree
arr.shuffle.each{|i|
  tree = addnode(tree, i[0,2], i[2], 0)
}

q = gets.to_i

q.times{
  range_search(tree, gets.split.map(&:to_i),  0).sort.each{|i|
    puts i
  }
  puts
}

Measured memory_bytes: 167196
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from itertools import accumulate

def main():
    N, K = LI()
    V = LI()
    acc = [0] + list(accumulate(V))
    ans = 0
    for i in range(min(N, K) + 1):
        for p in range(i + 1):
            tmp = acc[p] + (acc[-1] - acc[-(i - p + 1)])
            sub = sorted(V[:p] + V[N - (i - p):])
            for s in sub[:K - i]:
                if s >= 0:
                    break
                tmp -= s
            ans = max(ans, tmp)
    return ans

print(main())

Measured memory_bytes: 3064
N = int(input())
a = input().split(" ")
a = [int(i) for i in a]
list = []
x = 1
for i in range(N):
  x *= a[i]
#print(x)
i = x-1
#print(a)
while True:
    temp = 0
    for j in range(N):
        temp += i % a[j]
    #print(temp)
    list.append(temp)
    #print(list)
    if i >= 3:
        if list[i-(x-1)] == 0:
            print(list[i-1-(x-1)])
            break
    i += 1


#print(max(list))
#print(list)

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

import numpy as np
N = int(read())
U = 10**6 + 100
x = np.arange(1,U,dtype=np.int64)
div = x[N%x==0]
ans = (div + (N//div)).min() - 2
print(ans)

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int N, M, P;
	while (cin >> N >> M >> P, (N || M || P)) {
		int num, sum = 0;
		REP(i, 1, N + 1) {
			int x; cin >> x;
			sum += x;
			if (i == M) num = x;
		}

		sum *= (100 - P);
		if (num) {
			int ans = sum / num;
			cout << ans << endl;
		} else {
			cout << num << endl;
		}
	}
	return 0;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,m;cin>>n>>m;

  int a,b;
  vector<pii> x;
  rep(i, m){
    cin>>a>>b;
    x.pb(mp(b,a)); //終端でsort
  }
  sort(all(x));
  dump(x);

  int l,r;
  int mr=0;
  int cnt = 0;
  rep(i, m){
    r = x[i].first; l = x[i].second;
    if (mr<=l){
      cnt++;
      mr=r;
    }
  }
  cout << cnt << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<vector<int>> field(n+1,vector<int>(n+1,0));
  int l,r;
  for(int i=0;i<m;i++){
    cin >> l >> r;
    field[l][r]++;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      field[i][j]+=field[i-1][j]+field[i][j-1]-field[i-1][j-1];
    }
  }
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << field[n][r]-field[l-1][r] << endl;
  }

  return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#define MAX 100005
#define NIL -1
void print(int);
void rec(int,int);

typedef struct {
  int p, l, r;
} node;
 

 
node T[MAX];
int n,D[MAX];
 		       
int main() {
  int  i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
  }

  rec(r,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}
  
void rec(int u, int p) {
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

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

void solve(long long N, std::string S)
{
	int count = 0;

	for (int i = 0; i < N - 2; i++)
	{
		string s = S.substr(i, 3);

		if (s == "ABC")
			count++;
	}

	cout << count << endl;
}

int main()
{
	long long N;
	scanf("%lld", &N);
	std::string S;
	std::cin >> S;
	solve(N, S);
	return 0;
}


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

using namespace std;

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

    int n, l;
    int v[201];
    int rem[201];
    int soma = 0;
    int ret = 0;
    int menor = 999999999;
    int res = 0;

    cin >> n >> l;

    for (int i=1; i<=n; i++) {
        v[i] = l+i-1;
        soma += v[i];
    }

    for (int i=1; i<=n; i++) {
        rem[i] = soma-v[i];
    }

    for (int i=1; i<=n; i++) {
        if (abs(soma-rem[i]) < menor) {
            menor = abs(soma-rem[i]);
            res = i;
        }
    }

    cout << soma-v[res] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,s[333][333]={},t[333][333]={},r[333][333]={};
	int c=0;
	cin>>n;
	FOR(i,0,n){
		string st;
		cin>>st;
		FOR(j,0,n){

			s[i][j]=st[j]-'a';
		}
	}
	FOR(i,0,n){
		FOR(j,0,n){
			int f=1;
			FOR(d,1,n){
				int i1=i+d,j1=j+d;
				if(i1-n>=0)i1-=n;
				if(j1-n>=0)j1-=n;
				if(s[i1][j]!=s[i][j1])f=0;

			}
			r[i][j]=f;
		}
	}
	/*
	FOR(i,0,n){
		FOR(j,0,n){
			printf("%2d ",r[i][j]);
		}
		cout<<endl;
	}//*/
	FOR(a,0,n){
		FOR(b,0,n){
			int f=1;
			FOR(d,0,n){
				int i1=d-a,j1=d-b;
				if(i1<0)i1+=n;
				if(j1<0)j1+=n;
				if(r[i1][j1]==0)f=0;
			}
			c+=f;
		}
	}
	cout<<c<<endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<ll> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  ll res = (1ll<<60);
  for(ll i=-100;i<=100;i++){
    ll t = 0;
    for(int j=0;j<n;j++){
       t += pow(i-v[j], 2);
    }
    res = min(t, res);
  }
  cout<<res<<endl;

  return 0;
}


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

using namespace std;

vector<pair<char,char>> v;
int main()
{
    v.push_back(make_pair('A', 'T'));
    v.push_back(make_pair('T', 'A'));
    v.push_back(make_pair('C', 'G'));
    v.push_back(make_pair('G', 'C'));

    char b;
    cin>>b;
    for (int i=0; i<v.size(); i++)
    {
        if (b==v[i].first)
            cout<<v[i].second;
    }
}


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

int N;
vector<ll> s;
unordered_map<ll, int> nums;
bool is_prime[100001];
#define TEN_POWER_FIVE 100000
#define TEN_POWER_TEN 10000000000l

void set_eratosthenes() {
  for (int i = 2; i <= TEN_POWER_FIVE; i++) {
    is_prime[i] = true;
  }
  for (int i = 2; i <= TEN_POWER_FIVE; i++) {
    if (is_prime[i]) {
      for (int k = i + i; k <= TEN_POWER_FIVE; k += i) {
        is_prime[k] = false;
      }
    }
  }
}

void solve() {
  set_eratosthenes();

  // norm[s[i]]を求める
  for (int i = 0; i < N; i++) {
    for (ll k = 2; k <= CUBE_S_MAX; k++) {
      if (is_prime[k]) {
        while (s[i] % (k * k * k) == 0) {
          s[i] /= k * k * k;
        }
      }
    }
  }
  sort(s.begin(), s.end());

  // normをkey, 個数をvalueとしたunordered_mapに挿入
  for (int i = 0; i < N; i++) {
    if (nums.count(s[i])) {
      nums[s[i]]++;
    } else {
      nums[s[i]] = 1;
    }
  }

  int ans = 0;
  for (auto pair:nums) {
    ll key = pair.first;
    if (key != 1) {
      // pair(key) を求める
      ll acc = 1;
      double acc_double = 1.0;
      // 1. CUBE_S_MAXまでの素数
      for (ll k = 2; k <= CUBE_S_MAX; k++) {
        if (is_prime[k]) {
          if (key % (k * k) == 0) {
            key /= (k * k);
            acc *= k;
            acc_double *= k;
          } else if (key % k == 0) {
            key /= k;
            acc *= (k * k);
            acc_double *= (k * k);
          }
        }
      }
      if (key > 1) {
        // 2-1. 10^5までの素数の2乗
        ll square_tmp = (ll)(pow(float(key), 1.0/2.0) + 0.5);
        if (key == square_tmp * square_tmp && is_prime[square_tmp]) {
          acc *= square_tmp;
          acc_double *= square_tmp;
        }
        // 2-2. 10^5までの素数
        else if (key <= TEN_POWER_FIVE && is_prime[key]) {
          acc *= (key * key);
          acc_double *= (key * key);
        }
        else {
          acc = -1;
        }
      }

      if (acc_double <= (double)TEN_POWER_TEN && nums.count(acc)) {
        ans += max(nums[acc], nums[pair.first]);
        nums[acc] = 0;
        nums[pair.first] = 0;
      } else {
        ans += nums[pair.first];
      }
    }
  }
  if (nums.count(1)) ans++;
  cout << ans << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    ll x;
    cin >> x;
    s.push_back(x);
  }

  solve();
  return 0;
}


Measured memory_bytes: 5364
n,k=map(int,input().split())
count,point=0,0
if k%2!=0:
    while k*(count+1)<=n:
        count +=1
    print(count**3)
else:
    for i in range(1,n+1):
        if i%k==0:point +=1
        elif i*2%k==0:count +=1
    print(count**3+point**3)

Measured memory_bytes: 38896
import sys
input = lambda: sys.stdin.readline()


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x


n, m = map(int, input().split())
uf = UnionFind(n)

for _ in range(m):
    a, b, z = map(int, input().split())
    uf.unite(a - 1, b - 1)

cnt = 0
for x in uf.par:
    cnt += 1 if x < 0 else 0
print(cnt)


Measured memory_bytes: 78192
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
  int n=kbd.nextInt();
    int[] A= new int[n+1];
    for(int i=0;i<n-1;i++){
      A[kbd.nextInt()]++;
}
for(int t=1;t<=n;t++){
 System.out.println(A[t]);
}
}
}


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


int main(void){
    int n,m;
    cin >> n >> m;
    int ans = 1;
    for(int i=1; i<=min(m/n, (int)sqrt(m)); i++){
        if(m%i == 0){
            if(i >= n){
                ans = m/i;
                break;
            }else{
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).First();
            if (input >= 2800)
            {
                Console.WriteLine("AGC");
            }
            else if (input >= 1200)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


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

int main()
{
  int n,i,j,k,s=0,flag=0;;
  cin>>n;
  int A[n],B[n-1];




  for(i=0;i<n-1;i++)
    cin>>B[i];

    if(n==2)
      {
        cout<<2*B[0]<<endl;
        flag=1;
      }
  if(flag==0)
  {
  A[0]=B[0];
  s=A[0];
  for(i=0;i<n-2;i++)
  {
    if(B[i]>=B[i+1])
      A[i+1]=B[i+1];
    else
      A[i+1]=B[i];

    s+=A[i+1];
    if(i==n-3)
      A[n-1]=B[n-2];
  }
  s+=A[n-1];
  cout<<s<<endl;
  }
}


Measured memory_bytes: 764
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int count = 0;
            for(int i = 0; i < N; i++){
              int j = sc.nextInt();
              int k = sc.nextInt();
              int l = k - j + 1;
              count += l;
            }
            System.out.println(count);
          }
}

Measured memory_bytes: 25772
n,m=gets.split.map(&:to_i)
kiarray=Array.new(n).map{Array.new(2).map{Array.new}}
(n-1+m).times{
    parent,child=gets.split.map(&:to_i)
    kiarray[parent-1][1].push(child)
    kiarray[child-1][0].push(parent)
}

root=0
n.times{|k|
    if kiarray[k][0]==[]
        root=k+1
        break
    end
}

nisecount=0
que=[root]

while nisecount<m
    shift = que.shift
   children=kiarray[shift-1][1]

   
   children.map{|value|
        if !kiarray[value-1][0][1]
            que.push(value)
         else
            nisecount+=1
            kiarray[value-1][0].delete(shift)
        end
   }
end

kiarray.map.with_index{|value,index|
    if  index==root-1
        puts 0
    else
        puts value[0][0]
    end
}

Measured memory_bytes: 29692
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cerr << #x << ": " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int Smax = max(A*B, C*D);

    cerr << "S1 = " << A*B << endl;
    cerr << "S2 = " << C*D << endl;

    cout << Smax << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll, ll> > p;
ll a, b, c, d, nx, ny, nz, px, py, pz, dx, dy, dz, mod = 1000000007;
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
	return a.first * b.second < a.second * b.first;
}
int main() {
	cin >> a >> b >> c >> d;
	for (int i = 0; i <= d; i++) {
		if (i < a) {
			p.push_back({i, a});
			p.push_back({a - i - 1, a});
		}
		if (i < b) {
			p.push_back({i, b});
			p.push_back({b - i - 1, b});
		}
		if (i < c) {
			p.push_back({i, c});
			p.push_back({c - i - 1, c});
		}
	}
	sort(p.begin(), p.end(), cmp);
	ll ans = (min(a - 1, d) + 1) * (min(b - 1, d) + 1) * (min(c - 1, d) + 1);
	for (int i = 1; i < p.size(); i++) {
		nx = a * p[i].first / p[i].second;
		ny = b * p[i].first / p[i].second;
		nz = c * p[i].first / p[i].second;
		dx = min(a - 1, px + d) - max(0LL, px - d) + 1;
		dy = min(b - 1, py + d) - max(0LL, py - d) + 1;
		dz = min(c - 1, pz + d) - max(0LL, pz - d) + 1;
		if (nx + d < a) {
			ans += (nx - px) * dy % mod * dz % mod;
		}
		if (ny + d < b) {
			ans += (ny - py) * dz % mod * dx % mod;
		}
		if (nz + d < c) {
			ans += (nz - pz) * dx % mod * dy % mod;
		}
		px = nx;
		py = ny;
		pz = nz;
	}
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 10476
while 1:
    n,r = map(int, input().split())
    if n == r == 0:
        break
    a = list(range(1,n+1))[::-1]
    for i in range(r):
        p,c = map(int, input().split())
        p -= 1
        a = a[p:p+c]+a[:p]+a[p+c:]
    print(a[0])



Measured memory_bytes: 5612
#include <iostream>
#include <utility>
#include <algorithm>
#include <cstdlib>

using namespace std;

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

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

    int n;
    cin >> n;
    pii ai[n];
    for (int i = 0; i < n; i++) {
        cin >> ai[i].first;
        ai[i].second = i;
    }
    sort(ai, ai+n);

    ll dp[n][n];
    fill(dp[0], dp[n], 0);
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i; j < n; j++) {
            if (i < n - 1) {
                dp[i][j] = max(dp[i][j], dp[i+1][j] + 1ll * ai[j-i].first * abs(ai[j-i].second - i));
            }
            if (j > 0) {
                dp[i][j] = max(dp[i][j], dp[i][j-1] + 1ll * ai[j-i].first * abs(ai[j-i].second - j));
            }
        }
    }

    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 34932
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  string ws[n];
  for(int i = 0; i < n; i++) cin >> ws[i];
  sort(ws, ws + n);
  string out;
  for(int i = 0; i < n; i++) out += ws[i];
  cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a , b, c;
  cin >> a >> b >> c;
  cout << min(a+b,min(b+c,a+c)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

ll N,ans;

void dfs(ll x, int use){
  // cout << x << " " << use << endl;
  if(x>N) return;
  if(use == 0b111) ++ans;

  dfs(x*10+7, use | 0b001);
  dfs(x*10+5, use | 0b010);
  dfs(x*10+3, use | 0b100); 
}

int main() {
  cin >> N;
  dfs(0,0);
  cout << ans << endl;
}



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

int main() {
  int K;
  cin>>K;
  string S;
  cin>>S;
  int a;
  a=S.size();
  if(a<=K) cout<<S<<endl;
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<int> to[100005];
    vector<int> from[100005];
    for(int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        to[x].push_back(y);
        from[y].push_back(x);
    }

    ll dp[100005];
    for(int i = 0; i <= n; i++){
        dp[i] = -1;
    }
    
    for(int j = 0; j <= n; j++){
        stack<int> q;
        q.push(j);
        while(!q.empty()){
            int i = q.top();
            q.pop();
            if(dp[i] != -1) continue;

            ll count = 0;
            int j = 0;
            for(j; j < from[i].size(); j++){
                if(dp[from[i][j]] == -1){
                    q.push(i);
                    q.push(from[i][j]);
                    break;
                } else {
                    count = max(count, dp[from[i][j]]+1);
                }
            }
            if(j < from[i].size()){
                continue;
            }
            dp[i] = count;
        }
    }

    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ans = max(dp[i], ans);
    }

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

Measured memory_bytes: 12416
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
          	int ans = 0;
          	for(int i = 0;i<N;i++){
              for(int j = 0;j<N;j++){
                int sum = (i+1)*(j+1);
                if(sum<N){
                  ans++;
                }else{
                  break;
                }
              }
            }
          Console.WriteLine(ans);
                
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



Measured memory_bytes: 27516
using System;
using System.Collections.Generic;

namespace CodeForcesPractice
{
    class Program
    {
       
        public static int[] IntInput(string Line, int NumParam)
        {
            string[] RetArr = new string[NumParam];
            RetArr = Line.Split(' ');
            int[] arr = new int[NumParam];
            for (int i = 0; i < NumParam; i++)
            {
                arr[i] = Convert.ToInt32(RetArr[i]);
            }
            return arr;
        }
        
        public static void MixJuice()
        {
            int[] arr = IntInput(Console.ReadLine(), 2);
            int n = arr[0];
            int sum = 0;
            int k = arr[1];
            int[] nums = IntInput(Console.ReadLine(), n);
            Array.Sort(nums);
            for(int i=0;i<k;i++) {
                sum += nums[i];
            }
            Console.WriteLine(sum);
        }
        static void Main(string[] args)
        {
            MixJuice();
            Console.ReadLine();
        }
    }
}


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

int main(){
  int a , mn = 10 , ans = 0;
  for(int i = 0; i < 5; i++){
   cin >> a;
   if(a % 10 > 0){
     mn = min(mn , a % 10);
   }
   ans += (a + 9) / 10 * 10;
 }
  cout << ans - 10 + mn;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

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

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
    int a,b;
    cin >> a;
    
    double c;
    cin >> c;
    
    b = (c*100 + 0.5);
    
    int res = (a*b)/100;
    
    cout << res;
      
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3728
h,w = map(int,input().split())
a = ["." for i in range(w+2)]
dot_map = [a]
for _ in range(h):
    l = list(input())
    l.insert(0, ".")
    l.append(".")
    dot_map.append(l)
dot_map.append(a)

for i in range(1, h+1):
    for j in range(1,w+1):
        if dot_map[i][j] == ".":
            counter = 0
            if dot_map[i-1][j-1] == "#":
                counter += 1
            if dot_map[i-1][j] == "#":
                counter += 1
            if dot_map[i-1][j+1] == "#":
                counter += 1
            if dot_map[i][j-1] == "#":
                counter += 1
            if dot_map[i][j+1] == "#":
                counter += 1
            if dot_map[i+1][j-1] == "#":
                counter += 1
            if dot_map[i+1][j] == "#":
                counter += 1
            if dot_map[i+1][j+1] == "#":
                counter += 1
            dot_map[i][j] = str(counter)

for i in range(1, h+1):
    ans = dot_map[i]
    print("".join(ans[1:w+1]))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
//#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
//#include <cmath>
//#include <deque>
//#include <queue>
//#include <list>
#include <array>
using namespace std;
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	IOS;
	int n, k, x;
	cin >> n >> k >> x;
	cout << ((n + k - 1) / k ) * x;
}


Measured memory_bytes: 3604
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int n,q,t;
    string name;

    queue<pair<string,int> > Q;

    cin >> n >> q;
    for(int i=0;i<n;i++){
	cin >> name >> t;
	Q.push(make_pair(name,t));
     }
    
     pair<string,int> u;
     int elaps=0,a;

     while(!Q.empty()){
	u=Q.front(); Q.pop();
	a=min(u.second,q);
	u.second-=a;
	elaps+=a;
	if(u.second>0){
	    Q.push(u);
	}else{
	    cout << u.first << " " << elaps << endl;
	}
    }

    return 0;
}

Measured memory_bytes: 6148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n + 1, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
	vector<pair<int, string>> b(n);
	rep(i, n)  cin >> s[i]; 
	sort(s.begin(), s.end());
	int cnt = 1;
	int j = 0;
	rep(i, n) {
		if (s[i] != s[i + 1]) {
			b[j] = make_pair(-cnt, s[i]);
			cnt = 1;
			++j;
		}
		else ++cnt;
	}
	sort(b.begin(), b.begin()+j);
	cout << b[0].second << endl;
	rep2(i, 1, j) {
		if (b[i - 1].first == b[i].first) cout << b[i].second << endl;
		else return 0;
	}
}

Measured memory_bytes: 16384
x, y = gets.split.map(&:to_i)
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (a.include?(x) && a.include?(y)) || (b.include?(x) && b.include?(y)) || (c.include?(x) && c.include?(y))
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MAX_N 10010
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<ll> a(N + 1, 0), cnt(N + 1, 0);

  ll ans = 0;
  REP(i, N) {
    cin >> a[i];
    (a[i] > N) ? ans++ : cnt[a[i]]++;
  }
  REP(i, N + 1) {
    if (cnt[i] < i)
      ans += cnt[i];
    else if (cnt[i] > i)
      ans += cnt[i] - i;
  }

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

Measured memory_bytes: 1792
n, x = map(int, input().split())
A = list(map(int, input().split()))
counter = 0
if A[0] > x:
  counter += A[0] - x
  A[0] = x
for i in range(n-1):
  if A[i] + A[i+1] > x:
    counter += A[i+1] + A[i] - x
    A[i+1] = -A[i] + x
print(counter)

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

int main(){
    int n, m;// number of nodes & edges
    cin >> n >> m;

    vector<vector<int>> graph(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ans = 0;
    vector<int> paths(n-1);
    for(int i=0; i<n-1; i++){
        paths[i] = i+1;// 0-indexed
    }

    do{
        vector<int> p(n);// p[0] = 0
        for(int i=1; i<n; i++) p[i] = paths[i-1];
        
        int flag = 0;
        for(int i=0; i<n-1; i++){
            for(auto adjacent : graph[p[i]]){
                if(adjacent == p[i+1]){
                    flag += 1;
                    break;
                }
            }
        }
        if(flag == n-1) ans += 1;
    }while(next_permutation(paths.begin(),paths.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int D;
    std::cin>>D;
    int sum=0;
    if(D==25){
        cout << "Christmas" << endl;
    }else if(D==24){
        cout << "Christmas Eve" << endl;
    }else if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }else if(D==22){
        cout << "Christmas Eve Eve Eve" << endl;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;

int N,T,x[200009],n;
map<int,int>a[200009];
set<string>st;
vector<P2>v[200009];
string start,goal,str[200009];
map<int,string> s[200009];
P dis[200099];

int main(){
    cin>>N>>T;
    cin>>start>>goal;
    st.insert(start);
    st.insert(goal);
    r(i,N){
        cin>>x[i];
        r(j,x[i]){
            cin>>s[i][j];
            str[n+j]=s[i][j];
            a[i][j]=n+j;
            st.insert(s[i][j]);
        }
        r(j,x[i]-1){
            int y;
            cin>>y;
            v[n+j].push_back(P2(n+j+1,P(y,0)));
            v[n+j+1].push_back(P2(n+j,P(y,0)));
        }
        n+=x[i];
    }
    map<string,int>M;
    for(set<string>::iterator it=st.begin();it!=st.end();it++){
        string x=*it;
        str[n]=x;
        M[x]=n++;
    }
    r(i,N){
        r(j,x[i]){
            int y=M[s[i][j]];
            v[a[i][j]].push_back(P2(y,P(T,1)));
            v[y].push_back(P2(a[i][j],P(0,0)));
        }
    }
    priority_queue<P2,vector<P2>,greater<P2> >q;
    r(i,200099)dis[i]=P(1e9,1e9);
    r(i,n-st.size()){
        if(str[i]==start){
            q.push(P2(0,P(0,i)));
            dis[i]=P(0,0);
        }
    }
    while(!q.empty()){
        P2 p=q.top();q.pop();
        int now=p.second.second;
        int cost=p.first;
        int nori=p.second.first;
        if(dis[now]<P(cost,nori))continue;
        r(i,v[now].size()){
            int nex=v[now][i].first;
            int ncost=v[now][i].second.first+cost;
            int nnori=v[now][i].second.second+nori;
            P NEX=P(ncost,nnori);
            if(NEX<dis[nex]){
                dis[nex]=NEX;
                q.push(P2(ncost,P(nnori,nex)));
            }
        }
    }
    P ans=P(1e9,1e9);
    r(i,n-st.size()){
        if(str[i]==goal){
            ans=min(ans,dis[i]);
        }
    }
    if(ans==P(1e9,1e9))cout<<-1<<endl;
    else cout<<ans.first<<' '<<ans.second<<endl;
}


Measured memory_bytes: 62028