akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

string str;

void calc(char op, const set<int> a, const set<int> b, set<int>& dest) {
    for (const int v : a) {
        for (const int w : b) {
            if (op == '/' && w == 0) continue;
            dest.insert(
                op == '+' ? v + w :
                op == '-' ? v - w :
                op == '*' ? v * w :
                            v / w
            );
        }
    }
}

set<int> solve(int start, int end) {
    vector<set<int>> nums;
    vector<char> ops;
    for (int idx = start; idx < end;) {
        if (str[idx] == '(') {
            int idx_ = idx+1;
            for (int count = 1; ; ++idx_) {
                if (str[idx_] == '(') count++;
                if (str[idx_] == ')') {
                    count--;
                    if (count == 0) break;
                }
            }
            set<int> t = solve(idx+1, idx_);
            nums.push_back(t);
            idx = idx_ + 1;
        } else if (isdigit(str[idx])) {
            int acc = 0;
            while (idx < end && isdigit(str[idx]))
                acc = 10 * acc + (str[idx++] - '0');
            nums.push_back(set<int>{acc});
        } else {
            ops.push_back(str[idx++]);
        }
    }

    int L = nums.size();
    vector<vector<set<int>>> vs(nums.size());
    for (int j = 0; j < L; ++j) {
        vs[j].resize(L+1);
        vs[j][j+1] = nums[j];
    }

    for (int w = 2; w <= L; ++w) {
        for (int j = 0; j+w <= L; ++j) {
            set<int> res;
            for (int k = j+1; k < j+w; ++k) {
                calc(ops[k-1], vs[j][k], vs[k][j+w], res);
            }
            vs[j][j+w] = res;
        }
    }

    return vs[0][L];
}


int main() {
    while (true) {
        getline(cin, str);
        if (str == "#") break;
        cout << solve(0, str.size()).size() << endl;
    }
    return 0;
}



