akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    ll a, b;
    cin >> a >> b;
    cout << a/__gcd(a, b)*b << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  double X[4], Y[4];
  for (int i = 0; i < 3; i++){
    cin >> X[i] >> Y[i];
  }
  X[3] = X[0]; Y[3] = Y[0];
  
  vector <double> L(3);
  for (int i = 0; i < 3; i++){
    double x = X[i + 1] - X[i], y = Y[i + 1] - Y[i];
    L[i] = sqrt(x * x + y * y);
  }
  sort(L.begin(), L.end());
  
  double s = (L[0] + L[1] + L[2]) / 2;
  double S = sqrt(s * (s - L[0]) * (s - L[1]) * (s - L[2]));

  double K = s + 2 * S / L[2];

  double ans = S / K;

  cout << setprecision(32) << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

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

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

	int ans;

	if (N >= 10) { ans = R; }
	else { ans = R + 100 * (10 - N); }

	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(" ").map(String::toInt)
    var cost: Int? = null
    for (i in 1..n) {
        val (c, u) = readLine()!!.split(" ").map(String::toInt)
        if (t < u) continue
        if (cost == null || c < cost) {
            cost = c
        }
    }
    println(if (cost == null) "TLE" else cost)
}


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

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

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  for (int i = 0; i <= 110; i++) {
    int sp = 0, sm = 0;
    sp = x + i;
    sm = x - i;

    bool ap = true;
    bool am = true;

    for (int j = 0; j < n; j++) {
      if (sp == p[j]) {
        ap = false;
      }
      if (sm == p[j]) {
        am = false;
      }
    }

    if (ap && am) {
      cout << sm << endl;
      return 0;
    }

    if (ap) {
      cout << sp << endl;
      return 0;
    }
    if (am) {
      cout << sm << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

typedef long long ll;

using namespace std;
int main()
{
  int N, L;
  cin >> N >> L;
  vector<int> A(N,0);
  int sum = 0;
  for (int i=0;i<N;i++)
  {
    sum += (L+i);
  }
  int minD = __INT_MAX__;
  int minIdx = -1;
  for (int i=0;i<N;i++)
  {
    int diff = abs(sum - (sum -L-i));
    if (diff < minD) {
      minD = diff;
      minIdx = i;
    }
  }
  printf("%d\n", sum-L-minIdx);
  return 0;
}


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

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

int main(int argc,char* argv[]) {
	int N;
	int p_kizi,p_topping;
	int cal_kizi;
	int cal_topping[100];
	int i;
	int best_plice,best_cal;
	int now_plice,now_cal;
	scanf("%d",&N);
	scanf("%d %d",&p_kizi,&p_topping);
	scanf("%d",&cal_kizi);
	for(i=0;i<N;i++) {
		scanf("%d",&cal_topping[i]);
	}
	qsort(cal_topping,N,sizeof(int),comp);
	best_plice=p_kizi;
	best_cal=cal_kizi;
	now_plice=p_kizi;
	now_cal=cal_kizi;
	for(i=0;i<N;i++) {
		now_cal+=cal_topping[i];
		now_plice+=p_topping;
		if(best_cal/best_plice<now_cal/now_plice) {
			best_cal=now_cal;
			best_plice=now_plice;
		}
	}
	printf("%d\n",best_cal/best_plice);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,ll> P;
typedef struct pair<int,P> P2;

P dp[100001]={};
ll r[100001]={};

ll d[1001]={};
int a[200001]={};
int main() {
	int n,m;
	ll l;
	cin>>n>>m;
	int k=(1<<m);

	cout<<(100*(n-m)+1900*m)*k<<endl;
	return 0;
}


Measured memory_bytes: 1792
X,Y = map(int,input().split())
n = (2*X-Y)//3
m = X - 2*n

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if [m+2*n,2*m+n] != [X,Y]:
    print(0)
else:
    print(cmb(m+n,n,10**9+7))

Measured memory_bytes: 128584
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;


// const INF: i64 = 1_000_000_000;


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let N: usize = sc.read();
    let K: usize = sc.read();
    let md: usize = sc.read();
    let mut ans = vec![vec![0; K+1]; N+1];
    let mut anssum = vec![vec![0; K+1]; N+1];

    let mut c = vec![vec![0; N+1]; N+1];
    for n in 0..N+1 {
        for k in 0..n+1 {
            if k == 0 || k == n {
                c[n][k] = 1;
            } else {
                c[n][k] = (c[n-1][k-1] + c[n-1][k]) % md;
            }
        }
    }
    
    for k in 0..K+1 {
        for n in 0..N+1 {
            if k > 0 {
                anssum[n][k] = (anssum[n][k-1] + ans[n][k-1]) % md;
            }
            let mut ansnk: usize = 0;
            for t in 0..n {
                let tmp = ans[t][k] * anssum[n-1-t][k] % md;
                let tmp = tmp * c[n-1][t] % md;
                ansnk += tmp;
                ansnk %= md;
            }
            if n == 0 {
                ansnk = 1;
            }
            ans[n][k] = ansnk;
        }
    }

    println!("{}", ans[N][K]);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 6396
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8,i8,b1[:,:])", cache=True)
def solve(H, W, S):
    U = np.full(shape=(H + 2, W + 2), fill_value=-1, dtype=np.int64)
    D = np.full(shape=(H + 2, W + 2), fill_value=-1, dtype=np.int64)
    L = np.full(shape=(H + 2, W + 2), fill_value=-1, dtype=np.int64)
    R = np.full(shape=(H + 2, W + 2), fill_value=-1, dtype=np.int64)
    for h in range(1, H + 1):
        for w in range(1, W + 1):
            if not S[h][w]:
                continue
            if U[h][w] == -1:
                U[h][w] = 0
                d = 0
                while True:
                    d += 1
                    if not S[h + d][w]:
                        break
                    U[h + d][w] = d
            if L[h][w] == -1:
                L[h][w] = 0
                d = 0
                while True:
                    d += 1
                    if not S[h][w + d]:
                        break
                    L[h][w + d] = d

    for h in range(H + 1, 0, -1):
        for w in range(W + 1, 0, -1):
            if not S[h][w]:
                continue
            if D[h][w] == -1:
                D[h][w] = 0
                d = 0
                while True:
                    d += 1
                    if not S[h - d][w]:
                        break
                    D[h - d][w] = d
            if R[h][w] == -1:
                R[h][w] = 0
                d = 0
                while True:
                    d += 1
                    if not S[h][w - d]:
                        break
                    R[h][w - d] = d

    dist = U + D + L + R + 1
    ans = np.max(dist)
    return ans


def main():
    H, W = map(int, input().split())
    S = np.zeros(shape=(H + 2, W + 2), dtype=np.bool)
    for i in range(1, H + 1):
        S[i][1:-1] = [s == "." for s in input().rstrip()]

    ans = solve(H, W, S)

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
  return 0;
}


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

int main(){
 int count1=0,count2=0,n,a,b;
  string s;
  cin >> n >> a >> b >> s;
  r(i,n){
    if(s.at(i)=='a'){
      if(count1<a+b){
        cout << "Yes"<<endl;
        count1++;
      }
      else cout << "No"<<endl;
    }
    else if(s.at(i)=='b'){
      if(count1<a+b&&count2<b){
        cout << "Yes"<<endl;
        count1++; count2++;
      }
      else cout << "No"<<endl;
    }
    else cout << "No"<<endl;
}
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

int inf = 100000000;
int MAX_N = 100005;
vector<int> par(MAX_N ,inf); //親
vector<int> Rank(MAX_N); //木の深さ
vector<int> num(MAX_N); //グループの要素数(parentに保存)

//n要素で初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        Rank[i] = 0;
        num[i] = 1;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x ,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(Rank[x] < Rank[y]){
        num[par[y]] += num[par[x]];
        par[x] = y;
    }else{
        num[par[x]] += num[par[y]];
        par[y] = x;
        if(Rank[x] == Rank[y]) Rank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x ,int y){
    return find(x) == find(y);
}

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int>fri(n+1, 0);
    vector<int>blo(n+1, 0);

    init(n+1);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        unite(a, b);
        fri[a]++;
        fri[b]++;
    }
    for(int i=0;i<k;i++){
        int c, d;
        cin >> c >> d;
        if(same(c, d)){
            blo[c]++;
            blo[d]++;
        }
    }

    for(int i=1;i<=n;i++){
        int t = num[find(i)];
        if(t - fri[i] - blo[i] - 1 > 0){
            cout << t - fri[i] - blo[i] - 1 << " ";
        }else{
            cout << 0 << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 5088
#include<iostream>
#include<queue>
#include<set>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef pair<int,int> point;

int H, W;
char A[1023][1023];
int step=-1;
int qs=0;
int qi=0;
int qj=0;
set<point> qCand;

bool check(int i, int j){
  if(i<0||H<=i||j<0||W<=j||A[i][j]=='#') return false;
  else if(qCand.count(point(i,j))==1) return false;
  else return true;
}

bool check2(int i, int j){
  if(i<0||H<=i||j<0||W<=j||A[i][j]=='#') return false;
  else return true;
}

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

  cin>>H>>W;
  REP(i,H) REP(j,W) cin>>A[i][j];
  
  queue<point> q;
  REP(i,H) REP(j,W) if(A[i][j]=='#')q.push(point(i,j));

  while(q.size()){
    ++step;
    qs = q.size();
    qCand = {};
    REP(i,qs){
      qi=q.front().first;
      qj=q.front().second;
      q.pop();
      A[qi][qj]='#';
      if(check(qi+1,qj)) qCand.insert(point(qi+1,qj));
      if(check(qi-1,qj)) qCand.insert(point(qi-1,qj));
      if(check(qi,qj+1)) qCand.insert(point(qi,qj+1));
      if(check(qi,qj-1)) qCand.insert(point(qi,qj-1));
    }
    EACH(x,qCand){
      if(check2(x.first,x.second)) q.push(x);
    }
  }
      
  cout << step << endl;
  return 0;
}

Measured memory_bytes: 29312
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    s = S()
    if len(s) != a+b+1:
        return 'No'
    for i in range(a):
        if not ('0' <= s[i] <= '9'):
            return 'No'
    if s[a] != '-':
        return 'No'
    for i in range(b):
        if not ('0' <= s[i+a+1] <= '9'):
            return 'No'

    return 'Yes'

print(main())




Measured memory_bytes: 7628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int main(){

  string s;
  
  cin >> s ;
  
  vector<vector<long long> > dp(s.size()+1, vector<long long>(13, 0));
  
  dp[0][0] = 1;
  
  for(int i=0;i<s.size();i++){
    
    for(int j=0;j<13;j++){
      
    if(s[i] == '?'){
      for(int k=0;k<10;k++){
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= 1000000007;
      }
    }
      else{
       int k = (int) (s[i]-'0');
        
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= 1000000007;
      }
    }
    }
    
    cout << dp[s.size()][5]%1000000007 << endl;
    
  }
        


Measured memory_bytes: 13696
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<pint,int> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint mo=998244353;
lint ha=(mo+1)/2;
lint zyo(lint x,lint y){
    lint ret=1,a=x;
    while(y>0){
    	if(y%2==1) ret=(ret*a)%mo;
    	a=(a*a)%mo;y/=2;
    }
    return ret;
}
int ta[100100][8];
map<pint,int> me;
int ng=0;
lint rank1;
/*void dfs(int x,int y,int w){
	if(pa[x]>=0){
		if(pa[x]!=y) ng=1;
		return;
	}
	if(ta[x]>=0){
		if(ta[x]!=y) ng=1;
		else if(w==0) rank1++;
	}
	pa[x]=y;
	rep(i,gr[x].size()){
		int z=gr[x][y].fi;
		dfs(z,y^gr[x][y].se,0);
	}
}*/
lint dp[100100][3];
lint cal()
{
	memset(ta,-1,sizeof(ta));
	int n,m,a,b,c,st=-1;
	cin>>n>>m;
	lint ret=zyo(2,(lint)(n-2)*(n-3)/2);
	rep(i,m){
		cin>>a>>b>>c;a--;b--;
		if(abs(a-b)>2){
			if(me.count(mp(b,a))>0){
				int d=c^me[mp(b,a)];
				if(d>0) ret*=0;
			}
			else{
				ret*=ha;ret%=mo;
				me[mp(a,b)]=c;
			}
		}
		else if(a+b<1) st=c;
		else{
			ta[(a+b-1)/2][a-b+2]=c;
		}
	}
	//cout<<ret<<endl;
	memset(dp,0,sizeof(dp));
	if(st!=0) dp[0][1]++;if(st!=1) dp[0][0]++;
	rep(i,n-1) rep(l,2) rep(j,32){
		vector<int> bi(5);
		int x=j,f=0;
		rep(k,5){
			bi[k]=x%2;x/=2;
		}
		rep(k,5){
			if(ta[i][k]>=0 && ta[i][k]!=bi[k]) f=1;
		}
		if(f>0) continue;
		if((bi[0]+bi[4])%2!=bi[2]) continue;
		if((l+bi[1]+bi[3])%2!=bi[2]) continue;
		dp[i+1][bi[2]]+=dp[i][l];
		dp[i+1][bi[2]]%=mo;
	}
	ret*=(dp[n-1][0]+dp[n-1][1]);ret%=mo;
	ret*=ha;ret%=mo;
	return ret;
}
int main()
{
	cout<<cal()<<endl;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long h = fs.nextLong(), w = fs.nextLong();
		long ans = 0;
		
		if(h == 1 || w == 1) {
			System.out.println(1);
			return;
		}
		
		if(h%2==1&&w%2==1) {
			ans = (h * w)/2 + 1;
		}
		else{
			ans = h*w/2;
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, l[125];
  cin>>n;
  REP(i, n){
    cin>>l[i];
  }
  int ans=0;
  REP(i, n){
    REP(j, n){
      if(l[j]==l[i]){
        continue;
      }
      REP(k, n){
        if(l[k]==l[i] || l[k]==l[j]){
          continue;
        }
        if(l[i]+l[j]>l[k]&& l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
          ++ans;
        }
      }
    }
  }
  cout<<ans/6<<'\n';
  return 0;
}


Measured memory_bytes: 3612
n = int(input())

for k in range(1000):
    temp = k * (k - 1) // 2
    if n == temp:
        print('Yes')
        print(k)
        res = [[] for _ in range(k)]
        p = 1
        for i in range(k):
            for j in range(i + 1, k):
                res[i].append(p)
                res[j].append(p)
                p += 1
        for x in res:
            print(' '.join(map(str, [k - 1] + x)))
        break
    elif n < temp:
        print('No')
        break

Measured memory_bytes: 9076
<?php

$n = (int)(fgets(STDIN));
$dp = [];
$a = [];
$b = [];
$c = [];
for ($i=0; $i < $n; $i++) { 
    list($a[], $b[], $c[]) = preg_split('/ /', trim(fgets(STDIN)));
}

print dfs(0, -1);

function dfs($d, $preChoice) {
    global $dp, $n, $a, $b, $c;

    if ($d == $n) return 0;

    if (isset($dp[$d][$preChoice])) return $dp[$d][$preChoice];

    if ($preChoice != 0) $chooseA = dfs($d+1, 0) + $a[$d];
    if ($preChoice != 1) $chooseB = dfs($d+1, 1) + $b[$d];
    if ($preChoice != 2) $chooseC = dfs($d+1, 2) + $c[$d];

    return $dp[$d][$preChoice] = max([$chooseA, $chooseB, $chooseC]);
}

Measured memory_bytes: 245080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<map<char,int>> mp(n);
    char mx;
    rep(i, n)
    {
        cin >> s[i];
        rep(j,s[i].size()){
            mp[i][s[i][j]]++;
        }
    }
    vector<char> v;
    for (char c = 'a'; c <= 'z'; c++)
    {
        rep(i,n-1){
            mp[i+1][c] = min(mp[i + 1][c], mp[i][c]);
        }
        rep(i, mp[n - 1][c])
        {
            v.push_back(c);
        }
    }
    sort(v.begin(),v.end());
    for(auto e:v){
        cout << e;
    }
    cout << endl;
}

Measured memory_bytes: 256
//D
#include <iostream>
#include <vector>
int main() {
    int N;
    std::cin >> N;
    std::vector<int> yakusuu(N+1,1);
    for(int i=2;i<=N;i++){
        for(int j=i;j<=N;j=j+i){
            yakusuu[j] ++;
        }
    }

    long long ans=0;
    for(int i=1;i<=N;i++){
        ans += (long long)i*(long long)yakusuu[i];
    }
    std::cout << ans;

    return 0;
}

Measured memory_bytes: 42316
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#define N 1001

using namespace std;

int main(){
  int dp[N];
  dp[0]=1, dp[1]=2;
  for(int i=2; i<N; ++i) dp[i] = (dp[i-1]+dp[i-2])%N;
  int v, d;
  while(cin >> v >> d){
    vector<int> data(v);
    for(int i=0; i<v; ++i) data[i]=dp[i+1];
    sort(data.begin(), data.end());
    int ans=1;
    for(int i=1; i<data.size(); ++i){
      if(abs(data[i]-data[i-1]) >= d) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		sc.close();
		if(k >= s.length()) {
			System.out.println(s);
		} else {
			System.out.println(s.substring(0,k)+"...");
		}

	}

}


Measured memory_bytes: 38640
lis = list(input())

n = len(lis) - 1
for i in range(2**n):
    a = ["-", "-", "-"]
    for j in range(n):
        if (i >> j & 1):
            a[j] = "+"
    ans = "".join(["{}{}".format(k, kk) for (k, kk) in zip(lis, a+[''])])
    if (eval(ans)) == 7:
        print(ans + "=7")
        break

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

int main() {
    long long X;  cin >> X;
    long long now = 100;
    long long ans = 0;
    while (true) {
        if (now >= X) {
            cout << ans << endl;
            return 0;
        }
        else {
            now += now / 100;
            ++ans;
        }
    }
}


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

int main(){
  ll  a, b, n;
  cin >> a >> b >> n;
  ll x;
  x = min(b-1, n);
  cout <<  a*x/b << endl;

}


Measured memory_bytes: 3636
N = input()

S = raw_input()
sample = [i for i in S]

i = 0
while i < len(sample)-1:
    if sample[i] == '(' and sample[i+1] == ')':
        del sample[i],sample[i]
        i = -1
    i += 1

S = '('*sample.count(')')+S+')'*sample.count('(')
print S

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[12123];
int main()
{
    ll i,ans=0,ans2,b,v,w,t,flag=0,n,k,N,x;
    scanf("%lld",&n);
    x=1;
    while(n)
    {
        ll t = n%26;
        n = (n - 1) / 26;
        if (t == 0)
            t = 26;
        a[x++]=t;
    }
    //for(i=1; i<x; i++)
      //  cout<<a[i]<<"\n";

    for(i=x-1; i>=1; i--)
    {
        if(a[i]==0)
        {
            printf("%c",'z');
        }
        else
            printf("%c",a[i]+'a'-1);
    }
// printf("%c",N+'a'-1);



}


Measured memory_bytes: 3824
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm> 
using namespace std;

#define ls st<<1
#define rs st<<1|1
#define LL long long 
#define CLR(a,b) memset(a,(b),sizeof(a))

const int MAXN = 1e3+11;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f; 

/* ------------------------基本函数-------------------------*/
long long read()
{
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
bool prime(int x) {
	if(x==2 || x==3) 
		return true;
	if(x%2==0 || x%3==0 || x==1)
		return false;
	int k = sqrt(x)+1;
	for(int i = 5; i < k; i++) {
		if(x%i==0 || x%(i+2)==0)
			return false;
	}
	return true;
} 

LL pow_mod(int a, int b, int c) {
	LL ans = 1;
	while(b) {
		if(b&1)
			ans = (ans*1) % c;
		a = (a*a) % c;
		b /= 2;
	}
	return ans;
}
int gcd(int a, int b) {
	if(!b) 
		return a;
	return gcd(b,a%b);
}
/*-------------------------------------------------------*/

int arr[MAXN];
int main() {
	int n;
	while(cin >> n) {
		LL sum = 0;
		for(int i = 1; i<=n;i++) {
			cin >>arr[i];
			sum += arr[i];
		}
		int m;
		cin >> m;
		while(m--) {
			int x, y;
			LL num = sum;
			cin >> x >> y;
			num -= arr[x];
			num += y;
			cout << num << endl;
		}
	}
	
return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
bli = [int(i) for i in input().split()]
ans=0
for i in range(n):
	a = [int(j) for j in input().split()]
	sum=0
	for k in range(m):
		sum += a[k]*bli[k]
	if sum + c > 0:
		ans += 1

print(ans)



Measured memory_bytes: 3060
from collections import defaultdict
from itertools import accumulate

n, v = map(int, input().split())
programs = defaultdict(list)
for _ in range(n):
    s, t, c = map(int, input().split())
    programs[c].append((s, t))

imos = [0] * (2 * 10 ** 5 + 2)
for c, p in programs.items():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:]:
        if pt == s:
            pt = t
        else:
            imos[2 * ps - 1] += 1
            imos[2 * pt + 1] -= 1
            ps, pt = s, t
    imos[2 * ps - 1] += 1
    imos[2 * pt + 1] -= 1

print(max(accumulate(imos)))


Measured memory_bytes: 19280
#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()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int           D; // 問題レベル
    int           G; // 目標スコア
    int           sum      = 0; // 獲得スコア
    int           min_q    = 1000; // 求める最小問題数
    int           solve_q  = 0; // 解いた問題数
    int           chuto_at = -1;
    vector <int>  q_num(10); // 各レベルごとの問題数
    vector <int>  bonus(10); // ボーナスポイント
    vector <bool> solve(10, false);

    cin >> D >> G;
    rep(i, D)
    {
        cin >> q_num.at(i);
        cin >> bonus.at(i);
    }

    // 完全に解く問題->true 全く解かない->false
    for (int i = 0; i < pow(2, D); i++)
    {
        // 初期化
        rep(k, 10) {
            solve.at(k) = false;
        }
        sum      = 0;
        solve_q  = 0;
        chuto_at = -1;

        int buf        = i;
        int chutohanpa = 0;
        // cout << buf << endl;
        for (int j = 9; j >= 0; j--)
        {
            if (buf - pow(2, j) >= 0) { solve.at(j) = true; buf = buf - pow(2, j); }
            else if (j < D && chuto_at == -1) { chutohanpa = j; chuto_at = 0; }
        }

        /*rep(k, 10) {
            cout << solve.at(k);
        }*/
        // cout << "chutohanpa=" << chutohanpa << endl;
        // cout << endl;
        rep(k, 10)
        {
            if (solve.at(k)) {
                // cout << "q_num.at(" << k << ")=" << q_num.at(k) << endl;
                // cout << "bonus.at(" << k << ")=" << bonus.at(k) << endl;
                sum     += (100 * (k + 1) * q_num.at(k) + bonus.at(k));
                solve_q += q_num.at(k);
            }
        }
        // cout << "SUM=" << sum << "SOLVE=" << solve_q << endl;
        if (sum >= G) {  if (min_q > solve_q) { min_q = solve_q; } continue; }
        rep(k, q_num.at(chutohanpa))
        {
            sum += 100 * (chutohanpa + 1);
            solve_q++;
            if (sum >= G) { if (min_q > solve_q) { min_q = solve_q; } continue; }
        }
    }

    cout << min_q << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String[] getFigure(Scanner sc) {
		StringBuilder str = new StringBuilder();
		StringBuilder rev = new StringBuilder();
		int m = sc.nextInt();
		int startx = sc.nextInt();
		int starty = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int way = startx == x ? 0 : 1;
		String dir = "";
		if (y - starty < 0 || x - startx < 0) {
			way += 2;
		}
		int length = Math.abs(x - startx) + Math.abs(y - starty);
		str.append(length);
		rev.append(length);
		for (int j = 2; j < m; j++) {
			int nextx = sc.nextInt();
			int nexty = sc.nextInt();
			int newway = nextx == x ? 0 : 1;
			if (nexty - y < 0 || nextx - x < 0) {
				newway += 2;
				dir = way == 3 || way == 0 ? "L" : "R";
			} else {
				dir = way == 3 || way == 0 ? "R" : "L";
			}
			str.append(dir);
			rev.insert(0, dir.equals("L") ? "R" : "L");
			length = Math.abs(x - nextx) + Math.abs(y - nexty);
			str.append(length);
			rev.insert(0, length);
			x = nextx;
			y = nexty;
			way = newway;
		}
		String[] s = new String[2];
		s[0] = str.toString();
		s[1] = rev.toString();
		return s;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			String[] origin = getFigure(sc);
			for (int i = 0; i < n; i++) {
				String[] figure = getFigure(sc);
				if (origin[0].equals(figure[0]) || origin[1].equals(figure[0])) {
					System.out.println(i + 1);
				}
			}
			System.out.println("+++++");
		}
	}
}

Measured memory_bytes: 38388
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr char INF = 100;
constexpr int MOD = 1e9+7;

map<int,int> cnt;
int nxt[] = {1,-1,4,-4};

int main(void) {
    int i, j, k;
    cnt[1234567] = 0;
    queue<string> q;
    q.push("01234567");
    while (!q.empty()) {
        string s = q.front();
        q.pop();
        REP (i,8) if (s[i] == '0') REP (k,4) {
            string t = s;
            j = i + nxt[k];
            if (j < 0 || j >= 8 || i+j == 7) continue;
            swap(t[i],t[j]);
            if (!cnt.count(stoi(t)) || cnt[stoi(t)] > cnt[stoi(s)] + 1) {
                cnt[stoi(t)] = cnt[stoi(s)] + 1;
                q.push(t);
            }
        }
    }
    while (true) {
        int i, a, x = 0;
        for (i = 0; i < 8 && cin >> a; i++) x = x * 10 + a;
        if (x == 0) break;
        cout << cnt[x] << endl;
    }
    return 0;
}

Measured memory_bytes: 4136
using System;

namespace cola2
{
    class Program
    {
        static void Main(string[] args)
        {
            int first = 0;
            int second = 0;
            //int answer = 0;
            int amari = 0;
            string[] s_num = Console.ReadLine().Trim().Split(' ');
            if (int.Parse(s_num[0]) > int.Parse(s_num[1]))
            {
                first = int.Parse(s_num[0]);
                second = int.Parse(s_num[1]);
            }
            else
            {
                first = int.Parse(s_num[1]);
                second = int.Parse(s_num[0]);
            }

            while (true)
            {
                //answer = first / second;
                amari = first % second;
                if (amari == 0)
                {
                    Console.WriteLine(second);
                    break;
                }
                else
                {
                    first = second;
                    second = amari;
                }
            }
        }
    }
}

Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

int main(int argc, char **argv)
{
        int V, E, r;
        cin >> V >> E >> r;
        vector<vector< pair<int, int>>> A(V);
        for (int i = 0; i < E; i++) {
                int s, t, d;
                cin >> s >> t >> d;
                A[s].push_back({t, d});
        }
        vector<int> d(V, INT_MAX);
        d[r] = 0;
        bool done = false;
        while (!done) {
                done = true;
                for (int i = 0; i < V; i++) {
                        if (d[i] == INT_MAX)
                                continue;
                        for (auto n: A[i]) {
                                int m = d[i] + n.second;
                                if (m < d[n.first]) {
                                        d[n.first] = m;
                                        done = false;
                                }
                        }
                }
        }
        for (int i = 0; i < V; i++) {
                if (d[i] == INT_MAX)
                        cout << "INF";
                else
                        cout << d[i];
                cout << endl;
        }
        return 0;
}

Measured memory_bytes: 11940
#include <stdio.h>
long long expo(long long M, long long m, long long n){
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return m;
    }
    long long aHalf = expo(M, m, n / 2) % M;
    if(n % 2 == 1){
        return (((aHalf * aHalf) % M) * m) % M;
    }else{
        return (aHalf * aHalf) % M;
    }
}
int main(){
int m,n,i;
long long ans = 0, M = 1000000007;
scanf("%d%d", &m, &n);
int result = (int) expo(M, m * 1LL, n * 1LL);
printf("%d\n", result);
return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005

long int gcd(int a, int b) {
	if (a < 0) a *= -1;
	if (b < 0) b *= -1;
	if (a < b) {
		int t = a;
		a = b; 
		b = t;
	}
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int a, b;
	while (cin >> a >> b) {
		int g = gcd(a, b);
		cout << g << " " << (a / g * b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int jo(int a, int b) {
	int i, j;
	j = a;
	for (i = 1; i < b; i++) {
		a *= j;
	}

	return a;
}

int main() {
	int i, j, k, l, m, n, x;

	scanf("%d",&x);

	m = 1;
	for (i = 2; i <= x; i++) {
		j = 2;
		k = jo(i, j);
		while (k <= x) {
			m = m < k ? k : m;
			j++;
			k = jo(i, j);
		}
	}

	printf("%d", m);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int trump[101]={};
int n;

int main(void)
{
    scanf("%d",&n);
    int i,j;

    for(i=0;i<n;i++)
    {
        scanf("%d",&trump[i]);
    }
    int count=0;
    int minj,c;
    for(i=0;i<n;i++)
    {
        minj=i;
        for(j=i;j<n;j++)
        {
            if(trump[j]<trump[minj])
            {
                minj=j;
            }
        }
        if(i!=minj)
        {
            c=trump[i];
            trump[i]=trump[minj];
            trump[minj]=c;
            count++;
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d",trump[i]);
        if(i<n-1)printf(" ");
    }
    printf("\n%d\n",count);


    return 0;
}

Measured memory_bytes: 604
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    string s , t;
    cin >> s >> t;

    int ns = s.size();
    int nt = t.size();

    int ans = nt;

    forn(i,0,ns-nt+1){
        int flag = 0;
        forn(j,0,nt){
            if(s[i+j] != t[j]){
                flag++;
            }
        }

        if(ans > flag)ans = flag;

    }
    
    cout << ans ;    

    
    
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


Measured memory_bytes: 3608
#import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=int(input())
li= [int(x) for x in input().split()]
lar=li[0]
ans=1
for i in range(1,N):
  if li[i]>=lar:
    ans+=1
    lar=li[i]
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

struct Combination {
	vector<int64_t> _fact, _rfact, _inv;
	int64_t MOD;

	Combination(size_t sz, int64_t mod) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1), MOD(mod) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; ++i) {
			_fact[i] = _fact[i - 1] * i % MOD;
		}
		_rfact[sz] = inverse(_fact[sz]);
		for (int i = sz - 1; i >= 0; --i) {
			_rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
		}
		for (int i = 1; i <= sz; ++i) {
			_inv[i] = _rfact[i] * _fact[i - 1] % MOD;
		}
	}

	inline int64_t fact(int k) const { return _fact[k]; }
	inline int64_t rfact(int k) const { return _rfact[k]; }
	inline int64_t inv(int k) const { return _inv[k]; }

	int64_t inverse(int64_t x) const { return pow(x, MOD - 2); }
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}

	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(n - r) % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
	}
	int64_t H(int n, int r) const {
		if (n < 0 || r < 0) { return 0; }
		return r == 0 ? 1 : C(n + r - 1, r);
	}
};

int main() {
	constexpr Int MOD = 1e9 + 7;
	Int N, K;
	cin >> N >> K;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	Combination cb(K, MOD);
	Int ans = cb.P(K, g[0].size() + 1);
	vector<bool> used(N, false);
	used[0] = true;
	deque<int> que;
	for (auto v : g[0]) { que.emplace_back(v); }
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		if (used[u]) { continue; }
		used[u] = true;
		(ans *= cb.P(K - 2, g[u].size() - 1)) %= MOD;
		for (auto v : g[u]) {
			if (used[v]) { continue; }
			que.emplace_back(v);
		}
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 11996
#include<iostream>
using namespace std;
int main(){
  int a,d,n,so[1000000]={},c,i,j;
  so[1]=1;
  for(i=2;i<1000;i++)if(so[i]==0)for(j=2;i*j<1000000;j++)so[i*j]=1;
  while(1){
    cin>>a>>d>>n;
    if(n==0)break;
    c=0;
    for(i=a;c<n;i+=d)if(so[i]==0)c++;
    cout<<i-d<<endl;
  }
  return 0;
}

Measured memory_bytes: 5072
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
template<class T>void mini(T &a,T b){a=min(a,b);}
template<class T>void maxi(T &a,T b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
void addin(){}template<class Head,class...Tail>void addin(vector<Head>&vechead,Tail&&...tail){in(Head,head);vechead.emb(head);addin(forward<Tail>(tail)...);}
template<class C>void vecout(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}

#define int int64_t
// #define double long double


signed main(){
  IOS;

  in(int,n);
  VI a(n+2);fou(i,1,n+1) cin>>a[i];
  int allyen=0;
  fou(i,0,n+1) allyen+=abs((a[i+1]-a[i]));

  fou(i,1,n+1){
    int yen=allyen-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
    out(yen);
  }

}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
enum {LE = -1, EQ = 0, GE = 1};
int A[100000 + 1];
int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  int N; cin >> N;
  int total{1}, flag{EQ};
  if (N <= 2) {
    goto END;
  }
  cin >> A[0];
  for (size_t i{1}; i < N; ++i) {
    cin >> A[i];
    if (A[i] < A[i - 1]) {
      if (flag == GE) {
        ++total;
        flag = EQ;
        continue;
      }
      flag = LE;
    } else if (A[i] > A[i - 1]) {
      if (flag == LE) {
        ++total;
        flag =EQ;
        continue;
      }
      flag = GE;
    }
  }

  END:
  cout << total << "\n";
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		char[] ch = S.toCharArray();
		boolean bool = true;
		for(int i = 0;i < ch.length;i++) {
			if(((i+1)%2==0 && ch[i] =='R') || ((i+1)%2==1 && ch[i] =='L')) {
				bool = false;
			}
		}
		System.out.println(bool ? "Yes" : "No");
	}

}

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

int main(){
    int N; cin >> N;
    int a[N];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  string n;
  cin>>n;
  if((n[0]==n[1] || n[2]==n[3])&& n[1] ==n[2]){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N, K = list(map(int, input().strip().split()))
    return N, K


def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf


def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD


def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 24976
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		var x = Console.ReadLine().Split().Select(y=>int.Parse(y)).ToArray();
		int a = x[0];
		int b = x[1];
		int h = x[2];
		int m = x[3];
		
		double aa = 30*h + 0.5*m;
		double bb = 6*m;
		double theta;
		if(aa>=bb){
			theta = aa - bb;
		}else{
			theta = bb - aa;
		}
		if(theta>180){theta = 360 - theta;}
		double cos = Math.Cos(theta * (Math.PI / 180));
		
		double ans = Math.Sqrt(a*a + b*b - 2*a*b*cos);
		Console.WriteLine(ans);
		
	}
}

Measured memory_bytes: 28620
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<char> name(N);
    REP(i, N) {
        string allname;
        cin >> allname;
        name[i] = allname[0];
    }
    sort(name.begin(), name.end());

    vector<int> count(5);
    int index = 0;
    string march = "MARCH";
    sort(march.begin(), march.end());
    for (int i = 0; i < 5; i++) {
        int start = distance(name.begin(), lower_bound(name.begin(), name.end(), march[0]));
        if (start == N) {
            count[i] = 0;
        } else {
            int tmp = 0;
            for (int s = start; s < N; s++) {
                if (name[s] == march[i]) tmp++;
            }
            count[i] = tmp;
        }
    }


    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            for (int k = j+1; k < 5; k++) {
                ans += ll(count[i]) * count[j] * count[k];
            }
        }
    }
    print(ans);
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b,c,d; 
    cin >> a >> b >> c >> d;
    int s=0;
    
    if (a==b){
        if(c==d && a!=c){
            s=1;
        }
    }else if(a==c){
        if(b==d && a!=b){
            s=1;
        }
    }else if(a==d){
        if(b==c && a!=b){
            s=1;
        }
    }
    
    if(s==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256