akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;

            D = int.Parse(Console.ReadLine());

            if (D == 25)
            {
                Console.WriteLine("Christmas");
            }

            else if (D == 24)
            {
                Console.WriteLine("Christmas Eve");
            }

            else if (D == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }

            else if (D == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
#define w 200001
main(){
    int n,m,j;
    long int k,a[w],A[w],b[w],B[w];
    int p=0;
    
    
    scanf("%d%d%ld",&n,&m,&k);
    
   
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(i==0){
            A[i]=0;
        }
        A[i+1]=A[i]+a[i];
        
    }
    
    
    for(int i=0;i<m;i++){
        scanf("%ld",&b[i]);
        if(i==0){
            B[i]=0;
        }
        B[i+1]=B[i]+b[i];
        
    }
    int mo=m;
    
    for(int i=0;i<=n;i++){
        if(A[i]>k)break;
        
        for(j=mo;j>=0;j--){
            if(A[i]+B[j]<=k){
                if(i+j>p)p=i+j;
                mo=j;
                break;
            }
        }
        
    }
    
    
    printf("%d",p);
}

Measured memory_bytes: 7944
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

n, u, v = map(int, readline().split())
m = map(int,read().split())
data = list(zip(m,m))

graph = [[] for _ in range(n+1)]

for a,b in data:
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [None] * (n + 1)
    dist[v] = 0
    stack = [v]
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if dist[y] is None:
                dist[y] = dist[x] + 1
                stack.append(y)
    return dist
res = 0
du, dv = dfs(u), dfs(v)
for i in range(1, n+1):
    dvi = dv[i]
    if du[i] <= dvi:
        if dvi > res:
            res = dvi
print(res - 1)

Measured memory_bytes: 45236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int dfs(int i,bool vis[],set<int> adj[]){
	vis[i]=true;
	int cnt=0;
	for(auto j:adj[i]){
		if(vis[j])
			continue;
		// cout<<j<<" ";
		cnt+=dfs(j,vis,adj);
	}
	return cnt+1;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		set<int> a[n+1];
		for(int i=0;i<m;i++){
			int p,q;
			cin>>p>>q;
			a[p].insert(q);
			a[q].insert(p);
		}
		bool vis[n+1];
		memset(vis,false,sizeof(vis));
		for(int i=1;i<=n;i++)
		vis[i]=false;
		int ma=0;
		for(int i=1;i<=n;i++){
			if(vis[i])
				continue;
			ma=max(ma,dfs(i,vis,a));
			// cout<<vis[i]<<" ";
		}
		cout<<ma;
	}
	return 0;
}

Measured memory_bytes: 41244
N = int(input())
B = [int(i) for i in input().split()]
ans = 0

for i in range(N):
    if i == 0:
        ans += B[i]
    elif i == N-1:
        ans += B[i-1]
    else:
        ans += min(B[i-1], B[i])

print(ans)

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	CIN(int, N);
	CIN(int, K);
	vector<int> l;
	rep(i, N) {
		CIN(int, t);
		l.PB(-t);
	}
	int res = 0;
	sort(all(l));
	rep(i, K) res -= l[i];
	cout << res << endl;
	
}


Measured memory_bytes: 256
H, W = map(int, input().split())
dp = [[H*W for __ in range(W)] for _ in range(H)]
dh = [1, 0]
dw = [0, 1]
S = []
for i in range(H):
    s = input()
    S.append(s)

if (S[0][0] == '#'):
    dp[0][0] = 1
else:
    dp[0][0] = 0


for i in range(H):
    for j in range(W):
        for k in range(2):
            nh = i + dh[k]
            nw = j + dw[k]
            if nh >= H or nw >= W:
                continue
            add = 0
            if (S[nh][nw] == "#" and S[i][j] == "."):
                add = 1
            dp[nh][nw] = min(dp[nh][nw], dp[i][j] + add)


print(dp[H-1][W-1])


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

template <typename T, typename U>
T power(T x, U y)
{
    T ret;
    ret = 1;
    while (y > 0)
    {
        if ((y & 1) > 0)
        {
            ret *= x;
        }
        x *= x;
        y >>= 1;
    }
    return ret;
}

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

    if (N % 2 == 0)
    {
        unsigned long long ans = 0;
        for (int i = 1; i <= 25; i++)
        {
            unsigned long long n = N / 2;
            for (int j = 0; j < i; j++)
            {
                n /= 5;
            }
            ans += n;
        }
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


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

//macro
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
    string s;
    cin >> s;
    LL min, max;   
    min = s.find_first_of("A");
    max = s.find_last_of("Z");

    cout << max - min + 1 << endl;

}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

