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

int main(){
	string str;
	cin >> str;

	if( str == "zyxwvutsrqponmlkjihgfedcba" )
		cout << -1 << endl;
	else{
		vector<char> s;
		for( char ch : str ){
			s.push_back(ch);
		}

		if( str.length() != 26 ){
			sort(s.begin(), s.end());
			char p = 'a', out = '/';
			for( auto it : s ){
				//cout << it << p << endl;
				if( it != p ){
					out = p+1;
					break;
				}
				p = it+1;
			}
			cout << str << (char)(p) << endl;
		}

		else {
			char c, min = 'z'+1;
			vector<char> l;
			bool bl = false;
			int ind;
			for( int j = 25; j >= 0; --j ){
				c = str[j];
				//cout << "  " << c << endl;
				for( char ch : l ){
					//cout << ch << endl;
					if( ch > c && ch < min ){
						min = ch;
						bl = true;
						ind = j;
						break;
					}
				}
				if( bl ) break;
				l.push_back(c);
			}

			for( int k = 0; k < ind; ++k )
				cout << str[k];
			cout << min << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  long long int N;
  int i=0,a[10000];
  char s;

  scanf("%lld",&N);

  while(N != 0){
    N--;
    a[i] = N % 26;
    i++; 
    N /= 26;
  }

  i--;
  while(i >= 0){
    s = 'a' + a[i];
    printf("%c",s);
    i--;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1608
#include <iostream>

using namespace std;

int main() {
    int x, y;   cin >> x >> y;
    int ans = 0;
    if (x <= 3) {
        ans += 100000*(4-x);
    }

    if (y <= 3) {
        ans += 100000*(4-y);
    }

    if (x == 1 && y == 1) {
        ans += 400000;
    }

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

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

int main() {
  int N, sum;
  cin >> N;
  sum = 1;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int j=0; j<N-1; j++){
    if(vec.at(j)!=vec.at(j+1)){
      sum++;
    }
  }
  cout << sum;    
}

Measured memory_bytes: 9540
n,x,m=map(int, input().split())
a=x
ans=a
flg=[0]*m
flg[a]=1
l=[a]
lp=-1

for i in range(1,m+1):   
    if n <= i:
        break
    tmp=(a*a)%m
    a=tmp
    if flg[a]==1:
        lp = l.index(a)
        break
    else:    
        ans+=tmp
        l.append(a)
        flg[a]=1

if lp != -1:
    l2 = l[lp:]
    tmp = sum(l2)
    b=(n-len(l))//len(l2)
    c=n-len(l)-b*len(l2)
    ans=ans+(b*tmp)+sum(l2[:c])

print(ans)

Measured memory_bytes: 12360
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

const MODULO: i64 = 1_000_000_007;

fn solve(input: &str) -> i64 {
    let mut iter = input.split_whitespace().map(|w| w.parse().unwrap());
    let n: i64 = iter.next().unwrap();
    let k: i64 = iter.next().unwrap();
    if k >= n - 1 {
        binom(2 * n - 1, n - 1)
    } else {
        let mut factorial = vec![0; (n + 1) as usize];
        factorial[0] = 1;
        for i in 1..n + 1 {
            factorial[i as usize] = i * factorial[(i - 1) as usize] % MODULO;
        }
        let inverse_factorial: Vec<i64> = factorial.iter().map(|&x| inverse(x)).collect();
        let binom = |a: i64, b: i64| {
            let mut ans = factorial[a as usize];
            ans = ans * inverse_factorial[b as usize] % MODULO;
            ans = ans * inverse_factorial[(a - b) as usize] % MODULO;
            ans
        };
        let mut ans = 0;
        for m in 0..k + 1 {
            ans = (ans + binom(n - 1, n - m - 1) * binom(n, m) % MODULO) % MODULO;
        }
        ans
    }
}

fn power(base: i64, exponent: i64) -> i64 {
    let mut acc = 1;
    let mut base = base;
    let mut exponent = exponent;
    while exponent != 0 {
        if exponent & 1 == 1 {
            acc = acc * base % MODULO;
        }
        base = base * base % MODULO;
        exponent >>= 1;
    }
    acc
}

fn inverse(x: i64) -> i64 {
    power(x, MODULO - 2)
}

fn binom(n: i64, k: i64) -> i64 {
    let mut numer = 1;
    let mut denom = 1;
    for i in 0..k {
        numer = numer * (n - i) % MODULO;
        denom = denom * (k - i) % MODULO;
    }
    numer * inverse(denom) % MODULO
}

Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define repl(i, x) for(register int i = fi[x]; i; i = l[i].next)
using namespace std;
typedef long long ll;
const int maxn = 1000010, P = 924844033, g = 5;
struct line{
	int y, next;
}l[maxn];
int n, siz[maxn], cnt[maxn];
int lcnt, fi[maxn];
int fac[maxn], Inv[maxn];
int N, rev[maxn], A[maxn], B[maxn], C[maxn];
int read(){
	int num = 0, flag = 1; char c = getchar();
	for(; c < '0' || c > '9'; c = getchar())
		if(c == '-') flag = 0;
	for(; c >= '0' && c <= '9'; c = getchar())
		num = (num<<3)+(num<<1)+c-48;
	return flag? num: -num;
}
inline int Add(int x, int y){ return x+y < P? x+y: x+y-P; }
inline int Mul(int x, int y){ return 1LL*x*y%P; }
inline int Del(int x, int y){ return x >= y? x-y: x-y+P; }
void make_line(int x, int y){
	l[++lcnt].y = y; l[lcnt].next = fi[x]; fi[x] = lcnt;
}
int power(int x, int y, int ans = 1){
	for(; y; y >>= 1, x = Mul(x, x))
		if(y&1) ans = Mul(ans, x);
	return ans;
}

void init(){
	n = read();
	rep(i, 1, n-1){
		int x = read(), y = read();
		make_line(x, y); make_line(y, x);
	}
}

void get_siz(int x, int f){
	siz[x] = 1;
	repl(i, x){
		int v = l[i].y;
		if(v == f) continue;
		get_siz(v, x);
		siz[x] += siz[v];
	}
}

void get_cnt(int x, int f){
	repl(i, x){
		int v = l[i].y;
		if(v == f) continue;
		++cnt[siz[v]];
		get_cnt(v, x);
	}
	if(x != 1) ++cnt[n-siz[x]];
}

void NTT(int a[], int N, int opt){
	int L = log2(N);
	rep(i, 0, N-1) rev[i] = (rev[i>>1]>>1)|((i&1)<<(L-1));
	rep(i, 0, N-1) if(i < rev[i]) swap(a[i], a[rev[i]]);
	for(int i = 1; i < N; i <<= 1){
		int step = i<<1;
		int wn = power(g, (P-1)/step);
		if(opt == -1) wn = power(wn, P-2);
		for(int j = 0; j < N; j += step){
			int w = 1;
			for(int k = 0; k < i; ++k){
				int x = a[j+k], y = Mul(w, a[j+k+i]);
				a[j+k] = Add(x, y); a[j+k+i] = Del(x, y);
				w = Mul(w, wn);
			}
		}
	}
	if(opt == -1){
		int Inv = power(N, P-2);
		rep(i, 0, N-1) a[i] = Mul(a[i], Inv);
	}
}

void first(){
	get_siz(1, 0); get_cnt(1, 0);
	fac[0] = 1;
	rep(i, 1, n) fac[i] = Mul(fac[i-1], i);
	Inv[n] = power(fac[n], P-2);
	repd(i, n-1, 1) Inv[i] = Mul(Inv[i+1], i+1);
	rep(i, 1, n-1) A[i] = Mul(P-cnt[i], fac[i]);
	A[n] = Mul(n, fac[n]);
	rep(i, 1, n) B[i] = Inv[n-i+1];
	B[n+1] = 1;
//	rep(i, 1, n) printf("%d ", cnt[i]); puts("");
}

void work(){
	for(N = 1; N <= n*2; N <<= 1);
//	rep(i, 0, N-1) printf("%d ", A[i]); puts("");
//	rep(i, 0, N-1) printf("%d ", B[i]); puts("");
	NTT(A, N, 1); NTT(B, N, 1);
	rep(i, 0, N-1) C[i] = Mul(A[i], B[i]);
	NTT(C, N, -1);
//	rep(i, 0, N-1) printf("%d ", C[i]); puts("");
	rep(i, 1, n) printf("%d\n", Mul(C[n+i+1], Inv[i]));
}

int main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	init();
	first();
	work();
	return 0;
}

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

#define max(a,b) (((a) < (b)) ? (b) : (a))
int main(void) {
    int64_t N,R;
    cin >> N >> R;

    // R = inside - (100*(10-N))
    // R + 100*(10-N)

    cout << R +(100*max(0,10-N)) << "\n";
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

long long a[N], b[N], c[N];

void solve() {
  int x, y, z, K; scanf("%d%d%d%d", &x, &y, &z, &K);
  for (int i = 0; i < x; ++i) scanf("%lld", a+i);
  for (int i = 0; i < y; ++i) scanf("%lld", b+i);
  for (int i = 0; i < z; ++i) scanf("%lld", c+i);
  sort(a, a+x, greater<long long>());
  sort(b, b+y, greater<long long>());
  sort(c, c+z, greater<long long>());
  vector<long long> v;
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      for (int k = 0; k < z; ++k) {
	if ((i+1)*(j+1)*(k+1) > K) break;
	v.push_back(a[i]+b[j]+c[k]);
      }
    }
  }
  sort(v.begin(), v.end(), greater<long long>());
  for (int i = 0; i < K; ++i) printf("%lld\n", v[i]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4376
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int N,i,ans;                                                   
   scanf("%d",&N);                                                
   int data[N];                                                   
                                                                  
   for(i = 0; i < N; i++){                                        
      scanf("%d",&data[i]);                                       
   }                                                              
                                                                  
   ans = 0;                                                       
   for(i = 0; i < N; i++){                                        
      if(data[i] % 2 == 0){                                       
         if(data[i]%3 != 0 && data[i] % 5 != 0){                  
            ans = -1;                                             
            break;                                                
         }                                                        
      }                                                           
   }                                                              
   if(ans == 0){                                                  
      printf("APPROVED");                                         
   }else{                                                         
      printf("DENIED");                                           
   }                                                              
   return 0;                                                      
} 

Measured memory_bytes: 1728
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int N;
	bool flag_kuku = false;

	cin >> N;

	for (int i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i >= 1 && N / i <= 9 ) {
			flag_kuku = true;
		}
	}

	if (flag_kuku) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 998244353
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


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

    int a = 0;
    int b = 0;
    int ab = 0;
    int c = 0;
    for(int i = 0;i < n;++i){
        string s;
        cin >> s;
        bool f1 = s[s.length() - 1] == 'A';
        bool f2 = s[0] == 'B';
        if(f1 && f2)++ab;
        else if(f1)++a;
        else if(f2)++b;
        for(int j = 0;j < s.length() - 1;++j){
            if(s[j] == 'A' && s[j + 1] == 'B'){
                ++c;
                ++j;
            }
        }
    }
    if(a > 0 && ab > 0){
        ++c;
        --a;
    }
    if(b > 0 && ab > 0){
        ++c;
        --b;
    }

    cout << (c + max(0,ab - 1) + min(a,b)) << endl;
}




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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int n;
  cin >> n;
  int sum = 0;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n)
  {
    cin >> a[i];
  }
  rep(i, n)
  {
    cin >> b[i];
    sum += b[i];
  }
  rep(i, n - 1)
  {
    cin >> c[i];
  }

  rep(i, n - 1)
  {
    if (a[i + 1] == a[i] + 1)
      sum += c[a[i] - 1];
  }
  pr(sum);
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	int n,i, num, max, min;
	long sum;
	sum = 0;
	max = -1000000;
	min = 1000000;
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%d", &num);
		if (num < min){
			min = num;
		}
		if (num > max){
			max = num;
		}
		sum = sum + num;
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 1032
#include "bits/stdc++.h"
using namespace std;

