akhauriyash/Code-Regression huggingface dataset:
s = str(input())
if s[0] != "A":
    print("WA")
    exit()
cou = 0
for i in range(1,len(s)):
    num = ord(s[i])-ord("a")
    if 0 <= num and num <= 25:
        continue
    else:
        if s[i] == "C":
            if i == 1 or i == len(s)-1:
                print("WA")
                exit()
            else:
                cou += 1
        else:
            print("WA")
            exit()
if cou == 1:
    print("AC")
else:
    print("WA")

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, M;
    cin >> N >> M;
    int A = 0;
    REP(i, M) {
        int a;
        cin >> a;
        A += a;
    }
    N -= A;
    if(N < 0) { N = -1; }
    printf("%lld\n", N);

    return 0;
}


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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << P + Q + R - max(P, max(Q, R)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define se second
#define sz(x) (int)(x.size())
#define ll long long
#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define ull unsigned ll
 
#define pi 3.14159265358979
 
 
using namespace std;
 
const int N = (int)(1e6) + 322;
const ll INF = 2e18 + 17;
const int inf = 2e9;
const int mod = 1000000007;
const double eps = 1e-9;
 
int gcd(int a, int b) { return b ? gcd (b, a % b) : a; }
 
int nbr_bits(int a){
    return log2(a)+1;
}
 
 
ll fastpow(int a, int n, int mod) {
    if(n==0)
        return 1;
    if(n%2==0){
        ll res = fastpow(a,n/2,mod);
        res*=res;
        res%=mod;
        return res;
    }
    ll res = (fastpow(a,n-1,mod)*a)%mod;
    return res;
    
}
 
// ----------------------------------------------------

map<int,pair<string,int> > occ;
int n,t;
map<string, int> infos;

bool comp(int a, int b){
    if(occ[a].first==occ[b].first) return occ[a].second > occ[b].second ;
    return occ[a].first < occ[b].first;
}
 
 
int main()
{
     ios_base::sync_with_stdio(false);
     cin >> t ;
     while(t--){
	    
	    string s;
	    cin >> s;
	    infos[s]++;
	    
	  } 
	  
	  cout << "AC x " << infos["AC"] << endl; 
	  cout << "WA x " << infos["WA"] << endl; 
	  cout << "TLE x " << infos["TLE"] << endl; 
	  cout << "RE x " << infos["RE"] << endl; 
	  
     return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fa(i, a, b) for (auto (i) = (a); (i) < (b); ++(i))
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b,c,d;
   string s;

   cin>>a>>b>>c>>d;
   while(true){
    if(0<c-b){
        c-=b;
    }
    else{
      cout<<"Yes";
      break;
    }
    if(0<a-d){
        a-=d;
    }
    else{

        cout<<"No"<<endl;
        break;
    }

   }


   return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    map<int,int> A;
    ll sum = 0;
    rep(i,N) {
        int a; cin >> a;
        A[a]++;
        sum += a;
    }
    int Q; cin >> Q;
    rep(i, Q) {
        int b, c; cin >> b >> c;
        if (A.count(b) == 0) {
            cout << sum << endl;
            continue;
        }
        A[c] += A[b];
        sum += (c-b) * A[b];
        A.erase(b);
        cout << sum << endl;
    }
}


Measured memory_bytes: 6536
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[210000],b[210000];
int main() {
	cin >> n;
	cin >> str;
	rep(i, n)if (str[i] == 'R')ans++;
	if (n - ans < ans) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N);
        for(auto& t : A) cin >> t;
        long long res = 0;
        vector<int> visit(N, 0);
        for(int back=1;back<=N-2;back++){
            int a = N-1;
            int b = 0;
            int idx=1;
            long long cur = 0;
            while(true){
                a -= back;
                if(a <= back) break;
                if(a <= 0 || visit[a]) break;
                visit[a] = 1;
                b += back;
                if(b >= N-1 || visit[b]) break;
                visit[b] = 1;
                cur += A[a] + A[b];
                res = max(cur, res);
                ++idx;
            }
            a = N-1; b = 0;
            for(int i=0;i<idx;i++){
                a -= back; b += back;
                if(a >= 0) visit[a] = 0;
                if(b < N) visit[b] = 0;
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int m,d,r;
int main()
{
	cin >> m >> d;
	for (int i = 1;i <= m;i++)
	    for (int j = 1;j <= d;j++)
	    {
	    	int s = j / 10,g = j % 10;
	    	if (s > 1 && g > 1 && i == s * g) r++;
	    }
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    char table[256] = {};
    table['A'] = 'T';
    table['T'] = 'A';
    table['C'] = 'G';
    table['G'] = 'C';
    char b[2] = {};
    cin >> b[0];
    b[0] = table[b[0]];
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
int main ()
{
	int K=1-100,X=1-100000;
	scanf("%d", &K);
	scanf("%d", &X);
	
	if(K*500>=X){
		printf("Yes");
	}else if(K*500<=X){
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 3092
import math
from functools import reduce

"""[summary]
全体：10^N
0が含まれない：9^N
9が含まれない：9^N
0,9の両方が含まれない：8^N
0,9のどちらか一方が含まれない：9^N + 9^N - 8^N
"""

N = int(input())
mod = (10 ** 9) + 7

calc = (10**N - 9**N - 9**N + 8**N) % mod

print(calc)

Measured memory_bytes: 11400
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int32_t main()
{
	IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
		int a,b,c,k;
		cin>>a>>b>>c>>k;
		int ans=0;
		if(k>=a)
		{
			ans+=a;
			k-=a;
		}
		else
		{
			cout<<k;
			return 0;
		}
		if(k>=b)
		{
			k-=b;
		}
		else
		{
			cout<<ans;
			return 0;
		}
		if(k>=c)
		{
			ans-=c;
		}
		else
		{
			ans-=k;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

struct p {
  int a;
  int b;
  int c;
  int r;
};

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

    int n;
    cin >> n;

    vector<int> f(a + b + c, 2);

    vector<p> po;
    for (int i = 0; i < n; i++){
      p uyu;
      cin >> uyu.a >> uyu.b >> uyu.c >> uyu.r;
      uyu.a--; uyu.b--; uyu.c--;
      if (uyu.r == 1) {
        f[uyu.a] = 1;
        f[uyu.b] = 1;
        f[uyu.c] = 1;
      } else {
        po.push_back(uyu);
      }
    }

    for (auto &i : po) {
      int s = i.a, d = i.b, g = i.c;
      if (f[s] == 1 && f[d] == 1 && f[g] != 1){
        f[g] = 0;
      }
      if (f[d] == 1 && f[g] == 1 && f[s] != 1){
        f[s] = 0;
      }if (f[g] == 1 && f[s] == 1 && f[d] != 1){
        f[d] = 0;
      }
    }

    for (int i = 0; i < a + b + c; i++){
      cout << f[i] << endl;
    }

  }
}

Measured memory_bytes: 2992
#include<bits/stdc++.h>
//#define endl "\n"
using namespace std;

vector< long long > tab, t, primes;
map< long long, long long > mapka, q, pary;

long long ans, ile, x, i, n, y, jedynki;
bool z[100010];

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n;
	ans = n;
	for( int a = 2; a*a <= 2500; a++ )
	{
		if( !z[a] )for( int b = a + a; b <= 2500; b += a )z[b] = 1;	
	}
	for( long long a = 2; a <= 2500; a++ )
	{
		if( !z[a] )
		{
			t.push_back( a*a*a );
			primes.push_back( a );
		}
	}
//	for( int a = 0; a <= 5; a++ )cout<<t[a]<<" ";
//	cout<<endl;
	for( int a = 1; a <= n; a++ )
	{
		cin>>x;
		for( int b = 0; b < t.size(); b++ )
		{
			while( x%t[b] == 0 )x /= t[b];		
		}
		tab.push_back( x );
	}
	for( int a = 0; a < tab.size(); a++ )mapka[ tab[a] ]++;
	sort( tab.begin(), tab.end() );
//	for( int a = 0; a < tab.size(); a++ )cout<<tab[a]<<" ";
//	cout<<endl;
//	reverse( tab.begin(), tab.end() );
//	cout<<"ok"<<endl;
	for( int a = 0; a < tab.size(); a++ )
	{
		y = 1;
		x = tab[a];
		q[ tab[a] ]++;
		for( int b = 0; b < primes.size(); b++ )
		{
			i = 0;
			while( x%primes[b] == 0 )
			{
				x /= primes[b];
				i++;
			}
			if( i == 1 )
			{
				y *= primes[b];
				y *= primes[b];
			}
			else if( i == 2 )
			{
				y *= primes[b];	
			}
		}
		if( x <= 1000000000 )
		{
			x *= x;
			for( int b = 0; b < t.size(); b++ )
			{
				while( x%t[b] == 0 )x /= t[b];		
			}
			x *= y;
//			cout<<tab[a]<<" "<<x<<endl;
			if( x > tab[a] )
			{
				if( mapka[x] )pary[tab[a]] = mapka[x];	
			}
			if( x == 1 )
			{
				jedynki++;	
			}
			
		}
		mapka[ tab[a] ]--;
	}
	for( map<long long,long long>::iterator it = pary.begin(); it != pary.end(); it++ )
	{
//		cout<<it->first<<" "<<q[it->first]<<"  "<<it->second<<endl;
		ans -= min( q[it->first], it->second );	
	}
	if( jedynki )ans -= ( jedynki - 1 );
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 17780
import itertools

N = int(input())
v = list(map(int,input().split()))
ret = 0

v.sort(reverse=True)

shadow = v[:]

for i in range(N-1):

  a = shadow.pop()
  b = shadow.pop()

  shadow.append((a+b)/2)
ret = max(ret,shadow[0])

print(ret)


Measured memory_bytes: 3060
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


ll dfs(vector<set<ll>>& rs, vector<bool>& flgs, ll i) {
    ll result = 1;
    feach(it, rs[i]) {
        if (flgs[*it]) {
            continue;
        }
        flgs[*it] = true;
        result += dfs(rs, flgs, *it);
    }
    return result;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<set<ll>> rs(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b; --a; --b;
        rs[a].insert(b);
        rs[b].insert(a);
    }
    vector<bool> flg(n, false);
    ll result = -1;
    rep(i, n) {
        if (flg[i]) {
            continue;
        }
        flg[i] = true;
        emax(result, dfs(rs, flg, i));
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 35384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  
  string S ;
  cin >> S ;
  int N = S.size() ;
  int counter = 0 ;
  int ans = 0 ;
  rep(i,N){
    if(S[i] == 'A'|| S[i] == 'C'|| S[i] == 'G'|| S[i] == 'T'  )counter++ ;
    else {
    ans = max( ans , counter ) ;
    counter = 0 ;
    }
  }
  ans = max( ans , counter ) ;
  cout << ans << endl; 
}


Measured memory_bytes: 256
def main():
    n = int(input())
    ans = ''
    
    for i in range(1, 99):
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans += chr(ord('a') + n % 26)
                n //= 26
            break
        else:
            n -= 26 ** i
    
    print(ans[::-1])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

a, b = mi()

n = a * (10**(len(str(b)))) + b

for i in range(1000):
    if i**2 == n:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<numeric>
#include<stdio.h>

using std::cout;
using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

#define INF 999999999;
#define MOD 1000000007

using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, S;
int saiki(int n, int last, int sum){
    int rt=0;
    if(n == 1){
        if(sum == S) rt = 1;
    }else{
        for(int i = last+1; i < 10; i++){
            rt += saiki(n-1, i, sum+i);
        }
    }
    return rt;
}

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
    
    while(1){
        cin >> N >> S;
        if(N == 0 && S == 0) break;
        cout << saiki(N+1, -1, 0) << "\n";
    }
}


Measured memory_bytes: 3152
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(X):
    if i in A:
        ans1+=1

for j in range(X,N+1):
    if j in A:
        ans2+=1

if ans1<ans2:
    print(ans1)
else:
    print(ans2)

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

vector<int> g[2020];
int dist[2020];
int root[2020];

void dfs(int curr, int prev) {
	for (int next : g[curr]) if (next != prev) {
		dist[next] = dist[curr] + 1;
		root[next] = root[curr];
		dfs(next, curr);
	}
}

int main() {
	int n, K;
	cin >> n >> K;

	for (int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	int ans = INT_MAX;
	for (int i = 0; i < n; i++) {
		dist[i] = 0;

		for (int j : g[i]) {
			root[j] = j;
			dist[j] = 1;
			dfs(j, i);
		}

		int cnt = 0;
		map<int, int> mp;
		for (int j = 0; j < n; j++) {
			if (K % 2 == 0) {
				if (dist[j] > K / 2) {
					cnt++;
				}
			} else {
				if (dist[j] > (K + 1) / 2) {
					cnt++;
				} else if (dist[j] == (K + 1) / 2) {
					mp[root[j]]++;
				}
			}
		}
		int mx = 0;
		int sum = 0;
		for (auto kv : mp) {
			sum += kv.second;
			mx = max(mx, kv.second);
		}
		sum -= mx;
		ans = min(ans, sum + cnt);
	}
	cout << ans << endl; 
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <vector>
typedef long long unsigned int ll;
using namespace std;

int main() {
    int x;
    cin>>x;
    int t;
    for(int i=0;i<=x;i++){
        if(i*(i+1)/2>=x&&(i-1)*i/2<x){
            t=i;
            break;
        }
    }
    cout<<t<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};
 


int v[200007];
int main()
{
	int n; cin>> n;
	int last = 0, cont=0;
	for(int i = 1; i <= n; i++){
		cin>>v[i];
		if(v[i] == last+1){
			last = v[i];
			cont++;
		}
	}
	if(cont == 0)
		cout<<-1;
	else
		cout<<n - cont;
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<climits>

int main(){
	int n;
	int ans= INT_MAX;
	std::string s;

	std::cin>>n;
	std::cin>>s;

	int lw= 0;
	int re= 0;

	for(int i=0; i<n; i++)
		if(s[i]=='E')
			re++;

	for(int i=0; i<n; i++){
		if(s[i]=='W')
			ans= std::min(ans, (re+lw)), lw++;
		
		if(s[i]=='E')
			re--, ans= std::min(ans, (re+lw));
	}


	std::cout<<ans<<std::endl;

	return 0;
	
}

Measured memory_bytes: 900
a=[]
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
k=int(input())
a=sorted(a)
if k >= a[4]-a[0]:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define codefor int test;cin>>test;while(test--)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

int main(){
    vector<string> result={"AC","WA","TLE","RE"};
    int n;
    cin>>n;
    string s;
    vector<int> vec(4,0);
    rep(i,n){
        cin>>s;
        rep(j,4){
            if(s==result[j]){
                vec[j]++;
                break;
            }
        }
    }
    rep(i,4){
        cout<<result[i]<<" x "<<vec[i]<<endl;
    }
}

Measured memory_bytes: 3624
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

bool able[10];
const int use[10] = { 0, 2,5,5,4,5,6,3,7,6};
std::pair<int32_t, std::string> dp[11000];
const std::pair<int32_t, std::string>& func(int i)
{
	if (i == 0) {
		dp[i].first = 0;
		return dp[i];
	}
	if (dp[i].first != -1) {
		return dp[i];
	}

	char add = '0';
	for (size_t n = 1; n < 10; n++)
	{
		if (able[n] && i >= use[n])
		{
			const auto& next = func(i - use[n]);
			if (next.first < 0) { continue; }
			if (dp[i].first <= next.first) {
				dp[i] = next;
				add = '0' + n;
			}
		}
	}
	if (add != '0') {
		dp[i].first += 1;
		dp[i].second = add + dp[i].second;
	}
	return dp[i];
}


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
int main()
{
	fill_all(dp, std::pair<int32_t, std::string>{-1, ""});

	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int32_t N, M;
	in >> N>>M;
	for (size_t i = 0; i < M; i++)
	{
		int v;
		in >> v;
		able[v] = true;
	}
	out << func(N).second << endl;

	return 0;
}
#endif


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

int main(){
    int count=0;
    string s;
    string h="CODEFESTIVAL2016";
    cin>>s;
    for (int i=0; i<=15; i++) {
        if(s.at(i)!=h.at(i)){
            count++;
        }
    }
    cout<<count<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#define RANGE_1(e) (boost::irange(0,(e)))
#define RANGE_2(s,e) (boost::irange((s),(e)))
#define RANGE_3(s,e,step) (boost::irange((s),(e),(step)))
#define RANGE_SELECTER(_1,_2,_3,SELECT,...) SELECT
#define range(...) RANGE_SELECTER(__VA_ARGS__, RANGE_3, RANGE_2, RANGE_1) (__VA_ARGS__)
#define guard(x) if(x);
#define CINS(x) for(auto&& __E__:(x))cin>>__E__
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define CALL(x) (x).cbegin(),(x).cend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define BIT(n) (1LL<<(n))
#define MOD 1000000007

using namespace std;
using lint = long long;

// template<class T>class irange{private:struct I{T x;T operator*(){return x;}bool operator!=(I&lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;public:irange(T i,T n):i({i}),n({n}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>class srange{private:struct I{T x,s;T operator*(){return x;}bool operator!=(I&lhs){if(s<(T)0)return x>lhs.x;return x<lhs.x;}void operator++(){x=x+s;}};I i,n;public:srange(T i,T n,T s):i({i,s}),n({n,s}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>irange<T>range(T n){return irange(0,n);}template<class T>irange<T>range(T i,T n){return irange(i,n);}template<class T>srange<T>range(T i,T n,T s){return srange(i,n,s);}
template<class T>bool amax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool amin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

struct initialize{initialize(){cin.tie(nullptr);ios::sync_with_stdio(false);};}__ini__;

int main() {
    int x; // 各々チェックするだけでいいので vector に入れるまでもない
    for (auto&& i : range(4)) {
        cin >> x;
        guard (x != 0) else {
            cout << i + 1 << endl; // 0が見つかったならその時点で終了できる
            return 0;
        }
    }
    
    cout << 5 << endl; // 必ずひとつは置き換えられているので最初の 4 個になければ最後で確定できる
}


Measured memory_bytes: 3596
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

static size_t merge(int64_t left[], size_t size_left, int64_t right[], size_t size_right)
{
  size_t len = size_left + size_right;
  int64_t *buf = (int64_t *)malloc(sizeof(int64_t) * len);

  size_t count = 0;
  size_t left_count = 0;
  size_t right_count = 0;

  uint32_t i;
  for (i = 0; i < len; i++) {
    if ((left_count < size_left) && (right_count < size_right)) {
      if (left[left_count] < right[right_count]) {
        buf[i] = left[left_count];
        left_count++;
      } else {
        buf[i] = right[right_count];
        right_count++;
      }
      
    } else if (left_count < size_left) {
      buf[i] = left[left_count];
      left_count++;
    } else {
      buf[i] = right[right_count];
      right_count++;
    }
count++;
  }

  memcpy(left, buf, sizeof(int64_t) * len);
  free(buf);
  return count;
}

size_t merge_sort(int64_t data[], size_t len)
{
  if (data == NULL) return 0;

  if (len <= 1) {
    return 0;
  } else {
    size_t half = len / 2;
    size_t left = merge_sort(data, half);
    size_t right = merge_sort(&data[half], len - half);
    size_t num = merge(data, half, &data[half], len - half);
    return left + right + num;
  }
}

#if !defined(TEST)
#include <stdio.h>
static int64_t data[524288];

int32_t main(void)
{
  size_t len;
  scanf("%lu", &len);
  uint32_t i;
  for (i = 0; i < len; i++) {
    scanf("%ld", &data[i]);
  }

  size_t num = merge_sort(data, len);
  for (i = 0; i < len; i++) {
    if (i != 0) printf(" ");
    printf("%ld", data[i]);
  }
  printf("\n");

  printf("%lu\n", num);
  return 0;
}
#endif

Measured memory_bytes: 10324
import math
from functools import reduce
k = int(input())

def gcd(*numbers):
    return reduce(math.gcd,numbers)

ans = 0

for a in range(1,k+1):
    ans +=gcd(a,a,a)

for a in range(1,k+1):
    for b in range(1,k+1):
        if a!=b:
            ans += 3*gcd(a,a,b)

for a in range(1,k-1):
    for b in range(a+1,k):
        for c in range(b+1,k+1):
            #if a!=b and a!=c and b!=c:
            ans +=6*gcd(a,b,c)


print(ans)

Measured memory_bytes: 9564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題
{
    class Program
    {
        static void Main(string[] args)
        {
            //問題121-a
            //入力を受け取る
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            int c = Convert.ToInt32(input2[0]);
            int d = Convert.ToInt32(input2[1]);
            
            Console.WriteLine((a-c)*(b-d));
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

bool isBlack[100][100];

int main()
{
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            isBlack[i][j] = (i < 50);
        }
    }

    int a, b;
    cin >> a >> b;
    a--;
    b--;

    for (int i = 0; i < a; i++)
    {
        int x = i / 50;
        int y = i % 50;
        isBlack[2 * x][2 * y] = false;
    }

    for (int i = 0; i < b; i++)
    {
        int x = i / 50;
        int y = i % 50;
        isBlack[2 * x + 51][2 * y] = true;
    }

    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            cout << (isBlack[i][j] ? '#' : '.');
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def pgcd(m,n): 
    while m%n: 
        r=m%n 
        m=n 
        n=r 
    return n 
 
def ppcm(m,n): 
    return m*n//pgcd(m,n)

a,b=map(int,input().split())
print(ppcm(a,b))

Measured memory_bytes: 2940
def main():
    N = int(input())
    str_dict = dict()
    for n in range(N):
        s = input()
        if s in str_dict:
            str_dict[s] += 1
        else:
            str_dict[s] = 1
    max_s = max(str_dict.values())
    result_list = list()
    for a, b in str_dict.items():
        if b == max_s:
            result_list.append(a)
    result_list.sort()
    for r in result_list:
        print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32096
N,u,v=map(int, input().split())
import sys
sys.setrecursionlimit(10**6)
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int, input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)


def dfs(start):
    tolist=T[start]
    nowd=done[start]
    for next_n in tolist:
        if done[next_n]==-1:
            done[next_n]=nowd+1
            dfs(next_n)

done=[-1]*N
done[u-1]=0
dfs(u-1)
dtaka=done.copy()
done=[-1]*N
done[v-1]=0
dfs(v-1)
dao=done.copy()
ans=0
for i in range(N):
    t=dtaka[i]
    a=dao[i]
    if a>t:
        ans=max(ans, a)
print(ans-1)


Measured memory_bytes: 102420
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, ans = 0;
	std::cin >> n;

	vector<vll> x(10, vll(10, 0));

	ll nod = 1;
	repeq(i, 1, n) {
		if (i == nod * 10) {
			nod *= 10;
		}

		x[i / nod][i % 10]++;
	}

	nod = 1;
	repeq(i, 1, n) {
		if (i == nod * 10) {
			nod *= 10;
		}

		ans += x[i % 10][i / nod];
	}

	outn(ans);
	return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

struct Edge {
    long long from;
    long long to;
    long long cost;
};
vi reach, seen;
vii adj;

void dfs(int v){
    seen[v]=true;
    for(auto nv: adj[v]){
        if(seen[nv]) continue;
        dfs(nv);
    }
    return;
}

bool bellman_ford(const vector<Edge> &Es, int V, int s, vector<long long> &dis) {
    dis.resize(V, LINF);
    dis[s] = 0;
    int cnt = 0;
    while (cnt < V) {
        bool end = true;
        for (auto e : Es) {
            if(!reach[e.to]) continue;
            if (dis[e.from] != LINF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
                end = false;
            }
        }
        if (end) break;
        cnt++;
    }
    return cnt==V;
}


int main(){
    int n, m, p;
    cin >> n >> m >> p;
    vector<Edge> Es(m);
    adj.assign(n, vi(0));
    for(int i=0; i<m; i++){
        cin >> Es[i].from >> Es[i].to >> Es[i].cost;
        Es[i].from--, Es[i].to--;
        Es[i].cost=-Es[i].cost+p;
        adj[Es[i].from].push_back(Es[i].to);
    }
    reach.assign(n, 0);
    for(int i=0; i<n; i++){
        seen.assign(n, 0);
        dfs(i);
        reach[i]=seen[n-1];
    }
    vector<ll> dis;
    ll ans;
    if(bellman_ford(Es, n, 0, dis)) ans=-1;
    else ans=max(0LL, -dis[n-1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll x;
  cin >> x;
  if(x % 2 == 1){
    x = x / 2 + 1;
  }else{
    x /= 2;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	k, _ := strconv.Atoi(input())

	prices := make([]int, n)
	for i := 0; i < n; i++ {
		p, _ := strconv.Atoi(input())
		prices[i] = p
	}

	sort.Ints(prices)

	min := 0
	for i := 0; i < k; i++ {
		min += prices[i]
	}

	fmt.Println(min)
}


Measured memory_bytes: 1780
#include <functional> 
#include <iostream> 
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
pair<ll, ll>,
null_type,
less<pair<ll, ll>>,
rb_tree_tag,
tree_order_statistics_node_update> ost;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
    ll n;
    cin>>n;
    
    ll a[n];
    ll res=0;
    map<pii,ll>mp;
    for(ll i=0;i<n;i++){
        
        string s;
        cin>>s;
        ll cnt=0;
        ll sm=0;
        ll flag=0;
        
        for(ll j=0;j<s.size();j++){
            if(s[j]=='.')
            {flag=1;
            continue;
            }
            
            if(flag)
            cnt++;
            
            ll x=(ll)(s[j]-'0');
            
            sm*=10;
            sm+=x;
        }
        
        ll p,q;
        p=sm;
         q=1;
         
         for(ll kk=0;kk<cnt;kk++)
         q*=10;
        
        ll p_2=0;
        ll p_5=0;
        
        ll q_2=0;
        ll q_5=0;
        
        while(p%2==0){
            p_2++;
            p/=2;
        }
        
        while(p%5==0){
            p_5++;
            p/=5;
        }
        
       while(q%2==0){
            q_2++;
            q/=2;
        }
        
        while(q%5==0){
            q_5++;
            q/=5;
        }
        
        ll del2=q_2-p_2;
        ll del5=q_5-p_5;
        
        ll ans=0;
        
        for(ll j=del2;j<=30;j++){
            for(ll h=del5;h<=9;h++){
                ans+=mp[{j,h}];
            }
        }
        
        res+=ans;
        mp[{p_2-q_2,p_5-q_5}]++;

    }
    
    cout<<res<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

ll gcd(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll K;
	cin >> K;

	vvll all_gcs(K + 1);
	for (int j = 0; j <= K; j++)
	{
		all_gcs[0].emplace_back(-1);
	}
	for (int i = 1; i < K + 1; i++)
	{
		all_gcs[i].emplace_back(-1);
		for (int j = 1; j < K + 1; j++)
		{
			all_gcs[i].emplace_back(-1);
			ll g = gcd(i, j);
			
			all_gcs[i][j] = g;

		}
	}



	ll ans = 0;
	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			for (int k = 1; k <= K; k++)
			{
				int left = i;
				int right = all_gcs[j][k];

				ans += all_gcs[left][right];


			}
		}
	}



	cout << ans;


}





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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int m=b-a;
  int n=c-b;
  if(m==n){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  
  COMinit();
  
  int N, M;
  cin >> N >> M;
  vector<int> Q;
  
  int p = 2;
  int m = M;
  while (p * p <= M) {
    if (m % p == 0) {
      int q = 0;
      while (m % p == 0) {
        m /= p;
        q++;
      }
      Q.push_back(q);
    } else {
      p++;
    }
  }
  if (m != 1) {Q.push_back(1);}
  
  ll ans = 1;
  for (ll i = 0; i < Q.size(); i++) {
    ans = ans * COM(N-1+Q.at(i), N-1) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12288
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b;
    int c;
    cin>>a>>b;
     c=a*b;
    if(1<=a,b<=3)

    {

      if(c%2==1 )
      {
          cout<<"Yes";
      }
      else
      {
          cout<<"No";
      }
    }


    return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int, input().split())
import fractions

A -= 1
tmp1 = A - A//C - A//D + A//((C*D)//fractions.gcd(C,D))
tmp2 = B - B//C - B//D + B//((C*D)//fractions.gcd(C,D))
answer = tmp2-tmp1

print(answer)

Measured memory_bytes: 5432
#include <iostream>

int
main(int argc, char** argv) {
    int N;
    std::cin >> N;

    int H1;
    std::cin >> H1;
    int maxH = H1;
    int ans = 1;
    for (int i = 1; i < N; i++) {
       int H;
       std::cin >> H;
       if (maxH <= H) ans++;
       maxH = std::max(maxH, H);
    }

    std::printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.I;
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<t;i++) {
			var n=sc.I;
			var a=sc.La;
			var s=sc.S;
			var bo=true;
			var gj=new Gj();
			for(int j = n-1;j>=0;j--) {
				if(s[j]=='0'){gj.Add(a[j]);}
				else if(!(bo=gj.Ck(a[j]))){
					sb.Append("1\n");
					break;
				}
			}
			if(bo){sb.Append("0\n");}
		}
		Console.Write(sb);
	}
}
public class Gj{
	public List<long> li=new List<long>();
	public int cnt=0;
	public void Add(long v){
		int c=cnt;
		for(int j = 0;j<cnt;j++) {
			v=Min(v,li[j]^v);
			if(v>li[j]&&c==cnt){c=j;}
		}
		if(v!=0){
			li.Add(v);
			for(int j = cnt-1;j>=0;j--) {
				li[j]=Min(li[j],v^li[j]);
				if(j>=c){
					li[j+1]=li[j];
					if(j==c){li[c]=v;}
				}
			}
			cnt++;
		}
	}
	public long this[int i]{get{return li[i];}}
	public bool Ck(long v){
		for(int i = 0;i<cnt;i++) {v=Min(v,li[i]^v);}
		return v==0;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main(){

    int N,K;
    string S;

    cin >> N >> K;


    for(int i=0;i<N;i++){
        cin >> S[i];
    }

    char temp;
    temp = S[K-1];
 
    if ((temp >= 'A') && (temp <= 'Z')) { 
        temp = (temp + 0x20);
    }
    else if((temp >= 'a') && (temp <= 'z')) { 
        temp = (temp - 0x20);
    }

    S[K-1] = temp;

    for(int i=0;i<N;i++){
        cout << S[i];
    }


    return 0;
}

Measured memory_bytes: 256