akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans;
    
    if(a+b!=0){
        ll tmp = n / (a + b);
        ans = tmp*a;
    }else{
        cout<<0<<endl;
        return 0;
    }

    ll r = n%(a+b);
    ans += min(a,r);
    cout<<ans<<endl;

    return 0;
}

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<ll> out;
  out.push_back(a*c);
  out.push_back(a*d);
  out.push_back(b*c);
  out.push_back(b*d);
  if(a*b <= 0){
    out.push_back(0);
  }else if(c*d <= 0){
    out.push_back(0);
  }

  sort(out.begin(),out.end());
  reverse(out.begin(),out.end());
  
  cout << out[0] << endl;
  
  return(0);
}

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

    int N, Q, P, a;
    cin >> N;
    vector<int>  q, p;
    vector<int> array;

    for(int i = 0;i < N;i++){
        cin >> a;
        p.push_back(a);
    }
    for(int i = 0;i < N;i++){
        cin >> a;
        q.push_back(a);
    }
    for(int i = 1;i <= N;i++){
        array.push_back(i);
    }

    int num = 1;
    do {
        num++;
        if(array == p)P = num;
        if(array == q)Q = num;
    }while(next_permutation(array.begin(), array.end()));
    cout << abs(P - Q);
}

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

int main() {
    int n, Q;
    cin >> n >> Q;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    
    for (int j = 0; j < Q; j++){
        
        long long x;
        cin >> x;
        
        long long res = 0;
        
        int right = 0;
        long long sum = 0;
        
        for (int left = 0; left < n; left++){
            
            while (right < n && sum + a[right] <= x){
                
                sum += a[right];
                right++;
            }
            
            // breakした状態において, rightは条件を満たす最大値である
            
            res += (right - left); // sum <= Qとなる[left, right]の個数を表す
            
            if (right == left) right++; //rightを動かす必要がある
            else sum -= a[left]; // leftを次に動かすためにsumからa[left]を引く必要がある
        }
        
        cout << res << endl;
    }
}


Measured memory_bytes: 3544
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#factorization(24) 

## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1


import math
n = int(input())
A = list(map(int, input().split()))

#A = sorted(A)

ansN = A[0]
for i in range(1, n):
    ansN = math.gcd(ansN, A[i])
if ansN > 1:
    print('not coprime')
else:
    ans2 = True
    C = [0 for _ in range(10**6+10)]
    for a in A:
        F = factorization(a)
#        print(F)
        for f in F:
            if f[0] != 1:
                if C[f[0]] == 0:
                    C[f[0]] = 1
                else:
                    ans2 = False
                    break
        else:
            continue
        break
    if ans2:
        print('pairwise coprime')
    else:
        print('setwise coprime')

Measured memory_bytes: 204976
s = int(input())
l = 0
r = s
while l + 1 < r:
    m = (l + r) // 2
    if m**2 < s:
        l = m
    else:
        r = m
if r**2 == s:
    print("0 0 0 %d %d 0" % (r, r))
elif r**2 - s <= 1e9:
    ds = r**2 - s
    print("0 0 %d 1 %d %d" % (r, ds, r))
else:
    ds = s - (r - 1)**2
    print("0 1 %d 0 %d %d" % (r - 1, ds, r))

Measured memory_bytes: 38384
n, m = map(int, input().split())
l = []
k = ['_'] * m
x = [1] * (n+1)
for i in range(m):
    a, b = map(int, input().split())
    l.append([i, a, b])
y = sorted(l, key=lambda c: c[2])
for i in y:
    k[i[0]] = str(i[1]).zfill(6) + str(x[i[1]]).zfill(6)
    x[i[1]] += 1
for i in k:
    print(i)