Measured memory_bytes: 3300
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  char B,C,D,E;
  ci(B>>C>>D>>E);
  ll b=B-'0',c=C-'0',d=D-'0',e=E-'0';
  if(b+c+d+e==7)
    co(b<<'+'<<c<<'+'<<d<<'+'<<e<<'='<<7);
  else if(b+c+d-e==7)
    co(b<<'+'<<c<<'+'<<d<<'-'<<e<<'='<<7);
  else if(b+c-d+e==7)
    co(b<<'+'<<c<<'-'<<d<<'+'<<e<<'='<<7);
  else if(b-c+d+e==7)
    co(b<<'-'<<c<<'+'<<d<<'+'<<e<<'='<<7);
  else if(b+c-d-e==7)
    co(b<<'+'<<c<<'-'<<d<<'-'<<e<<'='<<7);
  else if(b-c+d-e==7)
    co(b<<'-'<<c<<'+'<<d<<'-'<<e<<'='<<7);
  else if(b-c-d+e==7)
    co(b<<'-'<<c<<'-'<<d<<'+'<<e<<'='<<7);
  else
    co(b<<'-'<<c<<'-'<<d<<'-'<<e<<'='<<7);
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
char s[110000];
int main(){
	scanf("%s",s);
	int l=strlen(s),ans=0;
	for(int i=0;i<l-1;++i)
		if(s[i]!=s[i+1]) ++ans;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
	string a, b, c, d;
	int ans;
	cin >> a >> b >> c;
	d = a + b + c;
	//string型からint型へ直接変換
	ans = stoi(d);
	if (ans % 4 == 0) {
		printf("YES");
	}
	else {
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 3208
import numpy as np
A,B = map(int,input().split())
"""
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
"""
def funcXOR(S):
  if S % 2 == 0:
    s = S // 2
    if s % 2 == 0:
      return 0^S
    else:
      return 1^S
  else:
    s = (S+1) // 2
    if s % 2 == 0:
      return 0
    else:
      return 1
print(funcXOR(A-1)^funcXOR(B))

Measured memory_bytes: 12508
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional;

void main(){
    (readln().chomp.isHaiku?"YES":"NO").writeln();
}
auto isHaiku(string str){
    return ["5 7 5", "7 5 5", "5 5 7"].canFind(str);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	ll summin = 0;
	ll summax = 0;
	for (ll k = 0; k <= N + 1; k++) {
		ans += (k >= K) ? (summax - summin + 1) : 0;
		ans %= mod;
		summax += (N - k);
		summin += k;
	}

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


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

// @@ !! LIM()

bool solve() {
  string S; cin >> S;
  ll N = S.size();
  if (S.at(0) != 'A') return false;
  ll cnt = 0;
  ll p = -1;
  for (ll i = 2; i <= N-2; i++) {
    if (S.at(i) == 'C') {
      cnt++;
      p = i;
    }
  }
  if (cnt != 1) return false;
  for (ll i = 1; i < N; i++) {
    if (i == p) continue;
    if (S.at(i) < 'a' || 'z' < S.at(i)) return false;
  }
  return true;
}



int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << (solve() ? "AC\n" : "WA\n");

  return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);


ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

int A[410], B[410];
ll dp[410][410];

ll X[410][410];
ll Y[410][410];

int main2() {
  int N = nextInt();
  int C = nextInt();
  REP(i, N) A[i] = nextInt();
  REP(i, N) B[i] = nextInt();
  CLR(dp, 0);
  dp[N][0] = 1;
  for (int n = N-1; n >= 0; n--) {
    for (int c = 0; c <= C; c++) {
      ll res = 0;
      for (int k = 0; k <= c; k++) {
        res += dp[n+1][c-k] * (Y[B[n]][k] - Y[A[n]-1][k]) % MOD;
        res = (res % MOD + MOD) % MOD;
      }
      dp[n][c] = res % MOD;
      // cout << n << " " << c << " " << dp[n][c] << endl;
    }
  }
  ll ans = dp[0][C];
  cout << ans << endl;
  return 0;
}

int main() {

  for (int x = 0; x <= 400; x++) {
    for (int k = 0; k <= 400; k++) {
      X[x][k] = mod_pow(x, k, MOD);
    }
  }
  for (int k = 0; k <= 400; k++) {
    for (int x = 0; x <= 400; x++) {
      Y[x][k] = (Y[x-1][k] + X[x][k]) % MOD;
    }
  }

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

const int MOD = 1000000007;

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  // dp[i][j] := i 番目の子どもまでで j 個の飴を分け合う方法の総数
  vector<vector<long long>> dp(N+1, vector<long long>(K+1, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= K; j++) {
      // dp[i+1][*] への遷移 : 区間 [j, j + a_i] に dp[i][j] を加算
      dp.at(i+1).at(j) += dp.at(i).at(j);
      dp.at(i+1).at(j) = mod(dp.at(i+1).at(j), MOD);
      if (j+A.at(i)+1 <= K) {
        dp.at(i+1).at(j+A.at(i)+1) -= dp.at(i).at(j);
        dp.at(i+1).at(j+A.at(i)+1) = mod(dp.at(i+1).at(j+A.at(i)+1), MOD);
      }
    }
    for (int j = 0; j < K; j++) {
      dp.at(i+1).at(j+1) += dp.at(i+1).at(j);
      dp.at(i+1).at(j+1) = mod(dp.at(i+1).at(j+1), MOD);
    }
  }
  cout << dp.at(N).at(K) << endl;
}

Measured memory_bytes: 80256
int main()
{
	int i,j;
	int rank1 = 0;
	int mountain[10] = {0};
	for (i = 0; i < 10; i++) {
		scanf("%d", &mountain[i]);
	}



	for (i = 0; i < 10; i++) {
		for (j = i + 1; j < 10; j++) {

			if (mountain[j] > mountain[i])
			{
				rank1 = mountain[i];
				mountain[i] = mountain[j];
				mountain[j] = rank1;
			}
		}
	}

	for (i = 0; i < 3; i++) {
		printf("%d\n", mountain[i]);

		}
	
	


    return 0;
}

Measured memory_bytes: 600
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0]*(ls+1) for i in range(lt+1)]
ans = ""

