akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a, b,c;
  cin >> a >> b >> c;
  if((100*a+10*b+c)%4==0)cout<<"YES"<<endl;
  else{cout<<"NO"<<endl;}
  

  return 0;
}

Measured memory_bytes: 256
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let square x = x * x

let dbg n = Printf.eprintf "%s\n" @@ dump n; n

module CombMemo = struct
  let prime = 1_000_000_000+7
  let size = 2*1_00_000+1

  let memo = let arr = Array.make size None in
    arr.(0) <- Some 1;
    arr

  let ( *% ) a b = a * b mod prime
  let (-%) a b = (a+prime - b) mod prime
  let (+%) a b = (a + b) mod prime

  let rec pow n m =
    if m = 0 then 1
    else if m mod 2 = 0 then pow (n*%n) (m/2)
    else n *% pow (n*%n) (m/2)

  let rec fact n =
    match memo.(n) with
    | None ->
      let m = n *% fact (n-1) in
      memo.(n) <- Some m;
      m
    | Some a -> a

  let comb n k =
    if n <= 0 || k <= 0 then 1
    else
      fact n *% (pow (fact k) (prime-2)) *% (pow (fact (n - k)) (prime-2))
end

let (n, k) = scan "%d %d" Tuple.Tuple2.make

let () =
  let open CombMemo in
  (0 -- if k >= n-1 then n-1 else k)
  |> Enum.fold (fun s m -> s +% (comb n m *% comb (n-1) m)) 0
  |> printf "%d\n"


Measured memory_bytes: 10240
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	vector<int>a(3);
	rep0(i, 2){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> e(1e5 + 1);
  vector<int> o(1e5 + 1);
  double a, b;
  cin >> a >> b;
  cout << ceil((b - a)/(a - 1)) + 1;

  return 0;
}


Measured memory_bytes: 1024
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

    rep(i, N) {
        cin >> A.at(i);
    }

    cout << abs(*max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end())) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,cntW=0,cntR=0,ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++)
		if(s[i]=='W')
			cntW++;
	for(ll i=n-1;i>=n-cntW;i--)
		if(s[i]=='R')
			ans++;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		int bis = b * (t / a);

		System.out.println(bis);
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;