Measured memory_bytes: 32972
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
map<p,ll> f, l;
bool calc(int k){
    int first=k%10;
    int last=k%10;
    while(k!=0){
        last=k%10;
        k/=10;
    }
    p temp=make_pair(first,last);
    f[temp]++;
    if(first==last){
        return true;
    }
    else{
        return false;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(calc(i))
        ans++;
    }
    ans=0;
    for(int i=0;i<10;i++){
        //cout<<f[i]<<" "<<l[i]<<"\n";
        for(int j=0;j<10;j++){
            p temp=make_pair(i,j);
            p temp1=make_pair(j,i);
            ans+=f[temp]*f[temp1];
        }
    }
    cout<<ans<<"\n";
}



Measured memory_bytes: 256
use proconio::input;
fn main() {
  input! {
  	s: String,
  }
  let last = &s.chars().collect::<Vec<char>>();
  let last = last[last.len() - 1].to_string();
  let mut ans = s;
  if &last == "s" {
    ans.push_str("es");
  } else {
    ans.push_str("s");
  }
  println!("{}", ans);
}

Measured memory_bytes: 2160
a,b,c=map(int,input().split())
K=int(input())
flag=0
if a>=b:
    while a>=b:
        if K>0:
            b=b*2
            K-=1
        else:
            flag=1
            break
if b>=c and flag==0:
    while b>=c:
        if K>0:
            c=c*2
            K-=1
        else:
            flag=1
            break
            
if flag==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9184
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc085/tasks/abc085_d
# N本の刀、それぞれ2種の攻撃力
# 最小の攻撃回数は？
# 投げつけるほうが必ず強い
# 一番強い通常攻撃<投げつけは全部使ったほうが得。
# 一番強い通常攻撃より強い投げつけに限定してソート強い方から使っていくのが最適

N, H = read_ints()
A, B = read_col(N)
A_ma = max(A)

B.sort()
B_use = B[bisect_right(B, A_ma):]
B_use = list(reversed(B_use))

ans = 0
dmg = 0
for b in B_use:
    if dmg >= H:
        break
    ans += 1
    dmg += b

H -= dmg
if H > 0:
    ans += (H - 1) // A_ma + 1

print(ans)


Measured memory_bytes: 68316
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int h1, h2, k1, k2, a, b, c, d;
	scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
	int hiroshi = h1 * a + h1 / 10 * c + h2 * b + h2 / 20 * d, kenjiro = k1 * a + k1 / 10 * c + k2 * b + k2 / 20 * d;
	printf("%s\n", (hiroshi == kenjiro ? "even" : (hiroshi > kenjiro ? "hiroshi" : "kenjiro")));

	Please AC;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,x; cin >> n >> x;
    vl a(n);
    rep(i,n) cin >> a[i];
    vvl mncost(n,vl(n,LINF));
    vl mn(n,INF);
    rep(i,n){
        rep(j,n){
            mncost[i][j] = min(mn[i], a[(i-j+n)%n]);
            mn[i] = min(mn[i], mncost[i][j]);
        }
    }
    ll ans = LINF;
    rep(j,n){
        ll sum = 0;
        rep(i,n){
            sum += mncost[i][j];
        }
        sum += x*j;
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 31616
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
//const int INF = 2000000000;
const double EPS = 10e-9;
const int mvm = 1000001;
int v[100], w[100], m[100];
int dp[10001];
int main()
{
	int n, W; cin >> n >> W;
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i] >> m[i];
	for (int i = 0; i < n; i++)
	{
		for (int a = 0; a < w[i]; a++)
		{
			deque <int> deq, deqi;
			{
				for (int j = 0; j * w[i] + a <= W; j++)
				{
					int val = dp[a + j * w[i]] - j * v[i];
					while (!deq.empty() && val >= deq.back()) { deq.pop_back(); deqi.pop_back(); }
					deq.push_back(val);
					deqi.push_back(j);
					dp[a + j * w[i]] = deq.front() + j * v[i];
					if (j - deqi.front() == m[i]) { deqi.pop_front(); deq.pop_front(); }
				}
			}
		}
	}
	cout << dp[W] << endl;
	return 0;
}

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