long double Dist(pair<long double, long double> P1, pair<long double, long double> P2) {
	return sqrt((P2.first - P1.first) * (P2.first - P1.first) + (P2.second - P1.second) * (P2.second - P1.second));
}

pair<pair<long double, long double>, pair<long double, long double> > Cross(pair<long double, long double> P1, pair<long double, long double> P2, long double R) {
	long double D = Dist(P1, P2) / 2.0;
	long double H = sqrt(R * R - D * D);
	long double dx = -(P2.second - P1.second), dy = P2.first - P1.first;
	long double d = sqrt(dx * dx + dy * dy);
	dx /= d, dy /= d;
	dx *= H, dy *= H;
	long double MX = (P1.first + P2.first) / 2, MY = (P1.second + P2.second) / 2;
	pair<long double, long double> A1 = { MX + dx, MY + dy };
	pair<long double, long double> A2 = { MX - dx, MY - dy };
	return { A1, A2 };
}

int main() {
	long double eps = 0.000000001;
	int N;
	cin >> N;
	vector<pair<long double, long double> > P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i].first >> P[i].second;
	}
	long double L = 0.0, R = 2000.0;
	while (R - L > eps) {
		long double MID = (L + R) / 2;
		bool check = false;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (Dist(P[i], P[j]) > MID * 2) continue;
				pair<pair<long double, long double>, pair<long double, long double> > PPD = Cross(P[i], P[j], MID);
				pair<long double, long double> P1 = PPD.first;
				pair<long double, long double> P2 = PPD.second;
				bool check2 = true;
				for (int k = 0; k < N; k++) {
					if (Dist(P1, P[k]) > MID + eps) check2 = false;
				}
				if (check2) check = true;
				check2 = true;
				for (int k = 0; k < N; k++) {
					if (Dist(P2, P[k]) > MID + eps) check2 = false;
				}
				if (check2) check = true;
			}
		}
		check ? R = MID : L = MID;
	}
	printf("%.12llf\n", L);
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> a(N); rep(i, N)cin >> a[i];

	vector<ll> r(N);
	rep(i, N) {
		while (a[i]%2 == 0) {
			r[i]++;
			a[i] /= 2;
		}
	}

	ll ans = 0;
	rep(i, N)ans += r[i];

	cout << ans << endl;
}

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [0]*n

    for i in range(m):
        a,b=map(int,input().split())
        HH[a-1]=max(HH[a-1],H[b-1])
        HH[b-1]=max(HH[b-1],H[a-1])
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>hh or hh==0:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 20124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
vector<ll>v[101000];
bool visited[100100];
ll dp[101000];
ll dfs(ll n){
    visited[n]=1;
    ll cnt=0;
    for(auto child :v[n]){
        if(visited[child]){
            dp[n]=max(dp[n],dp[child]+1);
            continue;
        }
        if(!visited[child]){
            dp[n]=max(dp[n],1+dfs(child));
        }
    }
    return dp[n];
}
int main(){

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
    ll n,m;
    cin>>n>>m;
    f(i,0,m){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    f(i,0,n+1){
        dp[i]=0;
        visited[i]=0;
    }
    f(i,1,n+1){
        if(!visited[i])dfs(i);
    }
    cout<<*max_element(dp+1,dp+n+1)<<endl;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
#define MAX (2000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;


int n;

int head[100];
int to[10000];
int next[10000];

int d[100];

void Search(int now)
{
	fill(d, d + 100, INF);
	d[now] = 0;
	
	while (true){
		bool f = false;
		
		for (int i = 0; i < n; i++){
			for (int e = head[i]; e != -1; e = next[e]){
				if (d[i] != INF && d[to[e]] > d[i] + 1){
					d[to[e]] = d[i] + 1;
					f = true;
				}
			}
		}
		
		if (!f) break;
	}
}

int main()
{
	memset(head, -1, sizeof(head));
	
	int m = 0;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int r, k;
		scanf("%d %d", &r, &k);
		r--;
		
		for (int j = 0; j < k; j++){
			int t;
			scanf("%d", &t);
			t--;
			
			next[m] = head[r];
			head[r] = m;
			to[m] = t;
			m++;
		}
	}
	
	int p;
	scanf("%d", &p);
	
	for (int i = 0; i < p; i++){
		int f, t, v;
		scanf("%d %d %d", &f, &t, &v);
		f--; t--;
		
		Search(f);
		
		if (d[t] + 1 <= v){
			printf("%d\n", d[t] + 1);
		}
		else {
			puts("NA");
		}
	}
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] pi = new int[N];

            double result = 0;
            int start = 0;
            int max = 0;
            int tmp = 0;
            for (int i = 0; i <= N - K; i++) {
                int test = 0;
                if (i == 0) {
                    pi[0] = sc.nextInt();
                    test = pi[0];
                    for (int j = 1; j < K; j++) {
                        pi[j] = sc.nextInt();
                        test += pi[j];
                    }
                } else {
                    pi[i + K - 1] = sc.nextInt();
                    test = tmp + pi[i + K - 1];
                }

                tmp = test - pi[i];
                if (max < test) {
                    max = test;
                    start = i;
                }
            }

            for (int j = start; j < start + K; j++) {
                int p = pi[j];
                result += (1 + p) / 2.0;
            }

            System.out.println(result);
        }
    }

}

