akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int n, m, ct;
vvi graph;
vi used;

void dfs(int a){
    used[a] = true;
    rep(i, graph[a].size()){
        if(!used[graph[a][i]])
            dfs(graph[a][i]);
    }

}

int main(){
    cin >> n >> m;
    graph = vvi(n);
//    cout << graph[0].size() << endl;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    rep(i, n)
        sort(graph[i].begin(), graph[i].end());
//    cout << graph[0].size() << endl;
    rep(i, n){
    //    cout << graph[0].size() << endl;
        rep(j, graph[i].size()){
            rep(k, n)
            sort(graph[k].begin(), graph[k].end());
            int va = graph[i][j];
            //cout << "i == " << i << " " << va << endl;
            graph[i].erase(graph[i].begin() + j);
            rep(k, graph[va].size())
                if(graph[va][k] == i)
                    graph[va].erase(graph[va].begin() + k);
            used = vi(n);
            dfs(0);
            rep(k, n)
                if(!used[k]){
                    ct++;
                    break;
                }
            graph[i].push_back(va);
            graph[va].push_back(i);
        }
    }
    cout << ct / 2 << endl;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}


int main(){
    ll n; cin >> n;
    ll sum = 0;
    vector<ll> r = divisor(n);
    for(auto i : r){
        ll c = i-1;
        if(c == 0){continue;}
        if(n/c == n%c){
            sum += c;
        }
    }
    cout << sum << endl;
}

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

int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	int b=1;
	string ans="";
	while(n!=0){
		if(abs(n)&abs(b)){
			ans='1'+ans;
			n-=b;
		}
		else{
			ans='0'+ans;
		}
		b=b*-2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int n, a[100010];

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    
    int x = a[n-1], i=-1;
    for(int j=0; j<n; j++){
        if(a[j]<=x){
            ++i;
            int tmp = a[j];
            a[j] = a[i];
            a[i] = tmp;
        }
    }
    for(int j=0; j<n; j++){
        if(j==i){
            printf("[%d]", a[j]);
        }else{
            printf("%d", a[j]);
        }
        if(j==n-1)
            printf("\n");
        else{
            printf(" ");
        }
    }
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int now = 999;
  while(now-N>=0){
		now-=111;
	}
	cout << now+111 <<endl;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
} read;

const int maxn = 3030, mod = 1000000007;
int a[maxn];
ll f[maxn][maxn];

int main () {
	int n = read, q = read;
	for (int i = 1; i <= n; i ++) a[i] = read;
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++)
			f[i][j] = a[i] > a[j];

	ll coe = 1, i2 = (mod + 1) >> 1;
	while (q --) {
		int x = read, y = read;
		for (int i = 1; i <= n; i ++)
			if (i != x and i != y)
				f[i][y] = f[i][x] = i2 * (f[i][x] + f[i][y]) % mod;
		for (int i = 1; i <= n; i ++)
			if (i != x and i != y)
				f[y][i] = f[x][i] = i2 * (f[x][i] + f[y][i]) % mod;
		f[y][x] = f[x][y] = i2 * (f[x][y] + f[y][x]) % mod;
		(coe <<= 1) %= mod;
	}

	/* for (int i = 1; i <= n; i ++) { */
	/* 	for (int j = 1; j <= n; j ++) */
	/* 		debug(" %lld", f[i][j]); */
	/* 	debug("\n"); */
	/* } */

	ll sum = 0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			sum += f[i][j];
	sum %= mod;
	printf("%lld\n", sum * coe % mod);
}


Measured memory_bytes: 71808
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;

int n, m;
vector<int> eg[200005];
bool vis[200005];