int main(){
    int amari;
    int n,day= 0;
    cin >> n >> day >> amari;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[n];
        amari += (day / a[n]) + 1;
        if(day % a[n] == 0) amari--;
    }
    
    cout << amari << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0261
{
    class Program
    {

        static readonly int[] DaysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
        static readonly int[] DaysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };

        static readonly DateTime BaseDate = new DateTime(2012, 12, 21);
        static readonly long[] MayaUnit = new long[] { 20, 20, 18, 20, 1 };
        static readonly int MayaCycle = 13;

        static void Main(string[] args)
        {

            while (true)
            {
                string s = RSt();
                if (s == "#") break;

                long[] vs = Array.ConvertAll(s.Split('.'), e => long.Parse(e));
                Console.WriteLine(vs.Length == 5 ? CalcAd(vs) : CalcMaya(vs));
            }

        }

        private static string CalcAd(long[] vs)
        {
            long days = 0;
            for (int i = 0; i < vs.Length; i++) days = (days + vs[i]) * MayaUnit[i];
            DateTime newDate = BaseDate.AddDays(days);
            return newDate.ToString("yyyy.M.d");
        }

        private static string CalcMaya(long[] vs)
        {
            long days = GetDays(vs[0], vs[1], vs[2]) - GetDays(2012, 12, 21);

            long[] mayaDate = new long[MayaUnit.Length];
            for (int i = MayaUnit.Length - 1; i > 0; i--)
            {
                mayaDate[i] = days % MayaUnit[i - 1];
                days /= MayaUnit[i - 1];
            }
            mayaDate[0] = days % MayaCycle;
            return WAr(mayaDate, ".");
        }

        private static long GetDays(long year, long month, long day)
        {
            int[] days = IsLeapYear(year) ? DaysToMonth366 : DaysToMonth365;
            long y = year - 1;
            long n = y * 365 + y / 4 - y / 100 + y / 400 + days[month - 1] + day;
            return n;
        }

        private static bool IsLeapYear(long year)
        {
            return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18816
// F
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int n,m,i,j,k,x,y,book[20005],st[20005],flag,f[2005][2005];
int cnt,nex[20005],to[20005],fir[20005];

int add(int u,int v){
	cnt++;
	nex[cnt]=fir[u];
	fir[u]=cnt;
	to[cnt]=v;
}

void dfs(int v){
	if(flag!=0)
		return;
	if(book[v]!=0){
		flag=book[v];
		return;
	}
	cnt++;
	book[v]=cnt;
	st[cnt]=v;
	for(int cnt1=fir[v];cnt1;cnt1=nex[cnt1])
		dfs(to[cnt1]);
	if(flag!=0)
		return;
	book[v]=0;
	st[cnt]=0;
	cnt--;
}

int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		f[x][y]=1;
		add(x,y);
	}
	for(i=1;i<=n;i++)
		if(flag==0)
			dfs(i);
	if(flag==0){
		printf("-1\n");
		return 0;
	}
	for(i=1;i<=cnt-flag+1;i++)
		st[i]=st[i+flag-1];
	cnt=cnt-flag+1;
	for(i=1;i<=n;i++)
		book[i]=0;
	for(i=1;i<=cnt;i++)
		book[st[i]]=i;
	while(1){
		flag=0;
		for(i=1;i<=cnt;i++){
			for(j=1;j<=cnt;j++)
				if(i+1!=j&&(i!=cnt||j!=1)){
					if(f[st[i]][st[j]]==1){
						flag=1;
						if(j<i){
							for(k=1;k<=i-j+1;k++)
								st[k]=st[j+k-1];
							cnt=i-j+1;
						}
						else{
							for(k=1;;k++){
								st[i+k]=st[j+k-1];
								if(j+k-1==cnt){
									cnt=i+k;
									break;
								}
							}
						}
					}
					if(flag==1) break;
				}
			if(flag==1) break;
		}
		if(flag==0) break;
	}
	printf("%d\n",cnt);
	for(i=1;i<=cnt;i++)
		printf("%d\n",st[i]);
	return 0;
}


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

p = ''
q = ''
for i in range(N):
    p += str(P[i])
    q += str(Q[i])
    
import itertools
A = [i for i in range(1,N+1)]
L = []

for i in itertools.permutations(A,N):
    tmp = ''
    for j in i:
        tmp += str(j)
    L.append(tmp)
L.sort()

for i in range(len(L)):
    if L[i]==p:
        PP = i
    if L[i]==q:
        QQ = i
print(abs(PP-QQ))

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

