akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(a>=13)printf("%lld",b);
  else if(a>=6)printf("%lld",b/2);
  else printf("0");
}

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

int main()
{
  int n;
  std::cin >> n;

  std::vector<int> as;
  for(int i=0; i<n; i++)
  {
    int a;
    std::cin >> a;
    as.push_back(a);
  }

  std::vector<int> bs;
  for(int i=((as.size()-1)/2)*2; 0<=i; i-=2)
  {
    bs.push_back(as[i]);
  }
  for(int i=1; i<as.size(); i+=2)
  {
    bs.push_back(as[i]);
  }
  
  std::vector<int> cs;
  if( as.size() % 2 == 1 )
  {
    cs = bs;
  }
  else
  {
    for(int i=bs.size()-1; 0<=i; i--) { cs.push_back(bs[i]); }
  }

  for(const auto& e : cs) { std::cout << e << " "; }
}


Measured memory_bytes: 4596
N = int(input())
B = [int(b) for b in input().split()]

L = []

while B:
    temp = []
    for i in range(len(B)):
        if B[i] == i+1:
            temp.append(i+1)
    if temp:
        L.append(max(temp))
        B.remove(max(temp))
    else:
        break

if B:
    print(-1)
else:
    L.reverse()
    for l in L:
        print(l)

Measured memory_bytes: 3064
"""

https://atcoder.jp/contests/agc037/tasks/agc037_d

まず分かりやすさのため全部-1してMで割る
2番目の操作後に上から0行目には全部0 , 1行目には全部1…となればおk

すなわち、1番目の操作では各列に1個づつ数字が入るようにする必要がある
→これは貪欲にやればok・・・じゃない

ある列をうまくはめれば必ず次も可能？
→最後の列を考えると、足りない要素と残りの要素のsetは等しいのでokそう
→2部マッチング！

=====解説=====

そもそも何をマッチングさせてた？
→各行の置けるaとa
→   次数は不定 & 不定
→　Hallが成り立つと証明できない…
→　あれ???????正解解法もおかしくないか

"""

from collections import defaultdict
from collections import deque

route = []

def Ford_Fulkerson_Func(s,g,lines,cost):

    global route
    N = len(cost)
    ans = 0
    queue = deque([ [s,float("inf")] ])

    ed = [True] * N
    ed[s] = False

    route = [0] * N
    route[s] = -1

    while queue:

        now,flow = queue.pop()
        for nex in lines[now]:

            if ed[nex]: 
                flow = min(cost[now][nex],flow)
                route[nex] = now
                queue.append([nex,flow])
                ed[nex] = False

                if nex == g:
                    ans += flow
                    break
            
        else:
            continue
        break

    else:
        return False,ans


    t = g
    s = route[t]

    while s != -1:
        cost[s][t] -= flow
        if cost[s][t] == 0:
            lines[s].remove(t)

        if cost[t][s] == 0:
            lines[t].add(s)
        cost[t][s] += flow
        t = s
        s = route[t]

    return True,ans

def Ford_Fulkerson(s,g,lines,cost):

    ans = 0

    while True:
        fl,nans = Ford_Fulkerson_Func(s,g,lines,cost)

        if fl:
            ans += nans
            continue
        else:
            break
    
    return ans


from sys import stdin
import sys
sys.setrecursionlimit(10000)

N,M = map(int,stdin.readline().split())
B = [[None] * M for i in range(N)]

Bs = [[True] * M for i in range(N)]

A = []
for loop in range(N):

    a = list(map(int,stdin.readline().split()))
    A.append(a)