Measured memory_bytes: 65020
#include<iostream>
#include<string>
using namespace std;
string A, B;
int main() {
	
	cin >> A >> B;
	if (A.size() > B.size()){
		cout << "GREATER" << endl;
		
	}
	 else if (A.size() < B.size()) {
		cout << "LESS" << endl;
		
	}

	 else {
		if (A > B) {
			cout << "GREATER" << endl;
			
		}
		else if (A < B) {
			cout << "LESS" << endl;
			
		}
		 else{
			cout << "EQUAL" << endl;
			return 0;
		}
	}

		
}


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

int main(void)
{
	char S[100000];
	scanf("%s",S);
	int N = strlen(S);
	int k[N],i;
	for(i = 0; i < N; i++)
	{
		k[i] = 0;
	}
	int r,l,j;
	int c = 0;
	int r_w,l_w,esp;
	r = 0; l = 0;i = 0;
	while(i != N){
		r = 0; l = 0;
		while(S[i+r]!= 'L')
		{
			r++;
		}
		r_w = i+r-1; l_w = i+r;
		while(S[i+r+l] != 'R')
		{
			l++;
			if(i+r+l == N) break;
		}
		
		//printf("r = %d, l = %d\n",r,l);
		i = i+r+l;
		
		k[r_w] += r/2;
		if(r%2 == 1)k[r_w]++;
		k[l_w] += r-k[r_w];
		
		esp = k[l_w];
		
		k[l_w]+= l/2;
		if(l%2 == 1) k[l_w]++;
		k[r_w]+= l-k[l_w]+esp;
		/*
		for(j = 0; j < N; j++)
		{
			printf("%d ",k[j]);
		}
		printf("\n");
		*/
		/*
		c++;
		if(c == 7) break;
		*/
	}
	for(i = 0; i < N; i++)
	{
		printf("%d ",k[i]);
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) #x << "=" << x << "  " <<
using namespace std;
using ll = long long;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;
int add(int x, int y) { return (x += y) < MOD ? x : x - MOD; }
int sub(int x, int y) { return (x -= y) >= 00 ? x : x + MOD; }
int mul(int x, int y) { return (ll) x * y % MOD; }
int pwr(int x, int p) {
  if (p == 0) return 1;
  if (p % 2) return mul(x, pwr(x, p - 1));
  return pwr(mul(x, x), p / 2);
}

char t[MXN];
char d[MXN];
char str[MXN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  cin >> (str + 1);
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  auto apply = [&] (int pos) {
    for (int i = 0; i < q; ++i) {
      if (str[pos] == t[i]) {
        pos += d[i] == 'R';
        pos -= d[i] == 'L';
      }
      if (pos == 0 || pos == n + 1) {
        break;
      }
    }
    return pos;
  };
  int sol = n;
  int lo = 0, hi = n;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (apply(mid) == 0) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  sol -= lo;
  lo = 0, hi = n;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (apply(n - mid + 1) == n + 1) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  sol -= lo;
  cout << sol << '\n';
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;


int main(){
   ll n;
   cin >> n;
   vector<ll>a(n),b(n);
   rep(i,n){
      cin >> a[i] >>b[i];
   }
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   double mi,ma;
   int ans;
   if(n%2!=0){
      mi = a[(n+1)/2-1];
      ma = b[(n+1)/2-1];
      ans = (ma-mi)+1;
   }
   else{
      double mi = (double)(a[n/2-1]+a[n/2])/2;
      double ma = (double)(b[n/2-1]+b[n/2])/2;
      ans = (ma-mi)*2+1;
   }
   cout << ans <<endl;
}

Measured memory_bytes: 6424
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f=0,i=0;
    int[] a=new int[n],b=new int[n];
    b[0]=1;
    for(int j=0;j<n;j++){
      a[j]=sc.nextInt();
    }
    while(f<n){
      b[i]=0;
      b[a[i]-1]++;
      f++;
      i=a[i]-1;
      if(i==1){
        System.out.println(f);
        break;
      }
    }
    if(f==n){
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 52080
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    long n,m;
    cin >> n >> m;
    long long hVal[n+1];//1始まり
    long road[m][2];//行数,A(0)B(1)
    long long niceCnt = n;//ここから引く
    int nFlg[n+1];//1始まり 1になってたらすでによくない
    hVal[0] = 0;
    rep(i,0,n){
        cin >> hVal[i+1];
        nFlg[i+1] = 0;
    }
    rep(i,0,m){
        cin >> road[i][0] >> road[i][1];
        if(hVal[road[i][0]] < hVal[road[i][1]] && nFlg[road[i][0]] < 1){
            nFlg[road[i][0]] = 1;
            niceCnt--;
        }else if(hVal[road[i][0]] > hVal[road[i][1]] && nFlg[road[i][1]] < 1){
            nFlg[road[i][1]] = 1;
            niceCnt--;
        }else if(hVal[road[i][0]] == hVal[road[i][1]])
        {   
            if(nFlg[road[i][0]] < 1){
                nFlg[road[i][0]] = 1;
                niceCnt--;
            }
            if(nFlg[road[i][1]] < 1){
                nFlg[road[i][1]] = 1;
                niceCnt--;
            }
        }
    }
    cout << niceCnt <<endl;
    //--------------
    return 0;
}

Measured memory_bytes: 6392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] ia;

		while (true) {
			ia = in.readLine().split(" ");
			int M = Integer.parseInt(ia[0]);
			int T = Integer.parseInt(ia[1]);
			int P = Integer.parseInt(ia[2]);
			int R = Integer.parseInt(ia[3]);
			if(M == 0 && T == 0 && P == 0 && R == 0){
				break;
			}
			ArrayList<team> al = new ArrayList<team>();
			for(int x = 1;x <= T; ++x){
				al.add(new team(x, P));
			}
			for(int x = 0;x < R; ++x){
				ia = in.readLine().split(" ");
				int m = Integer.parseInt(ia[0]);
				int t = Integer.parseInt(ia[1]);
				int p = Integer.parseInt(ia[2]);
				int j = Integer.parseInt(ia[3]);
				team tmp = al.get(t-1);
				if(j == 0){
					tmp.solved[p-1] = true;
					tmp.time[p-1] = m;
				} else {
					++tmp.submit[p-1];
				}
			}
			for(int x = 0;x < T; ++x){
				al.get(x).solve();
			}
			Collections.sort(al);
			for(int x = 0;x < T-1; ++x){
				System.out.print(al.get(x).teamnum);
				if(al.get(x).place(al.get(x+1))){
					System.out.print("=");
				} else {
					System.out.print(",");
				}
			} System.out.print(al.get(T-1).teamnum);
			System.out.println();
		}
	}

	static class team implements Comparable<team>{
		int teamnum;
		int problems;
		int point;
		boolean[] solved;
		int[] submit;
		int[] time;
		team(int x, int p){
			this.teamnum = x;
			this.problems = 0;
			this.point = 0;
			this.solved = new boolean[p];
			this.submit = new int[p];
			this.time   = new int[p];
		}
		void solve(){
			for(int i = 0;i < solved.length; ++i){
				if(solved[i]){
					++this.problems;
					this.point += time[i] + submit[i] * 20;
				}
			}
		}
		@Override
		public int compareTo(team o) {
			if(o.problems != this.problems){
				return o.problems - this.problems;
			} else if(o.point != this.point){
				return  -1 * (o.point - this.point);
			} else {
				return o.teamnum - this.teamnum;
			}
		}

		public boolean place(team o){
			if(o.problems != this.problems){
				return false;
			} else if(o.point != this.point){
				return false;
			} else {
				return true;
			}
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> A.at(i).at(j);
    }
  }

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << A.at(i).at(j);
    }
    cout << "\n";
  }
}

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