//https://beta.atcoder.jp/contests/agc028/tasks/agc028_a

public class Program_AGC028_A // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var st = Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = Koubai_Lcm(s.Length, t.Length);
        var x = new Dictionary<long, char>();

        var lSl = l / s.Length;
        for (int i = 0; i < s.Length; i++)
        {
            var pos = i * lSl + 1;
            x[pos] = s[i];
        }


        var lTl = l / t.Length;
        for (int i = 0; i < t.Length; i++)
        {
            var pos = i * lTl + 1;
            if (x.ContainsKey(pos))
            {
                if (x[pos] != t[i])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
        }

        Console.WriteLine(l);
    } // Main



    /// <summary>
    /// 最小公倍数 least common multiple
    /// aで最小公倍数を割っても、bで最小公倍数を割っても割り切れる一番小さな値
    /// </summary>
    public static long Koubai_Lcm(int a, int b)
    {
        //a,b 2つの値の場合、次の関係が成り立つ   a * b = gcd * lcm
        return (long)a * b / Kouyaku_Gcd(a, b);    //桁あふれをさせないように、最初にlongにキャストする。
    }


    /// <summary>
    /// 最大公約数 Greatest Common Measure
    /// 最大公約数でaを割っても、bを割っても割り切れる一番大きな値
    /// ユークリッドの互除法
    /// </summary>
    public static long Kouyaku_Gcd(int a, int b)
    {
        if (a < b) return Kouyaku_Gcd(b, a); // 引数を入替えて自身を呼び出す

        while (b != 0)
        {
            var temp = a % b;
            a = b;
            b = temp;
        }

        return a;
    }

}     // Class




Measured memory_bytes: 19936
#include <cstdio>
int h, w, cnt;
char a[55][55];
int main() {
    int i, j, x, y;
    scanf("%d%d", &h, &w);
    for (i=1; i<=h; i++) scanf("%s", &a[i][1]);
    for (i=1; i<=h; i++, puts("")) for (j=1; j<=w; j++) {
        if (a[i][j]=='#') {printf("#"); continue;}
        cnt = 0;
        for (x=i-1; x<=i+1; x++) for (y=j-1; y<=j+1; y++) if (a[x][y]=='#') cnt++;
        printf("%d", cnt);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
const int MAXN = 1e5 + 10, mod = 1e9 + 7, INF = 1e9;

signed main()
{
	int x;
	scanf("%d", &x);
	if(x == 0) puts("1");
	else if(x == 1) puts("0"); 
	return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
bool set[21][21];
int tx[]={1,0,-1,0},ty[]={0,1,0,-1}; //NESWの順
int x,y; //座標
void MOVE(char s,int a);
int main(){
		int n,a,b;
	while(1){
	for(int i=0;i<=20;i++)for(int j=0;j<=20;j++)set[i][j]=false;
	cin >> n;
	if(n==0)break;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		set[a][b]=true;
	}
	cin >> n;
	x=y=10;
	char s;
	for(int i=0;i<n;i++){
		cin >> s >> a;
		MOVE(s,a);
	}
	int flg=0;
	for(int i=0;i<20;i++){
		for(int j=0;j<20;j++){
			if(set[i][j]==true)flg=1;
		}
	}
	if(flg==0)cout << "Yes" << endl;
	else cout << "No" << endl;
}
}
void MOVE(char s,int a){
	int k;
	if(s=='N')k=0;
	else if(s=='E')k=1;
	else if(s=='S')k=2;
	else k=3;

	for(int i=0;i<a;i++){
		x+=ty[k];
		y+=tx[k];
		set[x][y]=false;
	}
	return;
}

Measured memory_bytes: 1152
//gauravsinghh
#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;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define lim 100000ll
#define siz 1000005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX lim
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll power(ll a, ll b) {
  if( b == 0 ) return 1;
  ll ret = 1;
  while(b) {
    if(b&1) ret = (ret*a) %MOD;
    a = (a * a) % MOD;
    b/=2;
  }
  return ret;
}

signed main(){ 
    IOS
    //io_set();
    ll n, x;
    cin >> n;
    ll c = 0;
    fo(i, 1, n){
        cin >> x;
        if(x != i){
            c++;
        }
    }
    if(c > 2){
        cout << "NO\n";
    }
    else{
        cout << "YES\n";
    }
    return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int N;
vector<int> A(20, 0);
bool solve(int i, int m) {
  if (m == 0) return true;
  if (i >= N) return false;
  bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);

  return res;
}

int main()
{

  cin>>N;
  rep(i, N) cin>>A[i];
  int Q;
  cin>>Q;
  vector<int> M(Q);
  rep(i, Q) cin>>M[i];

  for(int m : M) {
    if (solve(0, m)) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }

  return 0;
}



Measured memory_bytes: 3104
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$N = $in->nextInt();

$ans = 0;

for ($i = 0;$i < $N;$i++) {
	$l = $in->nextInt();
	$r = $in->nextInt();
	$ans += $r - $l + 1;
}

$out->println($ans);

?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string s;
  long long int num;
  cin >>s;
  cin >>num;
  for(long long int i=0;i<num;i++){
     if(s[i]!='1'){
        cout <<s[i];
        break;}
     else if(i==(num-1))cout <<s[i];
  }
 }



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c-max(a,max(b,c))==max(a,max(b,c)))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static double a, b, c, d, e, f;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }
    static boolean read(){
        if(!sc.hasNext())return false;
        a = sc.nextDouble();
        b = sc.nextDouble();
        c = sc.nextDouble();
        d = sc.nextDouble();
        e = sc.nextDouble();
        f = sc.nextDouble();
        return true;
    }
    static void solve(){
        double det = a*e - b*d;
        double x = (c*e - b*f)/det, y = (-c*d + a*f)/det;
        if(x==0)x=0;
        if(y==0)y=0;
        System.out.printf("%.3f %.3f\n", x, y);
    }
}

