akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()

int N;
vector<string> S;

bool judge(int n)
{
    for (int i=1; i<N; ++i){
        for (int j=n; j<n+i; ++j){
            if(S[i][j%N] != S[(j-n)%N][(i+n)%N]) return false;
        }
    }
    return true;
}

int main(int argc, const char * argv[]) {
    cin >> N;
    
    for (int n = 0; n < N; ++n) {
        string tmp;
        cin >> tmp;
        S.push_back(tmp);
    }
    
    ll res = 0;
    for (int n=0; n<N; ++n) {
        if(bool b = judge(n)) res++;
    }
    res *= N;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#include <iostream>
using namespace std;

int main()
{
    int a;
    int b;
     
    cin >> a >> b;
    
    int r1 = a / b;
    int r2 = a % b;
    double r3 = 1.0 * a / b;
    
    cout << r1 << " " << r2 << " ";
    printf ("%.8lf\n", r3);
    
    return 0;
    
    
}


Measured memory_bytes: 3228
S = input()

front = int(S[:2])
rear = int(S[2:])

if 0 < front < 13 :
    F_month = True
else:
    F_month = False
    
if 0 < rear < 13 :
    R_month = True
else:
    R_month = False

if F_month == True and R_month == False:
    print('MMYY')

if F_month == True and R_month == True:
    print('AMBIGUOUS')

if F_month == False and R_month == False:
    print('NA')

if F_month == False and R_month == True:
    print('YYMM')


Measured memory_bytes: 3060
module Main where

import Data.List
import qualified Data.Map.Strict as Map
import Control.Monad
import Data.Ord

main = do
    print =<< solve <$> readInteger

readInteger :: IO Integer
readInteger = read <$> getLine

solve :: Integer -> Int
solve n = if  mod n 2 == 0 then countZeros n 10 else 0

countZeros :: Integer -> Integer -> Int
countZeros n m
    | n < m = 0
    | otherwise = (countZeros n $ m * 5) + (fromIntegral $ div n m)


Measured memory_bytes: 508
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for z in range(X+1, Y+1):
  if z > max(x):
    if z <= min(y):
      print('No War')
      exit(0)

print('War')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int a, b, c;
    read(a, b, c);
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    print((s.size() == 2) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int a[3];
signed main(){
    cin>>a[0]>>a[1]>>a[2];
    int sum=a[0]+a[1]+a[2];
    sort(a,a+3);
    int ans=sum-a[2];
    cout<<ans<<endl;
}


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

int main(){
	int N;
	scanf("%d",&N);
	int X[N];
	for(int i=0;i<N;i++) scanf("%d",&X[i]);
	
	int min=INT_MAX;
	for(int i=1;i<=100;i++){
		int sum=0;
		for(int j=0;j<N;j++) sum+= (X[j]-i)*(X[j]-i);
		if( min>sum ) min=sum;
	}
	printf("%d",min);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("-Ofast")
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int32_t main(){_
	int n,k ;
	cin >> s >> k ;
	set<char> fs ;
	set<string> ds ;
	for(auto i : s)
		fs.insert(i) ;
	for(auto i : fs){
		for(int p = 0 ; p < sz(s) ; p++){
			if(s[p] != i) continue ;
			int cnt = 1 ;
			for(int j = p ; j < sz(s) && cnt <= 5 ; j++){
				string t = s.substr(p,cnt) ;
				ds.insert(t) ;
				cnt++ ;
				}
			}
		int a = 0 ;
		for(auto i = ds.begin() ; i != ds.end(); i++){
			a++ ;
			if(a == k){
				cout << *i << endl ;
				return 0 ;
			}
		}	
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    vector<int> kotae(1000000);
    for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){
                kotae[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cout << kotae[i] << endl;
    }
    
}

Measured memory_bytes: 6908
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int X, Y; cin >> X >> Y;
    cout << X + Y/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
LL a,b,tmp,ans;

LL solve(LL x)
{
    LL tmp = x % 4;
    //printf("mod = %d\n")
    if(tmp == 0)return x;
    else if(tmp == 1)return (LL)1;
    else if(tmp == 2)return (LL)x + 1;
    else return (LL)0;
}

int main()
{
    //freopen("new.txt","r",stdin);
    scanf("%lld %lld",&a,&b);
    a = solve(a - 1);
    b = solve(b);
    //printf("a = %lld,b = %lld\n",a,b);
    printf("%lld\n",a^b);
    return 0;
}


Measured memory_bytes: 256
don, curry,pasta,ramen,hamburger=[int(input()) for i in range(5)]
list=[[don,int(str(don)[-1]) if  10-int(str(don)[-1]) == 10 else 10-int(str(don)[-1]) ,int(str(don)[-1])]
,[curry,int(str(curry)[-1]) if  10-int(str(curry)[-1]) == 10 else 10-int(str(curry)[-1]) ,int(str(curry)[-1])]
,[pasta,int(str(pasta)[-1]) if  10-int(str(pasta)[-1]) == 10 else 10-int(str(pasta)[-1]) ,int(str(pasta)[-1])]
,[ramen,int(str(ramen)[-1]) if  10-int(str(ramen)[-1]) == 10 else 10-int(str(ramen)[-1]) ,int(str(ramen)[-1])]
,[hamburger,int(str(hamburger)[-1]) if  10-int(str(hamburger)[-1]) == 10 else 10-int(str(hamburger)[-1]) ,int(str(hamburger)[-1])]]

time=0
list = sorted(list, key=lambda x: x[1]) #注文する順
for food in list:
  time+=food[0] + food[1]

print(time-list[4][1])

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int gcd(int p, int q) {
	int upper, lower, r;

	if (p >= q) upper = p, lower = q;
	else upper = q, lower = p;

	if (lower == 0)
		return upper;
	r = upper % lower;
	if (r)return gcd(lower, r);
	else return lower;
}

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];

	vector<int> L(N + 1);
	vector<int> R(N + 1);

	for (int i = 0; i < N; i++) {
		L[i + 1] = gcd(L[i], A[i]);
	}

	for (int i = 0; i < N; i++) {
		R[i + 1] = gcd(R[i], A[N - 1 - i]);
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, gcd(L[i - 1], R[N - i]));
	}

	cout << ans << endl;
}


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

int main( void )
{
  int N;
  cin >> N;
  int D[ N ][ 2 ];
  int  max = -INT_MAX;
  int count = 0;
  
  for( int i = 0; i < N; i++ ) {
    cin >> D[ i ][ 0 ] >> D[ i ][ 1 ];
    if( D[ i ][ 0 ] == D[ i ][ 1 ] ) {
      count++;
    }
    else {
      if( max < count ) {
	max = count;
      }
      count = 0;
    }
  }
  
  if( max < count ) {
	max = count;
      }
  
  if( max >= 3 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
	
}
   

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 505;

int x[MAXN];

int ans[MAXN * MAXN];

pii pp[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &x[i]);
		pp[i] = mp(x[i], i);
		if (ans[x[i]]){
			printf("No\n");
			return;
		}
		ans[x[i]] = i;
	}
	sort(pp + 1, pp + n + 1);
	int cur = 1;
	REPN(i, 1, n){
		int a = pp[i]._2;
		int cnt = a - 1;
		for(; cnt; cur++){
			if (cur >= pp[i]._1){
				printf("No\n");
				return;
			}
			if (ans[cur]){
				
				continue;
			}
			ans[cur] = a;
			
			cnt--;
		}
	}
	cur = n * n;
	for(int i = n; i >= 1; i--){
		int a = pp[i]._2;
		int cnt = n - a;
		for(; cnt; cur--){
			if (cur <= pp[i]._1){
				printf("No\n");
				return;
			}
			if (ans[cur]){
				continue;
			}
			ans[cur] = a;
			
			cnt--;
		}
	}
	printf("Yes\n");
	REPN(i, 1, n * n){
		printf("%d ", ans[i]);
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define AAA (10000000l)

using namespace std;

unordered_map<ll, unordered_set<ll>> joint;
unordered_set<ll> visited;
unordered_map<ll, ll> answer_map;

void rec(ll node, ll color) {
  visited.insert(node);
  ll tmp = 1;

  for (auto it: joint[node]) {
    if (visited.count(it) != 0) continue;
    if (tmp == color) tmp++;
    answer_map[node * AAA + it] = tmp;
    answer_map[it * AAA + node] = tmp;
    rec(it, tmp);
    tmp++;
  }
}

void solve() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> edges(N - 1);
  rep (i, N - 1) {
    ll a, b;
    cin >> a >> b;
    edges[i] = make_pair(a, b);
  }

  for (auto it: edges) {
    joint[it.first].insert(it.second);
    joint[it.second].insert(it.first);
  }

  rec(1, 0);

  ll colors = 0;
  for (auto it: answer_map) colors = max(colors, it.second);
  cout << colors << endl;
  for (auto it: edges) cout << answer_map[it.first * AAA + it.second] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 33608
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.par = [-1]*(n+1)
    
    def find(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

N, M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
    a, b = map(int,input().split())
    uf.union(a,b)

ans = -min(uf.par)
print(ans)    

Measured memory_bytes: 14480
N,M=map(int,input().split())

if N==1 and M==1:
    ans=1
elif N==1 and M==2:
    ans=0
elif N==1 and M>=3:
    ans=M-2
elif N==2 and M==1:
    ans=0
elif N==2 and M==2:
    ans=0
elif M==1 and N>=3:
    ans=N-2
else:
    ans=(N-2)*(M-2)

print(ans)

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline

N = 1407
K = 38



Ans = [[] for _ in range(N)]
for i in range(N-1):
    Ans[i].append(1+i//(K-1))
for cnt in range(K):
    Ans[N-1].append(1+cnt)

for cnt in range(K+1, N+1):
    st = (cnt-K-1)//(K-1)
    Ans[st].append(cnt)
    sec = (cnt-K-1)%(K-1)
    for j in range(1, K):
        Ans[j*(K-1) + (sec+st*j)%(K-1)].append(cnt)

print(N, K)
print('\n'.join(' '.join(map(str, a)) for a in Ans))

"""
Ans = [frozenset(a) for a in Ans]

for i in range(N):
    for j in range(i):
        assert len(Ans[i] & Ans[j]) == 1, ''
"""

Measured memory_bytes: 46832
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

L=gets.to_i
A=gets.to_f
B=gets.to_f
C=gets.to_f
D=gets.to_f
japanese=(A/C).ceil
math=(B/D).ceil
if japanese>math
    puts L-japanese
else
    puts L-math
end


Measured memory_bytes: 6884
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <stack>

using namespace std;

const int MAX_N = 1e5;

int main() {
	//freopen("Transit_Tree_Path.txt", "r", stdin);

	int N;
	scanf("%d", &N);

	vector<map<int, int > > g(MAX_N);
	for (int i=0; i<N-1; i++) {
		int u,v,l;
		scanf("%d%d%d", &u, &v, &l);
		g[u-1][v-1] = l;
		g[v-1][u-1] = l;
	}

	int Q, K;
	scanf("%d%d", &Q, &K);

	vector<long long> dist;
	for (int i = 0; i < N; i++) {
		dist.push_back(-1);
	}
	dist[K-1] = 0;

	stack<int> s;
	s.push(K-1);

	while (!s.empty()) {
		int u = s.top();
		s.pop();
		for (const auto edge : g[u]) {
			int v = edge.first, l = edge.second;
			if (dist[v] == -1 || dist[u] + l < dist[v]) {
				dist[v] = dist[u] + l;
				s.push(v);
			}
		}
	}

	for (int i = 0; i < Q; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%lld\n", dist[x-1] + dist[y-1]);
	}
}


Measured memory_bytes: 16760
/*
ID: varunra2
LANG: C++
TASK: a
*/

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

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions

int n, k;
VI vals;

void init() {
  cin >> n >> k;
  vals.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vals[i];
  }
}

bool ok(int len) {
  if(len == 0) return false;
  int cop = k;
  for (int i = 0; i < n; i++) {
    // chop up vals[i] into vals[i]/len parts
    int cur = vals[i] / len + (bool)(vals[i] % len) - 1;
    cop -= cur;
  }
  return cop >= 0;
}

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

  init();
  int mx = 0;
  for (auto& x : vals) mx = max(mx, x);
  int x = -1;
  for (int b = mx + 10; b >= 1; b /= 2) {
    while (!ok(x + b)) x += b;
  }
  k = x + 1;

  cout << k << endl;

  return 0;
}


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

int main(){

int H,W,i,j,p,q;

while(1){

cin>>H>>W;

if (H==0&&W==0)break;

for(p=0;p<W;p++){

cout<<"#";

}

cout<<"\n";

for(i=0;i<H-2;i++){

cout<<"#";

for(j=0;j<W-2;j++){

cout<<".";

}

if(W!=1)cout<<"#";

cout<<"\n";

}


if(H!=1)for(p=0;p<W;p++){

cout<<"#";

}

if(H!=1)cout<<"\n";
cout<<"\n";

}

return 0;

}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

int gcd(int a, int b){
    if(b == 0) return a;

    return gcd(b, a%b);
}
 
int main(){
   
   int k;

    cin >> k;
    int ans = 0;
    rep(i, k){
        rep(j, k){
            rep(l, k){
                ans += gcd(gcd(i+1, j+1),l+1);
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3596
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
last_push_time = t[0]
for i in range(1, len(t)):
    if last_push_time + T <= t[i]:
        ans += T
    else:
        ans += t[i] - last_push_time
    last_push_time = t[i]
    
print(ans + T)

Measured memory_bytes: 26836
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define y second
#define x first
#define lsb(x) (x&-x)
#define pb push_back
#define y second
const int NMAX=100666; //LOL
const int MOD=1000000007; //LOL
const int SQRT=350;
using namespace std;
const double eps=1e-5;
const double PI=acos(-1.0);
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLD;
typedef vector<int> VI;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, 1, -1, 0};
const int MAXN=(1<<26);
char c;
int n;
int rs;
int p[100666];
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("input.in", "rt", stdin);
    //freopen("output.out", "wt", stdout);
	cin>>n;
	for(int i=1; i<=n; ++i)
	{
		cin>>p[i];
	}
	for(int i=1; i<=n; ++i)
	{
		if(i==p[p[i]])
			rs++;
	}
	cout<<rs/2;

	return 0;
}

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

int main(){
  string O,E;
  cin >> O >> E;
  for(int i=0;i<E.length();i++){
    cout << O[i] << E[i];
  }
  if(O.length()>E.length()){
    cout << O[O.length()-1];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	char s[4];
	int i;
	
	scanf("%s",s);
	
	for(i=0;i<3;i++){
		if(s[i]==s[i+1]){
			puts("Bad");
			return 0;
		}
	}
	
	puts("Good");
	
	return 0;
}

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

using namespace std;

const int MAX_N = 200000;
const double PI = 3.141592653589793;
int a,b,c,d;
int n;
pair<int, int> f[MAX_N];

int main()
{
  cin >> a >> b >> c >> d >> n;
  if (a > c) { swap(a,c); swap(b,d); }

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

  sort(f, f+n);
  int l = lower_bound(f, f+n, make_pair(a, 0)) - f;
  int r = upper_bound(f, f+n, make_pair(c, INT_MAX)) - f;

  vector<int> bd;
  if (d < b) {
    swap(b, d);
    reverse(f+l, f+r);
  }
  for (int i = l; i < r; i++)
    if (b <= f[i].second && f[i].second <= d)
      bd.push_back(f[i].second);

  int lis[bd.size()];
  fill_n(lis, bd.size(), INT_MAX);
  for (int i = 0; i < bd.size(); i++) {
    *lower_bound(lis, lis+bd.size(), bd[i]) = bd[i];
  }

  int k = lower_bound(lis, lis+bd.size(), INT_MAX) - lis;

  int s = c - a + d - b, p, q;
  if (min(c - a, d - b) + 1 == k) {
    p = k-1;
    q = 1;
  } else {
    p = k;
    q = 0;
  }

  printf("%.15f\n", 100.0 * s + (5.0*p + 10.0*q) * PI - 20.0 * (p + q));

  return 0;
}


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<stack>
using namespace std;
bool check(int x)
{
	if (x < 0) return false;
	int div = 1;
	while (x / div >= 10) {
		div *= 10;
	}
	while (x != 0) {
		int l = x / div;
		int r = x % 10;
		if (l != r) return false;
		x = (x % div) / 10;
		div /= 100;
	}
	return true;
}
int main()
{
	int cnt = 0;
	int a, b;
	cin >> a >> b;
	for (int i = a; i <=b; i++)
		if (check(i)) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
"""
# 

def main():
    alphabets = 'abcdefghijklmnopqrstuvwxyz'
    text = input().strip()

    result = 'None'
    for c in alphabets:
        if c not in text:
            result = c
            break
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const int hell=1000000007;
 
 int h[100010][3]={0};
 int dp[100010][3];
 int n,k;

int vac(int index,int k)
{
  if(index>n)return 0;
  if(dp[index][k]!=-1)return dp[index][k];
  
  int ans=0;
   
   rep(i,0,3)
   {
       if(k!=i)ans=max(ans,vac(index+1,i));
   }

  return dp[index][k]=ans+h[index][k];
}


int solve(){    

  memset(dp,-1,sizeof(dp));
  cin>>n;
  rep(i,0,n)rep(j,0,3)cin>>h[i+1][j];
  cout<<max({vac(1,0),vac(1,1),vac(1,2)});


return 0;
}

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


   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);  

 int t=1;                                                                                                                  
// cin>>t;
    while(t--)
     {
      solve();
     }
    return 0;
}

Measured memory_bytes: 8064
N, time = map(int ,input().split())
T = list(map(int ,input().split()))


ans = 0
start_time = T[0]
end_time = T[0] + time
for i in range(1, N):
    if T[i] <= end_time:
        ans += T[i] - start_time
        start_time = T[i]
        end_time = T[i] + time
    else:
        ans += time
        start_time = T[i]
        end_time = T[i] + time
ans += time


print(ans)

Measured memory_bytes: 26708
import java.util.*;
public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
    int X = sc.nextInt();
    int ALL = 0;
    int ans = 1;

    for(int i = 0; i < N; i++){
      ALL += sc.nextInt();

      if(ALL > X){
        break;
      }
			ans++;
    }



		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
#include <functional>
#include <stack>
#include <cmath>
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++)
#define llong long long

llong factorial(int n) {
  if(n == 0) return 1;
  return (llong)n * factorial(n-1);
}

int main() {
  int n;
  scanf("%d",&n);
  printf("%lld\n",factorial(n));
  return 0;
}

Measured memory_bytes: 2608
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e, x ^= e;
    for (ll e : a)
        cout << (e ^ x) << ' ';
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    ll n;
    ll sum = 0;
    cin >> n;
    for(ll i = 1;i <= n;i++){
        if(i%3 == 0 || i%5 == 0){

        }else{
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
	    Scanner s = new Scanner(System.in);
        int x = s.nextInt(),y=s.nextInt();
        boolean flag =false;

        for(int i=0;i<=x;i++){
            int cr = i;
            int tu = x-i;
            if(cr*2 + tu*4 == y){
                flag =true;
                break;
            }
        }
        System.out.println(flag?"Yes":"No");
    }
}





class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}


Measured memory_bytes: 25328
#include <stdio.h>

int main(){
    int m,f,r;
    scanf("%d %d %d",&m,&f,&r);
    while(!(m==-1&&f==-1&&r==-1)){
        if(m==-1||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(80>m+f&&m+f>=65){
            printf("B\n");
        }else if(65>m+f&&m+f>=50){
            printf("C\n");
        }else if(50>m+f&&m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else if(m+f<30){
            printf("F\n");
        }
        scanf("%d %d %d",&m,&f,&r);
    }
}


Measured memory_bytes: 2040
#include<stdio.h>
int main(void)
{
	int n,m[1001],i,a,b,h[101],k[101],flg=0,j;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d %d",&h[i],&k[i]);
	for(i=0;i<n;i++){
		if(a<=h[i]&&b>=k[i]) flg=1;
		if(h[i]<a&&b<k[i]) flg=1;
		if(h[i]<=a&&a<k[i]) flg=1;
		if(h[i]<b&&b<=k[i]) flg=1;
	}
	//for(i=0;i<=10;i++) printf("%d %d\n",i,m[i]);
	if(flg==1) printf("1\n");
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 100000
using namespace std;
typedef long long ll;

int main(){
	int n;
	int a[100010];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int cnt = 0;
	int temp = a[0];
	for (int i = 1; i < n; i++) {
		if (a[i] == temp) cnt++;
		temp = a[i];
	}
	cout << n - cnt-cnt%2<< endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();

		int[] a = new int[N];
		int maxDist = 0;
		for(int i = 0; i < N; i++) {
		 a[i] = sc.nextInt();
		 if(i > 0 && (a[i] - a[i-1]) > maxDist)
			 maxDist = a[i] - a[i-1];
		}
		sc.close();

		int tmp = (K-a[N-1]) + a[0];

		if( tmp> maxDist) {
			maxDist = tmp;
		}

		System.out.println(K-maxDist);

	}

}

Measured memory_bytes: 84780
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_Q 200000
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

int n, q;
string s;
string t[MAX_Q], d[MAX_Q];

bool left(int i){
  if(i == 0) return true;
  if(i == n + 1) return false;
  for(int j = 0; j < q; j++){
    if(t[j][0] == s[i - 1]){
      if(d[j] == "R") ++i;
      else --i;
    }
    if(i == n + 1) return false;
    if(i == 0) return true;
  }
  return false;
}

bool right(int i){
  if(i == n + 1) return true;
  if(i == 0) return false;
  for(int j = 0; j < q; j++){
    if(t[j][0] == s[i - 1]){
      if(d[j] == "R") ++i;
      else --i;
    }
    if(i == 0) return false;
    if(i == n + 1) return true;
  }
  return false;
}

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

  cin >> n >> q;
  cin >> s;
  for(int i = 0; i < q; i++){
    cin >> t[i] >> d[i];
  }

  int low = 0, high = n + 1;
  while(high - low > 1){
    int mid = (low + high) / 2;
    if(left(mid)) low = mid;
    else high = mid;
  }
  int left = high;

  low = 0, high = n + 1;
  while(high - low > 1){
    int mid = (low + high) / 2;
    if(right(mid)) high = mid;
    else low = mid;
  }
  int right = high;

  int ans = (right - left);

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

ll f(ll x)
{
  ll res = 0;
  while(x > 0){
    res += x%10;
    x /= 10;
  }
  return res;
}

double g(ll x)
{
  return (double)x/f(x);
}

int main()
{
  vl ans;

  ll t = 1;
  rep(i, 15){
    repi(j, 1, 150){
      ans.pb(t*(j+1)-1);
    }
    t *= 10;
  }

  sort(all(ans));
  ans.erase(unique(all(ans)), ans.end());

  rep(i, ans.size()){
    repi(j, i+1, ans.size()){
      if(g(ans[i]) > g(ans[j])){
        ans.erase(ans.begin()+i--);
        break;
      }
    }
  }

  int k;
  cin >> k;
  rep(i, k){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#define EPS 1e-10
#define EQ(a, b) (abs((a) - (b)) < EPS)
using namespace std;
typedef complex<double> P;

double cross(P a, P b) {
    return(a.real() * b.imag() - a.imag() * b.real());
}
int is_intersect(P a1, P a2, P b1, P b2) {
    return(cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) &&
    (cross(b2-a1, a1-b1) * cross(b2-b1, a2-b1) < EPS);
}

int main(void) {
    double xa, ya, xb, yb, xc, yc, xd, yd;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF) {
        P a(xa, ya), b(xb, yb), c(xc, yc), d(xd, yd);
        if(is_intersect(a, c, b, d) && is_intersect(b, d, a, c)) cout << "YES" << endl;
        else                                                 cout << "NO"  << endl;
    }
    return(0);
}
     

Measured memory_bytes: 1224
N = int(input())
list_A = [int(x) for x in input().split()]

ans = 1
A0 = list_A[0]
flag = 0

for i in range(1,len(list_A)) :
    if list_A[i] > list_A[i-1] :
        if flag == 0 :
            flag = 1
        elif flag == 1 :
            pass
        else :
            ans += 1
            flag = 0
    elif list_A[i] < list_A[i-1] :
        if flag == 0 :
            flag = -1
        elif flag == 1 :
            ans += 1
            flag = 0
        else :
            pass
    else :
        pass

print(ans)


Measured memory_bytes: 14224
#include<stdio.h>
#include<string.h>

long int gcd(long int a, long int b) {
	int big, small;
	if (a < b)big = b, small = a;
	else big = a, small = b;
	if (big % small == 0)return small;
	else return gcd(small, big % small);
}

int main(void) {
	long int n, m,lcm,g,i,ok = 1;
	char nn[100001], mm[100001];

	scanf("%d %d", &n, &m);
	scanf("%s", nn);
	scanf("%s", mm);
	g = gcd(n, m);
	lcm = n * m / g;

	for (i = 0; i < g; i++) {
		if (nn[n * i / g] != mm[m * i / g]) {
			ok--;
			break;
		}
	}

	if (ok) {
		printf("%ld\n", lcm);
	}
	else {
		printf("-1\n");
	}

}

Measured memory_bytes: 384
A,B,C = map(int, input().split())
d = [A,B,C]
d.sort()
n = 0
while d[0]+2 <= d[2]:
  d[0] += 2
  n += 1
while d[1]+2 <= d[2]:
  d[1] += 2
  n += 1
if d[0] == d[1] and d[0] != d[2]:
  print(n+1)
elif d[0] == d[1] and d[0] == d[2]:
  print(n)
else:
  print(n+2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  int ans = 753;
  REP(i, s.size() - 2){
    int tmp = stoi(s.substr(i,3));
    ans = min(ans, abs(753 - tmp));
  }
  cout << ans << endl;

  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  string s;
  cin>>s;
  n=s.size();

  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  int l, r, ans=n;
  REP(i, n-1){
    if(s[i]!=s[i+1]){
      l = i+1;
      r=n-i-1;
      ans=min(ans, max(l, r));
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N, M, X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
import numpy as np
A = np.array(A)
right = np.count_nonzero(A > X)
left = np.count_nonzero(A < X)
print(min(left, right))

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

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


Measured memory_bytes: 256
#include<stdio.h>

int group(int x){
  if(x==2)
    return 1;
  else if(x==4||x==6||x==9||x==11)
    return 2;
  else
    return 3;
}

int main(void){
  int x,x1,y,y1;

  scanf("%d %d",&x,&y);

  x1=group(x);
  y1=group(y);

  if(x1==y1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}

long int x,y;

int solve(){
    long int count=1,m=x;
    while(m*2<=y){
        m=m*2;
        count++;
    }
    return count;
}

int main(){
    int i;
    //入力
    cin>>x>>y;
    //処理
    int ans=solve();
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


Measured memory_bytes: 2100
n = int(input())
a = list(map(int, input().split()))

max_a = -float("inf")
max_index = 0 
min_a = float("inf")
min_index = 0
ans_li = []
for i in range(n):
    if a[i] >= max_a:
        max_a = a[i]
        max_index = i
    if a[i] <= min_a:
        min_a = a[i]
        min_index = i


if max_a == min_a:
    print(0)
elif 0 <= min_a:
    print(n-1)
    for i in range(n-1):
        print(i+1, i+2)
elif max_a <= 0:
    print(n-1)
    for i in range(n-1)[::-1]:
        print(i+2, i+1)
elif abs(min_a) <= abs(max_a):
    print(2*n-1)
    for i in range(n):
        print(max_index+1, i+1)
    for i in range(n-1):
        print(i+1, i+2)
elif abs(max_a) <= abs(min_a):
    print(2*n-1)
    for i in range(n):
        print(min_index+1, i+1)
    for i in range(n-1)[::-1]:
        print(i+2, i+1)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    vector<string> s;
    int n;
    cin >> n;
    REP(i, n)
    {
        string t;
        cin >> t;
        sort(t.begin(), t.end());
        s.push_back(t);
    }

    sort(s.begin(), s.end());

    /* 
    REP(i, n)
    {
        cout << s[i] << endl;
    }
*/

    long long ans = 0;
    int cnt = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i] == s[i - 1])
        {
            cnt++;
        }
        else
        {
            ans += (long long)cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    if (cnt > 1)
    {
        ans += (long long)cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5748
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint cal(lint n,lint b,lint k){
	if(k==0LL) return n;
	lint ret=(n/b)*(b-k);
	if(n%b>=k) ret+=n%b-k+1;
	return ret;
}
int main()
{
	int n,k;lint out=0;cin>>n>>k;
	REP(i,k+1,n+1){
		out+=cal(n,i,k);
		//cout<<i<<' '<<cal(n,i,k)<<endl;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
map<ll,ll> help;
ll a[55][55];
ll b[55][55];
int main(){
   ll x;
   cin>>x;
   if(x>=30)cout<<"Yes";
   else cout<<"No";
}
	
 
    

Measured memory_bytes: 3632
h,w = map(int,input().split())

al = []

MOD = 10**9 + 7
for _ in range(h):
   a = list(input())
   al.append(a)

dp = [[0 for i in range(w)] for j in range(h)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i+1 < h and al[i+1][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j+1 < w and al[i][j+1] == ".":
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD
            
print(dp[-1][-1])

Measured memory_bytes: 91228
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  int count=0;
  for(int i=0;i<10000000;i++){
    
    if(a==4||a==2||a==1){
      break;
    }
    
    else if(a%2==0){
      a=a/2;
        count++;
    }
    else if(a%2!=0){
      a=a*3+1;
        count++;
    }
    
  }
  cout<<count+4<<endl;
}
    


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

l = {}
for a in A:
	k = a // 400
	k = min(k, 8)
	if k not in l:
		l[k] = 1
	else:
		l[k] += 1
#print(l)
if 8 in l:
	print(max(1, len(l) - 1), max(1, len(l) - 1 + l[8]))
else:
	print(len(l), len(l))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main(){
		string x;
		cin >> x;
		int s = 0;
		int ans = x.size();
 
		for(int i=0;i<x.size();i++) {
				if(x[i]=='S') s++;
				if(x[i]=='T') {
						if(s>0){
								ans -= 2;
								s--;
						}
				}
		}
 
		cout << ans << endl;
}

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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  bool ans = true;
  for (i64 i = 0; i < n; i++)
    if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0)
      ans = false;
  if (ans)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		int[] yn = new int[N+1];
		for(int i = 1; i <= N; i++)
			for(int k = 1; k <= N / i; k++)
				yn[i*k]++;
		for(int i = 1; i <= N; i++)
			ans += (long)i * yn[i];
		System.out.println(ans);
	}

}

Measured memory_bytes: 75460