ll gojyo (ll s,ll t){
    ll max,ama,fb,sum=0,h;
    if(t>s){
        h=t;
        t=s;
        s=h;
    }
    fb=t;
    while(1){
        if(s%t==0&&sum==0){
            max=fb;
            break;
        }
        
        else if(s%t==0){
            max=ama;
            break;
        }
        else {
            ama=s%t;
            s=t;
            t=ama;
            sum+=1;
        }
    }
    return max;
}




int main(){

    ll a,b,c,d;

    cin >> a >> b >> c >> d;
    
    ll sumb=b,suma=a-1;

    sumb-=b/c;
    sumb-=b/d;
    sumb+=b/(c*d/gojyo(c,d));

    suma-=(a-1)/c;
    suma-=(a-1)/d;
    suma+=(a-1)/(c*d/gojyo(c,d));

    cout << sumb-suma << endl;


   




    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int r;
  cin >> r;
  cout << 3 * r* r << endl;
  return 0;
}


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

int main()
{
    int n,k;
    std::cin>>n>>k;
    std::vector<unsigned long long int> h(n);
    for (int i=0; i<n; i++)
        std::cin>>h[i];
    std::sort(h.begin(),h.end());
    unsigned long long s=0;
    for (int i=0; i<n-k; i++)
        s+=h[i];
    std::cout<<s;
    return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    int sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++) sum += d[i] * d[j];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool f = false;
  while (a > 0 && c > 0) {
    if (f) {
      a -= d;
      f = false;
    } else {
      c -= b;
      f = true;
    }
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << 1 << endl;
    else if (a != b && b != c && c != a) cout << 3 << endl;
    else cout << 2 << endl;
    return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug4(a,b,c,d) cout<<a<<" "<< b <<" "<<c<<" "<<d<<"\n";

ll mod = 1000000007;

using namespace std;

int main()
{


	int a,b,c;
	cin>>a>>b>>c;

	int sum = a+b;
	int diff = c-sum;

	if(diff <= 0 )
	{
		cout<<b+c<<"\n";
	}
	else
	{
		cout<<b+c-diff+1<<"\n";
	}

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: "List[int]"):
    k = len(set(A))
    if (N - k) % 2 == 1:
        k -= 1
    print(k)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    double x[100],y[100],z[100];
    for(int i=0; i<n; i++) cin >> x[i];
    for(int i=0; i<n; i++) cin  >> y[i];
    for(int i=0; i<n; i++) z[i] = abs(x[i]-y[i]);
    double p1,p2,p3,p;p1=p2=p3=p=0;
    for(int i=0; i<n; i++){
        p1 += z[i];
        p2 += pow(z[i],2);
        p3 += pow(z[i],3);
        p = max(p,z[i]);
    };
    p2 = pow(p2,0.5);
    p3 = pow(p3, 1.0/3.0);
    cout << fixed << setprecision(8) << p1 << endl << p2 << endl << p3 << endl << p << endl;
    return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)


