akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

	static int MOD = 1_000_000_007;
	static int MAX = 2_000_000;
	static long[] fac = new long[MAX+1];
	static long[] finv = new long[MAX+1];
	static long[] inv = new long[MAX+1];
	
	static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i <= MAX; i++) {
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}
	
	static long cmb(int n, int k){
		if(n < k || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		int N = S.length();
		COMinit();
		long ans = 0, p = 1;
		for(int i = 0; i <= K; i++) {
			ans = (ans + cmb(N+K, i) * p) % MOD;
			p = p * 25 % MOD;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 102788
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <unordered_map>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e9;
const LL MAX = 2e5 + 7;
const LL MAXN = 5e5 + 1;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	LL x, y;
	cin >> x >> y;

	if (x%y == 0)
	{
		cout << -1;
		return 0;
	}

	cout << x;
	




	return 0;
}

Measured memory_bytes: 764
import itertools
n,m = map(int,input().split())
vert = [[0] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    vert[a].append(b)
    vert[b].append(a)
parents = [0]
now = 1
ans = 0
for i in list(itertools.permutations(range(1,n+1))):
    if i[0] == 1:
        for j in range(1,n):
            if i[j] not in vert[i[j-1]]:
                break
        else:
            ans += 1
print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  int ans;
  if(N%2== 0){
    ans = N / 2 - 1;
  }
  else{
    ans = N/2;
  }
  
  cout << ans;
  return 0;
}

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

int main(){
	long i,l,r=0,N,a[200001],check,ans=0;
	scanf("%ld",&N);
	for(i=0;i<N;i++){
		scanf("%ld",&a[i]);
	}

	for(l=0;l<N;l++){
		while(r<=N){
			if(r==l){
				if(r==N-1){
					ans++;
					break;
				}
				check=a[r];
				r++;
				continue;
			}
			if(r==N || (check^a[r])!=check+a[r]){
				ans+=r-l;
				break;
			}
			check=check+a[r];
			r++;
		}
		check=check-a[l];
	}

	printf("%ld\n",ans);

	return 0;
}

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

int main() {
    long long a,b,c;
    cin>>a>>b>>c;

    if(a+b==c||a==b+c||a+c==b){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
a = list(map(int,input().split()))
th = a[0]
ta = a[1]
ah = a[2]
aa = a[3]
res = ''
while th>0 or ah>0:
    ah -= ta
    if ah<=0:
        res = 'Yes'
        break
    else:
        th -= aa
    if th<=0:
        res = 'No'
        break
print(res)
        

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
//typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n;
    while(cin>>n &&n){
        vector<vector<int>> v(n,vector<int>(n));
        rep(i,0,n){
            int x; cin>>x;
            rep(j,0,x){
                int num; cin>>num; num--;
                v[i][num]=1;
            }
        }
        int k; cin>>k;
        vector<int> ans;
        rep(i,0,k){
            int num; cin>>num; num--;
            ans.pb(num);
        }
        
        int count=0,ansnum=0;
        rep(i,0,n){
            bool ok=true;
            rep(j,0,ans.size()){
                if(v[i][ans[j]]!=1)ok=false;
            }
            if(ok){
                count++;
                ansnum=i+1;
            }
        }
        if(count==1)cout<<ansnum<<endl;
        else cout<<-1<<endl;
    }
    
    return 0;
}



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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> P(N), ord(N);
  for (int &e : P) std::cin >> e;
  std::iota(ord.begin(), ord.end(), 0);
  std::sort(ord.begin(), ord.end(),
            [&](int a, int b) { return P[a] < P[b]; });
  int left = N;
  int ans = 0;
  for (int i : ord) {
	if (i < left) {
      ans++;
      left = i;
    }
  }
  
  std::cout << ans << std::endl;
  return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;



int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];

    int A[n]={0};
    int bt=1;
    int ans=0;
    A[bt-1]++;
    while(1){
        bt=a[bt-1];
        A[bt-1]++;
        ans++;
        if(bt==2){
            cout<<ans<<endl;
            return 0;
        }
        if(A[bt-1]>1){
            cout<<-1<<endl;
            return 0;
        }
    }

    return 0;
}




Measured memory_bytes: 1024
#[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)*}
    };
}

#[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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      x: usize,
    }
    for n in 1.. {
        if n*(n+1)/2 >= x {
            println!("{}", n);
            return;
        }
    }
}


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

using namespace std;

double av;
int n;
vector<pair<int,int>> points;