for i in range(1,lt+1):
    for j in range(1,ls+1):
        if s[j-1] == t[i-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
i = lt
j = ls
while i>0 and j>0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = t[i-1] + ans
        i -= 1
        j -= 1

print(ans)

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

int main(void){
  int n; scanf("%d",&n);
  int a[n];
  rep(i,n) scanf("%d",&a[i]);
  vector<pair<int,int>> x(n);
  rep(i,n){
    x.at(i).first = a[i];
    x.at(i).second = i+1;
  }
  sort(x.begin(),x.end());
  rep(i,n-1){
    printf("%d",x.at(i).second);
    printf(" ");
  }
  printf("%d\n",x.at(n-1).second);
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[10002][2][102];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string k;
	ll d;
	cin >> k >> d;

	REP(i, 102)REP(j, 2)REP(f,d)dp[i][j][f] = 0;
	dp[0][0][0] = 1;

	ll n = k.size();
	REP(i, n) {
		REP(f, d) {
			REP(t, 10)
				dp[i + 1][1][(f + t) % d] = (dp[i + 1][1][(f + t) % d] + dp[i][1][f]) % MOD;
			REP(t, k[i] - '0')
				dp[i + 1][1][(f + t) % d] = (dp[i + 1][1][(f + t) % d] + dp[i][0][f]) % MOD;

			dp[i + 1][0][(f + k[i] - '0') % d] = (dp[i + 1][0][(f + k[i] - '0') % d] + dp[i][0][f]) % MOD;
		}
	}

	ll ans = (MOD+dp[n][0][0] + dp[n][1][0]-1)%MOD;
	cout << ans << endl;


}




Measured memory_bytes: 16256
n, m= map(int, input().split())
ps = [list(map(str,input().split())) for _ in range(m)]

str_l = ["WA"]*n
int_l = [0]*n
num = 0
ans = 0

for pp, s in ps:
    p = int(pp)-1
    if s == "AC":
        str_l[p] = "AC"
    else:
        if str_l[p] != "AC":
            int_l[p] += 1

for i in range(n):
    if str_l[i] == "AC":
        ans += int_l[i]
        num += 1

print(num,ans)

Measured memory_bytes: 33708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

ll gcd(ll a,ll b){//最大公約数を求める
    if(a<b){
        swap(a,b);
    }

    if(a%b == 0){
        return b;
    }else{
    return gcd(b,a%b);
    }
}
string s,t;
map<ll,char> Map;

signed main(){
    ll n,m,l;
    cin>>n>>m;
    
    cin>>s>>t;
    l=n*m/gcd(n,m);

    for(int i=0;i < n;i++)
    {
        Map.emplace(i*l/n,s.at(i));
    }

    for(int i=0;i < m;i++)
    {
        if(Map.count(i*l/m)!=0 && Map.at(i*l/m) != t.at(i)){
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<l<<endl;
}

Measured memory_bytes: 6144
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

#define MAX 100100
int V;
vector<int> G[MAX];

vector<int> path;
bool dfs(int cur,int pre) {
  if( cur == V-1 ) {
    path.push_back(cur);
    return true;
  }
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( nex == pre ) continue;
    if( dfs(nex,cur) ) {
      path.push_back(cur);
      return true;
    }
  }
  return false;
}

int color[MAX];

void compute() {
  assert( dfs(0,-1) );
  reverse(path.begin(),path.end());
  //rep(i,(int)path.size()) cout << i << " : " << path[i] << endl;
  memset(color,-1,sizeof color);
  int n = (int)path.size() / 2;
  if( (int)path.size() & 1 ) ++n;
  deque<int> deq;
  rep(i,(int)path.size()) {
    int v = path[i];
    if( i < n ) color[v] = 1, deq.push_back(v);
    else        color[v] = 0;   
  }

  while( !deq.empty() ) {
    int cur = deq.front(); deq.pop_front();
    rep(i,(int)G[cur].size()) {
      int nex = G[cur][i];
      if( color[nex] == -1 ) {
	color[nex] = 1;
	deq.push_back(nex);
      }
    }
  }

  int F = 0, S = 0;
  rep(i,V) {
    if( color[i] == 1 ) ++F;
    else ++S;
  }
  if( F >  S ) puts("Fennec");
  else         puts("Snuke");

}

int main() {
  cin >> V;
  rep(i,V-1) {
    int a,b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  compute();
  return 0;
}


Measured memory_bytes: 11384
def main():
    import sys
    input = sys.stdin.buffer.readline
    R, C, K = map(int, input().split())
    d = dict()
    for i in range(K):
        r, c, v = map(int, input().split())
        r -= 1
        c -= 1
        d[(r, c)] = v

    # DP = [[[0, -1, -1, -1] for i in range(C)] for j in range(R+1)]
    prev = [0 for i in range(C)]
    DP = [[0, -1, -1, -1] for i in range(C)]
    for i in range(R):
        DP[0][0] = prev[0]
        if (i, 0) in d:
            DP[0][1] = d[(i, 0)] + prev[0]

        prev[0] = max(DP[0])

        for j in range(1, C):
            if (i, j) in d:
                for k in range(3):
                    if DP[j-1][k] == -1:
                        break
                    else:
                        DP[j][k+1] = max(DP[j-1][k+1], DP[j-1]
                                         [k] + d[(i, j)], prev[j] + d[(i, j)])
            else:
                for k in range(1, 4):
                    DP[j][k] = DP[j-1][k]

            DP[j][0] = max(DP[j-1][0], prev[j])

            prev[j] = max(DP[j])
        # print(prev)
    print(prev[-1])


main()


Measured memory_bytes: 108168
package main

import (
	"strings"
	"fmt"
	"bufio"
	"strconv"
	"math"
	"os"
)

// test
func Test_solve() {
	input := `
3
0 0 3 0 1 1 2 -1
0 0 3 0 3 1 3 -1
0 0 3 0 3 -2 5 0
`
	input = strings.Trim(input, "\n")

	solve(bufio.NewScanner(strings.NewReader(input)))
}

//
func subVector(p1, p2 []float64) []float64 {
	return []float64{
		p1[0] - p2[0],
		p1[1] - p2[1],
	}
}

//
func dotVector(p1, p2 []float64) float64 {
	return p1[0]*p2[0] + p1[1]*p2[1]
}

//
func crossVector(p1, p2 []float64) float64 {
	return p1[0]*p2[1] - p1[1]*p2[0]
}

//
func absVector(p []float64) float64 {
	return math.Sqrt(p[0]*p[0] + p[1]*p[1])
}

//
func norrmalize(p []float64) float64 {
	return p[0]*p[0] + p[1]*p[1]
}

//
// 1: p1-p2より反時計周り側にp3
// 2: p1-p2より時計周り側にp3
// 3: p1-p2直線上、p2の先にp3
// 4: p1-p2直線上、p1の前にp3
// 5: p1-p2線分上にp3
func checkClockWise(p1, p2, p3 []float64) int {
	p1p2 := subVector(p2, p1)
	p1p3 := subVector(p3, p1)
	if crossVector(p1p2, p1p3) > 0.0 {
		return 1
	} else if crossVector(p1p2, p1p3) < 0.0 {
		return 2
	} else if dotVector(p1p2, p1p3) < 0.0 {
		return 4
	} else if norrmalize(p1p2) < norrmalize(p1p3) {
		return 3
	}
	return 5
}

func strSliceToFloat64(strSlice []string) []float64 {
	n := len(strSlice)
	sliceFloat := make([]float64, n)
	for i := 0; i < n; i++ {
		v, _ := strconv.Atoi(strSlice[i])
		sliceFloat[i] = float64(v)
	}
	return sliceFloat
}

// solve
func solve(sc *bufio.Scanner) {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		sc.Scan()
		slice := strSliceToFloat64(strings.Split(sc.Text(), " "))

		//fmt.Println(slice)

		p1 := []float64{slice[0], slice[1]}
		p2 := []float64{slice[2], slice[3]}
		p3 := []float64{slice[4], slice[5]}
		p4 := []float64{slice[6], slice[7]}

		c1 := checkClockWise(p1, p2, p3)
		c2 := checkClockWise(p1, p2, p4)

		c3 := checkClockWise(p3, p4, p1)
		c4 := checkClockWise(p3, p4, p2)

		conv := func(v int) int {
			if v == 2 {
				return -1
			} else if v == 5 {
				return 0
			} else if v == 4 {
			    return -1
			}
			return v
		}

		c1 = conv(c1)
		c2 = conv(c2)
		c3 = conv(c3)
		c4 = conv(c4)

		isInterSect := c1*c2 <= 0 && c3*c4 <= 0

		if isInterSect {
			fmt.Printf("%d\n", 1)
		} else {
			fmt.Printf("%d\n", 0)
		}
	}
}

// main
func main() {
    solve(bufio.NewScanner(os.Stdin))
}



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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  while(true){
    if(s.substr(0,5)=="esare" || s.substr(0,5)=="maerd"){
      s=s.substr(5,s.size()-5);
    }else if(s.substr(0,6)=="resare"){
      s=s.substr(6,s.size()-6);
    }else if(s.substr(0,7)=="remaerd"){
      s=s.substr(7,s.size()-7);
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
    if(s.size()==0){
      cout<<"YES"<<endl;
      return 0;
    }
  }
}
///////////////////////////




Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int n, m, X, Y;
    int x[100], y[100];
    int x_max = -1000, y_min = 1000;

    cin >> n >> m >> X >> Y;

    for(int i=0; i<n; i++){
        cin >> x[i];
        if(x[i] >= x_max) x_max = x[i];

    }
    for(int i=0; i<m; i++){
        cin >> y[i];
        if(y[i] <= y_min) y_min = y[i];
    }

    if(X <= x_max && x_max < y_min && y_min < Y){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

int main(void) {

  double l;
  cin >> l;
  double k = l/3.0;
  cout << std::setprecision(15) << k*k*k << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int a;
  std::cin>>a;
  for(int i=9;i>1;i--){
    if(a%i==0){
      a=a/i;
      break;
    }
  }
  if(a>9){
    std::cout<<"No"<<std::endl;
  }else std::cout<<"Yes"<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,a,b) for(register int i = a;i <= b;++i)
#define int long long
#define N 1000010
using namespace std;

int a[N];

inline int read(){
	int x = 0,f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-')f = -1;c = getchar();}
	while(isdigit(c)){x = x * 10 + c - '0';c = getchar();}
	return f * x;
}

signed main(){
	int n = read(),m = read(),k = read();
	fr(i,1,k){int x = read();a[x]++;}
	fr(i,1,n){
		if(m - k + a[i] > 0)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

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

int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.substr(i,3)=="ABC"){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

typedef long long ll;
/*
typedef struct Name   Name;
struct Name {
    int a[3];
};
*/
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) for (int i = 0; i < (a); i++)
int A[1000005];
bool visit[1000005];
int main()
{
    int N;
    
    
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        
        A[a]++;
        //cout << a << "" << A[a];
    }
    
    int sum = 0;
    for(int i = 1; i <= 1000000; i++)
    {
        if(A[i]==0 || visit[i])
            continue;
        if(A[i]== 1 && !visit[i])
        {
            sum++;
        }
            
        for(int j = i; j <= 1000000; j+=i)
            visit[j] = true;
    }
    

    

    
   
    cout << sum << "\n";
}

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

int main() {
    long long N; cin >> N;
    int A=floor(sqrt(N));
    int ans=to_string(N).size();
    int result;
    for(int i=1; i<A+1; i++){
        if(N%i==0){
            result=to_string(N/i).size();
            ans=min(ans,result);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
from bisect import bisect_left
import sys
input = sys.stdin.readline
a,b,q = map(int,input().split())
inf = float('inf')
S = [-inf]+[int(input()) for i in range(a)]+[inf]
T = [-inf]+[int(input()) for i in range(b)]+[inf]

def f(S,T):
    res = 10**30 
    s = bisect_left(S,x)

    ans = 0
    t = bisect_left(T,S[s-1])
    ans += abs(x-S[s-1])+min(abs(S[s-1]-T[t-1]),abs(S[s-1]-T[t]))
    if ans <= res:
        res = ans
    
    ans = 0
    t = bisect_left(T,S[s])
    ans += abs(x-S[s])+min(abs(S[s]-T[t-1]),abs(S[s]-T[t]))
    if ans <= res:
        res = ans

    return res


for i in range(q):
    x = int(input())
    print(min(f(S,T),f(T,S)))

Measured memory_bytes: 12804
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

int gcd(int x, int y) {
  int tmp;
  if(y<x) swap(x,y);
  while (y!=0) {
    tmp = y;
    y = x % y;
    x = tmp;
  }
  return x;
}

int main(){
  double x,y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int now=0;
    for(int i=1;i<=x;i++)
    {
        now+=i;
        if(now>=x)
        {
            cout<<i;
            break;
        }


    }
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

p = 10 ^ 9 + 7

f :: Int -> Int
f n = iter 1 n
  where
    iter s 1 = s
    iter s k = iter ((s * k) `mod` p) (k - 1)

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]

    case abs (n - m) of
        0 -> print $ (f n * f m * 2) `mod` p
        1 -> print $ (f n * f m) `mod` p
        _ -> print 0

Measured memory_bytes: 9596
n = int(raw_input())
u = raw_input()
q = int(raw_input())

def cmd_set(q,u):
    x = int(q[0])
    y = int(q[1])
    z = q[2]

    h = u[:x-1]
    t = u[y:]
    zz= z*(y-x+1)

    return h+zz+t

def cmd_comp(q, u):
    a = int(q[0])
    b = int(q[1])
    c = int(q[2])
    d = int(q[3])

    s = u[a-1:b]
    t = u[c-1:d]
    if s < t:
        print "s"
    elif s > t:
        print "t"
    else:
        print "e"

for i in range(q):
    q = raw_input().split()
    cmd = q[0]
    q.pop(0)

    if cmd == 'comp':
        cmd_comp(q, u)
    elif cmd == 'set':
        u = cmd_set(q, u)

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


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long[] abc = new long[3];
        long allBlocks = 1;

        for (int i = 0; i < 3; i++) {
            abc[i] = sc.nextInt();
            allBlocks *= abc[i];
        }

        Arrays.sort(abc);

        System.out.println(abc[2] % 2 == 0 ? 0: abc[0] * abc[1]);
    }

}


Measured memory_bytes: 35588
#include <iostream>
#define ll unsigned long long int
int main(void){
  ll N,L;
  std::cin >> N >> L;

  ll a[N+1];
  for(int i=1; i<=N; i++){
    std::cin >> a[i];
  }

  ll pivot = -1;
  for(int i=1; i<=N-1; i++){
    if(a[i]+a[i+1] >= L){
      pivot = i;
      break;
    }
  }

  if(pivot == -1){
    std::cout << "Impossible" << std::endl;
    return 0;
  }

  std::cout << "Possible" << std::endl;
  for(int i=1; i<pivot; i++){
    std::cout << i << std::endl;
  }
  for(int i=N-1; i>=pivot; i--){
    std::cout << i << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;

	if (k != 0) {
		if ((n / k) != n)
		{
			if (n - k >= 0)	cout << n - k;
			else cout << 0;
		}
		else
		{
			cout << 0;
		}
	}
	else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
int main()
{
    ll n, m, x, y, z, a, b, c, d;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << " " << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  if(a+b<=a+c && a+b<=b+c){
    printf("%d\n",a+b);
  } else if(b+c<=a+c && b+c<=a+c){
    printf("%d\n",b+c);
  } else if(c+a<=a+b && c+a<=b+c){
    printf("%d\n",c+a);
  }
    
  return 0;
}


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

#define int long long int
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int dp[3001][3001][2];
int mod=1e9+7;
int func(int arr[],int l,int r,int p)
{   //cout<<p<<endl;
    if(l>r)
    return 0;
    if(dp[l][r][p]!=-1)
    return dp[l][r][p];
    if(p==0)
    return dp[l][r][p]=max(arr[l]+func(arr,l+1,r,!p),arr[r]+func(arr,l,r-1,!p));
    else
    return dp[l][r][p]=min(func(arr,l+1,r,!p),func(arr,l,r-1,!p));
}

int32_t main() {
    IOS;
    int n;
    cin>>n;
    int arr[n];
    int sum=0;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
    cin>>arr[i];
    sum+=arr[i];
    }
    cout<<2*func(arr,0,n-1,0)-sum<<endl;
}

Measured memory_bytes: 141184
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            int ans = 0;
            int i;

            for(i = 1; i <= n && i < 10; i++)
            {
                ans++;
            }
            // n < 1000
            for(i = 100; i <= n && i < 1000; i++)
            {
                ans++;
            }

            // n < 100000
            for(i = 10000; i <= n && i < 100000; i++)
            {
                ans++;
            }

            System.Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) + "..." << endl;
}

int32_t main() {
  DESYNC;
  solution();
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(){
    int a,b,c,x,y;
    y=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int x=a;x<=b;x++){
        if(c%x==0){
            y+=1;
        }
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
const long long MOD = 1e9 + 7;
long long pwr(long long a, long long n) {
	a %= MOD;
	long long r = 1;
	for (; n > 0; n >>= 1) {
		if (n & 1) r = r * a % MOD;
		a = a * a % MOD;
	}
	return r;
}

void solve_E() {
	int n, k; std::cin >> n >> k;
	long long  answer = 0;
	const int N = 1e5 + 10;
	long long ways[N];
	for (int x = k; x >= 1; x--) {
		int m = k / x;
		ways[x] = pwr(m, n);
		for (int gg = 2 * x; gg <= k; gg += x) {
			ways[x] -= ways[gg];
		}
		ways[x] %= MOD;
		ways[x] += MOD;
		ways[x] %= MOD;

		answer += (ways[x] * x) % MOD;
	}
	answer %= MOD;
	std::cout << answer << std::endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	//solve_A();
	//solve_B();
	//solve_C();
	//solve_D();
	solve_E();
    return 0;
}

Measured memory_bytes: 4384
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
}   
int main()
{
	FAST
	ll a,b;
	cin>>a>>b;
	cout<<(a*b)/__gcd(a,b);
	return 0;
}















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

ll gcd(ll a,ll b)
{
	if (a%b==0)	{
		return(b);
    }
	else {
		return(gcd(b,a%b));
    }
}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll lcm = c*d/gcd(c,d);
  a -= 1;
  ll ans = b-a;
  ans -= (b/c + b/d - b/lcm);
  ans += (a/c + a/d - a/lcm);
  
  printf("%lld\n",ans);
}




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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    const ll MOD = 1000000007;
    vector<ll> modpow10(N, 0);
    modpow10[0] = 1;
    for(int i = 1; i < N; i++) {
        modpow10[i] = (10 * modpow10[i - 1]) % 13;
    }

    // rep(i, N) cout << modpow10[i] << " ";
    // cout << endl;

    vector<vector<ll>> DP(N, vector<ll>(13, 0LL));
    // cout << (S[N - 1] - '0') << endl;
    if(S[N - 1] == '?') {
        rep(j, 10) {
            int x = j * modpow10[0] % 13;
            DP[0][x] = 1;
        }
    } else {
        int x = (S[N - 1] - '0') * modpow10[0] % 13;
        DP[0][x] = 1;
    }

    for(int i = 1; i < N; i++) {
        if(S[N - 1 - i] == '?') {
            rep(j, 10) {
                int x = j * modpow10[i] % 13;
                rep(k, 13) {
                    int y = (k + x) % 13;
                    DP[i][y] = (DP[i][y] + DP[i - 1][k]) % MOD;
                }
            }
        } else {
            int x = (S[N - 1 - i] - '0') * modpow10[i] % 13;
            rep(k, 13) {
                int y = (k + x) % 13;
                DP[i][y] = (DP[i][y] + DP[i - 1][k]) % MOD;
            }
        }
    }

    cout << DP[N - 1][5] << endl;
}

Measured memory_bytes: 17480
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn = 101000;

int a[maxn];

int main() {
	ios::sync_with_stdio(0);
	int n, x; cin>>n>>x; rep(i, 0, n) cin>>a[i];
	ll ans = 0;
	rep(i, 1, n) {
		if(a[i] + a[i - 1] > x) {
			int delta = a[i] + a[i - 1] - x;
			a[i]  -= min(a[i], delta);
			ans += delta;
		}
		
	}
	cout<<ans<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n;
    long int a=0;
    cin>>n;
    vector <int> d(n);
    
    for(int i=0;i<n;i++){
        d.at(i)=i+1;
    }
    
    for(int i=0;i<n;i++){
        if(d.at(i)%3==0||d.at(i)%5==0){
            
        }else{
            a+=d.at(i);
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 7168
ans = Array.new

loop do
	a,b,c = gets.split.map(&:to_i)
	if a==0&&b==0&&c==0
		break
	end
	ok = Array.new
	ng = Array.new
	n = gets.to_i
	list = Array.new
	n.times do 
		n1,n2,n3,r=gets.split.map(&:to_i)
		if r==1
			ok.push(n1)
			ok.push(n2)
			ok.push(n3)
		else
			list.push([n1,n2,n3])
		end
	end
	ok.uniq!
	ok.sort!
	
	
	list.each do |v|
		if ok.include?(v[0])&&ok.include?(v[1])||ok.include?(v[0])&&ok.include?(v[2])||ok.include?(v[1])&&ok.include?(v[2])
			3.times do |i|
				if !ok.include?(v[i])
					ng.push(v[i])
				end
			end
			
		end

	end
	ng.uniq!
	ng.sort!
	
	(a+b+c).times do |num|
		if ok.include?(num+1)
			ans.push(1)
		elsif ng.include?(num+1)
			ans.push(0)
		else
			ans.push(2)
		end
	end

end

ans.each do |v|
	puts v
end

Measured memory_bytes: 8836
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(a:usize, b:usize);
    println!("{}", a * b);
}


Measured memory_bytes: 2124
#include "stdio.h"
int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	int maior = A + B;

	if(A - B > maior){ 
		maior = A - B;
	}		

	if(A * B > maior){ 
		maior = A * B; 	
	}
	
	printf("%d", maior);

	return 0;
}

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)
#define PI 3.14159265358979323846264338327950L

// -----



int main()
{
    ll n;
    cin >> n;
    pl(n+n*n+n*n*n);
}

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

int main() {
  ll n; cin >> n;
  vector<ll> t(5);
  rep(i,5) cin >> t[i];
  ll bn = *min_element(t.begin(),t.end());
  ll ans = 5;
  if (n>bn) {
    ans = n/bn + 4;
    if (n > (n/bn) * bn) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int n; cin >> n;
  string s1; cin >> s1;
  string s2; cin >> s2;

  ll ans = 1;
  int st = -1;
  rep(i, n) {
    if (s1[i] == s2[i]) {
      if (st == -1) {
        ans *= 3;
      } else if (st == 0) {
        ans *= 2;
      } else {
        ans *= 1;
      }
      st = 0;
    } else {
      i++;
      if (st == -1) {
        ans *= 6;
      } else if (st == 0) {
        ans *= 2;
      } else {
        ans *= 3;
      }
      st = 1;
    }
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  long long X;
  cin >> X;
  long long buffer=100;
  long long i=0;
  while(buffer<X){
    buffer = buffer + (buffer/100);
    i++;
  }
  cout << i << endl;
  return 0;
}


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

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

    int r = round(sqrt(n));
    long long ans = LLONG_MAX;
    for (int i = 1; i <= r; i++) {
        if (n%i == 0) {
            long long tmp = i-1 + n/i-1;
            ans = min (ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
l,r=input2()


if (r-l)>=2019:
	print(0)
else:
	ans=2019
	for i in range(l,r):
		for j in range(i+1,r+1):
			ans=min(ans,(i*j)%2019)
	print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int MOD  = 1e9+7;

int n, a, k;
int dp[100005];
int h[100005];

int32_t main() {
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a;	
		h[i] = a;
	}
	for (int i = 0; i <= n; i++){
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	// cout << "0 " << 0 << endl;
	for (int i = 1; i <= k; i++){
		for (int j = 1; j <= i; j++){
			dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]), dp[i]);
		}
		// cout << i << " " << dp[i] << endl;
	}
	dp[1] = abs(h[1]-h[0]);
	for (int i = k+1; i < n; i++){
		for (int j = 1; j <= k; j++){
			dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]), dp[i]);
		}
		// cout << i << " " << dp[i] << endl;
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution

int32_t main()
{
    IOS

    
    int n,m;
    cin>>n>>m;
    int a[n+1];
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    double te=(double)sum/(double)(4*m);
    
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=te)
        {
            ans++;
        }
    }
    if(ans>=m)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}       

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

#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> ab(n), cd(n);
    int a, b;
    rep(i, n){
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    rep(i, n){
        cin >> a >> b;
        cd[i] = make_pair(a, b);
    }
    sort(cd.begin(), cd.end());
    int ans = 0;
    rep(i, n){
        vector<pair<int, int>> tmp;
        rep(j, ab.size()){
            if(cd[i].first > ab[j].first && cd[i].second > ab[j].second) tmp.push_back(make_pair(-1 * ab[j].second, j));
        }
        if(!tmp.empty()){
            sort(tmp.begin(), tmp.end());
            ab.erase(ab.begin() + tmp[0].second);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

int N[10001]={};
long a=0,s=0;
int n;

while(1){
scanf("%d",&n);
if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&N[i]);

for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(N[j]<N[j-1]){int t=N[j];N[j]=N[j-1];N[j-1]=t;}

//if(n==1)s=0;
//else{
for(int i=1;i<n;i++)
{
a=a+N[i-1];s+=a;
}

//}
printf("%ld\n",s);
a=0;s=0;
for(int i=0;i<n;i++)
	N[i]=0;
}
return 0;
}

Measured memory_bytes: 1076
#include<stdio.h>
int main(){
  int a,b,c,min,mid,max;
  scanf("%d%d%d",&a,&b,&c);
  min=(a<b)?a:b;
  min=(min<c)?min:c;
  max=(a>b)?a:b;
  max=(max>c)?max:c;
  mid=a+b+c-min-max;
  if(min==mid&&mid==max){
    printf("1");
  }
  else if(min==mid||mid==max){
    printf("2");
  }
  else{
    printf("3");
  }
  return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    if(N > M) swap(N,M);
    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }

    if(N == 1 && M >= 2){
        cout << M-2 << endl;
        return 0;
    }

    cout << ll(N-2) * (M-2) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] coin = new int[100001];
	public static void main(String[] args) {
		maketable();
		int N = sc.nextInt();
		System.out.println(coin[N]);
	}
	static void maketable() {
		int i,k;
		for(i = 0;i <= 100000;i ++) {
			coin[i] = i;
		}
		int s = 6,n = 9;
		while(s <= 100000 || n <= 100000) {
			for(k = s;k <= 100000;k++) {
				if(coin[k] > coin[k-s]+1) coin[k] = coin[k-s] + 1;
			}
			for(k = n;k <= 100000;k++) {
				if(coin[k] > coin[k-n]+1) coin[k] = coin[k-n] + 1;
			}
			s = s * 6; n = n * 9;
		}
	}
}

Measured memory_bytes: 23252