akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

vector<int> vec;

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

int main(void) {
	long long a;
	long long b;

	vector<long long> vec;

	long long max = 0;
	long long nextmax = 0;
	long long maxcount = 0;
	long long maxindex = 0;

	long long ans = 0;


	cin >> a;


	for (int i = 0; i < a; i++) {
		cin >> b;
		if (max < b) {
			nextmax = max;
			max = b;
			maxindex = i;
			maxcount = 1;
					}
		else if (max == b) {
			maxcount++;
		}else if (nextmax < b) {
			nextmax = b;
		}

	}

	for (int i = 0; i < a; i++) {
		if (maxcount >= 2) {
			cout << max << endl;
		}
		else{
			if (i == maxindex) {
				cout << nextmax << endl;
			}
			else {
				cout << max << endl;
			}
		}
	}




}




Measured memory_bytes: 1664
ans = "No"
c = []
for i in range(3):
    t = list(map(int, input().split()))
    c.append(t)

n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(3):
    x = []
    for j in range(3):
        x.append(c[j][i])
    else:
        c.append(x)


for i in range(1):
    x = []
    for j in range(3):
        x.append(c[j][j])
    else:
        c.append(x)

for i in range(1):
    x = []
    for j in range(3):
        x.append(c[j][2-j])
    else:
        c.append(x)

for i in range(8):
    for j in range(3):
        if c[i][j] not in b:
            break
    else:
        ans = "Yes"
        break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair
#define int long long

using namespace std;

int x[4] = { -1, 1, 0, 0};
int y[4] = { 0, 0, -1, 1};

int h, w;

bool valid(int x, int y)
{
	return (x < h && y < w && x >= 0 && y >= 0);
}

std::vector<string> v;
std::vector<std::vector<bool> > vis;

void add(pair<int, int>& p1, pair<int, int> p2)
{
	p1.first += p2.first;
	p1.second += p2.second;
}

pair<int, int> dfs(int I, int J)
{
	vis[I][J] = true;
	pair<int, int> p = {v[I][J] == '#', v[I][J] == '.'};
	for (int i = 0; i < 4; ++i)
	{
		int j = i;
		if (valid(I + x[i], J + y[j]) && (!vis[I + x[i]][J + y[j]]) && (v[I + x[i]][J + y[j]] != v[I][J]))
			add(p, dfs(I + x[i], J + y[j]));
	}
	return p;
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	cin >> h;
	cin >> w;
	v.resize(h);
	for (int i = 0; i < h; ++i)
		cin >> v[i];
	vis.resize(h, std::vector<bool> (w, false));
	int ans = 0;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (!vis[i][j]) {
				auto va = dfs(i, j);
				ans += (va.first * (va.second));
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 12928
def rotate90 array
  length = array.size
  rotated = Array.new(length).map{Array.new(length)}
  for y in 0...length
    for x in 0...length
      rotated[x][length - 1 - y] = array[y][x]
    end
  end
  rotated
end

pattern = Array.new
8.times do
  pattern << $stdin.gets.chomp.split("")
end

printf "%d\n", 90
rotate90(pattern).each do |r|
  printf "%s\n", r.join()
end

printf "%d\n", 180
rotate90(rotate90(pattern)).each do |r|
printf "%s\n", r.join()
end

printf "%d\n", 270
rotate90(rotate90(rotate90(pattern))).each do |r|
printf "%s\n", r.join()
end

Measured memory_bytes: 6128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;
vector< int > Zalgorithm(string &S, int s) {
	vector< int > ret(S.size() - s, 0);
	for (int i = 1, j = 0; i < ret.size(); i++) {
		if (i + ret[i - j] < j + ret[j]) {
			ret[i] = ret[i - j];
		} else {
			int k = max(0LL, j + ret[j] - i);
			while (i + k < ret.size() && S[k + s] == S[i + k + s])
				++k;
			ret[i] = k;
			j = i;
		}
	}
	ret[0] = ret.size();
	return ret;
}
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	string S;
	cin >> S;
	vector< int > A;
	int ans = 0;
	rep(i, N) {
		A = Zalgorithm(S, i);
		for (int j = 0; j < A.size(); j++) {
			chmax(ans, min(A[j], j));
		}
		//cout << A;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
 
mod = 998244353  # type: int
 
 
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]  # 階乗を求めるためのキャッシュ
        self.invModulos = [0, 1]  # n^-1のキャッシュ
        self.invFactorial_ = [1, 1]  # (n^-1)!のキャッシュ
 
    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]
 
    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]
 
    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  # To make sure already calculated n^-1
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]
 
 
class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)
 
    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
 
 