int main() {
	cin >> n;
	points.resize(n);
	for(pair<int,int>& p: points)
		cin >> p.first >> p.second;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(i != j)
				av += sqrt((points[i].first - points[j].first)*(points[i].first - points[j].first) + (points[i].second - points[j].second)*(points[i].second - points[j].second));
	av /= n;
	cout << fixed << setprecision(6) << av;
	
    return 0;
}


Measured memory_bytes: 256
dic1 = {}
dic2 = {}
n = int(input())
for i in range(n):
    line = input()
    if line not in dic1:
        dic1[line] = 1
    else:
        dic1[line] += 1
m = int(input())
for i in range(m):
    line = input()
    if line not in dic2:
        dic2[line] = 1
    else:
        dic2[line] += 1
key1 = list(dic1.keys())
ls = [0]*len(dic1)
for i in range(len(dic1)):
    if key1[i] in dic2:
        ls[i] = dic1[key1[i]]-dic2[key1[i]]
    else:
        ls[i] = dic1[key1[i]]
print(max(ls) if max(ls)>0 else 0)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

visit=defaultdict(lambda: 0) #0:未訪問、1:訪問済み
d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((CH,CW))
d[(CH,CW)]=0

while q:
    fro_h, fro_w=q.popleft()
    if visit[(fro_h, fro_w)]==1: continue
    visit[(fro_h, fro_w)]=1
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and d[(fro_h, fro_w)]<d[(to_h, to_w)] and visit[(to_h, to_w)]==0:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]
            q.appendleft((to_h, to_w))

    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and d[(fro_h, fro_w)]+1<d[(to_h, to_w)] and visit[(to_h, to_w)]==0:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]+1
            q.append((to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


Measured memory_bytes: 248200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "SUN") cout << 7 << endl;
	if (s == "MON") cout << 6 << endl;
	if (s == "TUE") cout << 5 << endl;
	if (s == "WED") cout << 4 << endl;
	if (s == "THU") cout << 3 << endl;
	if (s == "FRI") cout << 2 << endl;
	if (s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		scanner.close();
		int num = 0;

		for (int n = 1; n <= K; n++) {
			for (int m = 1; m <= K; m++) {
				if (n <= m) {
					continue;
				}
				if (n % 2 == 0) {
					if (m % 2 == 1) {
						num++;
					} else {
						continue;
					}
				} else {
					if (m % 2 == 0) {
						num++;
					} else {
						continue;
					}
				}
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, b[10] = {}, c;
    cin >> n >> k;
    while (k--) cin >> c, b[c] = 1;
    for (int i = n; i < 890328; i++) {
        string s = to_string(i);
        bool d = 0;
        for (char e : s) if (b[e - '0']) d = 1;
        if (!d) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	int f[10001];
	f[1] = 2;
	rep2(i,2,10001) {
		f[i] = f[i-1] + i;
	}
	int n;
	while(cin >> n) {
		cout << f[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
n = int(input())
for i in range(n):
    s = input()
    train = [s[0]]
    for i in range(1,len(s),3):
        ind = train.index(s[i-1])
        if s[i:i+2] == "->" and s[i+2] not in train:
            train.insert(ind+1, s[i+2])
        elif  s[i:i+2] == "<-" and s[i+2] not in train:
            train.insert(ind,s[i+2])
    print("".join(train))


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

int main() {

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" <<endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" <<endl;
  }
  else {
    cout << "Right" <<endl;
  }
  
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
int main() {
   int n; cin >> n;
   vector<int> vec(n);
   rep(i,n) cin >> vec.at(i);
   int ans = 0;
   rep(i,n) if(i+1 != vec.at(i)) ans++;
   if(ans <= 2) cout << "YES" << endl;
   else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3608
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2000 + 5 , mod = 924844033 ;
int n , k , save[N][N] , dp[N] , fac[N] , ans ; 

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
	if (a < 0) a += mod ;
}

void pre () {
	save[0][0] = 1 , save[1][0] = 1 , save[1][1] = 1 ;

	for (int i = 2 ; i < N ; i ++) {
		for (int j = 0 ; j <= i ; j ++) {
			add(save[i][j] , save[i - 1][j]) ;
			if (j) add(save[i][j] , save[i - 2][j - 1]) ;
		}
	}

	fac[0] = 1 ;
	for (int i = 1 ; i < N ; i ++) fac[i] = 1ll * fac[i - 1] * i % mod ;
}

inline void upd (int c) {
	for (int i = n ; i >= 0 ; i --)
		for (int j = min(i , (c + 1) / 2) ; j > 0 ; j --)
			add(dp[i] , 1ll * dp[i - j] * save[c][j] % mod) ;
}

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

	pre() ;

	cin >> n >> k ;

	dp[0] = 1 ;

	for (int i = 0 ; i < k ; i ++) {
		int c = (n + k - i - 1) / k - 1 ;
		upd(c) ;
		upd(c) ;	
	}

	for (int i = 0 , z = 1 ; i <= n ; i ++ , z *= -1) {
		add(ans , 1ll * z * dp[i] * fac[n - i] % mod) ;
		int ad = 1ll * z * dp[i] * fac[n - i] % mod ;
	}

	add(ans , mod) ;

	cout << ans << '\n' ;
}


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

using namespace std;
typedef long long ll;

int main(void) {
  string s;
  cin >> s;
  int wsum = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'o')
      wsum++;

  //cout << wsum << endl;
  cout << (8 <= wsum + (15 - s.length()) ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    N%=1000;
    if(N==0)
      System.out.println("0");
    else
      System.out.println(1000-N);
  }
}

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

int main(void)
{
	int n, min, max;
	long sum;
	int i;

	scanf("%d", &n);

	int *p = (int *) malloc( n * sizeof(int) );

	for(i=0; i<n; i++)
		scanf("%d", p+i);

	min = *p;
	max = *p;
	sum = 0;

	for(i=0; i<n; i++)
	{
		if( min > *(p+i))
			min = *(p+i);
		if( max < *(p+i))
			max = *(p+i);
		sum += *(p+i);
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct Edge {
    ll to, id;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<Edge>> g(n);
    vector<ll> ans(n - 1, -1);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back((Edge){b, i});
        g[b].push_back((Edge){a, i});
    }
    rep(i, n) {
        set<ll> s;
        set<ll> colors;
        rep(ii, sz(g[i])) colors.insert(ii);
        rep(ii, sz(g[i])) {
            if (ans[g[i][ii].id] != -1) {
                colors.erase(ans[g[i][ii].id]);
            }
            else {
                s.insert(g[i][ii].id);
            }
        }
        for(auto p : s) {
            auto it = colors.begin();
            ans[p] = *it;
            colors.erase(it++);
        }
    }
    set<ll> cc;
    rep(i, n - 1) cc.insert(ans[i]);
    cout << sz(cc) << endl;
    rep(i, n - 1) {
        cout << (ans[i] + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 9460
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
INF = float("inf")


from collections import defaultdict


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append((t, w))
        self.E[t].append((f, w))


def solve(N: int, a: "List[int]", u: "List[int]", v: "List[int]"):

    g = Graph(N)
    for x, y in zip(u, v):
        g.add_edge(x-1, y-1)

    ans = [0]*N

    dp = [INF]*N
    event = []
    var = {"last": 0}

    def dfs(curr, par):
        i = bisect_left(dp, a[curr])
        if dp[i] > a[curr]:
            if dp[i] == INF:
                var["last"] = i
            event.append((curr, i, dp[i]))
            dp[i] = a[curr]

        ans[curr] = var["last"]+1

        for child, w in g.E[curr]:
            if child == par:
                continue
            dfs(child, curr)

        c, i, v = event[-1]
        if c == curr:
            dp[i] = v
            if v == INF:
                var["last"] = i-1
            event.pop()

    dfs(0, -1)
    print(*ans, sep="\n")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, a, u, v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 335740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int a,b;
	scanf("%d %d", &a, &b);

	if(a+b==15){
		printf("+\n");
	}else if(a*b==15){
		printf("*\n");
	}else{
		printf("x\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007
 
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/

int main()
{
	IOS;
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]!='s'){
		s.push_back('s');
	}
	else{
		s.pb('e');
		s.push_back('s');
	}
	cout<<s;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int h,w;
char f[60][60];

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

int main(){
  scanf("%d %d",&h,&w);
  REP(i,h){
    scanf("%s",f[i]);
  }
  REP(i,h)REP(j,w){
    int cnt=0;
    if(f[i][j]=='#')
      continue;
    REP(k,8){
      int y=i+dy[k],x=j+dx[k];
      if(y>=0&&y<h&&x>=0&&x<w){
        if(f[y][x]=='#')cnt++;
      }
    }
    f[i][j]='0'+cnt;
  }
  REP(i,h){
    printf("%s\n", f[i]);
  }
  return 0;
}


Measured memory_bytes: 128
/* -------------------------------- */
/* Name: MD. Khairul Basar          */
/* Institute: HSTU                  */
/* Dept: CSE                        */
/* Email: khairul.basar93@gmail.com */
/* -------------------------------- */

#include <bits/stdc++.h>
/* all header files */

#define fs            first
#define sc            second
#define sp            printf(" ")
#define nl            printf("\n")
#define pb(a)         push_back(a)

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))

#define tc1(x)        printf("Case %d: ",x)
#define tc2(x)        printf("Case #%d: ",x)
#define tc3(x)        printf("Case %d:\n",x)
#define tc4(x)        printf("Case #%d:\n",x)

#define iin(x)        scanf("%d",&x)
#define din(x)        scanf("%lf",&x)
#define lin(x)        scanf("%lld",&x)
#define clin(x)       scanf("%I64d",&x)

#define pr1(x)        cout<<x<<"\n"
#define pr2(x,y)      cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n"
#define pr4(w,x,y,z)  cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define fast          ios::sync_with_stdio(0)
#define read          freopen("input.txt","r",stdin)
#define write         freopen("output.txt","w",stdout)
#define prflag1(flag) printf("%s\n",(flag)?"YES":"NO")
#define prflag2(flag) printf("%s\n",(flag)?"Yes":"No")
#define prflag3(flag) printf("%s\n",(flag)?"yes":"no")
/* macro definitions */

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int>pii;
typedef pair<LL, LL>pll;
typedef vector<int>vi;
typedef vector<LL>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
/* type definitions */

LL MOD_EXPO(LL b, LL p, LL m)
{
    if(p==0) return 1;
    LL ret=MOD_EXPO(b,p/2,m)%m;
    ret=(ret*ret)%m;
    return ((p&1) ? (ret*b)%m : ret%m);
}
LL POWER(LL N, LL K)
{
    LL i,ans=1;
    for(i=1;i<=K;i++) ans*=N;
    return ans;
}
int SET(int N, int pos)
{
    return (N | (1<<pos));
}
int RESET(int N, int pos)
{
    return (N & !(1<<pos));
}
bool CHECK(int N, int pos)
{
    return (N & (1<<pos));
}
/* necessary functions */

int dx4[]= {1,-1,0,0};
int dy4[]= {0,0,1,-1};
int dx6[]= {0,0,1,-1,0,0};
int dy6[]= {1,-1,0,0,0,0};
int dz6[]= {0,0,0,0,1,-1};
int dx8[]= {1,-1,0,0,-1,1,-1,1};
int dy8[]= {0,0,1,-1,1,1,-1,-1};
int dkx8[]= {-1,1,-1,1,-2,-2,2,2};
int dky8[]= {2,2,-2,-2,1,-1,1,-1};
/* direction arrays */

int tc=1;
const double eps=1e-9;
const double pi=acos(-1.0);
const long long int mx=1e5;
const long long int mod=1e9+7;
/* global declarations */

int main()
{
    string s1,s2,s3;
    while(cin>>s1>>s2>>s3)
    {
        printf("%c%c%c\n",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 200005;

vector <char> visited;
vector <int> g1[MAXN];
vector <int> g2[MAXN];
map < pair <int, int>, int > m;
int cmp1[MAXN];
int cmp2[MAXN];

void dfs(vector<int> *g, int *cmp, int cmpcnt, int v)
{
    visited[v] = true;
    cmp[v] = cmpcnt;
    for (int i = 0; i < g[v].size(); i++)
    {
        if (!visited[g[v][i]]) dfs(g, cmp, cmpcnt, g[v][i]);
    }
}


int main()
{
    int n, k, l;
    cin >> n >> k >> l;
    for (int i = 0; i < k; i++)
    {
        int u, v;
        cin >> u >> v;
        g1[u].pb(v);
        g1[v].pb(u);
    }
    for (int i = 0; i < l; i++)
    {
        int u, v;
        cin >> u >> v;
        g2[u].pb(v);
        g2[v].pb(u);
    }

    int cmpcnt;

    visited.assign(n+1, false);
    cmpcnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            cmpcnt++;
            dfs(g1, cmp1, cmpcnt, i);
        }
    }

    visited.assign(n+1, false);
    cmpcnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            cmpcnt++;
            dfs(g2, cmp2, cmpcnt, i);
        }
    }


    for (int i = 1; i <= n; i++)
    {
        m[{cmp1[i], cmp2[i]}]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << m[{cmp1[i], cmp2[i]}] << " ";
    }



    return 0;
}


Measured memory_bytes: 28160
#include <stdio.h>
#include <iostream>
#include <string>
//#include <cmath>
#include <vector>
// #include <algorithm>
// #include <bits/stdc++.h>
using namespace std;

int main() {
  while (1) {
    int x, y;
    cin >> x >> y;

    for (int i=0; i<x; i++) {
      for (int j=0; j<y; j++) {
	if ((i+j) % 2 == 0) {
	  cout << "#";
	} else {
	  cout << ".";
	}
      }
      cout << endl;
    }

    if(x==0 || y==0) break;
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
long long lcm(long long x, long long y){
  return (x/__gcd(x,y))*y;
}
int main(){
  int n;
  long long ans = 1;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  long long c=a[0];
  for(int i=0;i<n;i++)
   ans = lcm(ans,a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		int C = scn.nextInt();
		System.out.println(Math.min(B/A, C));
	}

}


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

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};


// Set,Add,Getmin,Getsum
int main(){
  ll n,q;
  cin >> n >> q;
  segtree T(n);
  T.Set(0,n,2147483647);
  for(ll i=0;i<q;i++){
    ll type,a,b;
    cin >> type >> a >> b;
    if(type==0){
      T.Set(a,a+1,b);
    }
    else {
      cout << T.Getmin(a,b+1) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 11016
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vb = vector<bool>;
using qi = queue<int>;
using Graph = vector<vector<int>>;

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

qi que;
vi dist;

void bfs(Graph &G) {
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for(int next_v : G[v]) {
            if (dist[next_v] != -1) continue;
            que.push(next_v);
            dist[next_v] = dist[v] + 1;
        }
    }
}

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

    int n; cin >> n;
    Graph G(n);
    REP(i, n) {
        int u; cin >> u;
        int k; cin >> k;
        REP(j, k) {
            int v; cin >> v;
            G[i].push_back(v-1);
        }
    }

    que.push(0);
    dist.assign(n, -1);
    dist[0] = 0;
    bfs(G);

    REP(i, n) {
        cout << (i+1) << " " << dist[i] << "\n";
    }
}


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

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

typedef long long ll;

const ll INF = 1 << 30;

struct edge{
    int to;
    int cost;
    edge(int t, int c){
        to = t;
        cost = c;
    }
};

ll G[15][15];
ll dp[(1 << 15)][15];
int states;
int V,E;

void init(){
    rep(i, 15) rep(j, 15) G[i][j] = INF;
}

ll dfs(int S, int v){
    //S -> S | to への遷移
    if(dp[S][v] >= 0) return dp[S][v];
    if(S == states-1 && v == 0) return dp[S][v] = 0;

    ll ans = INF;
    for(int to = 0; to < V; to++){
        //まだtoに行っていない
        if(!((S >> to) & 1)) ans = min(ans, dfs(S|(1 << to), to) + G[v][to]);
    }
    dp[S][v] = ans;
    return ans;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    cin >> V >> E;
    states = (1 << V);
    memset(dp, -1, sizeof(dp));
    rep(i, E){
        int f, t, c; cin >> f >> t >> c;
        G[f][t] = c;
    }

    ll ans = min(INF, dfs(0, 0));
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 7052
import sys,queue,math,copy
input = sys.stdin.readline
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
N = int(input())
A = LI()
c =[0,0,0]
cnt = [0 for _ in range(N)]
for i in range(N):
    cnt[i] = c.count(A[i])
    if cnt[i] == 0: break
    c[c.index(A[i])] += 1
ans = 1
for i in range(N):
    ans = (ans * cnt[i]) % MOD
print (ans)

Measured memory_bytes: 57500
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}
int main(void){
  long i;
  long len,count;
  long price=0;
  long ii[1000000][2];
  scanf("%ld %ld",&len,&count);
  for(i=0;i<len;i++){
    scanf("%ld %ld",&ii[i][0],&ii[i][1]);
  }
  qsort(ii, len, sizeof(ii[0]), compare_int);
  for(i=0;i<len;i++){
//       printf("i%ld %ld %ld\n",i,ii[i][0],ii[i][1]);
  }
  for(i=0;i<len;i++){
        if(ii[i][1] >= count){
			price += ii[i][0] * count;
			printf("%ld\n",price);
          	return 0;
        }
    	else{
			price += ii[i][1] * ii[i][0];
			count -= ii[i][1];
        }
  }
  return 0;

}


Measured memory_bytes: 5244
n=int(input())
h=list(map(int, input().split()))

ans="Yes"

for i in reversed(range(1, len(h))):
    if h[i] < h[i-1]:
        h[i-1]-=1
        if h[i] < h[i-1]:
            ans="No"
            break
print(ans)


Measured memory_bytes: 14396
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int MAXA = 1e6 + 5;

int a[MAXN];
int t[MAXA];
bool cannt[MAXA];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	for(int i=1; i<=n; ++i)
		++t[a[i]];
	
	for(int i=1; i<MAXA; ++i)
	{
		if(!t[i]) continue;
		for(int j = i<<1; j<MAXA; j+=i)
			cannt[j] = 1;
	}
	
	int ans = 0;
	for(int i=1; i<=n; ++i)
		if(cannt[a[i]] || t[a[i]]>1);
		else ++ans;
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 7312
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=500069;
char s[N];
int s9[N],sp[N],sm[N];
int n;

bool check(int km)
{
	// printf("km=%d\n",km);
	int tk=km*9;
	int g=0;
	for(int i=1;i<=n;i++)
	{
		tk+=s9[i];
		g+=tk%10;
		tk/=10;
	}
	while(tk)
	{
		g+=tk%10;
		tk/=10;
	}
	return g<=km*9;
}

signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	reverse(s+1,s+1+n);
	int g;
	for(int i=1;i<=n;i++)
		s9[i]=9*(s[i]-'0');
	for(int i=1;i<=n;i++) s9[i+1]+=s9[i]/10,s9[i]%=10;
	if(s9[n+1]) n++;
	int el=0,er=n*2,em,ans;
	while(el<=er)
	{
		if(check(em=(el+er)>>1)) ans=em,er=em-1;
		else el=em+1;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  ll x,k,d,a=0;
  cin>>x>>k>>d;
  x=abs(x);
  double p=x/d;
  ll q=(p+0.5)/1;
  if(q==(p+0.5)){
    q=q-1;
  }
  else if(k<=q){
    q=k;
  }
   ll min=abs(x-q*d);
    if((k-q)%2==0){
      cout<<min<<endl;
    }
    else{
	cout<<abs(d-min)<<endl;
    }
}
    
  


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n; cin >> n;
    vector<pair<ll,ll>> r(n), b(n);
    rep(i, 0, n) cin >> r[i].first >> r[i].second;
    rep(i, 0, n) cin >> b[i].first >> b[i].second;

    sort(b.begin(), b.end());

    vector<bool> used(n, false);
    ll ans = 0;

    rep(i, 0, n){
        ll bx = b[i].first;
        ll by = b[i].second;
        ll target = -1, mx = -1;
        rep(j, 0, n){
            ll rx = r[j].first;
            ll ry = r[j].second;
            if(!used[j] && rx < bx && ry < by){
                if(ry > mx){
                    mx = ry;
                    target = j;
                }
            }
        }
        if(mx != -1){
            used[target] = true;
            ans++;
        }
    }

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


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

int main() {
	int n;
	cin >> n;
	string s[n];
	set<string> se;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		se.insert(s[i]);
	}
	cout << se.size() << endl;
}

Measured memory_bytes: 25504
N = int(input())
List = [input() for i in range(N)]
from collections import Counter
C = Counter(List)
C = C.most_common()
Newlist = []

for p in range(len(C)):
  if C[p][1] == C[0][1]:
    Newlist.append(C[p][0])
  else:
    break
Newlist.sort()
for i in range(len(Newlist)):
  print(Newlist[i])

Measured memory_bytes: 45072
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range;

void main() {
  auto N = readln.split[0].to!int;
  auto s = new string[N];
  foreach(i; 0..N) {
    s[i] = readln.split[0];
  }

  auto bucket = new int[26][N];
  foreach(i; 0..N) {
    foreach(c; s[i]) {
      bucket[i][c - 'a']++;
    }
  }

  int[int[26]] m;

  ulong ans = 0;
  foreach(b; bucket) {
    if(b in m) {
      ans += m[b];
    }
    m[b]++;
  }
  ans.writeln;
}


Measured memory_bytes: 31356
import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
    try{
      String str=mBufferedReader.readLine();
      String[] arr=str.split(" ");
      
      int W=Integer.parseInt(arr[0]);
      int H=Integer.parseInt(arr[1]);
      int x=Integer.parseInt(arr[2]);
      int y=Integer.parseInt(arr[3]);
      int r=Integer.parseInt(arr[4]);
      
      if((x>=r&&y>=r)&&(x+r<=W&&y+r<=H)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }catch(IOException e){
      System.out.println("Error");
    }
  }
}


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

using namespace std;

long long F[200001], AA[200001], BB[200001], D[200001], MOD=1000000007;

long long Power(long long a, long long k)
{
    long long t=1, S=a, Su=1;
    while (k > 0)
    {
        if (k % (2*t) != 0)
        {
            k -= t;
            Su *= S;
            Su %= MOD;
        }
        t *= 2;
        S *= S;
        S %= MOD;
    }
    return Su;
}

int main()
{
    long long N, A, B, C, P=0, Q=1, S1, S2, S;
    cin >> N >> A >> B >> C;
    AA[0] = 1;
    BB[0] = 1;
    F[0] = 1;
    D[0] = 1;
    for (int i = 1; i <= 2*N; i++)
    {
        AA[i] = AA[i-1] * A;
        BB[i] = BB[i-1] * B;
        AA[i] %= MOD;
        BB[i] %= MOD;
        F[i] = F[i-1] * i;
        F[i] %= MOD;
        D[i] = D[i-1] * (100-C);
        D[i] %= MOD;
    }
    for (int i = N; i <= 2*N-1; i++)
    {
        S1 = F[i-1];
        S2 = F[N-1];
        S1 *= i;
        S1 %= MOD;
        S = AA[N]*BB[i-N] + AA[i-N]*BB[N];
        S %= MOD;
        S1 *= S;
        S1 %= MOD;
        S1 *= 100;
        S1 %= MOD;
        S2 *= F[i-N];
        S2 %= MOD;
        S2 *= D[i+1];
        S2 %= MOD;
        P = (P*S2 + S1*Q) % MOD;
        Q = (S2*Q) % MOD;
    }
    S = (P * Power(Q, MOD-2)) % MOD;
    cout << S;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<long double> a(n);
  rep(i,n)cin >> a[i];
  long double x = 0;
  rep(i,n)x+=1.0/a[i];
  printf("%.10Lf\n",1.0/x);
  return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	int a2;
	int a3;
	int v;
	int v2;
	int v3;
	int b;
	
	
	scanf("%d", &n);
	v2 = -1;
	v3 = 0;
	
	for (b = 1; b <= n; b++){
		scanf("%d %d", &a, &v);
		if (v2 == v){
			if (v3 > a){
				v3 = a;
			}
		}
		
		if (v2 < v){
			v2 = v;
			v3 = a;
		}
	}
	printf ("%d %d\n", v3, v2);
	return (0);
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    for (int i = A; i <= min(B, A + K - 1); i++) {
        cout << i << endl;
    }
    for (int i = max (B - K + 1, A + K); i <= B; i++){
        cout << i << endl;
    }

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	string s;
	cin >> s;
	int n = s.size()-1;
  	ll ans = 0;
  	ll temp;
  	
	for (int bit = 0; bit < (1<<n); ++bit) {
    	 // 0 から 2^n-1 まで全探索
      	temp = 0;
      	rep(i,n){
            temp += s[i]-'0';
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                ans += temp; 
              	temp = 0;
            }else{
              	temp *= 10;
            }
        }
        temp += s[n] - '0';
      	ans += temp;
      	//cout << bit << temp << endl;
    }

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[10005];
int b[10005];
int main()
{
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> b[i];
	int temp = 1;
	int j = 1;
	for (int i = 1; i <= n; i++)
	{
		while (b[i] > 0)
		{
			a[j] = temp;
			j++;
			b[i]--;
		}
		temp++;
	}
	for (int i = 1; i <= h; i++)
	{
		if (i % 2 == 1)
		{
			for (int p = w*(i - 1) + 1; p <= i*w; p++)
			{
				cout << a[p] << " ";
			}
			if (i != h)
				cout << endl;
		}
		else if (i % 2 == 0)
		{
			for (int p = w*i; p >= w*(i - 1) + 1; p--)
			{
				cout << a[p] << " ";
			}
			if (i != h)
				cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define MN 3010

std::vector<int> v[MN];

int c[MN], p[MN];
bool ok[MN];
bool cmp(int a, int b) {return c[a] < c[b];}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &c[i]), p[i] = i;
	std::sort(p + 1, p + n + 1, cmp);
	for(int i = 1; i < n; i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		v[a].push_back(b); v[b].push_back(a);
	}
	for(int i = 1; i <= n; i++)
	{
		int u = p[i];
		for(int j = 0; j < v[u].size(); j++) 
			if(c[v[u][j]] < c[u] && ok[v[u][j]] == 0) ok[u] = 1; 
	}
	for(int i = 1; i <= n; i++) if(ok[i]) printf("%d ", i);
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        mut n: usize
    };

    let mut res: Vec<char> = Vec::new();
    while n > 0 {
        let mut a = n % 26;
        a = if a == 0 { 25 } else { a - 1 };
        res.push((0x61_u8 + a as u8).into());
        n = (n - 1) / 26;
    }
    let res = res.into_iter().rev().collect::<String>();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2252
k,n =  map(int,input().split())
a = list(map(int,input().split()))

sa =  []
for i in range(1,n):
    sa_ = a[i]-a[i-1]
    sa.append(sa_)

sa.append(k-max(a)+min(a))
ans = sum(sa)-max(sa)
# print(sa)
# print(k)
# print(sum(sa))
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 2147483647;

const int maxn = 1e5 + 7;
vector<int> e[maxn];

int dep[maxn], nxt1[maxn], nxt2[maxn];
int dfs(int u, int pre) {
  dep[u] = dep[pre] + 1;
  int rt = 0;
  if (e[u].size() == 1 && pre) return u;
  for (int i = e[u].size() - 1; i >= 0; i--) 
    if (e[u][i] != pre) {
      int tmp = dfs(e[u][i], u);
      //if (u == 1) {
        //cout << tmp << ' ' << dep[tmp] << ' ' << rt << ' ' << dep[rt] << endl;
      //}
      if (dep[tmp] > dep[rt]) rt = tmp;
    }
  return rt;
}

int cnt1[maxn], cnt2[maxn];
int tail;
bool check(int u, int pre, int *cnt, int *nxt) {
  dep[u] = dep[pre] + 1;
  bool flag = false;
  cnt[u] = 0;
  for (int i = e[u].size() - 1; i >= 0; i--) {
    int v = e[u][i];
    if (v == pre) continue;
    if (e[v].size() == 1) {
      cnt[u]++;
      continue;
    }
    if (flag) return false;
    flag = true;
    nxt[u] = v;
    if (!check(v, u, cnt, nxt)) return false;
  }
  if (!flag) {
    if (pre && e[u].size() < 2) exit(1);

    cnt[u]--;
    if (e[u][0] == pre) nxt[u] = e[u][1];
    else nxt[u] = e[u][0];
  }
  return true;
}

int answer[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  int root1 = dfs(1, 0);
  int root2 = dfs(root1, 0);
  //swap(root1, root2);
  if (!check(root1, 0, cnt1, nxt1)) {
    printf("-1\n");
    return 0;
  }
  //cout << root1 << ' ' << root2 << endl;
  check(root2, 0, cnt2, nxt2);

  bool flag = false;
  int cur1 = root1, cur2 = root2;
  while (cur1 && cur2) {
    //cout << cnt1[cur1] << ' ' << cnt2[cur2] << endl;
    if (cnt1[cur1] < cnt2[cur2]) break;
    if (cnt1[cur1] > cnt2[cur2]) {
      flag = true;
      break;
    }
    cur1 = nxt1[cur1];
    cur2 = nxt2[cur2];
    assert(!((cur1 && !cur2) || (!cur1 && cur2)));
  }
  int cur;
  int *cnt, *nxt;
  if (!flag) cur = root1, nxt = nxt1, cnt = cnt1;
  else cur = root2, nxt = nxt2, cnt = cnt2;
  //cout << cur << endl;

  int ptr = 1;
  while (cur) {
    answer[ ptr + cnt[cur] ] = ptr;
    for (int i = 1; i <= cnt[cur]; i++) answer[ptr + i - 1] = ptr + i;
    ptr += cnt[cur] + 1;
    cur = nxt[cur];
  }
  for (int i = 1; i <= n; i++) printf("%d ", answer[i]);
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> x(n), y(n);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    for(int j = 0; j < a; j++){
      int b, c;
      cin >> b >> c;
      b--;
      x.at(i).push_back(b);
      y.at(i).push_back(c);
    }
  }
  int res = 0;
  for(int i = 0; i < (1 << n); i++){
    vector<int> d(n, 0);
    int pos = 1;
    for(int j = 0; j < n; j++){
      if((i >> j) & 1) d.at(j) = 1;
    }
    for(int k = 0; k < n; k++){
      if(d.at(k) == 1){
        for(int l = 0; l < x.at(k).size(); l++){
          if(y.at(k).at(l) + d.at(x.at(k).at(l)) == 1) pos = 0;
        }
      }
    }
    if(pos == 1){
      int sum = 0;
      for(int k = 0; k < n; k++){
        if(d.at(k) == 1) sum++;
      }
      if(sum > res) res = sum;
    }
  }
  cout << res;
}

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

int main(){
	int n;
	cin >> n;
	int ds = 0;
	for(int i = 0; i <= 8; i++){
		ds += ((int)(n / pow(10, i)) % 10);
	}
	if(n % ds == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512