for loop in range(M):

    lines = defaultdict(set)
    cost = [ [0] * (2*N+2) for i in range(2*N+2) ]

    for i in range(N):
        lines[2*N].add(i)
        cost[2*N][i] = 1
    for i in range(N,2*N):
        lines[i].add(2*N+1)
        cost[i][2*N+1] = 1
    for i in range(N):
        for j in range(len(A[i])):
            lines[i].add((A[i][j]-1)//M + N)
            cost[i][(A[i][j]-1)//M + N] = 1

    Ford_Fulkerson(2*N,2*N+1,lines,cost)
    ans = []

    for i in range(N):
        for j in range(len(A[i])):
            if cost[i][(A[i][j]-1)//M + N] == 0:
                ans.append(A[i][j])
                del A[i][j]
                break
    #print (ans)
    for i in range(N):
        B[i][loop] = ans[i]
                

for i in B:
    print (*i)

C = [[None] * M for i in range(N)]
for j in range(M):
    tmp = []
    for i in range(N):
        tmp.append(B[i][j])
    tmp.sort()
    for i in range(N):
        C[i][j] = tmp[i]

for i in C:
    print (*i)


Measured memory_bytes: 88116
#include <bits/stdc++.h>    
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;

int n;
int L[33];
vector<int> v;
char S[100005];

ll dp[28][28];

int main()
{   
	ll ans = 0;
	scanf("%d%s",&n,S);
	for(int i=0; i<n; i++) L[(S[i]-'a')]++;
	for(int i=0; i<28; i++) if(L[i]>0) v.pb(L[i]);
	n = v.size();

	for(int i=0; i<n; i++) 

	dp[0][1] = v[0];
	
	for(int i=1; i<n; i++){
		dp[i][1] = (dp[i-1][1] + v[i]) % MOD;
		for (int l = 2; l <= n; ++l)
		{
			dp[i][l] = (dp[i-1][l] + ((dp[i-1][l-1] * v[i]) % MOD))%MOD;
		}
	}


	for(int i=1; i<=26; i++){
		ans = (ans + dp[n-1][i]) % MOD;
	}

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

Measured memory_bytes: 384
<?php

const CATEGORY_NUM = 3;

$piece_num = trim(fgets(STDIN));

$input_data = [];
for ($i = 0; $i < CATEGORY_NUM; $i++)
{
	$input_data[$i] = explode(' ', trim(fgets(STDIN)));
}

// sort
for ($i = 0; $i < CATEGORY_NUM; $i++)
{
	sort($input_data[$i]);
}

$res = 0;
$p = 0;
foreach (range(0, $piece_num) as $value)
{
	$bcon[$value] = 0;
}
foreach (range(0, $piece_num - 1) as $value)
{
	while ($p <= $piece_num - 1 && $input_data[1][$value] > $input_data[0][$p])
	{
		$p++;
	}
	$bcon[$value + 1] = $p + $bcon[$value];
}
$p = 0;
foreach (range(0, $piece_num - 1) as $value)
{
	while ($p <= $piece_num - 1 && $input_data[2][$value] > $input_data[1][$p])
	{
		$p++;
	}
	$res += $bcon[$p];
}

echo $res;


Measured memory_bytes: 85988
# 点数計算
def scoring(last_, c, s, t, d, score):
    # score += s[d][t[d]-1]
    score = s[d][t]
    k = 8
    
    for i in range(len(c)):
        # score -= c[i] * (d+1 - last_[d][i])
        # score -= c[i] * (d + 1 - last_[i])
        score -= k * c[i] * (d - last_[i]) + c[i] * (k * (k+1)) / 2
    return score


# input
score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
# t = []
# for i in range(D):
#     t.append(int(input()))
last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

ans = []
for d in range(D):
    # last[d][t[d]-1] = d+1
    last_dummy = last[d][:]
    score = 0
    t_d = 0
    for t in range(len(c)):
        last_dummy2 = last_dummy[:]
        last_dummy2[t] = d+1
        if score < scoring(last_dummy2, c, s, t, d, score):
            score = scoring(last_dummy2, c, s, t, d, score)

            t_d = t

    ans.append(t_d)
    last[d][t_d] = d+1


    # last更新
    for i in range(len(c)):
        last[d+1][i] = last[d][i]


[print(ans[i]+1) for i in range(D)]





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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll s;
  cin >> s;
  unordered_set<ll> nums {s};
  ll ans = 1;
  while (1) {
    if (s % 2 == 0) {
      s /= 2;
    } else {
      s = 3 * s + 1;
    }
    ans++;
    if (nums.find(s) != nums.end()) { break; }
    nums.insert(s);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N;
  while (cin >> N) {
    ll res = (N % 2 == 0 ? N / 2 - 1 : N / 2);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def dic_inc(d,k,v):
    if k in d: d[k] += v
    else: d[k] = v

s = {}
n = int(input())
for _ in range(n): dic_inc(s, input(), 1)
m = int(input())
for _ in range(m): dic_inc(s, input(),-1)
print(max(0, max(s.values())))


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  if(n%2!=0){
      cout << "No" << endl;
      return 0;
  }
  REP(i,n/2){
    if(s[i]!=s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for(int x=1;x<=n;++x){
		cout << "Case "<<x<<":\n";
		int T;
		cin>>T;
		for(int i=0; i<10; ++i){
			T=T*T;
			T%=100000000;
			T=	((T%1000000)/100000)*1000+
				((T%100000)/10000)*100+
				((T%10000)/1000)*10+
				((T%1000)/100);
			cout << T << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  int num = k - 1;
  int fst = x - num;
  int lst = x + num;

  for (int i = fst; i <= lst; i++) {
    cout << i ;
    cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());

		if (a % 2 == 0) {
			System.out.println(a/2 -1);			
		}else {
			System.out.println(a/2);
		}
		
		
	}
	
}

Measured memory_bytes: 21332
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,k = map(int,input().split())
  WANTS = n//k
  EX = n - k*WANTS
  dic = {}
  mi_ = float("inf")
  mi_ = min(mi_,EX)
  
  while True:
    if str(EX) in dic:
      break
    else:
      dic[str(EX)] = 1
      EX = abs(EX-k)
      mi_ = min(mi_,EX)
  print(mi_)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<vector<ll>> v;
vector<vector<ll>> comb(ll n){
  for(int i=0; i<v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int j=1; j<v.size(); j++){
    for(int k=1; k<j; k++){
      v[j][k]=(v[j-1][k-1]+v[j-1][k]);
    }
  }
  return v;
}
int main(){
  ll N,A,B,V; cin>>N>>A>>B;
  v.assign(N+1,vector<ll>(N+1,0));  
  vector<ll>Z(N);
  for(int i=0; i<N; i++){cin>>V; Z[i]=V;}
  sort(Z.begin(), Z.end());
  ll a=upper_bound(Z.begin(), Z.end(), Z[N-A])-lower_bound(Z.begin(), Z.end(), Z[N-A]);
  ll b=Z.end()-upper_bound(Z.begin(), Z.end(), Z[N-A]);
  if(Z[N-1]!=Z[N-A]) B=A;
  double ans=0; ll num=0;
  for(int i=0; i<A; i++) ans+=Z[N-1-i];
  ans/=A;
  comb(N);
  for(int i=A-b; i<=B-b; i++){
    num+=v[a][i];
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  cout<<fixed<<setprecision(0)<<num<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
vector<vector<int>> calcEvenGroups(int N){
    vector<vector<int>> groups(N/2);
    for(int i=0;i<N/2;i++){
        groups[i].push_back(i + 1);
        groups[i].push_back(N - i);
    }
    return groups;
}
void printv(vector<int> &v)
{
    for (auto item : v)
        cout << item << " ";
    cout << endl;
}
void printvv(vector<vector<int>> &v)
{
    for (auto item : v)
        printv(item);
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> groups;
    if(N%2==0){
        groups = calcEvenGroups(N);
    }
    else{
        groups = calcEvenGroups(N-1);
        groups.push_back({N});
    }
    // printvv(groups);
    vector<pair<int, int>> ans;
    for(int i=0;i<groups.size();i++){
        for(int j=i+1;j<groups.size();j++){
            // cout<<"i,j: "<<i<<" "<<j<<endl;
             if(j==i+1 || (i==0 && j==groups.size()-1))
                for(auto x: groups[i])
                    for(auto y: groups[j]){
                        ans.push_back(make_pair(x,y));
                    }
        }
    }
    cout<<ans.size()<<endl;
    for(auto pair: ans){
        cout<<pair.first<<" "<<pair.second<<endl;
    }
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 998244353;
constexpr llong inf = mod * mod;

int main() {
  llong N, K;
  vector<lpair> LR;

  cin >> N >> K;
  LR.resize(K);
  for (auto &in: LR) {
    cin >> in.first >> in.second;
  }

  vector<llong> ans(N + 1, 0);
  vector<llong> rui = {0, 1};
  ans[0] = 1;
  for (int i = 2; i <= N; i++) {
    for (auto lr: LR) {
      llong L = lr.first;
      llong R = lr.second;
      if (L > rui.size()) continue;

      // cerr << (int)rui.size() - L << " " << max((int)rui.size() - R - 1, 0ll) << " " << rui[rui.size() - L] << " " << rui[max((int)rui.size() - R, 0ll)] << endl;
      ans[i] = (ans[i] + (rui[(int)rui.size() - L] - rui[max((int)rui.size() - R - 1, 0ll)] + mod)) % mod;
    }
    rui.push_back((ans[i] + rui.back()) % mod);
  }

  cout << ans[N] << endl;

  return 0;
}

/*

[Li, Ri] = X + [0, Ri - X]

マス i に行く方法 → [i - Li, i - Ri] の和
大きい順にやりたいね

*/

Measured memory_bytes: 6908
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;

int main() {
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int maxw = 0,maxs = 0;
    for(int aa = 0;aa * a * 100 <= f;++aa)
        for(int bb = 0;aa * a * 100 + bb * b * 100 <= f;++bb) {
            int water = 100 * (a * aa + b * bb);
            int maxsugar = min(f - water,(a * aa + b * bb) * e);
            for(int cc = 0;c * cc <= maxsugar;++cc)
                for(int dd = 0;c * cc + d * dd <= maxsugar;++dd)
                    if(maxs == 0 || maxs * water < (c * cc + d * dd) * maxw) {
                        maxs = c * cc + d * dd,maxw = water;
                    }
        }
    printf("%d %d\n",maxs+maxw,maxs);}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	String s = sc.nextLine();
    	String s2 = s + s;
    	String p = sc.nextLine();
    	
    	if(s2.contains(p)) {
    		System.out.println("Yes");
    	}
    	else {
    		System.out.println("No");
    	}
    }
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N,cnt[3];
int main(){
	cin>>N;
	REP(i,N){
		int a;
		cin>>a;
		int p2=4;
		REP(i,3){
			if (a%p2==0){
				cnt[2-i]++;
				break;
			}
			p2/=2;
		}
	}
	if (cnt[0]<=cnt[2] || (cnt[0]==cnt[2]+1 && N==cnt[0]+cnt[2]))	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        String[] inputs = null;
        int n = 0;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line = br.readLine();
            n = Integer.parseInt(line);
            inputs = new String[n];
            for (int i = 0; i < n; i++) {
                inputs[i] = br.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        int[] mins = new int['z' - 'a' + 1];
        Arrays.fill(mins, 100);
        int[] tmp = new int[mins.length];
        for (int i = 0; i < n; i++) {
            char[] cs = inputs[i].toCharArray();
            Arrays.fill(tmp, 0);
            for (char c: cs) {
                tmp[c - 'a']++;
            }
            for (int j = 0; j < mins.length; j++) {
                if (mins[j] > tmp[j])
                    mins[j] = tmp[j];
            }
        }
        for (int i = 0; i < mins.length; i++) {
            for (int j = 0; j < mins[i]; j++)
                System.out.printf("%c", i+'a');
        }
    }
}


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

i = 100
j = 1

for t in range(100):
    if a % i == 0 and b % i == 0:
        if j==k:
            print(i)
            break
        else:
            j=j+1
            i=i-1
    else:
        i = i-1


Measured memory_bytes: 2940
# coding: utf-8
# Your code here!
num = int(input())
li =[]
count = 1
li.append(num)
while True:
    count += 1
    new_num = li[-1]/2 if li[-1]%2 == 0 else li[-1]*3+1
    if new_num in li:
        print (count)
        break
    else:
        li.append(new_num)

Measured memory_bytes: 2940
MOD = 10**9 + 7
K = input()
D = int(input())
N = len(K)
dp0 = [[0] * D for _ in range(N+1)]
dp1 = [[0] * D for _ in range(N+1)]
dp0[0][0] = 1
for i, digit in enumerate(K, 1):
    digit = int(digit)
    for d in range(D):
        for k in range(10):
            dp1[i][(d + k) % D] += dp1[i-1][d]
            dp1[i][(d + k) % D] %= MOD
            if k < digit:
                dp1[i][(d + k) % D] += dp0[i-1][d]
                dp1[i][(d + k) % D] %= MOD
            elif k == digit:
                dp0[i][(d + k) % D] += dp0[i-1][d]
                dp0[i][(d + k) % D] %= MOD
print((dp0[N][0] + dp1[N][0] - 1) % MOD)

Measured memory_bytes: 60524
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n,l);
  vector<int> a(n,0);
  int sm = 0;
  REP(i,n){
    a[i] = l+i;
    sm += a[i];
  }

  int mn = INF;
  RREP(i,n){
    if (abs(mn) > abs(a[i])) {
      mn = a[i];
    }
  }

  debug(mn);
  sm -= mn;
  OUT(sm)BR;
  
  
  return 0;
}


Measured memory_bytes: 384
// lannisters don't act like fools
#include <bits/stdc++.h>

using namespace std;
#define yah_faster_baby ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007









void solve() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 1 && i % 2 == 0)
            count++;
    }
    cout << count << endl;
}



int main() {
    yah_faster_baby
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int edge(int x, int y, int *a, int *b, int m){
  for(int i = 0; i < m; i++){
    if(a[i] == x && b[i] == y) return 1;
    if(a[i] == y && b[i] == x) return 1;
  }
  return 0;
}

int path(int *c, int n, int *a, int *b, int m){
  int cnt = 0;
  for(int i = 0; i < n - 1; i++){
    cnt += edge(c[i], c[i + 1], a, b, m);
  }
  if(cnt == n - 1) return 1;
  else return 0;
}

int perm[100], d = 0; char used[100] = {};
void perm1(int pos, int n, int c[][10]){
  if(pos == 0){
    perm[0] = 1;
    perm1(1, n, c);
  }
  if(pos == n){
    for(int i = 0; i < n; i++){
      c[d][i] = perm[i];
    }
    d++;
    return;
  }
  for(int i = 2; i <= n; i++){
    if(used[i] == 0){
      perm[pos] = i;
      used[i] = 1;
      perm1(pos + 1, n, c);
      used[i] = 0;
    }
  }
  return;
}

int
main(int argc, char *argv[])
{
  int a[100], b[100], n, m;
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d %d", &a[i], &b[i]);
  
  int c[10000][10];
  perm1(0, n, c);

  int ans = 0;

  for(int i = 0; i <= d; i++){
    ans += path(c[i], n, a, b, m);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
Ks = sorted(list(mi()), reverse=True)

i = 0
ans = 0
while i < (2*N):
  ans += min(Ks[i],Ks[i+1])
  i += 2

print(ans)



Measured memory_bytes: 38256
#include <stdio.h>
int main(void)
{
    int a, b,c ;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(a > b){
       if(a < c)printf("%d %d %d\n",b,a,c);
       else if(b > c)printf("%d %d %d\n",c,b,a);
       else printf("%d %d %d\n",b,c,a);
    }
    else if(a < b){
        if(b < c)printf("%d %d %d\n",a,b,c);
        else if(a > c)printf("%d %d %d\n",c,a,b);
        else printf("%d %d %d\n",a,c,b);
    }
    return 0;
}



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

int main()
{
    string n;
    cin >> n;
    int count = 0;
    
    if (n.at(0) == '1') ++count;
    if (n.at(1) == '1') ++count;
    if (n.at(2) == '1') ++count;
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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__)
using namespace std;
using ll = long long;

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

  ll order=0,sum=0;
  ll d,c;
  rep(i,M){
    cin >> d >> c;
    order += c;
    sum += d*c;
  }

  cout << (order-1)+((sum-1)/9) << "\n";
}


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

typedef struct List {
	struct List *next;
	int v[2];
} list;

int main()
{
	int i, j, N, A[1001][1001], *dist[1001], *deg[1001];
	scanf("%d", &N);
	list ***adj = (list***)malloc(sizeof(list**) * (N + 1)), *d = (list*)malloc(sizeof(list) * N * (N - 2));
	for (i = 1; i <= N; i++) {
		dist[i] = (int*)malloc(sizeof(int) * (N - i + 1));
		deg[i] = (int*)malloc(sizeof(int) * (N - i + 1));
		adj[i] = (list**)malloc(sizeof(list*) * (N - i + 1));
		for (j = 1; j <= N - i; j++) {
			adj[i][j] = NULL;
			dist[i][j] = 0;
			deg[i][j] = 0;
		}
	}
	for (i = 1; i <= N; i++) {
		scanf("%d", &(A[i][1]));
		for (j = 2; j <= N - 1; j++) {
			scanf("%d", &(A[i][j]));
			if (i < A[i][j]) {
				deg[i][A[i][j]-i]++;
				d[(i-1)*(N-2)+(j-1)].v[0] = i;
				d[(i-1)*(N-2)+(j-1)].v[1] = A[i][j] - i;
			} else {
				deg[A[i][j]][i-A[i][j]]++;
				d[(i-1)*(N-2)+(j-1)].v[0] = A[i][j];
				d[(i-1)*(N-2)+(j-1)].v[1] = i - A[i][j];
			}
			if (i < A[i][j-1]) {
				d[(i-1)*(N-2)+(j-1)].next = adj[i][A[i][j-1]-i];
				adj[i][A[i][j-1]-i] = &(d[(i-1)*(N-2)+(j-1)]);
			} else {
				d[(i-1)*(N-2)+(j-1)].next = adj[A[i][j-1]][i-A[i][j-1]];
				adj[A[i][j-1]][i-A[i][j-1]] = &(d[(i-1)*(N-2)+(j-1)]);
			}
		}
	}
	
	int q[1000001][2], head, tail, max = 0;
	list *p;
	for (i = 1, tail = 0; i <= N; i++) {
		for (j = 1; j <= N - i; j++) {
			if (deg[i][j] == 0) {
				q[tail][0] = i;
				q[tail++][1] = j;
			}
		}
	}
	for (head = 0; head < tail; head++) {
		for (p = adj[q[head][0]][q[head][1]]; p != NULL; p = p->next) {
			deg[p->v[0]][p->v[1]]--;
			if (dist[p->v[0]][p->v[1]] < dist[q[head][0]][q[head][1]] + 1) {
				dist[p->v[0]][p->v[1]] = dist[q[head][0]][q[head][1]] + 1;
				if (max < dist[p->v[0]][p->v[1]]) max = dist[p->v[0]][p->v[1]];
			}
			if (deg[p->v[0]][p->v[1]] == 0) {
				q[tail][0] = p->v[0];
				q[tail++][1] = p->v[1];
			}
		}
	}
	
	if (head < N * (N - 1) / 2) printf("-1\n");
	else printf("%d\n", max + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 32932
def ten2bi(i, N):
    bi_list = []    #二進数表記のリスト(ex. ten2bi(31, 5)  -> [1, 1, 1, 1, 1])
    for j in range(N):
        if i >= 2**(N - j - 1):
            bi_list.append(1)
            i -= 2**(N - j - 1)
        else:
            bi_list.append(0)

    return bi_list

H, W, K = map(int, input().split(' '))

c_list = [list(str(input())) for i in range(H)]

ans = 0
k = 0

for i in range(2**H):
    for j in range(2**W):
        row_list = ten2bi(i, H)
        column_list = ten2bi(j, W)
        for h in range(H):
            for w in range(W):
                if row_list[h] == 0 and column_list[w] == 0:
                    if c_list[h][w] == '#':
                        k += 1
        if k == K:
            ans += 1
        k = 0

print(ans)

Measured memory_bytes: 9060
import std.stdio,
    std.array,
    std.conv,
    std.string;

void main(){
  string s;
  for(;;){
    s=readln();
    if(stdin.eof()) break;
    for(int i = cast(int)s.length; i > 1; --i ){
      write(s[i-2]);
    }
    if(s.length > 0) write("\n");
  }
}

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

using namespace std;

#define int long long
#define PB push_back
#define MK make_pair
#define MKT make_tuple
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL<<60;
//constexpr int INF = 1<<28;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 5005;
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

int imos[2][MAX_N][MAX_N], n, m;

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

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
	int a, b, x;
	cin >> a >> b >> x;
	imos[0][b][a]++;
	imos[0][b][a + x + 1]--;
	imos[1][b + 1][a]--;
	imos[1][b + x + 2][a + x + 1]++;
    }

    for (int x = 1; x <= n; ++x) {
	for (int y = 1; y <= n; ++y) {
	    imos[0][x][y] += imos[0][x][y - 1]; 
	}
    }

    for (int y = 1; y <= n; ++y) {
	for (int x = 1; x <= n && x + y - 1 <= n; ++x) {
	    imos[1][x][x + y - 1] += imos[1][x - 1][x + y - 2];
	}
    }

    int ans = 0;
    for (int y = 1; y <= n; ++y) {
	int sum = 0;
	for (int x = 1; x <= y; ++x) {
	    sum += imos[0][x][y] + imos[1][x][y];
	    //dbg
	    imos[0][x][y] = sum;
	    if (0 < sum) ans++;
	}
    }

    cout << ans << endl;
}

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

int main() {
	int X, tmp = 0, i = 0;
	cin >> X;
	while(1){  // minimum i such that 1 + 2 + ... + i >= x
		i++;
		tmp += i;
		if(tmp >= X) break;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
  }
  int L = 0;
  for (int i = 1; i < n; ++i) {
    L += (int64)i * (n - i) % MOD * (a[i] - a[i - 1]) % MOD;
    L %= MOD;
  }
  int R = 0;
  for (int i = 1; i < m; ++i) {
    R += (int64)i * (m - i) % MOD * (b[i] - b[i - 1]) % MOD;
    R %= MOD;
  }
  printf("%lld\n", (int64)L * R % MOD);
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
P = list(map(int,input().split()))
A = []
y = 0

for n in range(1,N+1):
  A.append(n)

for p,a in zip(P,A):
  if p!=a:
    y+=1
    

if y<3:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> x(n), y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll ma1 = -longinf, mi1=longinf, ma2=-longinf, mi2=longinf;
    rep(i,n){
        ma1=max(ma1, x[i]+y[i]);
        mi1=min(mi1, x[i]+y[i]);
        ma2=max(ma2, x[i]-y[i]);
        mi2=min(mi2, x[i]-y[i]);
    }
    cout<<max(ma1-mi1, ma2-mi2)<<endl;
    return 0;
}


Measured memory_bytes: 6348
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 10:24:56 2020

@author: macbookyuma
"""
import numpy as np

S = str( input() )
N = len(S)
O = np.zeros( (N,), dtype=int )

last_R = 0
od_cnt = 0
ev_cnt = 0
for n in range(N):
    if( (n+1)%2 == 0 ):
        ev_cnt += 1
    else:
        od_cnt += 1
    
    if( S[n] == 'L'):
        # from R
        ido = int( np.floor( (last_R+1)/2.0 ) * 2)
        ide = int( np.floor(last_R / 2.0) * 2 + 1)
        O[ido]   += od_cnt
        O[ide]   += ev_cnt
        
        
        od_cnt = 0
        ev_cnt = 0
    else:
        last_R = n
    
print( ' '.join( list(O.astype(np.unicode)) ) )


Measured memory_bytes: 33092
n, k = (int(x) for x in input().split())
lis=[0]*n
for i in range(k):
    d = int(input())
    li = list(map(int, input().split()))
    for i in range(d):
        lis[li[i]-1]=1
    
count=0
for i in range(n):
    if lis[i]==0:
        count+=1
print(count)
    

Measured memory_bytes: 9188
#include <iostream>

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int res = 0;
    for (int i = 1; i <= n; i++) {
        int sum = 0;
        for (int j = i; j > 0; j /= 10) {
            sum += j % 10;
        }

        if (a <= sum && sum <= b) {
            res += i;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n,c=0;

    double d,x,y;

    cin>>n>>d;

    while(n--)
    {
        cin>>x>>y;




        double z=sqrt((x*x)+(y*y));

        //cout<<z<<endl;

        if(z<=d)
            c++;

    }

    cout<<c<<endl;




    return 0;
}


Measured memory_bytes: 3876
import java.util.Scanner;

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

    int N = sc.nextInt();
    int numOdd = 0;
    if (N %2==0) {
      numOdd = N / 2;
    } else {
      numOdd = N / 2 + 1;
    }
    System.out.println(numOdd / (float) N);
  }
}


Measured memory_bytes: 21716
def main():
    from itertools import permutations
    from math import hypot

    N = int(input())

    xys = []
    for _ in range(N):
        x, y = map(int, input().split())
        xys.append((x, y))

    ans = 0
    for perm in permutations(xys, r=2):
        x1, y1 = perm[0]
        x2, y2 = perm[1]
        d = hypot(x2 - x1, y2 - y1)
        ans += d
    ans /= N

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
    int M[10];
    for(int i = 0; i < 10; i++){
	cin >> M[i];
    }
    sort(M, M+10, greater<int>());
    for(int i = 0 ; i < 3 ; i++){
	cout << M[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int xy[11111][11111];
int n,m,size[11111],maxx=-1;
inline int read() {
    int X=0,w=0;
    char ch=0;
    while(!isdigit(ch)) {
        w|=ch=='-';
        ch=getchar();
    }
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline double dbread() {
    double X=0,Y=1.0;
    int w=0;
    char ch=0;
    while(!isdigit(ch)) {
        w|=ch=='-';
        ch=getchar();
    }
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,j;
	char c;
	cin>>a>>c>>b;
    if(c=='+')
	  j=a+b;
	if(c=='-')
	  j=a-b;
    cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll deg[100005];
bool c1(ll a, ll b)
{
    return deg[a] > deg[b];
}
vll adj[MAX];
ll vi[MAX];
priority_queue <ll> h;
ll ans = 0;
void dfs(ll cur)
{
    ll c = -1, i;
    for(i = 0; i < adj[cur].size(); i++)
    {
        if(vi[adj[cur][i]] == 0)
        {
            vi[adj[cur][i]] = h.top();
            ans += h.top();
            h.pop();
        }
        else
            c = i;
    }
    for(i = 0; i < adj[cur].size(); i++)
        if(i != c)
            dfs(adj[cur][i]);
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, u, v;
    cin >> n;
    vll c(n), a(n + 1);
    for(i = 1; i < n; i++)
    {
        cin >> u >> v;
        deg[u]++;
        deg[v]++;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(i = 0; i < n; i++)
        cin >> c[i];
    ll cur = -1, op = -1;
    for(i = 1; i <= n; i++)
    {
        if(deg[i] > op)
            cur = i;
        op = max(deg[i], op);
    }
    for(i = 0; i < n; i++)
        h.push(c[i]);
    vi[cur] = h.top();
    h.pop();
    for(i = 1; i <= n; i++)
        sort(all(adj[i]), c1);
    dfs(cur);
    cout << ans << endl;
    for(i = 1; i <= n; i++)
        cout << vi[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 26620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  string s;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int cnt = 0;
  for (int i = 0;i < n;i++){
    for (int j = i+1; j < n;j++){
     for (int k = j+1;k < n;k++){
       if (v[i] + v[j] > v[k] && v[j] + v[k] > v[i] && v[k] + v[i] > v[j] && v[i] != v[j] && v[j] != v[k] && v[k] != v[i] ) cnt++;
     }
   }
 }
 cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#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 all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> p(100100); // 1e5
vector<int> q(100100); // 1e5

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

  int n;
  cin >> n;

  p.resize(n);
  q.resize(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];

  vector<int> a(n); // {}
  iota(all(a), 1); // {1,2,3}
  int count, ansq, ansp;
  do { 
    count++;
    if (a == p) ansp = count;
    if (a == q) ansq = count;
  } while (next_permutation(all(a)));

  cout << abs(ansp - ansq) << endl;
  return 0;
}


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

int main(){
  long long x;
  cin >> x;
  long long p;
  long long r;
  r=x%11;
  p=x/11;
  long long ans;
  ans = 2*p;
  if(r>6){
    ans+=2;
  }else if(r>0){
    ans+=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {

	int w, a, b;
	cin >> w >> a >> b;

	if (b > a + w) {
		cout << b - a - w << endl;
	}
	else if (b + w < a) {
		cout << a - b - w << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}



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


int table[10][10001];
int perm[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };


int factorial(int n){
	int ret = 1;
	for (int i = 1; i <= n; i++) ret *= i;
	return ret;
}


int main(){
	do {
		int sum = 0;
		for (int i = 1; i <= 10; i++){
			sum += i * perm[i - 1];
			table[i - 1][sum]++;
		}
	} while (next_permutation(perm, perm + 10));

	int n, s;
	while (cin >> n >> s){
		cout << table[n - 1][s] / factorial(10 - n) << endl;
	}

	return 0;
}

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

int main() {
	const int G[13] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;
	cout << (G[x] == G[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;

#define ran 101101

int n;
int a[ran];
int q[ran], lq;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

bool chk(int x) {
	int cnt = 0;
	for(int i=n-1;i>0;i--) {
		if(a[i]%x) cnt++;
		if(cnt>1) return false;
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	
	int ans = a[1];
	for(int i=2;i<n && ans>1;i++)
		ans = gcd(ans, a[i]);
	
	lq=0;
	for(int i=1;i*i<=a[0];i++) {
		if (a[0]%i) continue;
		
		if(i>1) q[lq++] = i;
		if(i*i<a[0]) q[lq++] = a[0]/i;
	}
	sort(q, q+lq);
	
	for(int i=lq-1;i>=0;i--)
		if(chk(q[i])) {
			ans = max(ans, q[i]);
			break;
		}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  if(s[0]==t[2]){
    if(s[1]==t[1]){
      if(s[2]==t[0]){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

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

int main()
{
    unsigned long long int N;
    cin >> N;


    unsigned long long int h, n, w;
    bool flag = true;
    for( h = 1; h <= 3500 && flag; ++h ){
        for( n = 1; n <= 3500 && flag; ++n ){
            if( 4*h*n-N*n-N*h == 0 ) continue;
            w = floor((N*h*n) / (4*h*n-N*n-N*h));
            unsigned long long int leftI = 4 * h * n * w;
            unsigned long long int rightI = N * ( n*w + h*w + h*n );
            double leftD = 4.0/N;
            double rightD = 1.0/h+1.0/n+1.0/w;
            if( leftI == rightI && leftD == rightD ){
                flag = false;
                --h, --n, --w;
            }
            ++w;
            leftI = 4 * h * n * w;
            rightI = N * ( n*w + h*w + h*n );
            leftD = 4.0/N;
            rightD = 1.0/h+1.0/n+1.0/w;
            if( leftI == rightI && leftD == rightD ){
                flag = false;
                --h, --n, --w;
            }
        }
    }


    cout << h << " " << n << " " << w << endl;
    //cout << 4*h*n*w << " == " << N*(n*w+h*w+h*n) << endl;
    //cout << 4.0/N << " == " << 1.0/h+1.0/n+1.0/w << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    if (N<10) printf("%d", N);
    else if (N<100) printf("%d", 9);
    else if (N<1000) printf("%d", N-90);
    else if (N<10000) printf("%d", 909);
    else if (N<100000) printf("%d", N-9090);
    else printf("%d", 90909);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int hoge[100000000];        // 195584 KB

int main() {
  ios::sync_with_stdio(false);

  // vector<int> hoge(1e7);        // 39296 KB
  // vector<bool> hoge(1e7);        // 1536 KB KB
  // vector<int> hoge(5*1e7);        // 195584 KB
  // vector<int> hoge(6*1e7);        // 195584 KB

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}



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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0; i<N; i++) cin >> X.at(i);

    int ans = 1<<30;
    for(int i=1; i<=100; i++)
    {
        int sun = 0;
        for(auto x : X)
        {
            sun += (x-i)*(x-i);
        }
        chmin(ans, sun);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct stu
{
	int idx;
	int tol;
	bool operator<(const stu s) const
	{
		return tol<s.tol;
	}
};
const int sz=1e5+10;
stu stud[sz]; 
int main(void)
{
	int N;
	cin>>N;
	for(int i=1;i<=N;i++)		//从1开始 
	{
		stud[i].idx=i;
		cin>>stud[i].tol;
	} 
	sort(stud+1,stud+N+1);		//排完序
	for(int i=1;i<=N;i++)
		cout<<stud[i].idx<<" ";
	cout<<endl; 
	return 0;
} 

Measured memory_bytes: 1536
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N;
cin>>N;
ll dp[N+1];
dp[0]=0;
rep3(i,N){
    dp[i]=dp[i-1]+1;
    for(int x=1;(ll)pow(9,x)<=i;x++){
        dp[i]=min(dp[i],dp[i-(ll)powl(9,x)]+1);
    }
    for(int y=1;(ll)pow(6,y)<=i;y++){
        dp[i]=min(dp[i],dp[i-(ll)powl(6,y)]+1);
    }
}
cout<<dp[N]<<endl;
return 0;
}

Measured memory_bytes: 4848