def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m
n,m,k=map(int,input().split())
c=Combination(mod)
ans=0
for i in range(k+1):
    ans+=((powm(m-1,n-1-i,mod))*(c.ncr(n-1,i)%mod))%mod
    ans%=mod
m=m%mod
print((ans*m)%mod)

Measured memory_bytes: 87608
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,tp=0,hp=0,tl,hl,mijikai,gosa=0;
	char t[128],h[128];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s%s",t,h);
		tl=strlen(t);
		hl=strlen(h);
		mijikai=0;
		gosa=hl-tl;
		if(tl>hl){
			mijikai=1;
			gosa=tl-hl;
		}
		for(int k=0;k<gosa;k++){
			if(mijikai==0){
				strcat(t," ");
			}else{
				strcat(h," ");
			}
		}
		if(strcmp(t,h)>0){
			tp+=3;
		}else if(strcmp(t,h)==0){
			tp++;
			hp++;
		}else{
			hp+=3;
		}
	}
	printf("%d %d\n",tp,hp);
    return 0;
}

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

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

  int i = n % 10;

  string str;
  if(i == 3) str = "bon";
  else if(i == 1 || i == 0 || i == 6 || i == 8) str="pon";
  else str = "hon";

  cout << str << endl;
  
  return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		foreach (var t in tList)
		{
			if(sList.BinarySearch(t) > -1) count++;
		}
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