Measured memory_bytes: 12000
use std::io;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();

    let _ = reader.read_line(&mut s);
    let n: u32 = s.trim().parse().unwrap();
    let mut result = 0;

    for i in 1..n + 1 {
        if i % 2 == 0 { continue; }
        let mut count = 0;
        for j in 1..i + 1 {
            if i % j == 0 {
                count += 1;
            }
        }
        if count == 8 {
            result += 1;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }

    let mut ans = "NG";
    if (a - 1) / k != b / k {
        ans = "OK";
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
def main() :
    N = int(input())
    A = list(map(int, input().split()))
    sum = 0
    t = A[0]
    for i in range(1, N):
        if A[i] <= t:
            sum += t - A[i]
        else:
            t = A[i]
    print(sum)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //  //   freopen("output.txt", "w", stdout);
    //  //  freopen("error.txt", "w", stderr);
    // #endif
    int64_t n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, 0, n)
            cin >>
        a[i];
    rep(i, k, n)
    {
        if (a[i - k] < a[i])
            cout << "Yes\n";
        else
        {
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 4780
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl;
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int n,t;
  cin >> n >> t;
  vi v(n);
  rep(i,n)cin >> v[i];
  ll ans = 0;
  REP(i,1,n){
    ans += min(t,v[i]-v[i-1]);
  }
  ans += t;
  P(ans);
}

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


Measured memory_bytes: 1024
import java.util.*;
public class Main{
        static Scanner sc = new Scanner(System.in);
        static int n, pos;
        static ArrayList<Integer> preorder = new ArrayList<Integer>();
        static ArrayList<Integer> inorder = new ArrayList<Integer>();
        public static BinaryTree reconstruction(int l, int r) {
            if (l >= r){
                return new BinaryTree();
            }
            int node = preorder.get(pos++);
            int i = inorder.indexOf(node);
            BinaryTree left = reconstruction(l, i);
            BinaryTree right = reconstruction(i + 1, r);
            return new BinaryTree(node, left, right); }
            public static void read() { 
            n = sc.nextInt();
            for (int i = 0; i < n; i++){ 
                preorder.add(sc.nextInt());
            } 
            for (int i = 0; i < n; i++) { 
                inorder.add(sc.nextInt()); 
            } 
        } 
        public static void main(String[] args){ 
            read(); 
            pos = 0; 
            BinaryTree bt = reconstruction(0, preorder.size()); 
            System.out.println(bt); 
        } 
        public static class BinaryTree { 
            boolean isEmpty; 
            int node; 
            BinaryTree left; 
            BinaryTree right; 
            public BinaryTree(int node, BinaryTree left, BinaryTree right) { 
                this.isEmpty = false; 
                this.node = node; 
                this.left = left; 
                this.right = right; 
            } 
            public BinaryTree() { 
                this.isEmpty = true; 
            } 
            public String toString() { 
                if (this.isEmpty) 
                    return ""; 
                String l = this.left.toString() + " "; 
                String r = this.right.toString() + " "; 
                if (l.trim().equals("")) { 
                    l = ""; 
                } 
                if (r.trim().equals("")) { 
                    r = ""; 
                } 
                return l + r + this.node; 
            } 
        } 
    }


Measured memory_bytes: 26356
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <stack>
#include <limits.h>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <cfloat> 
using namespace std;
int main(void) {
	int a, b, c,day=0,i=7,j=0;
	scanf("%d %d %d", &a, &b, &c);
	while (1) {
		if (j >= c)
			break;
		j = j+a;
		day++;
		if (day%7==0) {
			i = i * 2;
			j = j + b;
		}
	}
	printf("%d\n", day);
	return 0;
}


Measured memory_bytes: 3224
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n=int(input())
#n=10**5
a=list(map(int,input().split()))
#a=[0 if i%2==0 else 1 for i in range(n)]
l=defaultdict(int)
r=defaultdict(int)
for i in range(n):
    ii=i+1
    l[ii+a[i]]+=1
    r[(ii-a[i])]+=1
#print(l)
#print(r)
ans=0
for each in l.keys():
    if each in r.keys():
        ans+=l[each]*r[each]

print(ans)

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

int main(){
	string s;
	cin>>s;
	int ans=100;
	for(char i='a';i<='z';++i){
		int now=0,mx=0;
		for(auto c:s){
			if(c==i)now=0;
			else mx=max(mx,++now);
		}
			ans=min(ans,mx);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def main():
    N, M = map(int, readline().split())
    m = map(int, read().split())
    AB = list(zip(m, m))

    p1 = []
    p2 = []
    for a, b in AB:
        if a == 1:
            p1.append(b)
        if b == N:
            p2.append(a)

    if len(list(set(p1) & set(p2))) >= 1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


main()


Measured memory_bytes: 49864
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int k;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k;
	if(k % 2) cout << (((k - 1) / 2 + 1) * (k - 1) / 2) << "\n";
	else cout << (k / 2 * k / 2) << "\n";
	return 0;
}

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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ans =  (b-a) == (c-b);
    if(ans){
        cout << "YES" << endl;
    }else{
        cout <<  "NO"  << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        String a = sc.next();
        String b = sc.next();
        boolean squareNumber = false;
        final int C = Integer.parseInt(a+b);
        for (int i = 1; i < C; i++) {
            if (i * i == C) squareNumber = true;
        }
        out.println(squareNumber ? "Yes" : "No");

        out.flush();
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> c(n), s(n), f(n);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    c[n-1] = s[n-1] = f[n-1] = 0;
    rep(i, n){
        ll time = s[i] + c[i];
        for(ll j = i+1; j < n-1; ++j){
            ll next = 0;
            if(time >= s[j]){
                ll t = (time - s[j])%f[j];
                if(t > 0) time += f[j] - t;
            }else time = s[j];
            time += c[j];
        }
        cout << time << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
n, m = map(int, input().split())
a = list(map(int, input().split()))

def f(x):
    """数xを作るために必要なマッチ棒の本数を返す関数

    :type x: str
    :param x: マッチ棒で作る数
    :rtype: int
    :return: xを作るために必要なマッチ棒の本数
    """

    num_base = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    ret = 0
    for i in range(len(x)):
        ret += num_base[int(x[i])]

    return ret


def max_num(x, y):
    """xとyの大きいほうを返す関数。
    1.文字列の長さが長い方が大きい
    2.文字列の長さが等しいとき、文字列として比較して大きい方が大きい

    :type x: str
    :param x: マッチ棒で作る数
    :type y: str
    :param y: マッチ棒で作る数
    :rtype: str
    :return: 大きい方の数
    """

    if len(x) > len(y):
        return x
    elif len(y) > len(x):
        return y
    else:
        if x > y:
            return x
        else:
            return y


dp = [""] * (n + 1)
for j in range(2, n + 1):
    for i in range(m):
        match = f(str(a[i]))

        if j == match:
            dp[j] = max_num(dp[j], dp[j - match] + str(a[i]))
            dp[j] = max_num(dp[j], str(a[i]) + dp[j - match])

        elif j > match:
            if dp[j - match] != "":
                dp[j] = max_num(dp[j], dp[j - match] + str(a[i]))
                dp[j] = max_num(dp[j], str(a[i]) + dp[j - match])

print(dp[n])

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n;
	cin >> n;
	int power = 1;
	for (size_t i = 1; i <= n; i++) {
		power = power * i % MOD;
	}
	cout << power << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int min(int n,int m){
    if(n<m) return n;
    else return m;
}
int max(int n,int m){
    if(n<m) return m;
    else return n;
}
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d\n",max(0,min(b,d)-max(a,c)));
}

Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		Stack<Double> stk=new Stack<>();
		
		while(in.hasNext()) {
			stk.clear();
			String d[]=in.nextLine().split(" ");
			for(int i=0;i<d.length;i++) {
				if(d[i].equals("+")) {
					double b=stk.pop(),a=stk.pop();
					stk.push(a+b);
				}
				else if(d[i].equals("*")) {
					double b=stk.pop(),a=stk.pop();
					stk.push(a*b);
				}
				else if(d[i].equals("-")) {
					double b=stk.pop(),a=stk.pop();
					stk.push(a-b);
				}
				else if(d[i].equals("/")) {
					double b=stk.pop(),a=stk.pop();
					stk.push(a/b);
				}
				else {
					stk.push(Double.parseDouble(d[i]));
				}
			}
			
			System.out.println(stk.pop());
		}
	}

}



Measured memory_bytes: 25916
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int mx=0;
    int ans=0;
    mx=max(a,b);
    mx=max(mx,c);
    if(mx==c){
        ans+=mx-max(a,b);
        a+=ans;
        b+=ans;
        if(a>b){
            ans+=((a-b)+(a-b)%2)/2;
            b+=((a-b)+(a-b)%2);
            if(b>a)
                ans++;
        }
        else{ans+=((b-a)+(b-a)%2)/2;
            a+=((b-a)+(b-a)%2);
            if(a>b)
                ans++;

        }
    }

    else if(mx==b){
        ans+=mx-max(a,c);
        a+=ans;
        c+=ans;
        if(a>c){
            ans+=((a-c)+(a-c)%2)/2;
            c+=((a-c)+(a-c)%2);
            if(c>a)
                ans++;
        }
        else{ans+=((c-a)+(c-a)%2)/2;
            a+=((c-a)+(c-a)%2);
            if(a>c)
                ans++;

        }
    }
    else{
        ans+=mx-max(b,c);
        b+=ans;
        c+=ans;
        if(b>c){
            ans+=((b-c)+(b-c)%2)/2;
            c+=((b-c)+(b-c)%2);
            if(c>b)
                ans++;
        }
        else{ans+=((c-b)+(c-b)%2)/2;
            b+=((c-b)+(c-b)%2);
            if(b>c)
                ans++;

        }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import heapq

S = []
while True:
    op = input()
    if op[:2] == "in":
        op, k = op.split()
        k = int(k)*(-1)
        heapq.heappush(S, k)

    elif op[:2] == "ex":
        print(heapq.heappop(S)*(-1))
    else:
        break


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

const int MAX_N = 100005;


//ll dp[MAX_N][3]={0};
ll subans[MAX_N];

int main(void){
    int N,K;
    cin >> N >> K;
    int R,S,P;
    cin  >> R >> S >> P;
    vector<string> machine(K,"");
    for(int i=0,j=0;i<N;i++,j++){
        char c;
        cin >> c;
        machine[j] += c;
        if(j==K-1) j = -1;
    }

    for(int k=0;k<K;k++){
        vector<vector<ll>> dp(N/K+3,vector<ll>(3,0));
        int last = machine[k].size();
        for(int i=0;i<last;i++){
            if(machine[k][i]=='s'){
                dp[i+1][0] = max(dp[i+1][0], max(dp[i][1] + R, dp[i][2] + R));
                dp[i+1][1] = max(dp[i+1][1], max(dp[i][0], dp[i][2]));
                dp[i+1][2] = max(dp[i+1][2], max(dp[i][1], dp[i][0]));
            }else if(machine[k][i]=='p'){
                dp[i+1][0] = max(dp[i+1][0], max(dp[i][1], dp[i][2]));
                dp[i+1][1] = max(dp[i+1][1], max(dp[i][0] + S, dp[i][2] + S));
                dp[i+1][2] = max(dp[i+1][2], max(dp[i][1], dp[i][0]));
            }else{
                dp[i+1][0] = max(dp[i+1][0], max(dp[i][1], dp[i][2]));
                dp[i+1][1] = max(dp[i+1][1], max(dp[i][0], dp[i][2]));
                dp[i+1][2] = max(dp[i+1][2], max(dp[i][1] + P, dp[i][0] + P));
            }
        }
        subans[k] = max(dp[last][0], dp[last][1]);
        subans[k] = max(subans[k],dp[last][2]);
    }

    ll ans = 0;
    for(int i=0;i<K;i++){
        ans += subans[i];
        //cout << subans[i] << endl;
    }   
    cout << ans << endl;

}


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

int main(){
int a;
cin>>a;
int s=0;
for(int c=0;c<a;c++){
	char d;int e;
	cin>>d>>e;
	for(int f=0;f<e;f++){
		if(d=='(')s++;
		else {
			if(s<1){puts("NO");return 0;}
			else s--;
		}
	}
}
if(s)puts("NO");
else puts("YES");
}

Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int n,k,ans,a[100005]; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	ans=1e9;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1,x,y;i<=n;i++){
		if(i+k-1>n) break;
		x=a[i];
		y=a[i+k-1];
		if(y<0){
			ans=min(ans,0-x);
		}
		else if(x<0&&y>=0){
			ans=min(ans,min(y-x-x,y-x+y));
		}
		else if(x>=0){
			ans=min(ans,y);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3996
function Main(input) {
  var toppings = input.match(/o/g);
  var num = toppings ? toppings.length : 0;
  console.log(700 + num * 100);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ind(i, j) ((i) * W + (j))
#define inf 1000000000

int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    vector<int> B(N);
    rep(i, N){
        cin >> A[i] >> B[i];
    }

    vector<vector<int>> dp(N + 1, vector<int>(H + 1));
    dp[0][0] = 0;
    for(int i = 1;i <= H;i++){
        dp[0][i] = inf;
    }
    
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= H;j++){
            if(j - A[i-1] >= 0){
                dp[i][j] = min(dp[i][j - A[i-1]] + B[i-1], dp[i-1][j]);
            }else{
                dp[i][j] = min(B[i-1], dp[i-1][j]);
            }
        }
    }

    // rep(i, N+1){
    //     rep(j, H+1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[N][H] << endl;
}

Measured memory_bytes: 39424
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    string S;
    cin>>S;
    if(S[S.size()-1] == 's')S = S+"es";
    else S = S+"s";

    cout<<S;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mod 924844033
using namespace std;
int n,x,y;
int fir[200005],nxt[400005],to[400005],cnt;
int siz[200005],Cnt[200005];
int fac[200005],ifac[200005];
int lim=1,L=0,f[800005],g[800005],R[800005],Inv;

int read(){
    int x=0;char ch=getchar();
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}

void print(int x){
    if(x>=10) print(x/10);
    putchar(x%10+'0');
}

void dfs(int x,int f){
    siz[x]=1;
    for(int i=fir[x];i;i=nxt[i]){
        if(to[i]==f) continue;
        dfs(to[i],x);
        siz[x]+=siz[to[i]];
        Cnt[siz[to[i]]]++;
    }
    if(x!=1) Cnt[n-siz[x]]++;
}

int ksm(int x,int y){
    int res=1;
    while(y){
        if(y&1) res=1ll*res*x%mod;
        x=1ll*x*x%mod,y/=2;
    }
    return res;
}

int C(int x,int y){
    int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
    return res;
}

void NTT(int *x,int on){
    for(int i=0;i<lim;i++) if(i<R[i]) swap(x[i],x[R[i]]);
    for(int i=2;i<=lim;i*=2){
        int wn=ksm(5,(mod-1)/i);
        if(on==-1) wn=ksm(wn,mod-2);
        for(int j=0;j<lim;j+=i){
            int w=1;
            for(int k=0;k<i/2;k++){
                int u=x[j+k],v=1ll*w*x[j+k+i/2]%mod;
                x[j+k]=(u+v)%mod;
                x[j+k+i/2]=(u+mod-v)%mod;
                w=1ll*w*wn%mod;
            }
        }
    }
}

int main(){
    n=read();
    fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*i*fac[i-1]%mod;
    ifac[n]=ksm(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) ifac[i]=1ll*(i+1)*ifac[i+1]%mod;
    for(int i=1;i<n;i++){
        x=read(),y=read();
        to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt;
        to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt;
    }
    dfs(1,0);
    while(lim<=2*n) lim*=2,L++;
    for(int i=0;i<lim;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(L-1));
    for(int i=1;i<=n;i++) f[i]=1ll*Cnt[i]*fac[i]%mod;
    for(int i=0;i<=n;i++) g[i]=ifac[n-i];
    NTT(f,1),NTT(g,1);
    for(int i=0;i<lim;i++) f[i]=1ll*f[i]*g[i]%mod;
    NTT(f,-1);
    Inv=ksm(lim,mod-2);
    for(int i=1,v;i<=n;i++){
        v=(1ll*n*C(n,i)%mod+mod-1ll*ifac[i]*f[n+i]%mod*Inv%mod)%mod;
        print(v),puts("");
    }

    return 0;
}

Measured memory_bytes: 29932
N,M=map(int,input().split(' '))
s = [list(map(int,input().split(' ')))[1:] for i in range(M)]
p = list(map(int,input().split(' ')))
s_bit = []
ans = 0
for i in s:
    tmp = 0
    for j in i:
        tmp += 2**(j-1)
    s_bit.append(bin(tmp))
for i in range(2**N):
    tmp = True
    for n,j in enumerate(s_bit):
        on_swich=bin(int(bin(i),0)&int(j,0))
        tmp = tmp and on_swich.count('1')%2==p[n]
    if tmp:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int a,b,k;
    int count = 0;
    int ans;
 
    scanf("%d%d%d",&a,&b,&k);
  
  	for (int i = 100; i >= 0; i--) {
        if (((a % i) == 0) && ((b % i) == 0)) {
            count++;
            if (count == k) {
                ans = i;
                break;
            }
        }
    }
 
    printf("%d\n",ans);
	return 0;
}

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

int main(void)
{
	char map[6][5] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
	char message[1000], after[1000];
	int i, flag;
	
	while (scanf("%s", message) != EOF){
		getchar();
		flag = 0;
		if (strlen(message) % 2 == 1){
			printf("NA\n");
			flag = 1;
		}
		i = 0;
		memset(after, '\0', sizeof(after));
		while (message[i] != '\0' && !flag){
			if (!('1' <= message[i] && message[i] <= '6') || !('1' <= message[i + 1] && message[i + 1] <= '5') || message[i] > '6' || message[i + 1] > '5'){
				printf("NA\n");
				flag = 1;
				break;
			}
			after[i / 2] =  map[message[i] - '0' - 1][message[i + 1] - '0' - 1];
			i += 2;
		}
		
		if (!flag){
			printf("%s\n", after);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>


int main()
{
	int H;
	int W;
	int iCount;
	int iCount1;
	int iCount2;
	int iPutNum = 0;
	int iH[1000];
	int iW[1000];

	//Hの入力
	scanf("%d", &H);
	//Wの入力
	scanf("%d", &W);

	while (H != 0 || W != 0)
	{

		iH[iPutNum] = H;
		iW[iPutNum] = W;
		//Hの入力
		scanf("%d", &H);
		//Wの入力
		scanf("%d", &W);
		iPutNum++;

	}

	//長方形を書く部分
	for (iCount = 0; iCount < iPutNum; iCount++)
	{
		//縦のループ(行)
		for (iCount1 = 0; iCount1 < iH[iCount]; iCount1++)
		{
			//横のループ（列）
			for (iCount2 = 0; iCount2 < iW[iCount]; iCount2++)
			{
				//偶数行偶数列(#)
				if (iCount1 % 2 == 0 && iCount2 % 2==0)
				{
					printf("#");
				}
				//偶数行奇数列(.)
				else if (iCount1 % 2 == 0 && iCount2 % 2 == 1)
				{
					printf(".");
				}
				//奇数行偶数列(.)
				else if (iCount1 % 2 == 1 && iCount2 % 2 == 0)
				{
					printf(".");
				}
				//奇数行奇数列(#)
				else
				{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

}


Measured memory_bytes: 2104
import sys
readline = sys.stdin.readline

import numpy as np

N,K = map(int,readline().split())
A = np.array(sorted(list(map(int,readline().split()))))
F = np.array(sorted(list(map(int,readline().split())),reverse = True))

ok = A[-1] * F[0]
ng = -1

def isOk(x):
  # 時間がxになるためには、A_iをx/F_i以下まで減らす必要がある
  return A.sum() - np.minimum(A,x // F).sum() <= K
  
while (ok - ng)>1:
  mid = (ok + ng) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid
print(ok)

Measured memory_bytes: 37280
A, B = map(int, input().split())
ra, rb = A%4, B%4

ans = 0
if B - A < 4:
  for i in range(A, B+1):
    ans ^= i
else:
  if ra:
    for i in range(4-ra):
      ans ^= A + i

  for i in range(rb+1):
    ans ^= B - i

print(ans)

Measured memory_bytes: 3060
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A
import Data.Bits

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show

solver (n:as) = patterns 0 0 as as

-- n <= 20
conb2 n = n * (n+1) `div` 2

patterns len sm [] _ = conb2 len
patterns len sm (a:as) (b:bs)
  = if (sm .&. a) > 0 then len + patterns (len-1) (sm-b) (a:as) bs
                      else patterns (len+1) (sm+a) as (b:bs)




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

using namespace std;

int main()
{
    int n, i, j, a, b, l, cnt = 1;

    string s;

    cin >> n >> s;

    for(i=0; i<n-1; i++){
        if(s[i] != s[i+1])
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
use std::collections::HashMap;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut map = HashMap::with_capacity(n);

    for _ in 0..n {
        let a_i: u64 = read();
        *map.entry(a_i).or_insert(0) += 1;
    }
    let mut v1: Vec<u64> = map
        .iter()
        .filter(|&(_, v)| *v >= 4)
        .map(|(k, _)| *k)
        .collect();

    v1.sort();
    let rec1 = if v1.len() >= 1 {
        v1[v1.len() - 1].pow(2)
    } else {
        0
    };

    let mut v: Vec<u64> = map
        .iter()
        .filter(|&(_, v)| *v >= 2)
        .map(|(k, _)| *k)
        .collect();
    v.sort();

    let rec2 = if v.len() >= 2 {
        v[v.len() - 1] * v[v.len() - 2]
    } else {
        0
    };
    println!("{}", std::cmp::max(rec1, rec2));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    string s;
    cin >> s;
    
    if( (s.size()+2)%2!=0 )
    {
        cout << "No" << endl;
        return 0;
    }
    rep(i,s.size()-1)
    {
        if( s[i] == 'h' && s[i+1] == 'i' ) i++;
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  s += s;
  if (s.find(t) != string::npos)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int d,t,s;
    cin >> d >> t >> s;
    double x = ceil((double)d/s);
    if(x<=t) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
#define ull unsigned long long
#define mod 1000000007

using namespace std;

int main() {
    int n;
    double* a;
    cin >> n;
    a = new double[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    double ans = 0;
    for(int i = 0; i < n; i++){
        ans += 1/a[i];
    }

    cout << 1/ans << endl;
}

Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, m]: number[] = tmp[0].split(" ").map(int => parseInt(int));
    const map: {[p: string]: {c: boolean, pCount: number}} = {};
    for (let i = 0; i < m; i++) {
      const [p, S]: string[] = tmp[1 + i].split(" ");
      let ma = map[p];
      if (ma == null) {
        ma = {c: false, pCount: 0};
        map[p] = ma;
      }
      if (ma.c) {
        continue;
      }
      if (S == "WA") {
        ma.pCount++;
      } else {
        ma.c = true;
      }
    }
    const keys = Object.keys(map);
    let clear = 0;
    let pena = 0;
    for (let i = 0, len = keys.length; i < len; i++) {
      const ma = map[keys[i]];
      if (ma.c) {
        clear++;
        pena += ma.pCount;
      }
    }
    return `${clear} ${pena}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 35636