akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		int[] alp = new int[26];
		for(int i=0; i<H; i++) {
			char[] c = sc.next().toCharArray();
			for(int j=0; j<W; j++) {
				alp[c[j] - 'a']++;
			}
		}
		
		int set4 = 0;
		int set2 = 0;
		int set1 = 0;
		if(H%2 == 0 && W%2 == 0) {
			set4 = H * W / 4;
		} else if(H%2 == 0) {
			set2 = H / 2;
			set4 = (W-1) * H / 4;
		} else if(W%2 == 0){
			set2 = W / 2;
			set4 = (H-1) * W / 4;
 		} else {
			set1 = 1;
			set2 = (H-1) / 2 + (W-1) / 2;
			set4 = (H-1) * (W-1) / 4;
		}
		
//		System.out.println(set4 + " " + set2 + " " + set1);
		
		int pos = 0;
		while(pos < 26) {
			if(alp[pos] == 0) {
				pos++;
				continue;
			}
			
			if(alp[pos]%4 == 0) {
				if(set4 > 0) {
					set4--;
					alp[pos] -= 4;
				} else if(set2 >= 2){
					set2 -= 2;
					alp[pos] -= 4;
				} else {
					System.out.println("No");
					return;
				}
			} else if(alp[pos] %2 == 0){
				if(set2 > 0) {
					set2--;
					alp[pos] -= 2;
				} else {
					System.out.println("No");
					return;
				}
			} else {
				if(set1 > 0) {
					set1--;
					alp[pos] -= 1;
				} else {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


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

int n;

int main() {
  cin >> n;
  n %= 10;
  if (n == 3) {
    cout << "bon" << endl;
  }else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


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

int main(){
  vector<int> vec;
  vec ={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;
  cin >> K;
  cout << vec.at(K-1) << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [-1] * 6001
dp[0] = 0
for a, b in sorted(X):
    for j in reversed(range(T)):
        if dp[j] == -1:
            continue

        dp[j + a] = max(dp[j + a], dp[j] + b)
            
print(max(dp))


Measured memory_bytes: 46296
n,c=map(int,input().split())
r=[[0,0]for _ in range(c)]
for s,t,c in sorted(list(map(int,input().split()))for _ in range(n)):
    for m in r:
        if m[0]<s-0.5or m[1]==c and m[0]<=s:
            m[0],m[1]=t,c
            break
print(len(list(filter(lambda x:x!=[0,0],r))))

Measured memory_bytes: 63448
import Control.Applicative

main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    putStrLn $ solve a b

solve :: Int -> Int -> String
solve a b = if mod a 3 == 0 || mod b 3 == 0 || mod (a+b) 3 == 0 then "Possible" else "Impossible"

Measured memory_bytes: 508
n = int(input())
h = list(map(int, input().split()))
count = 0
maxc = 0
for i in range(1, n):
  if h[i] <= h[i - 1]:
    count += 1
  else:
    count = 0
  if count > maxc:
    maxc = count
print(maxc)

Measured memory_bytes: 14224
#include <cstdio>
using namespace std;

//N is array size
int A[1000 + 10], N;

void trace(int A[], int N);
void insertionSort(int A[], int N);

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }

  insertionSort(A, N);

  return 0;
}

//display Array
void trace(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    if (i) { printf(" "); }
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    int j = i - 1;
    int v = A[i];

    while (j >= 0 && v < A[j]) {
      A[j + 1] = A[j];
      j--;
    }

    A[j + 1] = v;
    trace(A, N);
  }
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

string A, B;

int dp[3005][3005];
int tr[3005][3005];

int main(){
    fio;
    cin >> A >> B;
    int n = A.size(), m = B.size();
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(A[i-1] == B[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
                tr[i][j] = 3;
            }else{
                if(dp[i-1][j] > dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                    tr[i][j] = 2;
                }else{
                    dp[i][j] = dp[i][j-1];
                    tr[i][j] = 1;
                }
            }
        }
    }
    string L;
    for(int i = n, j = m; i && j;){
        int T = tr[i][j];
        if(T == 3){
            L += A[i-1];
        }
        i -= (T >> 1);
        j -= (T & 1);
    }
    reverse(L.begin(),L.end());
    cout << L << '\n';
}

Measured memory_bytes: 70784
S = str(input())
judge = 'Yes'
S = list(S)
for i in range(int(len(S)/2)):
    if S[i] != S[len(S) - 1 - i]:
        judge = 'No'
for i in range(int(len(S)/4)):
    if S[i] != S[int(len(S)/2) - 1 - i]:
        judge = 'No'
for i in range(int(len(S)/4)):
    if S[i + int(len(S)/2) + 1] != S[int(len(S)) - 1 - i]:
        judge = 'No'
print(judge)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }

    ll ans=n/10;
    n/=10;

    ll p5=5;
    while(p5<=n){
        ans+=n/p5;
        p5*=5;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3620
# ABC109B - Shiritori
n = int(input())
data = [input().rstrip() for _ in range(n)]
used = [data[0]]

for i in range(1, n):
    if data[i][0] == data[i - 1][-1] and data[i] not in used:
        used.append(data[i])
    else:
        print("No")
        break
        
if len(used) == n:
    print("Yes")

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

int main () {
    int N;
    scanf("%d", &N);
    unsigned long long *A = malloc((1 + N) * sizeof(unsigned long long));
    unsigned long long ans = 1;
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &A[i]);
        if (A[i] == 0) {
            printf("0\n");
            return 0;
        }
    }
    for (int i = 1; i <= N; i++) {
        unsigned long long remain  = 1000000000000000000ULL / ans;
        if (remain < A[i]) {
           printf("-1\n");
           return 0;
        }
        ans *= A[i];
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2516
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
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" ) } ; }
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 ) * } } ; }
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 ) * } } ; }
fn print_with_yes_no(b: bool) {
    if b {
        println!("Yes");
    }
    else {
        println!("No");
    }
}
fn solve() {
    input!(d: u64, t: u64, s: u64);
    let arrived = (d + s - 1) / s;

    print_with_yes_no(arrived <= t);
}

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