using namespace std;

typedef long long LL;

string S;
LL K;

void input()
{
  cin >> S;
  cin >> K;
}

string ALPHA = "abcdefghijklmnopqrstuvwxyz";

string solve()
{

  int pos = 0;
  while(K > 0){
    if(pos < S.length()-1){
      int sousa = 'z' - S[pos] + 1;
      if(sousa <= K && S[pos] != 'a'){
        S[pos] = 'a';
        K -= sousa;
      }
      pos++;
    }
    else{
      S[pos] = ((LL)(S[pos] - 'a') + K) % ('z' - 'a' + 1) + 'a';
      break;
    }
  }
  return S;

}

int main()
{

  input();

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 512
class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P

        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1]    

        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] * self.factinv[n-k] % self.P

def main():
    H,W,A,B = map(int,input().split())
    MOD = 10**9 + 7

    COMB = Combination(H+W, MOD)

    # (1,1) -> (i,B-1) -> (i,B+1) -> (H,W)

    ans = 0
    for i in range(1,H-A+1):
        tmp = COMB.getComb((i-1)+(B-1), i-1)
        tmp *= COMB.getComb((H-i)+(W-B-1), H-i)
        ans = (ans + tmp) % MOD

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int[] split = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

		int k = scanner.nextInt();
		System.out.println(split[k-1]);
	}

}


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