bool bfs()
{
    queue<int> q;
    q.push(1);
    q.push(0);
    vis[1] = 1;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        int d = q.front();
        q.pop();
        if(u == n)
        {
            if(d <= 2)
                return true;
            return false;
        }
        for(int i = 0;i < eg[u].size();i++)
        {
            int v = eg[u][i];
            if(!vis[v])
            {
                vis[v] = 1;
                q.push(v);
                q.push(d + 1);
            }
        }
    }
    return false;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1, a, b;i <= m;i++)
    {
        scanf("%d%d", &a, &b);
        eg[a].push_back(b);
        eg[b].push_back(a);
    }
    if(bfs())
        puts("POSSIBLE");
    else
        puts("IMPOSSIBLE");
    return 0;
}


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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum += m[i];
    }
    x -= sum;
    sort(m.begin(),m.end());
    int a = m[0];

    cout << n + x/a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	void run(){
		
		int n = sc.nextInt();	
		int a[] = new int[n];
	
		for(int i =0 ; i < n ; i++){
			a[i] = sc.nextInt();
		}
		
		
		int l = 0;
		int r = 0;
		
		int sum = 0;
		
		long res = 0;
		
		for(;;){
//			System.out.println(l+" "+r+" "+sum);
			if((sum & a[r]) == 0){
				
				sum |= a[r];
				r++;
				
				res += r-l;
				if(r >= n){
					break;
				}
				
			}else{
				
				sum -= a[l];
				l++;
			}
		}
		
		System.out.println(res);
		
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}


Measured memory_bytes: 83460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
//const long long mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


const int mod = 1000000007;
const int MAX = 300001;
 
ll fc[MAX];
ll fci[MAX];
 
long long powmod(ll a,ll b){
  return b?powmod(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
 
void init_fact() {
    fc[0] = fc[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fc[i] = (fc[i-1] * i) % mod;
    }
    fci[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fci[i] = (fci[i-1] * powmod(i, mod-2)) % mod;
    }
}
 
ll C(ll n, ll k) {
    if (k == 0 || n == k) return 1;
    if(k < 0 || k > n) return 0;
    return ((fc[n] * fci[k] % mod) * fci[n-k]) % mod;
}
 
ll add(ll a, ll b) { return (a + b) % mod; }
ll sub(ll a, ll b) { return (a - b + mod) % mod; }
ll mul(ll a, ll b) { return (a * b) % mod; }
 
int main() {
    init_fact();
    int n, K; cin >> n >> K;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));

    ll res = 0;
    // A[i]が最大値として選ばれる
    for (int i=0; i<n; ++i) {
        res = add(res, mul(a[i], C(i, K-1)));
    }
 
    // A[i]が最小値として選ばれる
    reverse(a.begin(), a.end());
    for (int i=0; i<n; ++i) {
        res = sub(res, mul(a[i], C(i, K-1)));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5376
while True:
    H, W = map(int, input().split())
    if H == 0:
        break
    for i in range(H):
        S = ""
        for j in range(W):
            if (i+j) % 2 == 0:
                S += "#"
            else:
                S += "."
        print(S)
    print()



Measured memory_bytes: 5616
import sys
sys.setrecursionlimit(1000000)
n,m = map(int,input().split())
bn = [[int(i) for i in input().split()]+[j] for j in range(m)]
ans = [0]*m
bn.sort()
temp = 0
cnt = 0

for i in bn:
  if temp == i[0]:
    cnt += 1
    ans[i[2]] = str(temp * 1000000 + cnt).zfill(12)
  else:
    temp = i[0]
    cnt = 1
    ans[i[2]] = str(temp * 1000000 + cnt).zfill(12)    
for j in ans:
  print(j)

Measured memory_bytes: 31296
#include<stdio.h>
#define N 250

typedef struct{
  int key;
  int par;
  int left;
  int right;
}node;

void ndset(int,int);

node T[N];
int main(){
  int i,n;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)T[i].par=-1;
  
  for(i=0;i<n;i++)scanf("%d",&T[i].key);
  
  for(i=0;i<n;i++){
    
    if(i!=0)T[i].par=(i+1)/2-1;
    
    if(2*(i+1)-1<n)T[i].left=2*(i+1)-1;
    
    else T[i].left=-1;
    
    if(2*(i+1)<n)T[i].right=2*(i+1);
    
    else T[i].right=-1;
  }
  
  for(i=0;i<n;i++){

    printf("node %d: key = %d, ", i+1, T[i].key);
    
    if(T[i].par!=-1) printf("parent key = %d, ",T[T[i].par].key);
    
    if(T[i].left!=-1) printf("left key = %d, ",T[T[i].left].key);
    
    if(T[i].right!=-1) printf("right key = %d, ",T[T[i].right].key);
    
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]), k = Integer.parseInt(line[1]);
        int[] p = new int[n];
        line = br.readLine().split(" ");
        for (int i = 0; i < n; ++i) {
            p[i] = Integer.parseInt(line[i]);
        }

        Queue<Integer> heap = new PriorityQueue<>(Comparator.comparingInt(a -> -a));

        for (int i = 0; i < n; ++i) {
            if (heap.size() < k) {
                heap.add(p[i]);
            } else {
                if (heap.peek() > p[i]) {
                    heap.remove();
                    heap.add(p[i]);
                }
            }
        }

        int res = 0;

        for (int price: heap) {
            res += price;
        }

        bw.write(Integer.toString(res));
        bw.newLine();

        bw.close();
        br.close();
    }
}