int main(void)
{
    ll K;
    cin >> K;

    ll base = 7;
    ll sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += base;
        base = (base * 10) % K;
        if(sum % K == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3592
"""

https://atcoder.jp/contests/arc093/tasks/arc093_c

各辺を含む最小全域木を考える
→重みがX未満なら、その全域木に含まれる辺は全て同一色で塗る必要がある

全ての辺に対してやれば十分？
→ではない

むしろ、X未満の全域木となった辺すべて同一色で塗る必要がある？
辺A,Bを含む全域偽は重みがX未満だが、同一色で塗る必要がないとする
→AとBの最小全域木は共有辺を一切持たない
A,Bを二つの頂点集合に分ける。頂点集合間は、別の辺l,Lで結ばれている
元の辺を除いた重みの輪を a,bとすると、 a+l < X  b+L < X である
よって、辺を交換するとどちらかは必ずX未満となる
→よって、その辺を含む最小全域木

AとBの辺を少なくとも1つづつ含む最小全域木が存在することを示せばいい
最小の重みの辺LがAにあるとする
Lに接続されている頂点Xには、Bの辺が1本ささっている
この辺を含む最小全域木をクラスカル法で構築していくと、Aの最小の辺を絶対含む
→よって、ただしい

まず、各辺を含む最小全域木を考え、重みがX未満なら白で塗る
重みがXを超える場合、重みXの全域木に含まれることはないため好きな色で塗る
→不要なため以後グラフに無いものとして扱う

今グラフには白い辺(X未満)と、未定(X)の辺がある
塗分け方は 2^X である。ここから補集合(Xの全域木を構成できない場合)を引く
全部白の場合は自明に無理

白で塗られた辺が1つ以上存在する場合を考える
黒が1つでも入っていれば構成可能？
→最小全域木に必ず白を含むことを証明できれば良い
未定の辺の最小 >= 白い辺の最小 が示せれば、白い辺の片方の頂点に来た時に絶対選ばれるのでおｋ
未定の辺が最小だった場合、片方に来た時に選ばれてしまうので示された

入っていない場合、すべて同一色でなければ構成可能？
→これも同様に証明可能なはず

"""

from sys import stdin
import sys

def uf_find(n,p):

    ufl = []

    while p[n] != n:
        ufl.append(n)
        n = p[n]

    for i in ufl:
        p[i] = n

    return n


def uf_union(a,b,p,rank):

    ap = uf_find(a,p)
    bp = uf_find(b,p)

    if ap == bp:
        return False
    else:

        if rank[ap] > rank[bp]:
            p[bp] = ap
        elif rank[ap] < rank[bp]:
            p[ap] = bp
        else:
            p[bp] = ap
            rank[ap] += 1

        return True

N,M = map(int,stdin.readline().split())

X = int(stdin.readline())

wvu = []

for i in range(M):

    u,v,w = map(int,stdin.readline().split())
    wvu.append((w,v-1,u-1))

overX = 0
justX = 0
underX = 0
wvu.sort()

for i in range(M):

    p = [i for i in range(N)]
    rank = [0] * N
    h = 0

    h += wvu[i][0]
    uf_union(wvu[i][1],wvu[i][2],p,rank)

    for j in range(M):

        if uf_union(wvu[j][1],wvu[j][2],p,rank):
            h += wvu[j][0]

    if h > X:
        overX += 1
    elif h == X:
        justX += 1
    else:
        underX += 1

print (overX,justX,underX,file=sys.stderr)
ans = 0
mod = 10**9+7

if justX == 0:
    ans = 0
elif underX > 0:
    ans = 2 * pow(2,overX,mod) * (pow(2,justX,mod)-1)
else:
    ans = pow(2,overX,mod) * (pow(2,justX,mod)-2)

print (ans % mod)


Measured memory_bytes: 82620
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

typedef long long int ll;

// 最大公約数
ll GCD(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return GCD(b,a%b);}

// 最小公倍数
ll LCM(ll a, ll b){ return a*b/GCD(a, b); }

int main(void){

    int n, x; cin >> n >> x;
    int ans = 0;

    vector<int> l(n), dis(n);
    queue<int> a;

    for(int i = 0;i < n;i++){
        cin >> l[i];
        a.push(abs(l[i] - x));
    }
    
    while(a.size() != 1){
        int tmp1 = a.front(); a.pop();
        int tmp2 = a.front(); a.pop();
        a.push(GCD(tmp1, tmp2));
    }

    cout << a.front() << endl;

    return 0;
}

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

int main()
{
string s;
string ans="YES";
cin >> s;
vector<string> matsubi={"dream", "dreamer","erase","eraser"};
reverse(s.begin(),s.end());
for(int i=0;i<4;i++){reverse(matsubi.at(i).begin(),matsubi.at(i).end());}
while(s.size()>0)
{
for(int i=0;i<4;i++)
{
  if(s.substr(0,matsubi.at(i).size())==matsubi.at(i))
  {
    s=s.erase(0,matsubi.at(i).size());
    ans="YES";
    break;
  }else ans="NO";
}
if(ans!="YES")break;
}
cout << ans;
}

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

int main(void)
{
    int N,a,b,imin = 10000000,sum;
    cin >> N;

    for(int i = 1;i < N;i++){
        sum = 0;
        a = i;
        b = N-i;
        while(a > 0){
            sum += a%10;
            a /= 10;
        }
        while(b > 0){
            sum += b%10;
            b /= 10;
        }

        imin = min(imin,sum);

    }

    cout << imin << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    rep(a, 0, A + 1) rep(b, 0, B + 1) rep(c, 0, C + 1)
    {
        if (500 * a + 100 * b + 50 * c == X)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  if (M == 1){
    cout << 1 << ' ' << 2 << endl;
    return 0;
  }
 
  if (N % 2 == 1){
    for (int i = 0; i < M; i++) {
      cout << i+1 << ' ' << M*2 - i << endl;
    }
  }
  else {
    for (int i = 0; i < (M+1)/2; i++) {
      cout << i+1 << ' ' << N/2 - i << endl;
    }
    for (int i = 0; i < M/2; i++) {
      cout << N/2 + i + 2 << ' ' << N - i << endl;
    }
  }
}



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

using namespace std;

typedef long long Long;

class SegTree {
public:
    int m_n;
    vector<Long> m_data;

    SegTree( int n ) { Init( n ); }

    void Init( int n ) {

	m_n = 1;
	while ( m_n < n ) m_n <<= 1;

	m_data.resize( 2*m_n - 1 );
    }

    void Add( int k, int val ) {

	k += m_n - 1;

	m_data[k] += (Long)val;
	
	while ( k > 0 ) {
	    k = ( k - 1 )/2;
	    m_data[k] = m_data[2*k+1] + m_data[2*k+2];
	}
    }

    Long Sum( int a, int b ) {
	return query( a, b + 1, 0, 0, m_n );
    }

protected:

    Long query( int a, int b, int k, int l, int r ) {

	if ( b <= l || a >= r ) return 0;

	if ( a <= l && r <= b ) return m_data[k];

	Long left = query( a, b, 2*k+1, l, (l+r)/2 );
	Long right = query( a, b, 2*k+2, (l+r)/2, r );

	return left + right;
    }
    
};


int main() {

    int n, q;

    cin >> n >> q;

    SegTree seg( n );

    int c, x, y;
    for ( int i=0; i<q; ++i ) {

	cin >> c >> x >> y;

	if ( c == 0 ) seg.Add( x-1, y );
	else cout << seg.Sum( x-1, y-1 ) << endl;
	
    }
    
    return 0;
}



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

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> broken(n + 1);

    rep(i, m) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    vector<int> dp(n + 2);
    const int mod = 1000000007;
    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i + 1] +  dp[i + 2]) % mod;
    }

    cout << dp[0] << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    char s;
    cin >> s;
    if (s == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
vector<int> v;
signed main(){
	int a,b;
	cin>>a;
	f(i,a){
		cin>>b;
		v.push_back(b);
	}
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	cout<<(int)(v.size())<<endl;
}




Measured memory_bytes: 3840
def resolve():
    s = int(input())
    dp = [0]*(max(6, s+1))
    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    mod = 10**9+7
    for i in range(6, s+1):
        ct = 1
        for j in range(i-3, 2, -1):
            ct += dp[i-j]
            ct %= mod
        dp[i] = ct % mod
    print(dp[s]%mod)
resolve()

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

using namespace std;

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(((x+r) <= w ) && ((x-r) >= 0) && ((y+r) <= h) && ((y-r) >= 0)) cout << "Yes\n";
    else cout << "No\n";
    
    
    
    return 0;
}


Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    H, W = map(int, input().strip().split())
    S = []
    for i in range(H):
        s = list(input().strip())
        S.append(s)
    return H, W, S