void solve(long long N, std::vector<std::string> S){

  bool flag=false;
  for(auto i=0;i<N;++i){
    if(S[i] == "Y")flag=true;
  }
  if(flag)cout << "Four" << "\n";
  else cout << "Three" << "\n";


}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<std::string> S(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f = toEnum . (+(fromEnum 'A')) . (`mod` 26) . (subtract 3) . (subtract (fromEnum 'A')) . fromEnum

main = getLine >>= putStrLn . map f

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()

int main(){

    string T; cin >> T;

    rep(i, T.size()){
        if(T[i]=='?'){
            if(i!=0 && T[i-1]=='P'){
                T[i]='D';
            }
            else T[i]='D';
        }
    }

    cout << T << endl;

}

Measured memory_bytes: 3724
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, ans = INF;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    ll a, count = 0;
    scanf("%lld", &a);
    while (a % 2 == 0)
    {
      a /= 2;
      count++;
    }
    ans = MIN(ans, count);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
function Main(input) {
    var N = parseInt(input[0], 10);

    var list = new Array(99);
    list.fill(0);
    var str, first, last, index, reverseIndex;
    var result = 0;

    for (var i = 1; i <= N; i++) {
        str = i.toString();
        first = str[0];
        last = str[str.length - 1];
        if (first === last) {
            index = parseInt(first, 10) - 1;
            result += list[index] * 2 + 1;
            list[index]++;
        } else if (first !== '0' && last !== '0') {
            index = parseInt(first + last, 10) - 1;
            reverseIndex = parseInt(last + first, 10) - 1;
            result += list[reverseIndex] * 2;
            list[index]++;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 16820
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    int n; ll L; scanf("%d %lld", &n, &L);
    ll a[n + 2];
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }

    for (int i = 1; i < n; i++) {
        if (a[i] + a[i + 1] >= L) {
            puts("Possible");
            vector <int> ans;
            for (int j = 1; j < i; j++) printf("%d\n", j);
            for (int j = n; j > i + 1; j--) printf("%d\n", j - 1);
            printf("%d\n", i);
            return 0;
        }
    }

    puts("Impossible");
}


Measured memory_bytes: 4612
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let v = parse_vec!(i32);
    let c = parse_vec!(i32);
    let mut num: i32 = 0;
    let mut i: usize = 0;
    while i < n {
        let temp = &v[i] - &c[i];
        if temp > 0 {
            num += temp;
        }
        i += 1;
    }
    println!("{}", num);
}



Measured memory_bytes: 4352
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int L = sc.nextInt();
		DJSet ds1 = new DJSet(N);
		DJSet ds2 = new DJSet(N);
		for (int i = 0; i < K; ++i) {
			int p = sc.nextInt() - 1;
			int q = sc.nextInt() - 1;
			ds1.setUnion(p, q);
		}
		for (int i = 0; i < L; ++i) {
			int r = sc.nextInt() - 1;
			int s = sc.nextInt() - 1;
			ds2.setUnion(r, s);
		}
		HashMap<List<Integer>, Integer> count = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			int v1 = ds1.root(i);
			int v2 = ds2.root(i);
			List<Integer> pair = Arrays.asList(v1, v2);
			if (count.containsKey(pair)) {
				count.put(pair, count.get(pair) + 1);
			} else {
				count.put(pair, 1);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; ++i) {
			int v1 = ds1.root(i);
			int v2 = ds2.root(i);
			sb.append(count.get(Arrays.asList(v1, v2)));
			if (i + 1 < N)
				sb.append(" ");
			else
				sb.append("\n");
		}
		System.out.println(sb.toString());

	}

	static class DJSet {
		int n;
		int[] upper;

		public DJSet(int n) {
			this.n = n;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		int root(int x) {
			return (upper[x] < 0 ? x : root(upper[x]));
		}

		boolean setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x != y) {
				if (upper[x] > upper[y]) {
					int d = x;
					x = y;
					y = d;
				}

				upper[x] += upper[y];
				upper[y] = x;

			}
			return x != y;
		}
	}
}