signed main () {
  int X,A=100,ans;
  double a=100;
  cin >> X;
  for(int i=1;i<INF;i++){
    a=A;
    a*=1.01;
    A=a;
    if(X<=A){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b, c;
int tmp;
void in(){
    char t;
    cin >> a >> t >> b >> t >> c; 
    tmp = a * 100000000 + b * 10000  +  c;
}

void solve(){

    if(tmp <= 201900040030){
        print("Heisei");
    }else{
        print("TBD");
    }

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
int main(){
 int H,i,A[MAX+1];
 cin>>H;
 for(i=1;i<=H;i++)cin>>A[i];
 for(i=1;i<=H;i++){
  cout<<"node "<<i<<": key = "<<A[i]<<", ";
  if(parent(i)>=1)cout<<"parent key = "<<A[parent(i)]<<", ";
  if(left(i)<=H)cout<<"left key = "<<A[left(i)]<<", ";
  if(right(i)<=H)cout<<"right key = "<<A[right(i)]<<", ";
  cout<<endl;
 }
 return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }

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

int main(){
  ll a,b,c,d;
  cin >>a>>b>>c>>d;

  ll ans_c = 0;
  ll ans_d = 0;
  ll ans_cd = 0;

  ans_c = b/c - (a-1)/c;
  ans_d = b/d - (a-1)/d;
  ans_cd = b/lcm(c,d) - (a-1)/lcm(c,d);

  cout << b-a+1 - (ans_c + ans_d - ans_cd) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int A, int B)
{
    string AA, BB;
    REP(i, B) {
        AA += to_string(A);
    }
    REP(i, A) {
        BB += to_string(B);
    }
    return (AA <= BB) ? AA : BB;
}

int main(void){
    int A, B;
    cin >> A >> B;
    cout << Main(A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
if A == 5 and B == 5 and C == 7:
  print("YES")
elif A == 5 and B == 7 and C == 5:
  print("YES")
elif A == 7 and B == 5 and C == 5:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 8992
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 100000

ll n, a, b, h[MAX];

bool check(ll k){
	ll cnt=0;
	for(int i=0; i<n; i++){
		if(h[i]>k*b){
			cnt+=(h[i]-k*b+a-1)/a;
		}
	}
	return cnt<=k;
}

int main(){
	cin >> n >> a >> b;
	a-=b;
	for(int i=0; i<n; i++){
		cin >> h[i];
	}

	ll l=0, r=(ll)(1e9), m;
	while(r-l>1){
		m=(l+r)/2;
		if(check(m)) r=m;
		else l=m;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int a, b, c;
  cin>>a>>b>>c;
  
  int cnt[10] = {};
  
  cnt[a]++;
  cnt[b]++;
  cnt[c]++;
  
  for(int i=0;i<10;i++){
    if( cnt[i] == 2 ){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define ERR 0.00000001
typedef long long ll;

int main(void)
{
	int X;
	cin >> X;
	if(X%100<=X/100*5) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
A = sum(A,[])
N = int(input())
flag = 0
for i in range(N):
    b = int(input())
    for j in range(9):
        if A[j] == b:
            A[j] = 0

for i in range(3):
    if A[i]==A[i+3] and A[i+3]==A[i+6] and A[i]==0 or\
        A[i*3] == A[i*3+1] and A[i*3+1] == A[i*3+2] and A[i*3] == 0:
        flag = 1
if A[0]==A[4] and A[4]==A[8] and A[0]==0 or\
     A[2]==A[4] and A[4]==A[6] and A[2]==0:
     flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n = gets.to_i
t, a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
h.map!{ |x| t - x * 0.006 }

min = 100000000
mini = 0
(1..n).each do |i|
  if min > (a - h[i-1]).abs
    min =  (a - h[i-1]).abs
    mini = i
  end
end

p mini



Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int H;
int main() {
	cin>>n;
	int x[n],y[n],h[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
	}
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			for(int l=0;l<n;l++){
				H=h[l]+abs(x[l]-i)+abs(y[l]-j);
				if(h[l]!=0)l=n;
				for(int k=0;k<n;k++){
					if(H!=(h[k]+abs(x[k]-i)+abs(y[k]-j))){
						if(h[k]==0&&H<(h[k]+abs(x[k]-i)+abs(y[k]-j))){
						}else{
							//cout<<1;
							break;
						}
					}if(k==n-1){
						cout<<i<<" "<<j<<" "<<H<<endl;
						return 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 

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

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)

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

typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si;
typedef map<int,int> mi;

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






signed main() {
bew;

    tar(k);
    tar(n);
    int ar[n+1];
    ip(ar,n);
    ar[n]=INT_MAX;
    for(int i=0;i<n;++i)
    ar[i]=ar[i]%k;
    sort(ar,ar+n);
    ar[n]=ar[n-1]+ar[0]+(k-ar[n-1]);
    int pre[n];
    for(int i=1;i<=n;++i)
    pre[i-1]=abs(ar[i]-ar[i-1]);
    cout<<k-*max_element(pre,pre+n);




return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

char C[2];

int main() {
  string S;
  cin >> S;
  char c = S[0];
  C[0] = '1';
  C[1] = '0';
  int cnt = 0;
  for (int i = 1; i < S.size(); ++i) {
    if (c == S[i]) {
      c = C[c - '0'];
      ++cnt;
    } else {
      c = S[i];
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3360
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

struct crop {
	double e;
	string name;
	crop(double e, string n): e(e), name(n){}

	bool operator<(const crop& c) const {
		return e != c.e ? e > c.e : name < c.name;
	}
};

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

	for(int n; cin >> n, n;) {
		vector<crop> kind;
		for(int i = 0; i < n; ++i) {
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			const int leaf = a + b + c, seed = d + e;
			const int time = leaf + m * seed;
			const int income = m * f * s - p;
			kind.push_back(crop((double)income / time, l));
		}

		sort(kind.begin(), kind.end());
		for(int i = 0; i < (int)kind.size(); ++i)
			cout << kind[i].name << endl;
		cout << '#' << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back
const int maxN = 1e6;
ll sv[maxN + 1];

void solve(){
    int n;
    cin >> n;
    vi A(n);
    cin >> A;
    vi cnt(maxN + 1, 0);
    int g = A[0];
    for (int i = 0; i < n; ++i) {
        g = __gcd(A[i], g);
        while(A[i] > 1) {
            int m = sv[A[i]];
            ++cnt[m];
            while(A[i] % m == 0) A[i] /= m;
        }
    }
    bool ok = true;
    for (int i = 0; i <= maxN; ++i) {
        if (cnt[i] > 1) {
            ok = false;
        }
    }
    if (ok) {
        cout << "pairwise coprime" << END;
    } else if (g == 1) {
        cout << "setwise coprime" << END;
    } else cout << "not coprime" << END;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (ll i = 1; i <= maxN; ++i) sv[i] = i;
    for (ll i = 2; i * i <= maxN; ++i) {
        if (sv[i] != i) continue;
        for (ll j = i * i; j <= maxN; j += i) {
            if (sv[j] == j) sv[j] = i; 
        }
    }
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 18772
def main():
  N=int(input())
  values=[]
  val=6
  while val<=N:
    values.append(val)
    val*=6
  
  val=9
  while val<=N:
    values.append(val)
    val*=9
  values.append(1)
  values.sort()
  dp=[N]*(N+1)
  dp[0]=0
  for i in range(N):
    for v in values:
      if i+v>N:break
      dp[i+v]=min(dp[i]+1,dp[i+v])
  print(dp[N])
  pass
if __name__ == '__main__':
  main()


Measured memory_bytes: 9660
//ΔARC100F
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 25555;
const int K = 444;
const int MO = 1e9+7;
int mul(int x,int y){
	return (LL)x*y%MO;
}
int fpow(int x,int y=MO-2){
	if(!y)
		return 1;
	int z=fpow(x,y>>1);
	z=mul(z,z);
	if(y&1)
		return mul(z,x);
	return z;
}
int n,k,f[N][K],g[N][K];
int m,a[N];
int s[K];
int main()
{
	int i,j,x;
	scanf("%d%d%d",&n,&k,&m);
	for(i=1;i<=m;i=i+1)
		scanf("%d",a+i);
	x=0;
	for(i=1;i<=m&&i<=k;i=i+1){
		if(!s[a[i]])
			x++;
		s[a[i]]++;
	}
	for(;i<=m;i=i+1){
		if(x==k)
			break;
		if(!s[a[i]])
			x++;
		s[a[i]]++;
		s[a[i-k]]--;
		if(!s[a[i-k]])
			x--;
		if(x==k)
			break;
	}
	if(x==k){
		cout<<mul(n-m+1,fpow(k,n-m));
		return 0;
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=1;i<=m;i=i+1)
		s[a[i]]++;
	for(i=1;i<=k;i=i+1)
		if(s[i]>1)
			break;
	if(i>k){
		f[0][0]=1;
		for(i=1;i<=n;i=i+1){
			x=0;
			for(j=k-1;j;j=j-1){
				x=(x+f[i-1][j])%MO;
				f[i][j]=(x+mul(k-j+1,f[i-1][j-1]))%MO;
			}
			x=0;
			for(j=k-1;j;j=j-1){
				x=(x+g[i-1][j])%MO;
				g[i][j]=(x+mul(k-j+1,g[i-1][j-1]))%MO;
			}
			for(j=m;j<k;j=j+1)
				g[i][j]=(g[i][j]+f[i][j])%MO;
		}
		x=0;
		for(j=1;j<k;j=j+1)
			x=(x+g[n][j])%MO;
		for(i=k;i>k-m;i=i-1)
			x=mul(x,fpow(i));
		x=mul(n-m+1,fpow(k,n-m))-x+MO;
		cout<<x%MO;
		return 0;
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=1;i<=m;i=i+1){
		if(s[a[i]])
			break;
		s[a[i]]++;
	}
	f[0][i-1]=1;
	for(i=1;i<=n;i=i+1){
		x=0;
		for(j=k-1;j;j=j-1){
			x=(x+f[i-1][j])%MO;
			f[i][j]=(x+mul(k-j+1,f[i-1][j-1]))%MO;
		}
	}
	for(i=1;i<=k;i=i+1)
		s[i]=0;
	for(i=m;i;i=i-1){
		if(s[a[i]])
			break;
		s[a[i]]++;
	}
	g[0][m-i]=1;
	for(i=1;i<=n;i=i+1){
		x=0;
		for(j=k-1;j;j=j-1){
			x=(x+g[i-1][j])%MO;
			g[i][j]=(x+mul(k-j+1,g[i-1][j-1]))%MO;
		}
	}
	for(i=0;i<=n;i=i+1)
		for(j=k;j;j=j-1)
			f[i][j-1]=(f[i][j-1]+f[i][j])%MO,g[i][j-1]=(g[i][j-1]+g[i][j])%MO;
	x=0;
	for(i=1,j=m;j<=n;i=i+1,j=j+1)
		x=(x+mul(f[i-1][0],g[n-j][0]))%MO;
	x=mul(n-m+1,fpow(k,n-m))-x+MO;
	cout<<x%MO;
	return 0;
}

Measured memory_bytes: 88320
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define ll long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 20005;

ll A[MAX_N];
ll dp[MAX_N];
int n,m;
ll K;

int main()
{
	ll a,b;
	scanf("%d%d%lld",&n,&m,&K);
	rep(i,n){
		scanf("%lld",&A[i]);
	}
	dp[n] = 0;
	for(int i=n-1;i>=0;i--){
		dp[i] = INF;
		a = b = A[i];
		for(int j=i;j<i+m&&j<n;j++){
			a = max(a,A[j]);
			b = min(b,A[j]);
			dp[i] = min(dp[i],dp[j+1]+(j-i+1)*(a-b)+K);
		}
	}
	printf("%lld\n",dp[0]);
	return 0;
}

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

int main() {
    string n;
    cin >> n;
    int counter = 0;
    for(int i = 0; i < n.length();i++){
        if(n[i] == '7'){
            counter++;
        }
    }  
    if(counter > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
        
    }
//--------------------
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n + 1);
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        tree.merge(a, b);
    }
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        if (tree.size(i) > ret) {
            ret = tree.size(i);
        }
    }
    cout << ret << endl;
    return 0;
}

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

 int N;cin>>N;
 vector<int> vec(N);
 
 for(int i=0;i<N;i++){
     cin>>vec.at(i);
 }
 
 reverse(vec.begin(),vec.end());
 
 for(int i=0;i<N-1;i++){
     cout<<vec.at(i)<<" ";
 }
 cout<<vec.at(N-1)<<endl;
}


Measured memory_bytes: 3064
h, w = map(int, input().split())
s = [input().split() for i in range(h)]
al = [chr(i) for i in range(65, 65+26)]
for i in range(h):
    if "snuke" in s[i]:
        print(al[s[i].index("snuke")] + str(i + 1))

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

const int maxn = 1e5;
vector<int> adj[maxn + 1];
int dp[maxn + 1] = {0};

int dfs(int x) {
  int &m = dp[x];
  if (m) return m;
  for (int y : adj[x]) m = max(m, dfs(y) + 1);
  return m;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y;
    adj[x - 1].push_back(y - 1);
  }
  for (int i = 0; i < n; i++)
    adj[n].push_back(i);
  cout << dfs(n) - 1 << '\n';
}

Measured memory_bytes: 7928
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

int x, y, a, b, c, p[111111], q[111111], r[333333];
ll sum = 0;

int cmp(const int *n, const int *m){
    return *m - *n;
}

main(){
    scanf("%d%d%d%d%d", &x,&y,&a,&b,&c);
    for(int i=0; i<a; i++)scanf("%d", &p[i]);
    for(int i=0; i<b; i++)scanf("%d", &q[i]);
    for(int i=0; i<c; i++)scanf("%d", &r[i]);
    qsort(p, a, 4, cmp);
    qsort(q, b, 4, cmp);
    for(int i=0; i<x; i++)r[i+c] = p[i];
    for(int i=0; i<y; i++)r[i+c+x] = q[i];
    qsort(r, x+y+c, 4, cmp);
    for(int i=0; i<x+y; i++)sum += r[i];
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3572
N=int(input())
a=list(map(int,input().split()))
sum=[0]
for i in range(0,N):
    sum.append(sum[-1]+a[i])
ans=abs(sum[N]-2*sum[1])
for i in range(1,N):
    ans=min(ans,abs(sum[N]-2*sum[i]))
print(ans)


Measured memory_bytes: 30696
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x) {
	return(x + 9) / 10 * 10;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> k(10,0);
	vector<vector<int>> D(M);
	vector<int> judge;
	for (int i = 0; i < M; i++) {
		int f;
		cin >> f;
		for (int j = 0; j < f; j++) {
			int t;
			cin >> t;
			D[i].push_back(t);
		}
	}


	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		judge.push_back(a);		
	}
	int cnt = 0;
	for (int i = 0; i < pow(2, N); i++) {
		int bit = i;
		for (int j = 0; j < N; j++) {
			k[j]=bit % 2;
			bit = bit / 2;
		}
		for (int h = 0; h < M; h++) {
			int c = D[h].size();
			int pop = 0;
			for (int l = 0; l < c; l++) {
				int q = D[h][l];
				if (k[q-1] == 1) {
					pop = pop + 1;
				}
			}
			if (judge[h] != pop % 2) {
				break;
			}
			if (h == M - 1) {
				cnt++;
			}
		}
	}
	cout << cnt;
}

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

int main()
{
        int n;
        cin >> n;
        vector<string> S;
        vector<map<int, int>> m(n);
        for (int i = 0; i < n; ++i) {
                string str;
                cin >> str;
                S.push_back(str);
                for (int j = 0; j < str.length(); ++j) {
                        m[i][str[j]-'a']++;
                }
        }
        vector<int> cnt(26, 0);
        for (int k = 0; k < 26; ++k) {

                int minv = -1;
                for (int i = 0; i < n; ++i) {
                        int tmp = m[i][k];
                        if (minv == -1) minv = tmp;
                        else if (minv > tmp) minv = tmp;
                }
                cnt[k] = minv;

        }
        for (int k = 0; k < 26; ++k) {
                int tmp = cnt[k];
                if (tmp > 0) {
                        for (int i = 0; i < tmp; ++i) {
                                char cc = k + 'a';
                                cout << cc;
                        }
                }
        }

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
sum = 0

flag = 1
while flag:
    flag = 0
    for j in range(1, N)[::-1]:
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            flag = 1
            sum += 1
print(*A)
print(sum)


Measured memory_bytes: 5604
import java.util.*;

class Main{
	static long lcm(long a, long b) {
		return a/gcd(a,b)*b;
	}
	static long gcd(long a, long b) {
		return a%b==0 ? b : gcd(b, a % b);
	}
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),m=s.nextInt();
		System.out.println(lcm(n,m));
	}
}


Measured memory_bytes: 23892
/*{{{*/
#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,D,ss,ans;
  int k,l,idis;
  double fdis;
  cin >> N>>D;
  vector<vector<ll>> X(N);
  REP(i,N){
    REP(j,D){
      int x;
      cin >> x;
      X[i].push_back(x);
    }
	}
  ans=0;
  REP(i,N){
    for(k=i+1;k<N;k++){
      ss=0;
      for(l=0;l<D;l++){
        ss = ss+(X[i][l]-X[k][l])*(X[i][l]-X[k][l]);
      }
      fdis = sqrt(ss);
      idis = sqrt(ss);
      if(fdis == idis){
        ans = ans+1;
      }
    }
	}
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
length = len(s)
ans = 0
for i in range(length // 2):
  if (s[i], s[-(i + 1)]) not in (("i", "i"), ("w", "w"), ("(", ")"), (")", "(")):
    ans += 1

if length % 2 and s[length // 2] in ("(", ")"):
  ans += 1
print(ans)



Measured memory_bytes: 5564
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {
  int n, k;
  char prev = ' ';
  char tmp;
  int cunks = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    if (prev != tmp)
      cunks++;
    prev = tmp;
  }
  int unhappy = max(1, cunks - 2 * k);

  cout << n - unhappy << endl;
  return 0;
}


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

vector<int> hana;
vector<int> taro;
int n, m, sumt, sumh, tmp;
bool flag = false;

int main(void){
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    
    sumt = 0; sumh = 0;
    hana.clear(); taro.clear();
    for(int i = 0; i < n; i++){
      cin >> tmp;
      taro.push_back(tmp);
      sumt += tmp;
    }
    for(int i = 0; i < m; i++){
      cin >> tmp;
      hana.push_back(tmp);
      sumh += tmp;
    }
    
    sort(hana.begin(), hana.end());
    sort(taro.begin(), taro.end());
    
    flag = false;
    for(int i = 0; i < taro.size(); i++){
      for(int j = 0; j < hana.size(); j++){
        if((sumh - hana[j] + taro[i]) == (sumt - taro[i] + hana[j])){
          cout << taro[i] << " " << hana[j] << endl;
          flag = true;
          break;
        }
      }
      if(flag){
        break;
      }
    }
    if(!flag) cout << -1 << endl;
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int len= s.size(); //入力した文字列の長さN
  ll ans=0; //出力する答えを0として

  for(int t=0; t<1<<(len-1); t++){
    ll num=s[0]-'0'; 
    for(int i=0; i<len-1; i++){
      if(t&(1<<i)){
        ans+=num;
        num=0;
      }
      num=num*10+s[i+1]-'0';
    }
    ans+=num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,n,m,i,j,array[100000+10],p,q,sum=0,cnt1=0,cnt,cnt2=0,cnt3=0,flag=0;
    long long int it,st,ct,qt;
    string str,ptr;
    vector<long long int> veci;
    vector<char>vecc;
    vector<string>vecs;
    queue<long long int>vecq;
    set<long long int>si;
    cin>>n;
    cout<<2*3.1416*n<<endl;




    return 0;
}


Measured memory_bytes: 3708
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; }
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[warn(dead_code)]
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

#[warn(unused_mut)]
#[warn(unused_imports)]
use std::collections::BTreeSet;
fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let ans = (0..n).fold(
        0,
        |ans, y| if s[y] != s[(n - 1) - y] { ans + 1 } else { ans },
    );
    println!("{}", ans / 2);
}


Measured memory_bytes: 4352