Measured memory_bytes: 15796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 準備
            int[] iAryA = new int[] { 1, 3, 5, 7, 8, 10, 12, };
            int[] iAryB = new int[] { 4, 6, 9, 11, };

            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int ix = int.Parse(sS[0]);
            int iy = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (ix == 2 || iy == 2) { sOut = "No"; }
            else if (iAryA.Contains(ix) && iAryA.Contains(iy)) { sOut = "Yes"; }
            else if (iAryB.Contains(ix) && iAryB.Contains(iy)) { sOut = "Yes"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int cardCount = int.Parse(Reader.ReadLine());

        long[] cards = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        long total = cards.Sum();

        long ans = Math.Abs(total - (cards[0]*2));
        long subTotal = cards[0];
        for (int i = 1; i < cards.Length - 1; i++) {
			subTotal += cards[i];
            ans = Math.Min(ans, Math.Abs(total - (subTotal*2)));
		}
        Console.WriteLine(ans);
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"




2
10 -10

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 34500
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string O, E;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> O >> E;

  int i = 0, j = 0;
  while (i < O.length() || j < E.length()) {
    if (O[i] != '\0') cout << O[i];
    if (E[i] != '\0') cout << E[j];
    if (i < O.length()) i++;
    if (j < E.length()) j++;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[105], b[105];

void Main() {
  int n; cin >> n;
  for(int i = 1; i < n; i++) cin >> b[i];
  b[0] = b[n] = INT_MAX;
  int ans = 0;
  for(int i = n; ~i; i--) {
    a[i] = min(b[i], b[i - 1]);
    ans += a[i];
  }
  cout << ans << "\n";
}



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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

class UnionFind
{
public:
  // parentの番号。親だった場合は-(その集合のサイズ)
  vector<int> parent;
  // parentはすべて-1にする。全てバラバラになる。
  UnionFind(int N) { parent = vector<int>(N, -1); }
  // Aがどのグループに属しているかを調べる
  int root(int A)
  {
    if (parent[A] < 0)
      return A;
    return (parent[A] = root(parent[A]));
  }
  // 自分のいるグループの頂点数を調べる
  int size(int A) { return -parent[root(A)]; }
  // AとBをくっつける
  int connect(int A, int B)
  {
    // AとBを直接つなぐのではなくroot(A)とroot(B)をくっつける
    A = root(A);
    B = root(B);
    if (A == B) {
      // すでにくっついている
      return false;
    }
    // 大きい方(A)を小さい方(B)にくっつけたい
    // 大小が逆だったらひっくり返す
    if (size(A) < size(B))
      swap(A, B);
    // Aのサイズを更新する
    parent[A] += parent[B];
    // Bの親をAに変更する
    parent[B] = A;
    return true;
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++) {
    int ia, ib;
    cin >> ia >> ib;
    ia--, ib--;
    a[i] = ia, b[i] = ib;
  }
  vector<ll> ans(M);
  ans[M - 1] = (ll)N * (N - 1) / 2;
  UnionFind uf(N);
  for (int i = M - 1; 1 <= i; i--) {
    if (uf.root(a[i]) != uf.root(b[i])) {
      ans[i - 1] = ans[i] - (ll)uf.size(a[i]) * uf.size(b[i]);
      uf.connect(a[i], b[i]);
    } else {
      ans[i - 1] = ans[i];
    }
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;

int n;
set<int> s;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; ++i)
  {
    int x;
    cin >> x;
    if (s.find(x) != s.end()) { cout << "NO"; return 0; }
   	s.insert(x);
  }
  cout << "YES";
}

Measured memory_bytes: 9600
import sys

n = int(input())
arr = map(int, input().split())

for a in arr:
    if a % 2 == 0:
        if a % 3 == 0:
            continue
        elif a % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
else:
    print('APPROVED')

Measured memory_bytes: 2940
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    long long  N,K;
    cin >> N >> K;
    cout << (K%2==0?(((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)):0)+(N/K)*(N/K)*(N/K) << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int l,r;
  int A;
  for(int i = 0; i < N ; i++){
    cin >> l >> r;
    A = A + r - l + 1;
  }
  cout << A << endl;
}

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

namespace ABC148A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            Console.WriteLine(6 - A - B);
        }
    }
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll N, K, ans=0;

	cin >> N >> K;

	for(ll k = K+1; k <= N; k++){
		ans += (N / k) * (k - K) + max<ll>(0, N % k - max<ll>(0, K-1));
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    double X;
    std::cin >> X;

    double A = 100.0;
    int ret = 0;
    while (A < X) {
        A = std::floor(A * 1.01);
        ++ret;
    }

    std::cout << ret << std::endl;            
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s; cin >> s;
    string s1 = s;
    int ans = 0;
    int size = s.size();
    reverse(s1.begin(),s1.end());
    if(s == s1) ans++;

    string a = s.substr(0,(size-1)/2);
    string a1 = a;
    reverse(a1.begin(),a1.end());
    if(a == a1) ans++;

    string b = s.substr((size+3)/2 - 1);
    string b1 = b;
    reverse(b1.begin(),b1.end());
    if(b == b1) ans++;

    if(ans == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#import"iostream"
#define F(i,n)for(int i=0;i<n;i++)
main(){int k,s,c=0,v;std::cin>>k>>s;k++;F(i,k)F(j,k){v=s-(i+j);if(v<=k-1&&0<=v)c++;}std::cout<<c;}

Measured memory_bytes: 256
/*
 *  Created on: 22-December-2019
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
#define INF 1000000005
 
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int a, b; cin>>a>>b;
    bool vis[4];
    memset(vis, false, sizeof(vis));
    vis[a] = true;
    vis[b] = true;
    fi(i,1,4)
    {
    	if(!vis[i])
    	{
    		cout<<i;
    	}
    }
    return 0;
}   

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
#print(a)
di = ""
count = 0
i = 0
while i != n - 1:
    if a[i] == a[i+1] and di == "":
        di = ""
    elif a[i] == a[i+1]:
        di = di #そのまま

    if a[i] < a[i+1] and di == "":
        di = "増加"
    if a[i] > a[i+1] and di == "":
        di = "減少"

    if di == "増加" and a[i] > a[i+1]:
        count += 1
        di = ""
    if di == "減少" and a[i] < a[i+1]:
        count += 1
        di = ""

    i += 1
print(count + 1)


Measured memory_bytes: 14480
def prefactor(x):
  ret = set()
  for i in range(2, int(x**0.5)+1):
    if x%i==0: ret.add(i)
    while x%i==0: x //= i
  if x>1: ret.add(x)
  return ret
    

a, b = map(int, input().split())
print(1+len(prefactor(a) & prefactor(b)))

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Arrays.sort(s);

        System.out.println( new String(s).equals("abc")?"Yes":"No" );
    }
}


Measured memory_bytes: 22100
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a ; 
		a = a * a ;
		b = b >> 1;
	}

	return res;
}

int main(){
	ItsFUN;

    string s;cin >> s;

    unordered_map<char,int> m;

    for(int i = 0; i<(int)s.length(); ++i){
    	m[s[i]-'a']++;
    }


    int c = 0, cnt = 0;
    for(auto i : m) {
    	if(i.S==2) ++c;
    	++cnt;
    }

    if(c==2 && cnt ==2) cout << "Yes\n";
    else cout << "No\n"; 


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, T, A, max_h= 0, h;
	double max_a = 1234567, t;
	
	cin >> N >> T >> A;
	REP(i, 0, N){
		cin >> h;
		t = T- h*0.006;
		if(abs(t-A) < max_a){
			max_a = abs(t-A);
			max_h = i+1;
		}
	}
	cout << max_h;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,i,j,k=0,a,b,x,y;
    string s,t;
    cin>>s>>t;
    for(i=0;i<s.size();i++)
    {
        if(s[i]==t[i])
            k++;
        else
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 3652
let x = Int(readLine()!)!

let nums = Array(-999...999).map { n -> (Int, Int) in
    var r = 1
    for _ in 0..<5 {
        r *= n
    }
    return (n, r)
}

root: for a in nums {
    for b in nums {
        if a.1 - b.1 == x {
            print("\(a.0) \(b.0)")
            break root
        }
    }
}


Measured memory_bytes: 8024
r,c = map(int,input().split())
rc=[]
total=[]
for _ in range(r): rc.append(list(map(int,input().split())))
for i in range(r): rc[i].append(sum(rc[i]))
for i in zip(*rc): total.append(sum(i))
rc.append(total)
for col in rc: print(*col)

Measured memory_bytes: 8216
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int x,y,z;
  cin>>x>>y>>z;

  x -= z;
  cout<<(x/(y+z))<<endl;
}

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

void trace(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i < n-1) cout << " ";
	}
	cout << endl;
}

void insertionsort(int a[], int n) {
	int v, j;
	for (int i = 0; i < n; i++) {
		v = a[i];
		j = i - 1;
		while ( j >= 0 and a[j] > v) {
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		trace(a, n);
	}
}

int main() {
	int n;
	int a[100];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	insertionsort(a, n);
	return 0;
}

Measured memory_bytes: 3088
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))


    Flag = False
    biga = 0
    lessa = 0
    for i in range(n):
        if a[i] > b[i]:
            biga += a[i] - b[i]
        else:
            lessa += (b[i] - a[i]) //2

    tmp = lessa - biga

    if tmp >= 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 4600
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int main() {
	int n,a,b,y;
	cin >> n>>a>>b;
	y = min(n*a, b);
	cout<<y <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  for(int i=1;i<=n;i++)
  {
    int x;
    cin>>x;
    a[x]=i;
  }
  for(int i=1;i<=n;i++)
    cout<<a[i]<<" ";
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cassert>
using namespace std;

using P = pair<int, long>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<P> td(N);
  for (int i{}; i < N; ++i) {
    int t, d;
    cin >> t >> d;
    td[i] = P{t, d};
  }
  sort(td.begin(), td.end(), [](P l, P r) {
    return l.second > r.second;
  });

  map<int, vector<long >> choice;
  long point{};
  int type{};
  for (int i{}; i < K; ++i) {
    choice[td[i].first].push_back(td[i].second);
    point += td[i].second;
  }
  type = choice.size();
  point += type * type;

  for (auto &p : choice) {
    auto &v = p.second;
    if (v.size() > 1)
      sort(v.begin(), v.end(), greater<long>());
  }

  int alt{K};
  long ans{point};
  for (int i{K - 1}; i >= 0; --i) {
    int t = td[i].first;
    int d = td[i].second;
    if (choice[t].size() == 1)
      continue;
    while (alt < N) {
      int nt = td[alt].first;
      int nd = td[alt].second;
      ++alt;
      if (choice.find(nt) == choice.end()) {
        point += (nd - d) + ((type + 1) * (type + 1) - type * type);
        if (ans < point) {
          ans = point;
        }
        assert(choice[t].back() == d);
        choice[t].pop_back();
        choice[nt].push_back(nd);
        ++type;
        break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e5+5;
int n,m,ans;
char c[2005][2005];
int dpl[2005][2005],dpr[2005][2005];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++)
	{
		int ji=0,last=0;
		for(int j=0;j<m;j++)
		{
			if(c[i][j]=='#')
			{
				for(int k=last;k<j;k++)
					dpl[i][k]=ji;
				ji=0;
				last=j+1;
			}
			else
				ji++;
		}
		for(int k=last;k<m;k++)dpl[i][k]=ji;
	}
	for(int j=0;j<m;j++)
	{
		int ji=0,last=0;
		for(int i=0;i<n;i++)
		{
			if(c[i][j]=='#')
			{
				for(int k=last;k<i;k++)
					dpr[k][j]=ji;
				ji=0;
				last=i+1;
			}
			else
				ji++;
		}
		for(int k=last;k<m;k++)dpr[k][j]=ji;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(c[i][j]=='.')ans=max(ans,dpl[i][j]+dpr[i][j]-1);
	cout<<ans<<endl;
	return 0;
}    

Measured memory_bytes: 35584
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string stro, str;
  while(getline(cin, stro)){
    for(int i = 0; i < 26; i++){
      str = stro;
      for(int j = 0; j < stro.length(); j++){
	if(str[j] >= 'a' && str[j] <= 'z')
	  if(str[j] + i > 'z')
	    str[j] += i - 26;
	  else
	    str[j] += i;
      }
      if(str.find("the") != string::npos || str.find("this") != string::npos || str.find("that") != string::npos)
	cout << str << endl;
    }
  }
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll a[3],i;
    for(i=0;i<3;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,3,sizeof(ll),compare);
    ll b=0;
    for(i=0;i<2;i++){
        if(a[i]==a[i+1]) b++;
    }
    if(b==1) printf("Yes\n");
    else printf("No\n");
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, max int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	for i := 0; i < n-1; i++ {
		if i > 0 && h[i-1] >= h[i] {
			continue
		}
		var cnt int
		for j := 0; j < n-i-1; j++ {
			if h[i+j] >= h[i+j+1] {
				cnt++
			} else {
				break
			}
		}
		if max < cnt {
			max = cnt
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		if(A == 1){
			if(B == 2){
				System.out.println(3);
			}
			else{
				System.out.println(2);
			}
		}
		else if(B == 1){
			if(A == 2){
				System.out.println(3);
			}
			else{
				System.out.println(2);
			}
		}
		else{
			System.out.println(1);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35336
#include <iostream>

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c;
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	if(b > c){
		d = b;
		b = c;
		c = d;
	}
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	cout << a << " " <<b <<" "<< c << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int a, b, quot, remain;
    double floatNum;
    
    cin >> a >> b;
    quot = a / b;
    remain = a % b;
    floatNum = (double)a / (double)b;
    
    printf("%d %d %f\n", quot, remain, floatNum);
    
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
using namespace std;
const int MAX = 100;
const int INF = 200000;
int n, G[MAX][MAX];
int dis[MAX];
bool book[MAX] = { false };
void init()
{
	for (int i = 0; i < n; i++)
		dis[i] = G[0][i];
	book[0] = true;
}
void dijkstra()
{
	for (int k = 1; k <= n - 1; k++)
	{
		int min = INF;
		int u;
		for (int j = 0; j < n; j++)
			if (dis[j] > 0 && dis[j] < INF && !book[j] && dis[j] < min)
			{
				min = dis[j];
				u = j;
			}
		book[u] = true;
		for (int v = 0; v < n; v++)
			if (!book[v] && dis[u]+G[u][v] < dis[v])
				dis[v] = dis[u] + G[u][v];
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j)
				G[i][j] = INF;
			else
				G[i][j] = 0;
	for (int i = 0; i < n; i++)
	{
		int u, d;
		cin >> u >> d;
		for (int j = 0; j < d; j++)
		{
			int v, w;
			cin >> v >> w;
			G[u][v] = w;
		}
	}
	init();
	dijkstra();
	for (int i = 0; i < n; i++)
		cout << i << " " << dis[i] << endl;
}


Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main(){
  int data[14];
  for(int i=0, j=1; i<14; ++i, j*=5) data[i]=j;
  int n;
  while(1){
    cin >> n;
    if(!n) break;
    int ans=0;
    for(int i=1; i<14; ++i){
      if(n < data[i]) break;
      ans += n / data[i];
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<int> xs(n), ys(n);
    rep(i, 0, n) {
        cin >> x[i] >> y[i];
        xs[i] = x[i]; ys[i] = y[i];
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    long long area = 1LL * (xs.back() - xs[0]) * (ys.back() - ys[0]);
    rep(lx, 0, n) rep(rx, lx, n) rep(ly, 0, n) rep(ry, ly, n) {
        int ps = 0;
        rep(i, 0, n) if (xs[lx] <= x[i] && x[i] <= xs[rx] && ys[ly] <= y[i] && y[i] <= ys[ry])
            ++ps;
        if (ps >= k) area = min(area, 1LL * (xs[rx] - xs[lx]) * (ys[ry] - ys[ly]));
    }
    cout << area << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    if(n%2 != 0) No();
    else{
        if(s.substr(0, n/2) == s.substr(n/2, n/2)) Yes();
        else No();
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl P(N);
  REP(i, N) cin >> P[i];
  ll ans = 0;
  REP(i, N) {
    if (P[i] != i + 1)
      ans++;
  }
  if (ans <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
K, S = map(int, input().split())
cnt = 0

for x in range(K + 1):
    S2 = S - x
    if S2 < 0:
        break
    elif S2 > 2*K:
        continue
    else:
        cnt += (S2 + 1) - 2*max(0, S2 - K)

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int z=0,a=0,b=0;
	bool f[26];
	char a1='~',b1='~';
	memset(f,false,sizeof(f));
	for(int i=0;i<4;i++)
	{
		if(!f[s[i]-'A'])
		{
			z++;
			if(a1=='~')
			{
				a++;
				f[s[i]-'A']=true;
				a1=s[i];
			}
			else
			{
				b++;
				f[s[i]-'A']=true;
				b1=s[i];
			}
		}
		else
		{
			if(s[i]==a1)
			a++;
			else
			b++;
		}
	}
	if(z==2&&a==2&&b==2)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef pair<ll,ll> P;
const ll INF=10000000000000000;
const ll mod=1000000007;
#define F first
#define S second
#define all(a) (a.begin(),a.end())
int main(void){
    int n;cin>>n;
    vector<vector<P>>v(n);
    ll x,y,c;
    rep(i,n-1){
        cin>>x>>y>>c;x--;y--;
        v[x].push_back(make_pair(y,c));
        v[y].push_back(make_pair(x,c));
    }
    ll a,k;cin>>a>>k;k--;
    vector<ll>dis(n,-1);
    dis[k]=0;
    queue<int>q;q.push(k);
    while(!q.empty()){
        int f=q.front();q.pop();
        for(auto t:v[f]){
            if(dis[t.F]!=-1)continue;
            else{
                dis[t.F]=dis[f]+t.S;
                q.push(t.F);
            }
        }
    }
    rep(i,a){
        cin>>x>>y;
        cout<<dis[x-1]+dis[y-1]<<endl;
    }
}

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

using namespace std;

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

    vector<bool> spades(14);
    vector<bool> hearts(14);
    vector<bool> clubs(14);
    vector<bool> diamonds(14);

    for (int i = 0; i < n; i++) {
        char shape;
        int x;
        cin >> shape >> x;
        if (shape == 'S')
            spades[x] = true;
        if (shape == 'H')
            hearts[x] = true;
        if (shape == 'C')
            clubs[x] = true;
        if (shape == 'D')
            diamonds[x] = true;
    }

    for (int i = 1; i <= 13; i++) {
        if (!spades[i])
            cout << 'S' << " " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (!hearts[i])
            cout << 'H' << " " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (!clubs[i])
            cout << 'C' << " " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (!diamonds[i])
            cout << 'D' << " " << i << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int inf = 1e18;
const int M = 1e9 + 7;
int A[N];
int n;

int pwr(int a,int b)
{
     int res = 1;
     while(b)
     {
          if(b&1) res = (res*a)%M;
          a = (a*a)%M;
          b >>= 1;
     }
     return res%M;
}

int mul(int a, int b) { return (a * b) % M; };
int add(int a, int b)
{
      int res = a + b;
      if ( res < 0 ) res += M;
      if ( res >= M) res -= M;
      return res;
}

void solve()
{
      int n , k;
      cin >> n >> k;

      for(int i = k; i >= 1; i--)
      {
            int r = k/i;
            A[i] = pwr(r,n);
            for(int j = 2*i; j <= k; j += i)
            {
                  A[i] = add(A[i],-A[j]);
            }
      }

      int ans = 0;

      loop(i,1,k+1)
      {
            ans = add(ans , mul(i,A[i]));
      }

      cout << ans;
}     
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

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


Measured memory_bytes: 4380
import sys
A, B, C = map(int, input().split())
ans = 0

if A == B == C and not A == 1:
    print(-1)
    sys.exit()

while True:
    if A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        t_A, t_B, t_C = A, B, C
        A = (t_B + t_C) // 2
        B = (t_C + t_A) // 2
        C = (t_A + t_B) // 2
        ans += 1
    else:
        print(ans)
        break

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    int n,k,x,y;cin >> n >> k >> x >> y;
    
    if (n <= k){
        cout << n * x << endl;
        return 0;
    }
    
    int ans = k * x;
    
    ans += (n-k)*y;
    
    cout << ans << endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	double w, h, x, y;
	double ans;
	cin >> w >> h >> x >> y;
	ans = (double)w * h / 2.0;
	if (x == w / 2 && y == h / 2) {
		cout << ans << " " << 1 << endl;
	}
	else {
		cout << ans << " " << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 55;
int n, a[MAXN];
int main () {
	scanf("%d", &n); int ans = 0;
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		for(int j = 1; j < i; ++j)
			ans += a[i]*a[j];
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
while True:
    try:
        card = set([1,2,3,4,5,6,7,8,9,10])
        c1, c2, c3 = map(int, input().split())
        card_now = card - set([c1,c2,c3])
        p = 0
        for c in card_now:
            if c + c1 + c2 <= 20:
                p += 1
        if p/7 >= 0.5:
            print("YES")
        else:
            print("NO")
    except:
        break



Measured memory_bytes: 5604
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
  ll n;
  cin>>n;
  ll i,a,cnt=0;
  for(i=1;i<=n;i++)
  {
  	cin>>a;
  	if(a!=i)
  		cnt++;
  }
  if(cnt>2)
	return cout<<"NO",0;
	cout<<"YES";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  int N[3];
  int i;
  
  scanf("%d",&n);

  N[0] = n/100;
  n = n - N[0]*100;
  N[1] = n/10;
  n = n - N[1]*10;
  N[2] = n;
  
  i = 0;
  while(i<3){
    if(N[i] == 7){
      puts("Yes");
      break;
    }
    else if(i == 2){
      puts("No");
    }
    i++;
  }
  
  return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  int cnt[n + 1] = {0};
  for(int i = 2; i <= n; i++){
    int tmp = i;
    for(int j = 2; j <= tmp; j++){
      while(tmp % j == 0){
        cnt[j]++;
        tmp /= j;
      }
    }
  }

  ll ans = 1;
  REP(i, n + 1) ans = ans * (cnt[i] + 1) % mod;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
string a,b;
int x,y;
string u;

int main(){

	cin >> a >> b;
	cin >> x >> y;
	cin >> u;
	if ( u == a ) x--;
	else y--;

	cout << x << " " << y << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,C;
vector<P> ch[30];
vector<P> v;
vector<ll> r;

int main(){
    cin >> N >> C;
    for(int i=0;i<N;i++){
        ll s,t,c;
        cin >> s >> t >> c;
        ch[c-1].push_back(make_pair(s,t));
    }
    for(int i=0;i<C;i++){
        if(ch[i].size()==0) continue;
        sort(ch[i].begin(),ch[i].end());
        ll s,t,ls,lt;
        ls = ch[i][0].first;
        lt = ch[i][0].second;
        for(int j=1;j<ch[i].size();j++){
            s = ch[i][j].first;
            t = ch[i][j].second;
            if(s != lt){
                v.push_back(make_pair(lt,ls));
                ls = s;
                lt = t;
            }else{
                lt = t;
            }
        }
        v.push_back(make_pair(lt,ls));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        ll s,t;
        s = v[i].second;
        t = v[i].first;
        ll ind = -1;
        ll t_max = -1;
        for(int j=0;j<r.size();j++){
            if(r[j] < s){
                if(t_max < r[j]){
                    ind = j;
                    t_max = r[j];
                }
            }
        }
        if(ind == -1) r.push_back(t);
        else r[ind] = t;
    }
    cout << r.size() << endl;
    return 0;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;


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

	ll a[n];
	ll x = -1;
	rep ( i, n ) {
		cin >> a[i];
		if ( x == -1 ) {
			x = a[i];
		}
		else {
			x ^= a[i];
		}
	}

	rep ( i, n ) {
		if ( i != n - 1 ) {
			cout << (x ^ a[i]) << " ";
		}
		else {
			cout << (x ^ a[i]) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 5116