Measured memory_bytes: 2240
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s, t; cin >> s >> t;
  int res = 0;
  for(int i=0; i<s.size(); ++i){
    if(s[i] != t[i]) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3900
n=int(input())
C=list(list(map(int,input().split())) for i in range(n-1))
ans=0
for i in range(n-1):
    start=0
    for j in range(i,n-1):
        if i==j:
            start=C[i][0]+C[i][1]
            continue
        else:
            if start<=C[j][1]:start=C[j][1]
            elif start%C[j][2]==0:start +=0
            else:start +=C[j][2]-(start%C[j][2])
            start +=C[j][0]
    print(start)
print(0)

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<stdlib.h>

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>

#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=2500010;//maxn*maxs
const int maxs=1e8+10;
char s[maxn];
int a[maxn];
int main()
{
    cin>>s;
    int len=strlen(s);
    if(s[len-1]!='s'){
        cout<<s<<'s'<<endl;
    }
    else{
        cout<<s<<"es"<<endl;
    }
    system("pause");
    return 0;
}
	



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

ll powmod(ll x, ll n, ll m = MOD) {
    ll ans = 1;
    while(n) {
        if(n & 1) {
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}
inline ll invmod(ll x, ll m = MOD) {
    return powmod(x, m - 2);
}

const int N = 111111;
ll fact[N], invfact[N];
vector<int> tree[N];
int n, k;

void initfact(ll m = MOD) {
    fact[0] = 1;
    invfact[0] = 1;
    rep(i, 1, N - 1) {
        fact[i] = fact[i - 1] * i % m;
        invfact[i] = invmod(fact[i]);
    }
}
inline ll ncr(ll n, ll r, ll m = MOD) {
    if(r < 0 || r > n) return 0;
    if(r == 0 || r == n) return 1;
    return fact[n] * invfact[r] % m * invfact[n - r] % m;
}

int dfs(int u, int p = 0) {
    int choose = tree[u].size() - (p > 0);
    int from = k - 1 - (p > 0);
    int ans = 1;
    rall(v, tree[u]) {
        if(v != p) {
            ans = (ans * dfs(v, u)) % MOD;
        }
    }
    ans = ans * ncr(from, choose) % MOD * fact[choose] % MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    initfact();
    cin >> n >> k;
    rep(i, 2, n) {
        int u, v;
        cin >> u >> v;
        tree[u].pb(v);
        tree[v].pb(u);
    }
    rep(u, 1, n) {
        if(tree[u].size() + 1 > k) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << k * dfs(1) % MOD << endl;
    return 0;
}


Measured memory_bytes: 13568
import java.util.Scanner;

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

        int t[] = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            total += t[i];
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            int x = sc.nextInt();

            System.out.println(total - (t[p - 1] - x));
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    double T, X;
    cin>>T>>X;
    cout<<setprecision(20)<<T/X<<endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    char ch = sc.next().charAt(0);
    if(ch>=65 && ch<=90)
      System.out.println('A');
    else 
      System.out.println('a');
  }
}

Measured memory_bytes: 26940
#include <iostream>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000
#define llong long long

using namespace std;

llong solve(llong A, llong B) {
    if(A == B)
        return A;
    
    llong res = 0;
    if(A % 2 == 1) res ^= A++;
    if(B % 2 == 0) res ^= B--;

    res ^= ((B - A + 1) / 2) % 2;
    return res;
}

int main(int argc, char **argv) {
    llong A, B;
    cin >> A >> B;
    cout << solve(A, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(i = 0; i <= (n); i++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
typedef long long ll;
typedef unsigned long long ull;

int dp[5005][5005];

int main()
{
    ull N, bi, ci, sum = 0;
    cin >> N;
    int a[20] = {0};
    vector<pair<int, int>> b;
    rep(i, N){
        cin >> a[i];
    }
    rep(i, N){
        cin >> bi;
        b.push_back(make_pair(bi, 0));
    }
    rep(i, N - 1){
        cin >> ci;
        b[i].second = ci;
    }
    sum += b[a[0] - 1].first;
    for(int i = 1 ; i < N; i++){
        sum+=b[a[i] - 1].first;
        if(a[i-1] + 1 == a[i])sum+=b[a[i-1]-1].second;
    }
    cout << sum << endl;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool have = true;
  if(n % 2 == 1){
    have = false;
  }
  else{
    if(s.substr(0,(n/2)) != s.substr((n/2),(n/2))){
      have = false;
    }
  }
  if(have){
    cout << "Yes";
  }
  else{
    cout << "No";
  }


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef long long ll;
typedef pair<int,int> P;
/*
mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++){
    for(int k=0;k<B.size();k++){
      for(int j=0;j<B[0].size();j++){
	C[i][j]=(C[i][j]+A[i][k]*B[k][j]);
      }
    }
  }
  return C;
} 

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++)B[i][i]=1;
  while(n>0){
    if(n&1)B=mul(B,A);
    A=mul(A,A);
    n>>=1;
  }
  return B;
}
*/

mat identity(int n) {
  mat A(n, vec(n));
  for (int i = 0; i < n; ++i) A[i][i] = 1;
  return A;
}

mat mul(const mat &A, const mat &B) {
  mat C(A.size(), vec(B[0].size()));
  for (int i = 0; i < C.size(); ++i)
    for (int j = 0; j < C[i].size(); ++j)
      for (int k = 0; k < A[i].size(); ++k)
        C[i][j] += A[i][k] * B[k][j];
  return C;
}

mat pow(const mat &A, int e) {
  return e == 0 ? identity(A.size())  :
     e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1));
}

int main(void){

  int n,m,z,s,d;
  vector<P>G;

  while(cin >> n >> m >> z,n|m|z){
    G.clear();
    G.push_back(P(1,1));
    for(int i=0;i<m;i++){
      cin >> s >> d;
      G.push_back(P(s,d));
      G.push_back(P(d,s));
    }

    mat A(G.size(),vec(G.size()));
 
    for(int i=0;i<G.size();i++){
      for(int j=0;j<G.size();j++){
	if(i==j || !j || G[i].f==G[j].s)A[i][j]=0;
	else A[i][j]=(G[i].s==G[j].f);
      }
    }
    
    A=pow(A,z);

    bool fg=false;
    for(int i=0;i<A.size();i++){
      if(G[i].s==n && A[0][i])fg=true;
    }

    if(fg)cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 2640
#include<iostream>
#include<string>

int main(void){
  int loop,num;
  std::string str;
  while(true){
    std::cin>>str;
    if(str=="-") break;
    std::cin>>loop;
    for(int i=0;i<loop;i++){
      std::cin>>num;
      str=str.substr(num,str.size()-num)+str.substr(0,num);
    }
    std::cout<<str<<std::endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#define taskname "K"

#include <iostream>
#include <algorithm>

using namespace std;
#define long long long

const int N = 1e5 + 10;

int n, k, a[N], dp[N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int stone = 1; stone <= k; ++stone)
        for (int i = 1; i <= n; ++i)
            if (stone >= a[i] && !dp[stone - a[i]]) dp[stone] = 1;
    cout << (dp[k] ? "First" : "Second");


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int X, Y;
    cin >> X >> Y;
    for(int i=0; i<=X; i++){
        int j = X - i;
        if(2*i+4*j==Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
h,w=map(int, input().split()) 
s=[list(input()) for i in range(h)] 

s1=[['.' for i in range(w+2)] for i in range(h+2)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            s1[i+1][j+1]='#'
for i in range(h+2):
    for j in range(w+2):
        if s1[i][j]=='#':
            if s1[i-1][j]==s1[i+1][j]==s1[i][j-1]==s1[i][j+1]=='.':
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
n = int(input())
t = [0 for i in range(n)]
for i in range(n-1):
    c,s,f = map(int,input().split())
    for j in range(i+1):
        if t[j] <= s:
            t[j] = c + s
        elif t[j] % f == 0:
            t[j] += c
        else:
            t[j] += f - (t[j] % f) + c
for i in t:
    print(i)

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

const int NOT_VISITED = -1;

void bfs(int v, vector<vector<int>>& g, queue<int>& q, vector<int>& dist) {
  dist[v] = 0;
  q.push(v);

  while (!q.empty()) {
    int v = q.front();
    q.pop();

    for (auto nv : g[v]) {
      if (dist[nv] != NOT_VISITED)
        continue;
      q.push(nv);
      dist[nv] = dist[v] + 1;
    }
  }
}

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

  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  vector<int> ans(n + 1);
  for (int i = 0; i < n; ++i) {
    vector<int> dist(n, NOT_VISITED);
    queue<int> q;

    bfs(i, g, q, dist);

    for (int j = 0; j < n; ++j) {
      int x = dist[j];
      if (x > 0)
        ans[x]++;
    }
  }

  for (int i = 1; i < n; ++i)
    cout << ans[i] / 2 << endl;
}

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

char t[6] = { 'M', 'A', 'R', 'C', 'H' };

int main(){
	int n;
	long long int c[5] = {};
	string s;
	long long int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		for (int j = 0; j < 5; j++){
			if (s[0] == t[j]){
				c[j]++;
			}
		}
	}
	/*組み合わせは5C3で10通り*/
	for (int i = 0; i < 5; i++){
		for (int j = i+1; j < 5; j++){
			for (int k = j+1; k < 5; k++){
				ans += c[i] * c[j] * c[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = sc.next().toCharArray();

        int ans = 700;
        for (int i = 0; i < 3; i++) {
            if (s[i] == 'o')
                ans += 100;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

L=II()
INL=LI()

ODDS=INL[::2]
EVNS=INL[1::2]

MP_ODDS = {}
MP_EVNS = {}

if L == 2:
    print(0)
    exit()

for i in ODDS:
    if not i in MP_ODDS:
        MP_ODDS[i] = 0
    MP_ODDS[i] += 1

for i in EVNS:
    if not i in MP_EVNS:
        MP_EVNS[i] = 0
    MP_EVNS[i] += 1

ODDSC = []
EVNSC = []
for i,j in MP_ODDS.items():
    ODDSC.append((j,i))
for i,j in MP_EVNS.items():
    EVNSC.append((j,i))
ODDSC.sort(reverse=True)
EVNSC.sort(reverse=True)
EVNSC.append((0, -1))
ODDSC.append((0, -1))

# print(ODDSC, L)
if ODDSC[0][1] == EVNSC[0][1]:
    print(min(L-ODDSC[1][0]-EVNSC[0][0], L-ODDSC[0][0]-EVNSC[1][0]))    
else:
    print(L - ODDSC[0][0] - EVNSC[0][0])


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

int main() {
    int N;
    cin >> N;
    vector<long long> L(N);
    for(int i=0; i<N; i++){
        cin >> L.at(i);
    }

    int ans=0;

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int k=0; k<N; k++){
                if(L.at(i)!=L.at(j)&&L.at(j)!=L.at(k)&&L.at(k)!=L.at(i)&&L.at(i)+L.at(j)>L.at(k)&&L.at(j)+L.at(k)>L.at(i)&&L.at(k)+L.at(i)>L.at(j)){
                    ans++;
                }
            }
        }
    }
    cout << ans/6 <<endl;
    }


  
  

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n, x, ans;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &x);
		ans += x;
	}
	printf("%d\n", ans - n);
	return 0;
} 

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(true){
    int n = getInt();
    int w = getInt();

    if(n + w == 0) break;

    map<int, int> v;
    v[0] = 0;

    REP(i,n)
      v[getInt() / w]++;

    int mx  = v.rbegin()->first;
    int mxv = 0; FOR(it, v) mxv = max(mxv, it->second);
    double ans = 0.01;
    if(mx == 0){
      ans += 1.0;
    }else{
      REP(i,mx+1){
        ans += (((double)v[i]) / mxv) * (((double)(mx - i)) / mx);
      }
    }
    printf("%.7f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int x, y;
int ans=0;

int get(int x)
{
	if(y<x)
		return 1e15;
	return y-x;
}

int get2(int x)
{
	if(-y<x)
		return 1e15;
	return -y-x;
}

int32_t main()
{
	IOS;
	cin>>x>>y;
	int ans=min(get(x), 1 + get(-x));
	ans=min({ans, 1 + get2(x), 2 + get2(-x)});
	cout<<ans;
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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 LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
    int n;
    cin>>n;
    vector<ll> arr(n);
    for(int i = 0; i<n; i++)
    {
        cin>>arr[i];
    }
    if(n<3)
    {
        cout<<0;
        return;
    }
    sort(arr.begin(),arr.end());
    int count = 1;
    for(int i = 0; i<n-2; i++)
    {
        for(int j = i+1; j<n-1; j++)
        {
            if(arr[i] == arr[j])
                continue;
            for(int k=j+1; k<n; k++)
            {
                if(arr[i] == arr[k] || arr[j] == arr[k])
                    continue;
                if(arr[i]+arr[j]>arr[k])
                    count++;
            }
        }
    }
    cout<<count-1;

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc = 1; 
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


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

int main() {
  int N;
  cin>>N;
  bool flag=false;
  rep(i,N){
    rep(j,N){
      if (i*4+j*7==N) {
        flag=true;
      }
    }
  }
  if(flag) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
s = [input() for _ in range(2)]
mod = 10 ** 9 + 7
""" 
たて*たて = *2
たて*よこ = *2
よこ*よこ = *3 (1,2)=(2,3)(2,1),(3,1)
よこ*たて = *1
"""
tmp = 1
pos = 0  # 移動させる
pre_state = -1  # 0:tate 1:yoko
while pos < n:
    if s[0][pos] == s[1][pos]:
        if pos == 0:
            tmp *= 3
        else:
            if pre_state == 0:
                tmp *= 2
            else:
                tmp *= 1
        pre_state = 0
        pos += 1
    else:
        if pos == 0:
            tmp *= 6
        else:
            if pre_state == 0:
                tmp *= 2
            else:
                tmp *= 3
        pre_state = 1
        pos += 2
    tmp %= mod
print(tmp)


Measured memory_bytes: 9152
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num+1) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = sorted([x for x in set(cat) if cat.count(x) > 1])
dup.reverse()
print(dup[K-1])

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;
inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; } 
inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int dp[N][5][5][5];
bool OK (int a, int b, int c) {
	if (a == 1 && b == 2 && c == 3) return 0;
	if (a == 1 && b == 3 && c == 2) return 0;
	if (a == 2 && b == 1 && c == 3) return 0;
	return 1;
}
bool check (int a, int b, int c, int d) {
	if (a == 1 && b == 2 && d == 3) return 0;
	if (a == 1 && c == 2 && d == 3) return 0;
	
	if (!OK(a, b, c)) return 0;
	if(!OK(b, c, d)) return 0;

	return 1;
}



int main () {               
    cin >> n;
    for (int a = 1; a <= 4; a ++)
    	for (int b = 1; b <= 4; b ++)
    		for (int c = 1; c <= 4; c ++)
    			if (OK(a, b, c))
    				dp[3][a][b][c] = 1;
    for (int i = 4; i <= n; i ++) {
   		for (int d = 1; d <= 4; d ++)
   		for (int a = 1; a <= 4; a ++)
    	for (int b = 1; b <= 4; b ++)
    	for (int c = 1; c <= 4; c ++)
    		if (check(a, b, c, d))
    			(dp[i][b][c][d] += dp[i - 1][a][b][c]) %= mod;
   	}
   	int ans = 0;
   	for (int a = 1; a <= 4; a ++)
    	for (int b = 1; b <= 4; b ++)
    		for (int c = 1; c <= 4; c ++)
    			(ans += dp[n][a][b][c]) %= mod;
   	cout << ans;
   	return Accepted;
}

// B...a D....

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
        var a = input[0];
        var b = input[1];
        var c = input[2];
        var k = input[3];
        
        var ret = 0;
        if(k <= a) {
            ret = k;
        } else {
            ret = a;
        }

        if(k <= a + b){
            
        } else{
            ret -= k - a - b;
        }

        System.Console.WriteLine(ret);
    }
}


Measured memory_bytes: 28216
a[100],b[100],s,t,x,y,i;main(n,m){for(;scanf("%d%d",&n,&m)*n;s=t=!printf(x>998?"-1\n":"%d %d\n",x,y)){x=y=999;for(i=n;i--;s+=a[i])scanf("%d",a+i);for(i=m;i--;t+=b[i])scanf("%d",b+i);for(;n--;)for(i=m;i--;)s+b[i]*2==t+a[n]*2&&a[n]+b[i]<x+y?x=a[n],y=b[i]:0;}}

Measured memory_bytes: 0
K = "keyence"
N = len(K)


def judge(s):
    for i in range(N + 1):
        if s.startswith(K[:i]) and s.endswith(K[i:]):
            return True
    else:
        return False


def main():
    print("YES" if judge(input()) else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>


typedef std::pair<int,int> edge;

void init(int* count)
{
	for (int i=0; i<101; i++) count[i] = 0;
}

void init(bool* visited)
{
	for (int i=0; i<101; i++) visited[i] = false;
}


bool DFS(std::vector<edge> edge_list, int* count, bool* visited, int v)
{
	for (std::vector<edge>::iterator it = edge_list.begin(); it != edge_list.end(); ++it) {
		if ( (*it).first == v) {
			int u = (*it).second;
			if ( !visited[u] ) {
				visited[u] = true;
				DFS(edge_list, count, visited, u);
			}
		} else if ( (*it).second == v ) {
			int u = (*it).first;
			if ( !visited[u] ) {
				visited[u] = true;
				DFS(edge_list, count, visited, u);
			}
		}
	}
	
	for (int i=1; i<101; i++) {
		if (count[i]>0 && !visited[i]) return false;
	}
	
	return true;
}

int main()
{
	int count[101];
	std::vector<edge> edge_list;
	bool visited[101];
	
	for (int i=0; i<50; i++) {
		
		init(count);
		edge_list.clear();
		
		int a,b;
		do {
			std::cin >> a >> b;
			count[a]++; count[b]++;
			edge_list.push_back( edge(a,b) );
		} while (a>0 || b>0);
		
		if (count[1] == 0) continue;
		
		// check if Eulerian
		bool eulerian = true;
		if ((count[1] & 1) == 1 && (count[2] & 1) == 1) {
			for (int j=3; j<=100; j++) {
				if ( (count[j] & 1) == 1 ) { eulerian = false; break; }
			}
		}
		else {
			eulerian = false;
		}
		
		// check connectivity
		init(visited);
		visited[1] = true;
		bool connected = DFS(edge_list, count, visited, 1);
		if (eulerian && connected) std::cout << "OK" << std::endl;
		else std::cout << "NG" << std::endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int count = 0;
    string word, str;
    cin >> word;
    while(cin >> str){
        transform(str.begin(), str.end(), str.begin(), ::tolower);
        if(str == word) count++;
    }
    cout << count << endl;
    
    return 0;
    
}

Measured memory_bytes: 3196
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]

    cnt = 0
    for i in range(N):
        if B[i] < A[i]:
            cnt += B[i]
            A[i] -= B[i]

        elif A[i] <= B[i] <= A[i] + A[i+1]:
            cnt += B[i]
            A[i+1] -= B[i] - A[i]
            A[i] = 0

        elif A[i] + A[i+1] < B[i]:
            cnt += A[i] + A[i+1]
            A[i+1] = 0
            A[i] = 0

    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 19004
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

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

int main()
{
	int a, b;
	cin >> a >> b;
	char ans = 'x';
	int x = a + b;
	if (x == 15) {
		ans = '+';
	} else {
		x = a * b;
		if (x == 15) {
			ans = '*';
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int n, m; cin >> n >> m;
    vvec<array<int, 2>> g(n);
    vec<array<int, 3>> e(m);
    for (int i = 0; i < m; ++i) {
        int a, b, c; cin >> a >> b >> c; --a; --b;
        g[a].push_back({ b, c });
        g[b].push_back({ a, c });
        e[i][0] = a; e[i][1] = b; e[i][2] = c;
    }

    vvec<int> dist(n, vec<int>(n, INT_MAX / 4));
    for (int i = 0; i < n; ++i) dist[i][i] = 0;
    for (int i = 0; i < n; ++i) {
        for (auto [v, c] : g[i]) {
            dist[i][v] = min(dist[i][v], c);
        }
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < m; ++i) {
        bool found = false;
        for (int s = 0; s < n && !found; ++s) {
            for (int t = s + 1; t < n && !found; ++t) {
                found =
                    dist[s][e[i][0]] + e[i][2] + dist[e[i][1]][t] == dist[s][t] ||
                    dist[s][e[i][1]] + e[i][2] + dist[e[i][0]][t] == dist[s][t];
            }
        }
        ans += !found;
    }

    cout << ans << endl;
}



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

const int N = 1 << 17;
typedef long long ll;

int n;
int t, e;
int x[N];
ll dp[N];

struct SegT {
	ll Min[N << 1], Lazy[N << 1];

	void pushdown(int i) {
		if (!Lazy[i]) return ;
		Min[i] += Lazy[i];
		if (i < N) {
			Lazy[i << 1] += Lazy[i];
			Lazy[i << 1 | 1] += Lazy[i];
		}
		Lazy[i] = 0;
	}

	void upd(int l, int r, ll v, int i = 1, int a = 0, int b = N) {
		if (l <= a && b <= r) {Lazy[i] += v; pushdown(i); return ;}
		pushdown(i); if (r <= a || b <= l) return ;
		int m = (a + b) >> 1;
		if (l < m) upd(l, r, v, i << 1, a, m);
		if (m < r) upd(l, r, v, i << 1 | 1, m, b);
		Min[i] = min(Min[i << 1], Min[i << 1 | 1]);
	}

	ll qry(int l, int r, int i = 1, int a = 0, int b = N) {
		pushdown(i); if (l <= a && b <= r) return Min[i];
		if (r <= a || b <= l) return 1e18;
		int m = (a + b) >> 1; ll ans = 1e18;
		if (l < m) ans = min(ans, qry(l, r, i << 1, a, m));
		if (m < r) ans = min(ans, qry(l, r, i << 1 | 1, m, b));
		return ans;
	}
} segt;

int main() {
	cin >> n >> e >> t;
	++ n;
	for (int i = 1; i < n; ++ i) cin >> x[i];
	dp[0] = 0;
	segt.upd(0, 1, dp[0] + t);
	for (int i = 1, j = 0; i < n; ++ i) {
		segt.upd(0, j, (x[i] - x[i - 1]) * 2LL);
		while (j < i && (x[i] - x[j + 1]) * 2LL >= t) {
			segt.upd(j, j + 1, (x[i] - x[j + 1]) * 2LL - t);
			++ j;
		}
		dp[i] = segt.qry(0, i);
		segt.upd(i, i + 1, dp[i] + t);
	}
	cout << dp[n - 1] + e << endl;
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define push_back(x) push_back(x)
#define ll long long
#define MP make_pair
int main()
{
	
		ll n,k;
		cin>>n>>k;
		if(k>=n)
			cout<<"unsafe"<<endl;
		else
			cout<<"safe"<<endl;

}

Measured memory_bytes: 3620
N,W=map(int,input().split())
a,b=map(int,input().split())
w0=[b]
w1=[]
w2=[]
w3=[]
for i in range(N-1):
    w,v=map(int,input().split())
    if w-a==0:
        w0.append(v)
    elif w-a==1:
        w1.append(v)
    elif w-a==2:
        w2.append(v)
    else:
        w3.append(v)
w0=sorted(w0,reverse=True)
w1=sorted(w1,reverse=True)
w2=sorted(w2,reverse=True)
w3=sorted(w3,reverse=True)
ans=0
for i in range(max(len(w0)+1,1)):
    for j in range(max(len(w1)+1,1)):
        for k in range(max(len(w2)+1,1)):
            for l in range(max(len(w3)+1,1)):
                if a*i+(a+1)*j+(a+2)*k+(a+3)*l<=W:
                    lst=w0[:i]+w1[:j]+w2[:k]+w3[:l]
                    ans=max(sum(lst),ans)
print(ans)

Measured memory_bytes: 76136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(void){
    int N,K,Q;
    scanf("%d %d %d",&N,&K,&Q);
    vector<int> A;
    A.resize(N);
    for(int i=0;i<N;i++)scanf("%d",&A[i]);
    vector<int> B;
    B=A;
    sort(B.begin(),B.end());
    int ans=1145141919;
    for(int i=0;i<N;i++){
        priority_queue<int,vector<int> , greater<int> > po;
        vector<int> buri;
        priority_queue<int,vector<int> , greater<int> > emp;
        for(int j=0;j<N;j++){
            if(A[j]<B[i]){
                while(po.size()>=K){buri.push_back(po.top());po.pop();}
                po=emp;
            }
            else po.push(A[j]);
            if(j==N-1){
                while(po.size()>=K){buri.push_back(po.top());po.pop();}
                po=emp;
            }
        }
        sort(buri.begin(),buri.end());
        if(buri.size()>=Q&&ans>buri[Q-1]-buri[0])ans=buri[Q-1]-buri[0];
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdbool.h>

int main(void){
        char s[10], c;
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((c=getchar())!='\n') s[l++] = c;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}


Measured memory_bytes: 128
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        s=""
        for j in range(W):
            if i==0 or i==H-1:
                s+="#"
            elif j==0 or j==W-1:
                s+="#"
            else:
                s+="."
        print(s)
    print("")

Measured memory_bytes: 7656
#include <iostream>
using namespace std;
 
int F[105][105];
int xg,yg,w,h;
 
 
void DFS(int Y,int X,int c){
  if(F[Y][X] != c || Y >w || X>h){
    return;
  }
 
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
 
 
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<105; i++){
      for(int j=0; j<105; j++){
        F[i][j]=10;
      }
    }
     
    cin >> xs >> ys >> xg >> yg >> n;
 
 
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }

  DFS(xs,ys,F[xs][ys]);
 
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3220
def otoshidama():
    n, y = map(int, input().split())

    for x_10000 in range(n+1):
        for y_5000 in range(n+1):
            z_1000 = n - x_10000 - y_5000

            if x_10000 * 10000 + y_5000 * 5000 + z_1000 * 1000 == y\
                    and z_1000 >= 0:

                return "{} {} {}".format(x_10000, y_5000, z_1000)

    return "-1 -1 -1"


if __name__ == '__main__':
    print(otoshidama())

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++)
        cin >> t[i];

    long long res = 0;
    for (int i = 1; i < N; i++) {
        int diff = t[i] - t[i - 1];
        res += min(diff, T);
    }

    res += T;
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

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

  sort(vx.begin(), vx.end());
  n--;

  vector<int> dists(m - 1);
  for (int i = 0; i < m - 1; ++i) {
    dists[i] = abs(vx[i + 1] - vx[i]);
  }

  sort(dists.begin(), dists.end(), greater<int>());

  int sum = accumulate(dists.begin(), dists.end(), 0);
  for (int i = 0; i < min(n, static_cast<int>(dists.size())); ++i) {
    sum -= dists[i];
  }

  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

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

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];

ll dp[100010][4];
int main(){
    int A, B; cin >> A >> B;
    if(A%2==0||B%2==0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6912
N, Q = map(int, input().split())
 
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [INF]*(2*N0)
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])
def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
 
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s
 
 
ans = []
for q in range(Q):
    t, x, y = map(int, input().split())
    if t:
        ans.append(str(query(x, y+1)))
    else:
        update(x, y)
for i in ans:
    print(i)


Measured memory_bytes: 13236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n) {
        char c = 'p';
        if (i%2==0) c = 'g';
        if (s[i]==c) continue;
        if (c=='p') ans++;
        else ans--;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
SIRO = '.'
KURO = '#'
N = int(input())
S = input()
sCnt = S.count(SIRO)
kCnt = 0
ans = sCnt
for i in S:
    if i == KURO:
        kCnt += 1
    else:
        sCnt -= 1
    ans = min(ans, kCnt + sCnt)

print(ans)

Measured memory_bytes: 3500
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s =sc.next();
        String t = sc.next();
        int ans = 2*N;
        for(int start=0;start<N;start++){
            if(s.substring(start,N).equals(t.substring(0,N-start))){
                ans = N+start;
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N, R = map(int,input().split())

if N >= 10:
    print(R)
else:
    print(R+100*(10-N))

Measured memory_bytes: 3572
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double[] v = new double[N];
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      v[i] = (double)a;
    }
    Arrays.sort(v);
    
    int count = 0;
    while (count < v.length-1) {
      double x = (v[count] + v[count+1])/2;
      v[count] = 0;
      v[count+1] = x;
      count++;
      Arrays.sort(v, count, v.length);
    }
    
    System.out.println(v[count]);
  }
}

Measured memory_bytes: 23124