Measured memory_bytes: 34312
s=input()
n=len(s)
a=[0]*n
e,o=0,0
for i in range(n):
  if s[i]=='R':
    e+=1
    e,o=o,e
  else:
    a[i]+=e
    a[i-1]+=o
    e,o=0,0
for i in range(n):
  if s[n-i-1]=='L':
    e+=1
    e,o=o,e
  else:
    a[n-i-1]+=e
    a[n-i]+=o
    e,o=0,0
print(*a)

Measured memory_bytes: 47548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        StringBuilder s1 = new StringBuilder();
        StringBuilder s2 = new StringBuilder();
        for(int i=0; i<b; i++) {
            s1.append(a);
        }
        for(int i=0; i<a; i++) {
            s2.append(b);
        }

        if(s1.toString().compareTo(s2.toString()) < 0) {
            System.out.println(s1.toString());
        } else {
            System.out.println(s2.toString());
        }

    }
}


Measured memory_bytes: 21076
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int[] AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    if (AB[0]%AB[1] == 0) {
      Console.WriteLine(0);
    } else {
      Console.WriteLine(1);
    }
  }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<cmath>
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<ll,ll> LLP;
const int MAXN=2e5+10;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const int MOD=1e9+7;
const int LOGN=20;
int arr[MAXN];
int ans[MAXN];
signed main()
{
    int n,k;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
        scanf("%d",&arr[i]);
    for(int i=1;i<=n;++i)
        ans[arr[i]]=i;
    for(int i=1;i<n;++i)
        printf("%d ",ans[i]);
    printf("%d\n",ans[n]);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int table[110][110];

int main(){
  ll a,b;cin>>a>>b;
  cout<<100<<" "<<100<<endl;
  rep(i,100){
  	rep(j,100){
  		if(i<50){
  			table[i][j]=1;
  		}
  	}
  }
  a--;
  b--;
  rep(i,50){
  	if(i%2==0){
	  	rep(j,100){
	  		if(a==0){
	  			break;
	  		}
	  		if(j%2==0){
	  			table[i][j]=0;
	  			a--;
	  		}
	  	}
	  }
  }
  FOR(i,50,100){
  	if(i%2==1){
	  	rep(j,100){
	  		if(b==0){
	  			break;
	  		}
	  		if(j%2==0){
	  			table[i][j]=1;
	  			b--;
	  		}
	  	}
	  }
  }

	rep(i,100){
  	rep(j,100){
  		if(table[i][j]==0){
  			cout<<".";
  		}else{
  			cout<<"#";
  		}
  	}
  	cout<<endl;
  }  

  return 0;
}

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

int main() {
  int N, M, i, j;
  std::cin >> N >> M;
  
  int s[M], c[M];
  for (i = 0; i < M; i++) {
    std::cin >> s[i] >> c[i];
  }
  
  int A[N][2];
  int B = 0;
  for (i = 0; i < N; i++) {
    A[i][0] = 0;
    A[i][1] = 0;
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      if (s[j]-1 == i) {
        if (A[i][0] == 0) {
          A[i][0] = 1;
          A[i][1] = c[j];
        } else {
          if (A[i][1] != c[j]) {
            B = -1;
            i = N;
            j = M;
          }
        }
      }
    }
  }
  
  if (B == 0) {
    for (i = 0; i < N; i++) {
      if (A[i][0] == 0) {
        if ((i == 0) && (N != 1)) {
          B += std::pow(10, N-i-1);
        }
      } else {
        if ((i == 0) && (N != 1) && (A[i][1] == 0)) {
          B = -1;
          break;
        }
        B += A[i][1] * std::pow(10, N-i-1);
      }
    }
  }
  std::cout << B << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char s[100][101];

int cmpstr(const void * a, const void * b) {
    //const char *x = a, *y = b;
    return strcmp(a, b);
    //return 0;
}

int cmpindices(const void * a, const void * b) {
    const int *x = a, *y = b;
    return strcmp(s[*x], s[*y]);
}

int main() {
    int n, l;

    scanf("%d %d", &n, &l);

    int indice[n];

    //printf("%p %p %p\n", s, s[0], s[n-1]);

    for(int i = 0; i < n; ++i) {
        scanf("%s", s[i]);
        indice[i] = i;
    }

    // ordenar as strings
    //qsort(s, n, sizeof(s[0]), cmpstr);
    qsort(indice, n, sizeof(indice[0]), cmpindices);

    for(int i = 0; i < n; ++i)
        printf("%s", s[indice[i]]);
    printf("\n");










    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
  
#define AMAX 20
#define MMAX 200
 
int A[AMAX+1];
int n, q;

int solve_loop( int p, int t, int res )
{
	return  ( p <= n ) ? solve_loop( p+1, t-A[p],  !t ) || solve_loop( p+1, t,  !t  ): res;
}
int solve( int p, int t )
{
	return  solve_loop( p, t, 0 );
}
 
int main( void ) 
{
    int i;
    int num;
     
    scanf( "%d", &n );  
    for( i=0; i<n; i++ ) {
        scanf( "%d", &A[i] );
    }   
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
        if( solve( 0, num ) ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
    return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int[] x = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    System.out.println(x[k-1]);
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include<cmath>
#include<cstring>

int main() {
	int n;
	scanf("%d",&n);
	long long numbers[99] = {2,1};
	for (int i = 2; i <= n;i++) {
		numbers[i] = numbers[i - 1] + numbers[i - 2];
	}
	printf("%lld\n",numbers[n]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, s;
    cin >> n >> s;
    int a[n];
    rep(i,n)cin >> a[i];
    ll MOD = 998244353;
    ll dp[n][3001];

    rep(i,n){
        rep(j,3001){
            if(i == 0){
                dp[i][j] = 0;
                if(j == 0) dp[i][j] = 2;
                if(j == a[i]) dp[i][j] = 1;
            }else{
                dp[i][j] = dp[i-1][j];
                if(j == 0)dp[i][j]++;
                if(a[i] <= j) dp[i][j] += dp[i-1][j-a[i]];
                dp[i][j] %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(i,n){
        ans += dp[i][s];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 70656
from string import digits

n = int(input())
s = input()

cnt = 0
for i in digits:
    x = s.find(i)
    if x == -1:
        continue
    for j in digits:
        y = s.find(j, x + 1)
        if y == -1:
            continue
        for k in digits:
            z = s.find(k, y + 1)
            if z == -1:
                continue
            cnt += 1

print(cnt)

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

int main(){
  string s,t;
  cin >> s >> t;
  if(s.size() > t.size()) cout << "GREATER" << endl;
  else if(s.size() < t.size()) cout << "LESS" << endl;
  else{
    rep(i,0,s.size()){
      if(s[i] > t[i]){
        cout << "GREATER" << endl;
        return 0;
      }
      else if(s[i] < t[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }

    cout << "EQUAL" << endl;
  }
}

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

int main() {
    int N, Y, t1=-1, t2=-1, t3=-1;
    cin >> N >> Y;
    for (int i=0;i<=N;i++) {
        for (int j=0;j<=N-i;j++) {
            int k = N-i-j;
            int sol = 10000*i + 5000*j + 1000*k;
            if (sol == Y) {
                t1 = i, t2 = j, t3 = k;
            }
        }
    }
    printf("%d %d %d", t1,t2,t3);
}


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

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

void factorize(ll n, unordered_map<ll, ll>& out){
    out.clear();
    while(n % 2 == 0){
        out[2]++;
        n /= 2;
    }
    for(ll p = 3; p * p <= n; p += 2){
        while(n % p == 0){
            out[p]++;
            n /= p;
        }
    }
    if(n > 2){
        out[n]++;
    }
}

void solve(long long N, std::vector<long long> A){
    unordered_map<ll, ll> m;
    for(const auto x : A){
        unordered_map<ll, ll> tmp;
        factorize(x, tmp);
        for(auto it = tmp.begin(); it != tmp.end(); ++it){
            m[it->first] = max(m[it->first], it->second);
        }
    }
    mint l = 1;
    for(auto it = m.begin(); it != m.end(); ++it){
        REP(j, it->second){
            l *= it->first;
        }
    }
    mint ans = 0;
    for(const auto x : A){
        ans += l / x;
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(a-b*2 <=0){
		cout<<0<<endl;
	}else{
		cout<<a-b*2<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[3*N];
    for (int i = 0; i < 3*N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    long ans = 0;
    for (int i = N; i < 3*N; i+=2) {
      ans += a[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 92156
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(auto &a:A){
        cin >> a;
    }
    for(auto &b:B){
        cin >> b;
    }

    int b=0;
    vector<int> achieved(N,0);
    int cnt=0;
    ll ans=0;
    int tmp=0;
    while(cnt<N){
        if(tmp==N){
            cout << -1 << endl;
            return 0;
        }
        int a=(N+b-1)%N;
        int c=(N+b+1)%N;
        //cout << a << ' ' << b << ' ' << c << ' ' << tmp << endl;
        if(achieved[b]==0 && B[b]==A[b]){
            achieved[b]=1;
            cnt++;
            b=(b+1)%N;
            continue;
        }else if(B[b]<A[b]){
            cout << -1 << endl;
            return 0;
        }

        if(B[b]>B[a]+B[c]){
            if((B[b]-A[b])%(B[a]+B[c])==0){
                ans+=(ll)(B[b]-A[b])/(B[a]+B[c]);
                B[b]=A[b];
            }else{
                ans+=(ll)B[b]/(B[a]+B[c]);
                B[b]%=(B[a]+B[c]);
            }
            tmp=0;
        }else{
            tmp++;
        }
        b=(b+1)%N;
        //cout << ans << endl;
        //cout_vec(B);
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  int x[N][N], y[N][N];
  for (int i=0;i<N;i++) {
    cin >> A[i];
    for (int j=0;j<A[i];j++) {
      cin >> x[i][j] >> y[i][j]; //i+1がx[i][j](j番目の供述)がy[i][j]だと言っている
    }
  }
  //正直者の証言が嘘だったらダメ
  int ans = 0;
  for (int bit=0;bit < 1<<N;bit++) { //bitは誰が正直者で誰が嘘つきかを表す
    int count=0;
    bool flag = true;
  	for (int i=0;i<N;i++) {
      if (bit>>i &1) count += 1;
    }
    for (int i=0;i<N;i++) {
      if (bit>>i&1){ //i+1が正直者だったら
        for (int j=0;j<A[i];j++) {
          if (y[i][j]^bit>>(x[i][j]-1) & 1) flag = false;
        }
      } 
    }
    
    if (flag) ans = max(ans,count);
  }
      
  cout << ans << endl;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
 int N;
 int A[100000];
 int mult[3]={0,};
 cin>>N;
 fx(N){
 cin>>A[x];	
 if(A[x]%4==0){
 	mult[0]++;
 }else if(A[x]%2==0){
 	mult[1]++;
 }else{
 	mult[2]++;
 }
}
 
 if(mult[0]+1>=mult[1]+mult[2]){
 	ce("Yes");
 }else{
 	if((mult[2]>mult[0]+1&&mult[1]==0)||(mult[2]>mult[0]&&mult[1]%2==1)){
 		ce("No");
 	}else{
 		ce("Yes");
 	}
 }
 
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define forup(i,a,b) for (int i = a; i < b; i++)
#define fordown(i,a,b) for (int i = b-1; i >= a; i--)
#define foreach(i,c) for (auto &i: (c))
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#ifdef DEBUG
#define dump(v) cerr << "["#v << ":" << (v) << "]";
#else
#define dump(v)
#endif
#define endl "\n"
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
const ll MOD = (1e9+7);
const ll INF = (1e9+123456789);
const ll INFL = (INF*INF);
inline ll addm(ll a, ll b, ll m = MOD) {return ((a+b)%m);}
inline ll subm(ll a, ll b, ll m = MOD) {return (((a-b)%m+m)%m);}
inline ll mulm(ll a, ll b, ll m = MOD) {return ((a*b)%m);}
ll powm(ll a, ll b, ll m = MOD) {ll ret=(!b)?1:powm(a, b/2);return (!b)?1:mulm(mulm(ret,ret,m),b%2?a:1,m);}
ll gcd(ll a, ll b) {return (!b)?a:gcd(b,a%b);}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
ll inv(ll x, ll m = MOD) {return powm(x,m-2,m);}

int vis[505], sum[505];

void solve()
{
    int n;
    cin >> n;
    int s = (n*(n+1))/2;
    vector<pii> edge;
    if (s%2) {
        if (s%n == 0) {
            fordown(i, 1, n) fordown(j, i+1, n) {
                if (i != j && i+j != n) edge.emplace_back(i, j);
            }
            fordown(i, 1, n) edge.emplace_back(i, n);
        }
        else {
            fordown(i, 1, n+1) fordown(j, i+1, n+1) {
                if (i+j != (n+1)) edge.emplace_back(i, j);
            }
        }
    }
    else {
        s /= 2;
        fordown(i, 1, n+1) {
            if (s >= i) {
                s -= i;
                vis[i] = 1;
            }
        }
        forup(i, 1, n+1) if (vis[i]) {
            forup(j, 1, n+1) if (!vis[j]) edge.emplace_back(i, j);
        }
    }
    cout << sz(edge) << endl;
    foreach(x, edge) {
        cout << x.first << " " << x.second << endl;
        sum[x.first] += x.second;
        sum[x.second] += x.first;
    }
    /* set<int> st; */
    /* forup(i, 1, n+1) { */
    /*     st.insert(sum[i]); */
    /*     cerr << i << " " << sum[i] << endl; */
    /* } */
    /* assert(st.size() == 1); */
}

int main(int argc, char *argv[])
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l.append(list(map(int,input().split())))
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    swi=[]
    for _ in range(n):
        swi.append(i%2)
        i=i//2
    all=0
    for j in range(m):
        cnt=0
        for s in range(1,l[j][0]+1):
            if swi[l[j][s]-1]==1:
                cnt+=1
        if cnt%2==p[j]:
            all+=1
    if all==m:
        ans+=1
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		scan.close();
		
		// 0がaになり、1大きい数が渡されるけど、アルファベットだけの26進数にしてね
		System.out.println(convertOriginalShinsuStr(n, 'a', 1, 26));
		
//		for(long n = 1; n < 704 ; n ++) {
//			System.out.println(convertOriginalShinsuStr(n, 'a', 1, 26));
//		}
		
	}
	
	/**
	 * 10進数をオリジナル進数(アルファベット)文字列に変換
	 * @param dNum 変換する10進数
	 * @param origin 10進数の0をオリジナル進数で変換した後の文字
	 * @param offset オリジナル変数の0に何を足せば10進数の0になるか？
	 * @param baseNumber 何進数に変換するの
	 * @return オリジナル進数(アルファベット)文字列
	 */
	public static String convertOriginalShinsuStr(
			long dNum, final char origin, final int offset, final int baseNumber) {
		
		// 終わってますやん
		if(dNum <= 0) {
			return "";
		}
		
		// 邪魔なのでオフセットは消化
		dNum -= offset;
		
		// char型とintの足し算で文字を求める
		String ret = String.valueOf((char)(origin + dNum % baseNumber));
		// 小数点以下は切り捨てられる
		dNum /= baseNumber ; 
		
		// 次の位も頼みます
		return convertOriginalShinsuStr(dNum, origin, offset, baseNumber) + ret;
		
	}

}


Measured memory_bytes: 39536
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

ll combination(ll n, ll r) {
    ll nf = 1, rf = 1;
    if (r * 2 > n) r = n - r;
    for (ll i = 1; i <= r; ++i) {
        nf = ((n - r + i) * nf) % MOD;
        rf = (i * rf) % MOD;
    }

    return (nf / rf);
}

ll kaijo(ll a) {
    ll ans = 1;
    for (ll i = 2; i <= a; ++i) {
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

ll kaijo2(ll n, ll a) {
    ll ans = 1;
    for (ll i = 0; i < a; ++i) {
        ans *= (n - i);
        ans %= MOD;
    }

    return ans;
}

ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int main(void) {
    cin >> n;

    if (n % 2) {
        cout << n / 2 + 1 << endl;
    }
    else {
        cout << n / 2 << endl;
    }

    return 0;
}



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

int n,m,q;
vector<int> a,b,c,d;
int ans = 0;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]]-A[a[i]]==c[i]) {
        now += d[i];
      }
    }
    ans = max(ans,now);

    return;
  }
  A.push_back(A.back());
  while (A.back() <= m ) {
    dfs(A);
    A.back()++;
  }

  //cout << now << endl;

  
}

int main() {
  
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vector<int> A(1);
  A[0] = 1;
  dfs(A);
  cout << ans;

}


Measured memory_bytes: 3620
#include <iostream>
#include <limits.h>
#define ll long long
using namespace std ;

ll dampode (int n, ll dp[], int ht[])
{
    if(n==0) return INT_MAX;
    if(n==1) return 0;
    
    if(dp[n] == -1)
    {
        ll ans = min(dampode(n-1, dp,ht)+abs(ht[n]-ht[n-1]), dampode(n-2, dp,ht)+abs(ht[n]-ht[n-2]));
        dp[n] = ans;
        return ans;
    }
    else return dp[n];
}

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

    /*for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        ht.push_back(a);
    }
    ht.insert(ht.begin(),INT_MAX);
    vector<ll> dp (-1, n+1);
    //memset(dp, -1, sizeof(dp));
    for(int i=0;i<=n;i++)
    {
        cout<<ht[i]<<" ";
    }*/
    
    int ht[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>ht[i];
    }
    ll dp[n+1];
    for(int i=0;i<=n;i++)
    {
        dp[i]=-1;
    }
    cout<<dampode(n, dp, ht)<<endl;
    
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  
  bool ac[n];
  int wa[n];
  int account=0;
  int wacount=0;
  
  rep(i,n) {
    ac[i] = false;
    wa[i] = 0;
  }
  
  rep(i,m) {
    int p; cin>>p;
    string s; cin>>s;
    
    if(ac[p-1]) continue;
    
    if(s=="AC") {
      ++account;
      ac[p-1] = true;
      wacount += wa[p-1];
    } else if (s=="WA") {
      ++wa[p-1];
    }
  }
  
  
  cout<<account<<" "<<wacount;
  
}

Measured memory_bytes: 4108
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s1,s2;
    vector<int> v;
    cin>>n>>m;
    int a[n];
    rep(i,0,n)
    a[i]=0;
    int h[n];
    rep(i,0,n) cin>>h[i];
    ans=n;
    rep(i,0,m){
        cin>>p>>q;
        if(h[q-1]<=h[p-1]){
        a[q-1]++;
        if(a[q-1]==1)
        ans--;;
        }
        if(h[p-1]<=h[q-1]){
        a[p-1]++;
        if(a[p-1]==1)
        ans--;;
        }
    }
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 5128
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a;
    cin>>a;
    long long cou=1;
    long long ans=0;
    while(a>1){
        a/=2;
        ans+=cou;
        cou*=2;
    }
    ans+=cou;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int):
    if 1 not in [A, B]:
        print(1)
    elif 2 not in [A, B]:
        print(2)
    else:
        print(3)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }
    return ret;
}

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

    int n, k;
    cin >> n >> k;

    vector <mint> vec(k + 1);
    for (int i = 1; i <= k; i++) {
        mint x(k / i);
        vec[i] = x.pow(n);
    }

    for (int i = k; i; i--) {
        auto div = divisor(i);
        for (int d : div) {
            if (d == i) continue;
            vec[d] -= vec[i];
        }
    }

    mint ans(0);
    for (int i = 1; i <= k; i++) {
        ans += vec[i] * i;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll gcd(ll a, ll b){
    if (a < b) swap(a, b);
    ll r = a % b;
    while(r){
        a = b, b = r;
        r = a % b;
    }
    return b;
}
int main() {
    init();
    ll s, t;
    cin >> s >> t;
    string S, T;
    cin >> S >> T;

    ll gc = gcd(s, t);
    ll ds = s / gc, dt = t / gc;

    bool isok = true;
    rep(i,gc){
        if (S[i * ds] != T[i * dt]) isok = false;
    }

    cout << (isok ? s * t / gc : -1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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 main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }
    ll per=N*(N+1)/2;
    if (sum%per!=0){
        cout << "NO" << endl;
        return 0;
    }
    ll round=sum/per,c=0;
    rep(i,N){
        ll a=A[(i+1)%N]-A[i];
        if ((round-a)%N!=0||a>round){
            cout << "NO" << endl;
            return 0;
        }
        c+=(round-a)/N;
    }
    if (c==round){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
import math
import fractions

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

# 約数リスト
l = []
x = fractions.gcd(a,b)
for i in range(1, x):
    if i ** 2 > x : break
    if x % i == 0:
        l.append(i)
        if i != x // i:
            l.append(x//i)

if l == []:
    l.append(1)
#print(l)

def isprime(x):
    if x <= 3:
        return True
    elif x % 2 == 0:
        return False
    else:
        i = 3
        while i <= math.sqrt(x):
            if x % i == 0:
                return False
            i = i +2
        return True

ans = []
for i in l:
    if isprime(i):
        ans.append(i)

print(len(ans))


Measured memory_bytes: 66008
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K= Integer.parseInt(sc.next());
		List<Integer> list = new ArrayList();
		for(int i=0; i<N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(list);
//		Collections.reverse(list);
		if(list.size() <= K) {
			System.out.println(0);
			return;
		}
//		for(int i=0; i<K; i++) {
//			list.remove(i);
//		}
		Long count = 0L;
		for(int i=0; i< N-K; i++) {
			count += list.get(i);
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 63896
#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
long long modpow(long long a, long long b){
	a %= MOD;
	long long res = 1;
	while (b > 0){
		if (b % 2 == 1) res = res * a % MOD;
		a = a * a % MOD;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf;
long long modfact(long long n){
	if (n < mf.size()){
		return mf[n];
	} else {
		if (mf.empty()) mf.push_back(1);
		long long res = mf.back();
		for (int i = mf.size(); i <= n; i++){
			res = res * i % MOD;
			mf.push_back(res);
		}
		return res;
	}
}
long long modbinom(long long n, long long r){
	long long res;
	res = modfact(n);
	res = res * modinv(modfact(r)) % MOD;
	res = res * modinv(modfact(n - r)) % MOD ;
	return res;
}
int main(){
  long long N, A, B, K;
  cin >> N >> A >> B >> K;
  long long ans = 0;
  for (int i = 0; i <= N; i++){
    long long R = (K - A * i);
    if (R % B != 0){
      continue;
    }
    long long j = R / B;
    if (j < 0 || j > N){
      continue;
    }
    ans = (ans + modbinom(N, i) * modbinom(N, j) % MOD) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
long long ans(int i,long long cur,long long sum,string s)
{
	if(i==s.size())
	{
		return sum;
	}
	int d=s[i]-'0';
	long long res=0;
	if(i+1!=s.size())
	{
		res+=ans(i+1,cur*10+d,sum,s);
	}
	res+=ans(i+1,0,sum+cur*10+d,s);
	return res;
}
int main()
{
	string s;
	cin>>s;
	cout<<ans(0,0,0,s); 
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<int> c(n);
    rep(i, n) c[i] = a[i] - b[i];
    ll cansub = 0;
    ll mustsub = 0;
    rep(i, n)
    {
        if (c[i] > 0)
        {
            mustsub += c[i];
        }
        else
        {
            cansub -= c[i] / 2;
        }
    }
    cerr << cansub << " " << mustsub << endl;
    if (cansub >= mustsub)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) / 2 + (int)((a + b) % 2) << endl;
}


Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,cnt,k=0,ar[100];
  bool f=false ;
  cin>>a>>b;
   cnt=a*b;
     if(a>9 || b>9)
        cout<<"-1"<<endl;
        else
         cout<<cnt<<endl;



return 0;}


Measured memory_bytes: 256