akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int N;
int arr[1000100];
ll res;
map <int, int> mm;

int main()
{
    ios_base::sync_with_stdio(0);

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

    for (int i = 0; i < N; i++)
        cout << res - mm[arr[i]] + 1 << "\n";
}

Measured memory_bytes: 8320
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	string s;
	cin >> s;
	int ans = INF;
	for (int i = s.size() - 1; i >= 0; i--) {
		vector<int>v;
		int cnt = 0;
		for(int j = 1; j <= i; j++) {
			if (s[i - j] != s[i])cnt++;
			else {
				v.push_back(cnt);
				cnt = 0;
			}
		}
		v.push_back(cnt);
		sort(v.begin(), v.end());
		int top = v[v.size() - 1];
		int n = s.size() - 1 - i;
		int num = max(n, top);
		ans = min(ans, num);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

 
int main(){
    ofstream out("output.txt");

    int p,q,r;
    cin>>p>>q>>r;

    vi a;
    a.pb(p);
    a.pb(q);
    a.pb(r);
    int min = 100000;
    for(int i = 0; i<a.size()-1; i++){
        for(int j = i+1; j<a.size(); j++){
            if(a[i]+a[j] < min){
                min = a[i]+a[j];
            }
        }
    }
    cout<<min<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t,res,re;
  cin>>s>>t;
  rep(i,s.size())res+="z";
  re=res;
  if((int)s.size()-t.size()+1<0){cout<<"UNRESTORABLE"<<endl;return 0;}
  rep(i,(int)s.size()-t.size()+1)
  {
    int f=1;
    rep(j,t.size())
    {
      if(s[i+j]!='?'&&s[i+j]!=t[j])f=0;
    }
    string ts=s;
    if(f)
    {
      rep(j,t.size())ts[i+j]=t[j];
    }
    else continue;
    rep(i,s.size())if(ts[i]=='?')ts[i]='a';
    chmin(res,ts);

  }
  if(res!=re)cout<<res<<endl;
  else cout<<"UNRESTORABLE"<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////

const int units = 63;
ll na[units];
ll nb[units];
ll ans[units];

int main(){
    ll a,b; cin >> a >> b;
    a -= 1;
    FOR(i,1,units){
        ll plus_a=0, plus_b=0;
        if(a%(1LL<<i) >= (1LL<<(i-1))) plus_a = a%(1LL<<i) - (1LL<<(i-1)) +1;
        if(b%(1LL<<i) >= (1LL<<(i-1))) plus_b = b%(1LL<<i) - (1LL<<(i-1)) +1;
        na[i] = a/(1LL<<i)*(1LL<<(i-1)) + plus_a;
        nb[i] = b/(1LL<<i)*(1LL<<(i-1)) + plus_b;
        ans[i] = nb[i] - na[i];
    }
    
    ll fin = 0;
    FOR(i,1,units){
    if(ans[i] % 2 == 1)
        fin = (fin | (1LL<<(i-1))) ;
    }
    cout  << fin;
    return 0;
}


Measured memory_bytes: 256
function Main(input){
  var n = parseInt(input,10);
  if(n % 2 == 0){
    console.log(n);
  }else{
    console.log(n * 2);
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def is_nth_bit_set(x, n):
    if x & (1 << n):
        return 1
    else:
        return 0


N = int(input())
comment = {}
for i in range(N):
    A = int(input())
    comment[i] = []
    for _ in range(A):
        x, y = map(int, input().split())
        x -= 1
        comment[i].append((x, y))

ans = 0
for i in range(2 ** N):
    judge = [None] * N
    flag = True
    for j in range(N):
        honest = is_nth_bit_set(i, j)
        judge[j] = honest

    for j in range(N):
        honest = judge[j]
        if not honest:
            continue
        for x, y in comment[j]:
            if honest:
                if judge[x] == y:
                    continue
                else:
                    flag = False
                    break
    if not flag:
        continue

    tmp = sum(judge)
    if tmp > ans:
        ans = tmp
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100001];
int main()
{
    ll n,m,i,j;
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>a[i];
    if (n==1)
    {
        cout<<abs(a[1]-m)<<endl;
        return 0;
    }
    n++;
    a[n]=m;
    sort(a+1,a+n+1);
    ll ans=a[2]-a[1];
    for(i=2;i<n;i++)
    {
        ans=__gcd(a[i+1]-a[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int  d = Integer.parseInt(sn.next());
        int  t = Integer.parseInt(sn.next());
        int  s = Integer.parseInt(sn.next());
      if (d <= (t * s)){
        System.out.println("Yes");
      } else {
         System.out.println("No");
      }
   }
}


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

using namespace std;

#define int long long

const int N = 1e5 + 100;

vector <int> X[N], Y[N];
int x[N], y[N], par[N];
set <int> s[N], a, b;
int n, ans;

int getPar(int v) {
	return (par[v] == v ? v : par[v] = getPar(par[v]));
}

void merge (int v, int u) {
    v = getPar(v);
    u = getPar(u);
	par[u] = v;
}

int32_t main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		X[x[i]].push_back(i);
		Y[y[i]].push_back(i);
		par[i] = i;
	}
	for (int i = 1; i < N; i++) {
		for (auto v : X[i])
			merge(X[i][0], v);
		for (auto v : Y[i])
			merge(Y[i][0], v);
	}
	for (int i = 0; i < n; i++)
		s[getPar(i)].insert(i);
	for (int i = 0; i < n; i++) {
		if (!s[i].size()) continue;
		for (auto v : s[i]) {
			a.insert(x[v]);
			b.insert(y[v]);
	    }
		ans += a.size() * b.size();
		a.clear(); b.clear();
	}
	return cout << ans - n, 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

#define INF INT_MAX/3

struct state{
  int i,j,t,d;
};
bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

int di[]={-1,0,1,0,0};
int dj[]={0,-1,0,1,0};

int H,W,N;
vector<vector<string> > bs;
int si,sj,ti,tj;
int dist[22][22][201];

bool can(int t,int i,int j){
  if(bs[t][i][j]!='#')return true;
  else return false;
}

int main(){
  cin>>H>>W;
  bs.resize(201);

  int pret=0;
  vector<string> preb(H);
  rep(j,H)cin>>preb[j];
  rep(i,H)rep(j,W){
    if(preb[i][j]=='S'){
      si=i; sj=j;
    }
    if(preb[i][j]=='G'){
      ti=i; tj=j;
    }
  }

  cin>>N;
  rep(i,N){
    int T;
    vector<string> input(H);
    cin>>T;
    rep(j,H)cin>>input[j];
    repl(j,pret,T){
      bs[j]=preb;
    }
    preb=input;
    pret=T;
  }
  repl(j,pret,201)bs[j]=preb;

  rep(i,H)rep(j,W)rep(t,201)dist[i][j][t]=INF;
  priority_queue<state> que;
  que.push((state){si,sj,0,0});
  while(que.size()){
    state s=que.top(); que.pop();
    if(dist[s.i][s.j][s.t]!=INF)continue;
    dist[s.i][s.j][s.t]=s.d;
    if(s.i==ti&&s.j==tj){
      cout<<dist[s.i][s.j][s.t]<<endl;
      return 0;
    }
    rep(dir,5){
      int ni=s.i+di[dir],nj=s.j+dj[dir],nt=min(200,s.t+1);

      if(ni<0||ni>=H||nj<0||nj>=W||!can(nt,ni,nj))continue;

      {
        if(dir==4) que.push((state){ni,nj,nt,s.d});
        else que.push((state){ni,nj,nt,s.d+1});
      }
    }
  }
  cout<<-1<<endl;

}



Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
int n,k,x,y,a,b,posx=0,posy=0,lx=1,ly=1;
int dis(int pos1,int pos2,int pos3,int pos4) {
	return abs(pos3-pos1)+abs(pos4-pos2);
}
int main()
{
	scanf("%d%d%d",&k,&x,&y);
	if(x<0) {
		x=0-x;
		lx=-1;
	}
	if(y<0) {
		y=0-y;
		ly=-1;
	}
	if(k%2==0&&(x+y)%2==1) {
		printf("-1");
		return 0;
	}
	if(x+y==k) {
		printf("1\n");
		printf("%d %d",x*lx,y*ly);
		return 0;
	}
	for(n=2;;++n) {
		if((n*k)%2==(x+y)%2&&n*k>=x+y) {
			a=(n*k+x+y)/2;
			b=(n*k-x-y)/2;
			printf("%d\n",n);
			break;
		}
	}
	while(b>=k) {
		b-=k;
		posx-=k;
		printf("%d %d\n",posx*lx,posy*ly);
	}
	if(b>0) {
		if(posx+(k-b)>x) {
			posx-=b;posy+=(k-b);
		}
		else if(posy+(k-b)>y) {
			posy-=b;posx+=(k-b);
		}
		else {
			int f1=dis(posx-b,posy+k-b,x,y),f2=dis(posx+k-b,posy-b,x,y);
			if(f1<f2&&f1%k==0) {
				posx-=b;posy+=(k-b);
			}
			else {
				posy-=b;posx+=(k-b);
			}
		}
		printf("%d %d\n",posx*lx,posy*ly);
	}
	while(posx+k<=x) {
		posx+=k;
		printf("%d %d\n",posx*lx,posy*ly);
	}
	if(posx!=x) {
		posy+=k-(x-posx);
		posx=x;
		printf("%d %d\n",posx*lx,posy*ly);
	}
	while(posy+k<=y) {
		posy+=k;
		printf("%d %d\n",posx*lx,posy*ly);
	}
	return 0;
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            int A = sc.nextInt();
            if (i%2 == 1 && A%2 == 1) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> team(n);
		for(int i = 0; i < n; ++i)
		{
			int c1, m1, s1, m2, s2, m3, s3, m4, s4;
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			team[i].second = c1;
			team[i].first = (m1 + m2 + m3 + m4) * 60 + (s1 + s2 + s3 + s4);
		}
		sort(team.begin(), team.end());
		cout << team[0].second << endl;
		cout << team[1].second << endl;
		cout << team[n - 2].second << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1236
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        n : usize,
        m : usize,
        k : i64,
        a : [i64; n],
        b : [i64; m]
    }
    let pSumA = iter::once(0)
        .chain(a.into_iter())
        .scan(0, |sum, i| {
            *sum += i;
            Some(*sum)
        })
        .collect::<Vec<i64>>();
    let pSumB = iter::once(0)
        .chain(b.into_iter())
        .scan(0, |sum, i| {
            *sum += i;
            Some(*sum)
        })
        .collect::<Vec<i64>>();
    let mut j = m;

    let res = pSumA
        .iter()
        .take_while(|aSum| **aSum <= k)
        .enumerate()
        .map(|(i, aSum)| {
            while 0 < j && pSumB[j] > k - aSum {
                j -= 1;
            }
            i + j
        })
        .max()
        .unwrap();

    println!("{}", res);
}


Measured memory_bytes: 12068
#include <stdio.h>

int main(){
	int n,i,j,a[100];
	float x1,y1,x2,y2,x3,y3,x4,y4,b,c;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		b=(y2-y1)/(x2-x1);
		c=(y4-y3)/(x4-x3);
		if(b==c){
			a[i]=1;
		}else{
			a[i]=2;
		}
	}
	for(i=0;i<n;i++){
		if(a[i]==1){
			printf("YES\n");
		}else if(a[i]==2){
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 616
/**
 *    author:  FromDihPout
 *    created: 2020-08-06
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    if (x < 30) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int x, y;
    lld value;
}node;

int cmpAsc(const void* a, const void* b){
    lld x = ((node*)a)->value, y = ((node*)b)->value;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    lld a[n+1][n+1];
    lld b[n+1][n+1];
    rep(i, 1, n+1){
        rep(j, 1, n+1){
            scanf("%lld", &a[i][j]);
            b[i][j] = a[i][j];
        }
    }
    rep(k, 1, n+1){
        rep(i, 1, n+1){
            rep(j, 1, n+1){
                if(b[i][j] > b[i][k] + b[k][j]){
                    b[i][j] = b[i][k] + b[k][j];
                }
            }
        }
    }
    int f = 1;
    rep(i, 1, n+1){
        rep(j, 1, n+1){
            if(b[i][j] != a[i][j]){
                f = 0;
            }
        }
    }
    if(f){
        node road[n*(n-1) / 2];
        int len = 0;
        rep(i, 1, n){
            rep(j, i+1, n+1){
                road[len].value = a[i][j];
                road[len].x = j;
                road[len].y = i;
                len++;
            }
        }
        qsort(road, len, sizeof(node), cmpAsc);
        rep(i, 1, n+1){
            rep(j, 1, n+1){
                b[i][j] = 3000000000000;
                if(i == j){
                    b[i][j] = 0;
                }
            }
        }
        lld ans = 0;
        rep(l, 0, len){
            if(b[road[l].y][road[l].x] <= road[l].value){
                continue;
            }
            b[road[l].y][road[l].x] = road[l].value;
            b[road[l].x][road[l].y] = road[l].value;
            ans += road[l].value;
            int k = road[l].x;
            rep(i, 1, n+1){
                rep(j, 1, n+1){
                    if(b[i][j] > b[i][k] + b[k][j]){
                        b[i][j] = b[i][k] + b[k][j];
                    }
                }
            }
            k = road[l].y;
            rep(i, 1, n+1){
                rep(j, 1, n+1){
                    if(b[i][j] > b[i][k] + b[k][j]){
                        b[i][j] = b[i][k] + b[k][j];
                    }
                }
            }
            int sf = 1;
            rep(i, 1, n+1){
                rep(j, 1, n+1){
                    if(b[i][j] != a[i][j]){
                        sf = 0;
                    }
                }
            }
            if(sf){
                break;
            }
        }
        printf("%lld", ans);
    }else{
        printf("-1");
    }

    return 0;
}

Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		List<String> s = Arrays.asList(sc.next().split(""));
    
		// 出力
		System.out.println(s.contains("a") && s.contains("b") && s.contains("c") 
                           ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String S = sc.next();
		int inc = S.indexOf('C');
		int inf = S.lastIndexOf('F');
		if(inc != -1 && inf != -1 & inc < inf) System.out.println("Yes");
		else System.out.println("No");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

int main(void)
{
    int smin=123, smax=0, tmax=0, i, slen, tlen;
    char s[200], t[200];

    scanf("%s", s);
    scanf("%s", t);

    slen = strlen(s);
    tlen = strlen(t);

    for (i = 0; i < slen; i++){
        if(s[i] < smin){
            smin = s[i];
        }
        if(s[i] > smax){
            smax = s[i];
        }
    }
    for (i = 0; i < tlen; i++){
        if(t[i] > tmax){
            tmax = t[i];
        }
    }

    if(smin < tmax){
        printf("Yes\n");
    } else if(tmax < smin){
        printf("No\n");
    } else {
        if(smax > tmax){
            printf("No\n");
        } else if(smax < tmax){
            printf("Yes\n");
        } else {
            if(slen < tlen){
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]

l = len(a)+1 #社員数

sub = [0] * l

for i in range (n-1):
    sub[a[i]-1] += 1

ans = '\n'.join(map(str,sub)) #これで改行区切り出力

print(ans)

Measured memory_bytes: 32916
//#include <bits/stdc++.h>
#include <iostream>
int read(){
	int x=0,f=1;char c;
	do{c=getchar();if(c=='-')f=-1;}while(!isdigit(c));
	do{x=x*10+c-'0';c=getchar();}while(isdigit(c));
	return x*f;
}
using Int = signed long long int;
const int N=100000+10;
const Int mod=Int(1e9)+7LL;

int vis[N],phi[N],prime[N],pcnt;
Int qpow(Int a,Int p){
	Int r=1; while(p){
		if(p&1) r=r*a%mod;
		a=a*a%mod; p>>=1;
	} return r;
}

void sieve(){
	phi[1]=1;
	for(int i=2;i<N;i++){
		if(!vis[i]){
			prime[pcnt++]=i;
			phi[i]=i-1;
		}
		for(int j=0;j<pcnt&&1LL*i*prime[j]<N;j++){
			int t=i*prime[j]; vis[t]=1;
			if(i%prime[j]==0){ phi[t]=phi[i]*prime[j]%mod; break; }
			phi[t]=phi[i]*(prime[j]-1)%mod;
		}
	}
}

int main(){
	int n=read(),k=read();
	sieve();


	Int ans=0;
	for(int i=1;i<=k;i++) ans=(ans+qpow(k/i,n)*phi[i]%mod)%mod;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 4456
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let mut v = vec![false; n + 1];
    fn f(v: &mut [bool], i: usize, n: usize) {
        if i > n {
            return;
        }
        v[i] = true;
        f(v, i + 4, n);
        f(v, i + 7, n);
    }
    f(&mut v, 0, n);
    let ans = if v[n] { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input = Reads();
        var n = input[0];
        var t = input[1];
        var l = new List<long>();
        bool b = false;
        for(int i = 0; i < n; i++)
        {
            input = Reads();
            var a = input[0];
            if (input[1] <= t)
            {
                b = true;
                l.Add(a);
            }
        }
        if (b)
            Console.WriteLine(l.Min());
        else
            Console.WriteLine("TLE");
        
        Console.Out.Flush();
    }
}

Measured memory_bytes: 13396
n = int(input())
x =[list(map(int, list(input().split()))) for i in range(n)]

sum = 0

def dist(x_1, y_1, x_2, y_2):
  return ((x_2 - x_1)**2 + (y_2 - y_1)**2)**0.5

for i in range(n):
  for j in range(i+1, n):
    sum += dist(x[i][0], x[i][1], x[j][0], x[j][1])
    
print(sum*2/n)

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

int main(){
  int r, D;
  cin >> r >> D;

  int x;
  cin >> x;

  
  int size = x;
  for (int i = 0; i < 10; i++)
  {
    size = r * size - D;
    cout << size << endl;
    
  }
}

Measured memory_bytes: 3640
/* ex 5_4
   Kohei_Suzuki */

#include <stdio.h>
#define SIZE 50

int main(void){
    int count=0, ans=0;
    char sequence[SIZE], *ptr;


    scanf("%s", sequence); //入力受取

    ptr = &sequence[0]; //ポインタへの代入

    while(*ptr){
        if(*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            count++;
            if(count > ans){
                ans = count;
            }
        }
        else{
            count = 0;
        }
        ptr++;
    }

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

Measured memory_bytes: 1708
#!/usr/bin/env python3


M = 1000000
P = 180


def compute(x):
    for n in range(1, M):
        k, mo = divmod(2 * n * P, x)
        if mo == 0:
            return k
    raise Exception("Not Found")    


def main():
    x = int(input())
    k = compute(x)
    print(k)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  auto pos=new int[](n+1);
  foreach(int i; 0..n) pos[a[i]]=(i+1);
  auto tree=new SquareRootDecomposition(n);
  long sum=0;
  for(int v=n; v>=1; v--){
    int i=pos[v];
    tree.merge(i);
    auto seq=tree.get(i);
    auto l=seq.left, r=seq.right,
         dl=(i-l+1).to!(long), dr=(r-i+1).to!(long);
    sum+=(dl+dr-1)*v;
    sum+=(dl-1)*(dr-1)*v;
    // writeln(i, " ", l, " ", r, " ", dl, " ", dr, " ", sum);
    // tree.show;
  }
  writeln(sum);
}

struct Seq{int left, right;}

class SquareRootDecomposition{
  import std.algorithm;
  int D=1, inf=1_000_000_000;
  int[] left, right;
  int[] buc_left, buc_right;
  this(int n){
    while(D*D<n) D++;
    left.length=right.length=(D*D+1);
    buc_left.length=buc_right.length=(D+1);
    fill(left, inf); fill(right, -inf);
    fill(buc_left, -1); fill(buc_right, -1);
  }
  void merge(int i){
    int l=i, r=i;
    if(buc_left[(i-1)/D+1]>=0) chmin(l, buc_left[(i-1)/D+1]);
    if(buc_right[(i-1)/D+1]>=0) chmax(r, buc_right[(i-1)/D+1]);
    if(i-1>=1){
      chmin(l, left[i-1]);
      if(buc_left[(i-1-1)/D+1]>=0) chmin(l, buc_left[(i-1-1)/D+1]);
    }
    if(i+1<=D*D){
      chmax(r, right[i+1]); 
      if(buc_right[(i+1-1)/D+1]>=0) chmax(r, buc_right[(i+1-1)/D+1]);
    }
    int bl=(l-1)/D+1, br=(r-1)/D+1;
    if(br-bl<=1){
      eachUpdate(l, r, l, r);
    }else{
      eachUpdate(l, bl*D, l, r);
      buc_left[(bl+1)..br]=l;
      buc_right[(bl+1)..br]=r;
      eachUpdate((br-1)*D+1, r, l, r);
    }
  }
  void eachUpdate(int st, int ed, int l, int r){ // j in [st, ed], left[j]<-l, right[j]<-r
    push((st-1)/D+1); push((ed-1)/D+1); // ここらへん、頭使わないといけないので、よくない
    for(int j=st; j<=ed; j++) left[j]=l, right[j]=r;
  }
  void push(int k){
    if(buc_left[k]>=0){
      for(int j=(k-1)*D+1; j<=k*D; j++) left[j]=buc_left[k];
      buc_left[k]=-1;
    }
    if(buc_right[k]>=0){
      for(int j=(k-1)*D+1; j<=k*D; j++) right[j]=buc_right[k];
      buc_right[k]=-1;
    }
  }
  Seq get(int i){
    auto ret=Seq(i, i);
    if(buc_left[(i-1)/D+1]>=0) chmin(ret.left, buc_left[(i-1)/D+1]);
    else chmin(ret.left, left[i]);
    if(buc_right[(i-1)/D+1]>=0) chmax(ret.right, buc_right[(i-1)/D+1]);
    else chmax(ret.right, right[i]);
    return ret;
  }
  void show(){
    import std.stdio;
    writeln(left);
    // writeln(buc_left);
    writeln(right);
  }
}

void chmin(T)(ref T l, T r){if(l>r)l=r;}
void chmax(T)(ref T l, T r){if(l<r)l=r;}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 11664
bad = 0
in_in = int(input())
four = in_in // 1000
three = (in_in % 1000) // 100
two = (in_in % 100) // 10
one = in_in % 10
if(four == three) :
  bad += 1
if(three == two) :
  bad += 1
if(two == one) :
  bad += 1
if(bad >= 1) : 
  print("Bad")
else :
  print("Good")

Measured memory_bytes: 3188
/**
 * Princess's Gamble
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);
			int n, m, p;
			n = parseInt(st.nextToken());
			m = parseInt(st.nextToken());
			p = parseInt(st.nextToken());
			if ((n | m | p) == 0) break;

			int[] bets = new int[n];
			int total = 0;
			for (int i = 0; i < n; i++) {
				bets[i] += parseInt(br.readLine());
				total += bets[i];
			}

			if (bets[m - 1] == 0) {
				System.out.println("0");
			} else {
				int dividend;
				dividend = total;
				dividend *= 100 - p;
				System.out.println(dividend / bets[m - 1]);
			}
		} //end while
	} //end main
}

Measured memory_bytes: 22168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
    //???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif



int binarySearch(int key, int data[], int begin, int end) {
    
    int i = (begin + end + 1) / 2;

    
    if(data[i]==key) return i;
    else if(begin==end) return -1; //Not Found
    else if(key < data[i]) return binarySearch(key, data, begin, i-1);
    else if(data[i] < key) return binarySearch(key, data, i+1, end);
    
    return -1;
}


int main(void) {
    int n, q;
    
    cin >> n;
    int S[n];
    for(int i=0; i<n; i++) cin>>S[i];
    
    cin >> q;
    int T[n];
    for(int i=0; i<q; i++) cin>>T[i];
    
    
//    dout<<"S = ";
//    for(int i=0; i<n; i++) dout<<S[i]<<" ";
//    dout<<endl;
//    
//    dout<<"T = ";
//    for(int i=0; i<q; i++) dout<<T[i]<<" ";
//    dout<<endl;
    
    
    //search T from S
    int ans = 0;
    for (int i=0; i<q; i++) { //S[]????????????T[i]???key?????¢?´¢
        int key = T[i];
        int foundIndex = -1;
//        int foundIndex = binarySearch(key, S, 0, n);
//        if ( foundIndex != -1 ) ans++;
        
        int left = 0;
        int right = n;
        
        while(left<right) {
            int mid = (left + right) / 2;
            
            if( S[mid]==key ) {
                foundIndex=mid;
                ans++;
                break;
            }
            else if (key<S[mid]) right=mid;
            else if (S[mid]<key) left=mid+1;
        }
        
        if(left==right) foundIndex=-1;
        
        
        

        //Test display
//        dout << "i=" << i << " : key=" << key << " foundIndex=" << foundIndex << " left=" <<left <<" right=" << right << " ans=" << ans << endl;
        
    }
    
    
    //output
    cout << ans << endl;
    
    
    return 0;
}

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

int main() {
 string s;
 cin >> s;
 int n = s.size();
 int first = 0;
 int end   = n-1;
 for(int i = 0;i<n;i++){
    if(s[i] == 'A') break;
    first++;
 }
 for(int i=n-1;i>0;i--){
    if(s[i] == 'Z') break;
    end--;
 }
 cout << end - first +1 << endl;
}

Measured memory_bytes: 640
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List

main = do
    [r, c] <- map read . words <$> getLine
    a <- replicateM r $ map read . words <$> getLine
    forM_ a (\s -> putStrLn . unwords . map show $ s ++ [sum s])
    let ta = map sum . transpose $ a
    putStrLn . unwords . map show $ ta ++ [sum ta]

Measured memory_bytes: 6504
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

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

  int V[N];  // numeric value
  char C[N];  // character

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

  int V_b[N];   // copy for bubble sort
  char C_b[N];
  for (int i = 0; i < N; i++) {
    V_b[i] = V[i];
    C_b[i] = C[i];
  }

  int V_s[N];   // copy for selection sort
  char C_s[N];
  for (int i = 0; i < N; i++) {
    V_s[i] = V[i];
    C_s[i] = C[i];
  }


  // do bubble sort
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j > i; j--) {
      if (V_b[j] < V_b[j - 1]) {
        int t = V_b[j];
        V_b[j] = V_b[j - 1];
        V_b[j - 1] = t;

        char c = C_b[j];
        C_b[j] = C_b[j - 1];
        C_b[j - 1] = c;
      }
    }
  }

  // output the result of bubble sort
  for (int i = 0; i < N; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << C_b[i] << V_b[i];
  }
  cout << endl;

  // bubble sort is always stable
  cout << "Stable" << endl;


  // do selection sort
  for (int i = 0; i < N; i++) {
    int mini = i;
    for (int j = i; j < N; j++) {
      if (V_s[j] < V_s[mini]) {
        mini = j;
      }
    }

    if (mini != i) {
      int t = V_s[i];
      V_s[i] = V_s[mini];
      V_s[mini] = t;

      char c = C_s[i];
      C_s[i] = C_s[mini];
      C_s[mini] = c;
    }
  }

  // output the result of selection sort
  for (int i = 0; i < N; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << C_s[i] << V_s[i];
  }
  cout << endl;

  // bubble sort is always stable
  for (int i = 0; i < N; i++) {
    if (C_b[i] != C_s[i]) {
      cout << "Not stable" << endl;
      return 0;
    }
  }
  cout << "Stable" << endl;
  return 0;
}

Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());

		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		int INF_MIN = -1000;//Integer.MIN_VALUE;
		
		boolean flag = true;
		if(c[0] == c[1] || c[1] == c[2] || c[2] == c[3]){
			flag = false;
		}

		if(flag){
			System.out.println("Good");
		}else{
			System.out.println("Bad");
		}
		
	
		
		
	}
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

inline int tax(int p, int x) {
    return p * (100 + x) / 100;
}

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

    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    int m;
    cin >> m;
    bool locked = true;
    rep(i, m) {
        string s;
        cin >> s;
        if (st.count(s)) {
            cout << (locked ? "Opened by " : "Closed by ") << s << endl;
            locked ^= 1;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    set<string> a;
    int n; cin >> n;
    rep(i,0,n){
        string s; cin >> s;
        a.insert(s);
    }
    cout << a.size()<<endl;

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){

    ll H,W,ANS=INF;
    cin>>H>>W;
    if(H%3==0||W%3==0){
        cout<<0<<endl;
        return 0;
    }
    REP(h,1,H){
        ll Sa=h*W,Sb,Sc;
        ll bc=H-h;
        if(bc%2==0){
            Sc=Sb=bc/2*W;
        }else{
            Sb=(bc-(bc+1)/2)*W;
            Sc=(bc+1)/2*W;
        }
        ANS=min(ANS,max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc)));
        ll w=W/2;
        Sb=(H-h)*w;Sc=(H-h)*(W-w);
        ANS=min(ANS,max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc)));
    }
    REP(w,1,W){
        ll Sa=w*H,Sb,Sc;
        ll bc=W-w;
        if(bc%2==0){
            Sc=Sb=bc/2*H;
        }else{
            Sb=(bc-(bc+1)/2)*H;
            Sc=(bc+1)/2*H;
        }
        ANS=min(ANS,max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc)));
        ll h=H/2;
        Sb=(W-w)*h;Sc=(W-w)*(H-h);
        ANS=min(ANS,max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc)));
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

struct hl_decomp {
	int N, M;
	vector<vi> G;
	vi sz, id, par, dep;
	hl_decomp(int _N, vector<vi> _G)
		: N(_N), G(_G), sz(N), id(N), par(N), dep(N) {
		dfs_sz(0, -1);
		dfs_decomp(0, -1);
		M = 1; par[0] = -1; dfs_decomp(0, -1);
		dfs_dep(0, -1);
	}
	void dfs_sz(int u, int p) {
		sz[u] = 1;
		for (int v : G[u]) if (v != p) {
			dfs_sz(v, u);
			sz[u] += sz[v];
		}
	}
	void dfs_decomp(int u, int p) {
		int v0 = -1;
		for (int v : G[u]) if (v != p)
			if (v0 == -1 || sz[v] > sz[v0]) v0 = v;
		for (int v : G[u]) if (v != p) {
			if (v == v0) {
				id[v] = id[u];
				par[v] = par[u];
			}
			else {
				id[v] = M++;
				par[v] = u;
			}
			dfs_decomp(v, u);
		}
	}
	void dfs_dep(int u, int p) {
		for (int v : G[u]) if (v != p) {
			dep[v] = dep[u] + 1;
			dfs_dep(v, u);
		}
	}
	int lca(int u, int v) {
		while (id[u] != id[v]) {
			int _u = par[u], _v = par[v];
			if (_u != -1 && dep[_u] >= dep[_v]) u = _u;
			else v = _v;
		}
		return dep[u] < dep[v] ? u : v;
	}
};

int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(u, N) {
		int K; scanf("%d", &K);
		while (K--) {
			int v; scanf("%d", &v);
			G[u].pb(v);
		}
	}
	hl_decomp hl(N, G);
	int Q; cin >> Q;
	while (Q--) {
		int u, v; scanf("%d%d", &u, &v);
		int w = hl.lca(u, v);
		printf("%d\n", w);
	}
}

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

using namespace std;

struct Dice
{
  int x, y;
  int l, r, f, b, d, u;

  void RollF()
  {
    --y;
    int buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
  }

  void RollB()
  {
    ++y;
    int buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
  }

  void RollL()
  {
    --x;
    int buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
  }

  void RollR()
  {
    ++x;
    int buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
  }
};


int main()
{
  Dice dice;
  cin >> dice.u;
  cin >> dice.f;
  cin >> dice.l;
  cin >> dice.r;
  cin >> dice.b;
  cin >> dice.d;

  int dd[25][25];

  for(int i = 0; i < 4; i++) {
    dice.RollL();
    for(int j = 0; j < 4; j++) {
      dice.RollB();
      for(int k = 0; k < 4; k++) {
        dice.RollL();
        dd[dice.u][dice.f] = dice.l;
      }
    }
  }

  int Q;
  cin >> Q;
  while(Q--) {
    int u, f;
    cin >> u >> f;
    cout << dd[u][f] << endl;
  }
}

Measured memory_bytes: 3052
#include<stdio.h>
int main(void){
	int i,N;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		int j,a[3]={},b[3]={};
		for(j=0;j<3;j++){
			scanf("%d",&a[j]);
			}
		
		b[0]=a[0];
		if(a[0]<a[1]){
			b[1]=a[0];
			b[0]=a[1];
		}else b[1]=a[1];
		if(b[0]<a[2]){
			b[2]=b[1];
			b[1]=b[0];
			b[0]=a[2];
		}else if(b[1]<a[2]&&a[2]<b[0]){
			b[2]=b[1];
			b[1]=a[2];
		}else b[2]=a[2];
		
	
		if(b[0]*b[0]==b[1]*b[1]+b[2]*b[2])
			puts("YES");
		else puts("NO");
	}
	return 0;
}

	

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  for(int i =l;i<=r;i++) {
    if(i%d==0) {
      c++;
    }
  }
  cout << c;
  return 0;
}


Measured memory_bytes: 3620
n,m = map(int, input().split())
arr = list(map(int, input().split()))

if n >= m:
    print(0)

else:
    arr.sort()

    diff = [arr[i+1] - arr[i] for i in range(m-1)]
    diff.sort()

    print(sum(diff[0:m-n]))

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<int> a(n+1,0);
  rep(i,m) {
    int b;
    cin >> b;
    a[b] = 1;
  }
  ll dp[n+1] = {};
  dp[0] = 1;
  for(int i = 1; i <= n; i++) {
    if(!a[i]) {
      if(i > 1) (dp[i] += dp[i-2]) %= mod;
      (dp[i] += dp[i-1]) %= mod; 
    } 
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; string s;
    cin >> n >> s;

    set<string> S;
    S.insert("");

    set<string> ans;
    REP(i, n) {
        set<string> T;
        for(auto &e: S) {
            T.insert(e);
            if (e.size() == 2) {
                ans.insert(e + s[i]);
            } else {
                T.insert(e + s[i]);
            }
        }
        swap(S, T);
    }

    print(ans.size());
}

Measured memory_bytes: 3720
import sys
sys.setrecursionlimit(100000000)
input=lambda : sys.stdin.readline().rstrip()

def dist(a,b):
    ans=0
    for x,y in zip(a,b):
        ans+=(x-y)**2
    return ans**0.5

n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(n):
    for j in range(i+1,n):
        if abs(int(dist(x[i],x[j])+0.5)-dist(x[i],x[j]))<0.000000001:
            count+=1
print(count)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  const i32 m = 11;
  char *s = (char *) calloc (m * n, sizeof (char));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%s", s + i * m);
  }
  i32 a = 0;
  i32 b = 0;
  i32 ab = 0;
  i32 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    char *p = s + i * m;
    i32 len = strlen (p);
    if (p[0] == 'B') ++b;
    if (p[len - 1] == 'A') ++a;
    if (p[0] == 'B' && p[len - 1] == 'A') ++ab;
    for (i32 j = 0; j + 1 < len; ++j) {
      if (p[j] == 'A' && p[j + 1] == 'B') {
	ans++;
      }
    }
  }
  a -= ab;
  b -= ab;
  if (ab > 0) {
    ans += ab - 1;
    if (a > 0) {
      ans++;
      a--;
    }
    if (b > 0) {
      ans++;
      b--;
    }
  }
  ans += MIN(a, b);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);

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

            // 解析
            int iOut = (int)Math.Pow((double)iN, 3d);

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

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

}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;

void solve(void){

  int n;
  std::cin >> n;
  std::vector<llint> l(n);
  for(int i=0; i<n; i++){
    std::cin >> l[i];
  }

  llint cnt = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
	std::vector<llint> tmp = {l[i], l[j], l[k]};
	std::sort(tmp.begin(), tmp.end());
	if(tmp[0] != tmp[1] && tmp[1] != tmp[2]
	   && tmp[0]+tmp[1] > tmp[2]){
	  cnt++;
	}
      }
    }
  }

  std::cout << cnt << std::endl;
}
int main(void){
  solve();
  return 0;
}





Measured memory_bytes: 3632