Measured memory_bytes: 123252
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt();
		int xdis = 0, ydis = 0;
		if(x1 >= x2) {
			xdis = x1 - x2;
			if(y1 >= y2) {
				ydis = y1 - y2;
				System.out.printf("%d %d %d %d\n",x2+ydis,y2-xdis,x1+ydis,y1-xdis);
			}else if(y1 < y2) {
				ydis = y2 - y1;
				System.out.printf("%d %d %d %d\n",x2-ydis,y2-xdis,x1-ydis,y1-xdis);
			}
		}else if(x1 < x2) {
			xdis = x2 - x1;
			if(y1 >= y2) {
				ydis = y1 - y2;
				System.out.printf("%d %d %d %d\n",x2+ydis,y2+xdis,x1+ydis,y1+xdis);
			}else if(y1 < y2) {
				ydis = y2 - y1;
				System.out.printf("%d %d %d %d\n",x2-ydis,y2+xdis,x1-ydis,y1+xdis);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
map<int,int> m;

int main()
{
    int a;
    cin >> n;
    rep(i,n){
        cin >> a;
        if(m[a]==1){
            m[a] = 0;
        }
        else m[a] = 1;
    }
    int ans=0;
    for(auto it=m.begin(); it!=m.end(); it++){
        if(it->se == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k,h,w;
string s,t;
string a[10];

int main() {
  cin >> h >> w;
  rep(i,h) cin >> a[i];
  int cnt=0;
  rep(i,h)rep(j,w)if(a[i][j]=='#') cnt++;
  cout << (cnt==h+w-1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
int a[300];
int b[300];
int x=0;
int y=0;
int z=0;
while (1){
    scanf ("%d %d",&a[300],&b[300]);
    if (a[300]==0&&b[300]==0)break;
    for (x=0; x<b[300]; x++){
        printf ("#");
    }
        printf ("\n");
for (z=0; z<a[300]-2; z++){
    for (y=0; y<b[300]; y++){
        if(y==0 || y==b[300]-1){
        printf ("#");}
        else  {printf (".");}
    } printf ("\n");
}
for (x=0; x<b[300]; x++){
        printf ("#");
    }

        printf ("\n");
        printf ("\n");

}
return 0;

}

Measured memory_bytes: 572
#フィボナッチ数列か…
#c問題も解けないのか…
#典型問題なんだろうな
#踏めない段の分は除いて考えれば良い
n,m=input().split()
n,m=int(n),int(m)
ax=[1]*(n+1)
for i in range(m):
    ax[int(input())]=0
bx=[1,1]
for i in range(2,n+1):
    if ax[i-1]==1:
        f1=bx[i-1]
    else:
        f1=0
    if ax[i-2]==1:
        f2=bx[i-2]
    else:
        f2=0
    bx.append((f1+f2)%(10**9+7))

print(bx[n])


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

template<class T>
void prvec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}


int main() {
	// freopen("./input.txt", "r", stdin);
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << "\n";
	
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

int H, W;
queue<int> q;
vvi grid;
int s[2], e[2];
int step;

int h(int x, int y) {
    return W * x + y;
}

void rh(int x, int p[]) {
    p[0] = x / W;
    p[1] = x % W;
}

void dfs(int x, int y) {
    if (x >= 0 && x < H && y >= 0 && y < W && !grid[x][y]) {
        grid[x][y] = 1;
//        cout << x << ' ' << y << '\n';
        q.push(h(x, y));
        dfs(x+1, y);
        dfs(x-1, y);
        dfs(x, y+1);
        dfs(x, y-1);
    }
}

void solve() {
    cin >> H >> W;
    cin >> s[0] >> s[1] >> e[0] >> e[1];
    s[0]--;
    s[1]--;
    e[0]--;
    e[1]--;
    grid = vvi(H, vi(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            grid[i][j] = c == '#';
        }
    }
    q.push(h(s[0], s[1]));
    while (!q.empty()) {
        int size = q.size();
        for (int k = 0; k < size; k++) {
            int p[2];
            rh(q.front(), p);
            q.pop();
            dfs(p[0], p[1]);
        }
        size = q.size();
        for (int k = 0; k < size; k++) {
            int p[2];
            rh(q.front(), p);
            q.pop();
            int x = p[0], y = p[1];
            if (x == e[0] && y == e[1]) {
                cout << step;
                return;
            }
            for (int i = -2; i <= 2; i++) {
                for (int j = -2; j <= 2; j++) {
                    int xx = x + i;
                    int yy = y + j;
                    if (xx >= 0 && xx < H && yy >= 0 && yy < W && !grid[xx][yy]) {
                        q.push(h(xx, yy));
//                        cout << xx << ' ' << yy << '\n';
                    }
                }
            }
        }
        step += 1;
    }
    cout << -1;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

Measured memory_bytes: 7660
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Measured memory_bytes: 29640
# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


N = int(input())
#N = int(line)
sum = 0
for i in range(N):
	x, u = input().split()
	#line = test_data.readline()
	#x, u = line.split()
	if u == "BTC":
		sum += float(x) * 380000
	else:
		sum += float(x)

print(sum)

Measured memory_bytes: 2940
import math
def dist(x, y, d):
    sum = 0
    for i in range(d):
        sum += (x[i] - y[i])**2

    return math.sqrt(sum)

N, D = map(int, input().split())
p = []

for k in range(N):
    p.append(list(map(int, input().split())))


cnt = 0
for i in range(N):
    for j in range(i+1, N):
        x = dist(p[i], p[j], D)

        if x == int(x):
            cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
import enum
class Direction(enum.Enum):
    N = "N"
    E = "E"
    W = "W"
    S = "S"

    @classmethod
    def value_of(cls, value):
        return [v for v in cls if v.value == value][0]


class Dice:
    def __init__(self, *value_list):
        self.__value_list = list(value_list)

    def rotate(self, direction):
        l = self.__value_list
        if  direction == Direction.N:
            l[0],l[1],l[5],l[4] = l[1],l[5],l[4],l[0]
        elif  direction == Direction.E:
            l[0],l[2],l[5],l[3] = l[3],l[0],l[2],l[5]
        elif  direction == Direction.W:
            l[0],l[2],l[5],l[3] = l[2],l[5],l[3],l[0]
        elif  direction == Direction.S:
            l[0],l[1],l[5],l[4] = l[4],l[0],l[1],l[5]

    def adjust_top_front(self, top_value, front_value):
        for _ in range(2):
            for _ in range(3):
                if self.front_value() == front_value:
                    break
                self.rotate(Direction.N)
            if self.front_value() == front_value:
                break
            self.rotate(Direction.E)
        
        for _ in range(3):
            if self.top_value() == top_value:
                break
            self.rotate(Direction.E)

    def top_value(self):
        return self.__value_list[0]

    def front_value(self):
        return self.__value_list[1]

    def right_value(self):
        return self.__value_list[2]


dice = Dice(*input().split())
for _ in range(int(input())):
    top,front = input().split()
    dice.adjust_top_front(top, front)
    print(dice.right_value())


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,k,ans=1;
	cin>>n>>k;
	for (int i = 0; i < n; ++i)
		{
			
			ans = min(ans*2,ans+k);
		}
		cout<<ans;	

   return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;

int main(void)
{
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << (P + Q + R) - max(P, max(Q, R));
}

Measured memory_bytes: 256
import itertools
import numpy as np

N = int(input())
x = [0] * N
y = [0] * N
for k in range(N):
  x[k], y[k] = map(int, input().split())

lst = np.arange(1,N+1)
perm = list(itertools.permutations(lst))

ans = 0
lenperm = len(perm)
for k in range(lenperm):
  for p in range(N-1):
    x1 = x[perm[k][p+1]-1]
    y1 = y[perm[k][p+1]-1]
    x0 = x[perm[k][p]-1]
    y0 = y[perm[k][p]-1]
    tans = np.sqrt((x1-x0)**2 + (y1-y0)**2)
    ans += tans

print(ans / lenperm)

Measured memory_bytes: 31904