def solve(H, W, S):
    if H == 1 and  W == 1 and S[0][0] == "#":
        return "No"
    
    dd = [(1, 0), (0, 1), (-1, 0), (0, -1)]

    def dfs(y, x):
        depth = 1
        S[y][x] = "."
        for dy, dx in dd:
            ny = y + dy
            nx = x + dx
            if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == "#":
                depth = max(depth, dfs(ny, nx) + 1)
        return depth

    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                depth = dfs(i, j)
                if depth == 1:
                    return "No"
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 5364
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e18;

int main() {
    ll n, m, p;
    cin >> n >> m >> p;
    VL a(m), b(m), c(m);
    VVI e(n);
    REP(i,m){
        a[i] = in() - 1;
        b[i] = in() - 1;
        c[i] = in();
        e[b[i]].push_back(a[i]);
    }
    VI reach(n);
    reach[n - 1] = 1;
    queue<int> que;
    que.push(n - 1);
    while (!que.empty()){
        int now = que.front();
        que.pop();
        for (int next : e[now]){
            if (reach[next]) continue;
            reach[next] = 1;
            que.push(next);
        }
    }
    VL dist(n, -INF);
    dist[0] = 0;
    REP(i,n+1){
        bool found = false;
        REP(j,m){
            if (!reach[b[j]] || dist[a[j]] == -INF) continue;
            ll x = dist[a[j]] + c[j] - p;
            if (x > dist[b[j]]){
                found = true;
                dist[b[j]] = x;
            }
        }
        if (!found) break;
        if (i == n){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0LL, dist[n - 1]) << endl;

    return 0;
}


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

S = list(input())
new = []
for s in S:
    if s=='x':
        continue
    new.append(s)

leng = len(new)
for n in range(leng//2):
    if new[n]!=new[-n-1]:
        print(-1)
        break
else:
    lis = []
    cnt = 0
    for s in S:
        if s!='x':
            lis.append(cnt)
            cnt = 0
        else:
            cnt += 1
    lis.append(cnt)
    leng = len(lis)
    ans = 0
    for i in range(leng//2):
        ans += abs(lis[i]-lis[-i-1])
    print(ans)

Measured memory_bytes: 85348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, num;
	cin>>n;
	
	vector<int> ip(n);
	map<int, long> count;
	for(int i=0; i<n; i++) {
		cin>>num;
		ip[i] = num;
		count[num]++;
	}
	
	long long totalWays = 0LL;
	map<int, long>::iterator it = count.begin();
	for(; it!= count.end(); it++) {
		totalWays += ((it->second)*(it->second - 1))/2;
	}
	
	for(int i=0; i<n; i++) {
		cout<<totalWays - (count[ip[i]] - 1)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	bool flag = true;
	for (int i = 1; i <= a + b + 1; i++) {
		if (i == a + 1) {
			if (s.at(i - 1) != '-') flag = false;
		}
		else {
			if (s.at(i - 1) == '-') flag = false;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    string s;
    cin>>s;

    if(s == "ABC")
        cout<<"ARC";
    else
        cout<<"ABC";


}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
const int mod = 1e9 + 7;
    
long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> aa = a;
    vector<int> v(1000001, 0);
    for (int i = 2; i <= 1000; i++) {
        for (int j = 0; j < n; j++) {
            int c = 0;
            while (a[j] % i == 0) {
                a[j] /= i;
                c++;
            }
            v[i] = max(v[i], c);
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] > 1) {
            v[a[i]] = max(v[a[i]], 1);
        }
    }
    long long int num = 1;
    for (int i = 2; i <= 1000000; i++) {
        num = num * mypow(i, v[i]) % mod;
    }
    long long int res = 0;
    for (int i = 0; i < n; i++) {
        res += num * mypow(aa[i], mod - 2) % mod;
        res %= mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 7188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


int main(void) {
	ll n;

	cin >> n;
	map<ll, ll> factorize;

	for (ll i = 2; i <= n; ++i) {
		auto fs = GetPrimeFactorize(i);

		
		for (auto itr = fs.begin(); itr != fs.end(); ++ itr ) {
			factorize[itr->first] += itr->second;
		}
	}

	ll ans = 1;
	for (auto itr = factorize.begin(); itr != factorize.end(); ++itr) {
		ans *= itr->second + 1;
		ans %= PrimeBigNum10_9_7;
	}

	auto output = ans;
	cout << output;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int count = 0;
    if(n%2 == 0){
        for(int i = 0; i < n/2; i++){
            if(s[i] != s[n - 1 - i]) count++;
        }
    }
    else{
        for(int i = 0; i < (n - 1)/2; i++){
            if(s[i] != s[n - 1 - i]) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3624
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9423322
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n), deg(n);
    rep(i, n){
        scanf("%d", &a[i]);
        --a[i];
        deg[a[i]] += 1;
    }
    vector<int> b(n, -1), used(n, 0);
    function<void(int, int)> Dfs = [&](int v, int mn){
        if(v == n){
            rep(i, n){
                if(i > 0) printf(" ");
                printf("%d", b[i] + 1);
            }
            puts("");
            exit(0);
        }
        if(v > 0){
            int who = a[b[v - 1]];
            if(!used[who] && deg[who] == n - v - 1) return 0;
        }
        while(used[mn]) ++mn;
        repx(i, mn, n){
            if(used[i]) continue;
            if(v > 0 && i == a[b[v - 1]]) continue;
            int new_mn = mn;
            if(i == mn) ++new_mn;
            b[v] = i;
            --deg[a[i]];
            used[i] = 1;
            Dfs(v + 1, new_mn);
            used[i] = 0;
            ++deg[a[i]];
            b[v] = -1;
        }
    };
    Dfs(0, 0);
    puts("-1");
    return 0;
}

Measured memory_bytes: 11776
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int year, month, day;
		int k;

		while (sc.hasNext()) {
			year  = sc.nextInt();
			month = sc.nextInt();
			day   = sc.nextInt();
			k = 0;
			
			k += year * 10000;
			k += month * 100;
			k += day;
			
			if (k < 18680908) {
				System.out.println("pre-meiji");
			} else if (k <= 19120729) {
				System.out.println("meiji " + (year - 1867) + " " + month + " " + day);
			} else if (k <= 19261224) {
				System.out.println("taisho " + (year - 1911) + " " + month + " " + day);
			} else if (k <= 19890107) {
				System.out.println("showa " + (year - 1925) + " " + month + " " + day);
			} else {
				System.out.println("heisei " + (year - 1988) + " " + month + " " + day);
			}
		}
	}
}

Measured memory_bytes: 12000
n, a, b, c = gets.split.map(&:to_i)
l = Array.new(n) { gets.to_i }
ans = Float::INFINITY

(4**n).times do |i|
  x = y = z = 0
  mp = (n - 3) * 10

  format("%0#{n}d", i.to_s(4)).each_char.with_index do |j, idx|
    case j
    when '0' then mp -= 10
    when '1' then x += l[idx]
    when '2' then y += l[idx]
    when '3' then z += l[idx]
    end
  end

  next if x == 0 || y == 0 || z == 0

  mp += (x - a).abs + (y - b).abs + (z - c).abs
  ans = [mp, ans].min
end

puts ans

Measured memory_bytes: 14364
#include<iostream>
using namespace std;
long N,x;
char S[100010];
int main(){
  cin >> N >> S;
  for (int i=0;i<N;i++){
    if (S[i]=='R'){
      x++;
    }else{
      x--;
    }
  }
  if (x>=1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<sstream>
#include<bitset>
using namespace std;
using ull = unsigned long long;

const long long hash_base = 1e9 + 7;

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

  vector<unsigned int> a(N), b(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i++){
    cin >> b[i];
  }

  vector<unsigned int> a_diff(N), b_diff(N);
  for(int i = 0; i < N; i++){
    a_diff[i] = a[i] ^ a[(i + 1) % N];
    b_diff[i] = b[i] ^ b[(i + 1) % N];
    //cout << a_diff[i] << ' ' << b_diff[i] << endl;
  }

  ull hash_base_pow = 1;
  for(int i = 0; i < N; i++){
    hash_base_pow *= hash_base;
  }

  ull a_hash = 0, b_hash = 0;
  for(int i = 0; i < N; i++){
    a_hash = a_hash * hash_base + a_diff[i];
    b_hash = b_hash * hash_base + b_diff[i];
  }
  
  for(int i = 0; i < N; i++){
    if(a_hash == b_hash){
      cout << i << ' ' << (a[i] ^ b[0]) << endl;
    }
    a_hash = a_hash * hash_base + a_diff[i] - a_diff[i] * hash_base_pow;
  }
}


Measured memory_bytes: 6656
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

const int MaxN = 1e5 + 6;
typedef long long LL;

int main(){
	int n;
	cin>>n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		for(int j = 1; j <= i; j++){
			if(i % j == 0 && i % 2) cnt++;
		}
		if(cnt == 8) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

list <int> lis;
list <int>::iterator lit;

int main()
{
//    ios::sync_with_stdio(false);
    string ctrl;
    int n, num;
    cin >> n;
    while (n--)
    {
        cin >> ctrl;
        if (ctrl == "deleteFirst")
            lis.pop_front();
        else if (ctrl == "deleteLast")
            lis.pop_back();
        else
        {
            cin >> num;
            if (ctrl == "insert")
                lis.pf(num);
            else
            {
                lit = lis.begin();
                while (lit != lis.end())
                {
                    if (*lit == num)
                    {
                        lis.erase(lit);
                        break;
                    }
                    lit++;
                }
            }
        }
    }
    for (lit = lis.begin(); lit != lis.end(); lit++)
    {
        if (lit != lis.begin())
            cout << ' ';
        cout << *lit;
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 34404
#include <iostream>
using namespace std ;
int main(){
	int m , f , r , x , y ;
	while ( 1 ){
		cin >> m >> f >> r ;
		if ( m == -1 && f == -1 && r == -1 ) break ;
		else if ( m == -1 || f == -1 )
			cout << "F" << endl ;
		else if ( m + f >= 80 )
			cout << "A" << endl ;
		else if ( m + f >= 65 && m + f < 80 )
			cout << "B" << endl ;
		else if ( m + f >= 50 && m + f < 65 )
			cout << "C" << endl ;
		else if ( m + f >= 30 && m + f < 50 && r >= 50 )
			cout << "C" << endl ;
		else if ( m + f >= 30 && m + f < 50 )
			cout << "D" << endl ;
		else if ( m + f < 30 )
			cout << "F" << endl ;
		}


}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	int n, m;
	cin >> m >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll s = accumulate(all(a), 0);
	if(m < s)
		cout << -1 << endl;
	else
		cout << m - s << endl;
	return 0;
}

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

using lint = int64_t;
const lint n_max = 100010;

int main() {
    vector<int> can(n_max);
    for (int i = 2; i < n_max; i++) {
        vector<lint> divs;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                divs.push_back(j);
                if (j != i / j) {
                    divs.push_back(i / j);
                }
            }
        }
        lint tmp = 1;
        for (int j = 0; j < divs.size(); j++) {
            tmp *= divs[j];
            if (tmp >= 2 * i) {
                can[i] = 1;
                break;
            }
        }
        can[i] += can[i - 1];
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int n;
        cin >> n;
        cout << can[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 3412
//abc147_e.cpp
//Sat Jan  4 23:15:23 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h >> w;

	int a[h][w];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cin >> a[i][j];
		}
	}

	int b[h][w];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cin >> b[i][j];
		}
	}

	bool dp[h][w][(h+w+1)*80];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			for (int k=0;k<(h+w+1)*80;k++){
				dp[i][j][k] = false;
			}
		}
	}

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			if (i==0 && j==0){
				dp[i][j][abs(a[i][j]-b[i][j])] = true;
			}else{
				for (int k=0;k<=(h+w)*80;k++){
					if (j>0 && dp[i][j-1][k]){
						dp[i][j][k+abs(a[i][j]-b[i][j])] = true;
						dp[i][j][abs(k-abs(a[i][j]-b[i][j]))] = true;
					}
					if (i>0 && dp[i-1][j][k]){
						dp[i][j][k+abs(a[i][j]-b[i][j])] = true;
						dp[i][j][abs(k-abs(a[i][j]-b[i][j]))] = true;
					}
				}
			}
		}
	}

	for (int i=0;i<=(h+w)*80;i++){
		if (dp[h-1][w-1][i]){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 80768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  intt k;
  cin >> k;
  intt ans = 0;
  // puts("EDS");
  rep(i, 1, k + 1){
    rep(j, 1, k + 1){
      rep(l, 1, k + 1){
        ans += __gcd(__gcd(i, j), l);
      }
    }
  }
  cout << ans << endl;
}

int main() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<cctype>
#define For(i,a,b) for(i=(a),i##end=(b);i<=i##end;++i)
#define Forward(i,a,b) for(i=(a),i##end=(b);i>=i##end;--i)
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
using namespace std;
template<typename T>inline void read(T &x){
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&k^'-')k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
const int MAXN=60;
static int aid,iid,ma,mi,n,a[MAXN];
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
void init()
{
    read(n);
    Rep(i,1,n)
    {
        read(a[i]);
        if(a[i]>ma)Chkmax(ma,a[i]),aid=i;
        else if(a[i]<mi)Chkmin(mi,a[i]),iid=i;
    }
}
static int opt;
static int sta[MAXN<<1][2];
void solve()
{
    if(ma>=-mi)
    {
        Rep(i,1,n)if(a[i]<0)
            sta[++opt][0]=aid,sta[opt][1]=i;
        Rep(i,1,n-1)sta[++opt][0]=i,sta[opt][1]=i+1;
        printf("%d\n",opt);
        Rep(i,1,opt)printf("%d %d\n",sta[i][0],sta[i][1]);
    }
    else
    {
        Rep(i,1,n)if(a[i]>0)
            sta[++opt][0]=iid,sta[opt][1]=i;
        Repe(i,n,2)sta[++opt][0]=i,sta[opt][1]=i-1;
        printf("%d\n",opt);
        Rep(i,1,opt)printf("%d %d\n",sta[i][0],sta[i][1]);
    }

}
int main(void){
    init();
    solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

//最小公倍数, 複数の時はlcm(a,lcm(b,c))みたいな感じで
template <class T>
T lcm(T a,T b){
	return a*(b/gcd(a,b));
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<ll> a(n);
	ll l=1;
	rep(i,n){
		cin>>a[i];
		a[i]/=2;
		l=lcm(l,a[i]);
	}
	ll ans=m/l;
	rep(i,n){
		if((l/a[i])%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	if(ans==0){
		cout<<0<<endl;
		return 0;
	}
	ans--;
	ans/=2;
	ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  double n,t,a,h[2000],x[2000];
  cin >> n >> t >> a; 
  for(int i = 0; i < n; i++) {
    cin >> h[i];
    x[i] = 1000*t - h[i] * 6;
  }

  int mi = 1000000000, num;
  for(int i = 0; i < n; i++) {
    if(mi > abs(x[i]-1000*a)) {
      mi = abs(x[i]-1000*a);
      num = i;
    }
  }
  cout << num+1 << endl;
}


Measured memory_bytes: 3796
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int H, W;
	for (;;){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break;
		}
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if ((i + j) % 2 == 0){
					cout << "#";
				}
				else if ((i + j) % 2 == 1){
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
	}


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

typedef long long ll;
int main() {
	ll n;
	cin >> n;
	
	vector<ll> a(n);
	unordered_map<ll,ll> map;
	
	ll sum = 0;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
		map[a[i]]++;
	}
	
	ll q;
	cin >> q;
	
	while(q--){
		ll b,c;
		cin >> b >> c;
	
		ll times = map[b];
	
		map[b] = 0;
		map[c] += times;
		
		sum -= b * times;
		sum += c * times;
		
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 7716
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

def get_mean_of_temp(x, t):
    return t-x*0.006

temp_diff = [abs(get_mean_of_temp(h_i, t)-a) for h_i in h]

min_v = min(temp_diff)
min_i = temp_diff.index(min_v)
print(min_i+1)

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

int main() {
  int N, L;
  cin >> N >> L;
  string S[N];
  string ans = "";
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort (S, S + N);
    for (int i = 0; i < N; i++) {
      ans += S[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import combinations
def solve():
    L, R = map(int, input().split())
    l, r = L%2019, R%2019
    if R-L >= 2019-1 or l >= r or l == 0:
        return '0'
    elif R-L >= 673-1 or ((R-L >= 3-1 or L%3 >= R%3 or L%3 == 0) and L%673 >= R%673) or ((R-L >= 3-1 or L%3 >= R%3 or L%3 == 0) and L%673 == 0):
        return '0'
    elif R-L == 1:
        return str((L*R)%2019)
    else:
        return str(min((i*j)%2019 for i, j in combinations(range(L,R+1),r=2)))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    int ans = 0;
    rep(i, 0, n) if(h[i] >= k) ans++;
    cout << ans << endl; 
}

Measured memory_bytes: 1024