akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>

int main() {

	int H, N;
	std::cin >> H, std::cin >> N;

	int a;
	int b = 0;

	for (int i = 1; i <= N; i++) {
		std::cin >> a;
		b += a;
	}

	if (H <= b) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

int main()
{
	double v;
	int floor;
	while(cin >> v){
		floor = static_cast<int>(v*v/98)+1;
		if(static_cast<double>(static_cast<int>(v*v/98)) != v*v/98)
			floor++;
		cout << floor << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N,X = map(int,input().split())
L = [int(i) for i in input().split()]

from itertools import accumulate

Lcum = accumulate(L)

count = 1
for l in Lcum:
    if l > X:
        print(count)
        exit()
    else:
        count += 1

print(N+1)

Measured memory_bytes: 3060
n = int(input())
v = [int(i) for i in input().split()]

a, b = dict(), dict()
for i in range(n):
    if i%2 == 0:
        a[v[i]] = a.get(v[i], 0) + 1
    else:
        b[v[i]] = b.get(v[i], 0) + 1
alst = sorted(list(a.items()), key=lambda x: x[1], reverse=True)
blst = sorted(list(b.items()), key=lambda x: x[1], reverse=True)

if alst[0][0] != blst[0][0]:
    print(n-alst[0][1]-blst[0][1])
elif len(alst) == 1 and len(blst) == 1:
    print(blst[0][1])    
elif len(alst) == 1:
    print(n-alst[0][1]-blst[1][1])
elif len(blst) == 1:
    print(n-alst[1][1]-blst[0][1])
elif blst[0][1]+alst[1][1] > alst[0][1]+blst[1][1]:
    print(n-alst[1][1]-blst[0][1])
else:
    print(n-alst[0][1]-blst[1][1])

Measured memory_bytes: 21144
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long int l, r;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		sum += (r - l) + 1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
k=n
i=2
while i <= max_root
	if n%i==0
		prime << i
		n=n/i
	elsif i==2
		i+=1
	else
		i+=2
	end
end
if m==n || n!=1
	prime << n
end

prime.uniq!

j=0
while j <= prime.length-1
	k= k-k/prime[j]
	j+=1
end
puts k

Measured memory_bytes: 8624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N=0;
	cin >> N;
	string X;
	string namae[N];
	int jikan[N];
	for (int i = 0;i < N;i++) {
		cin >> namae[i]>>jikan[i];
	}
	cin >> X;
	int koko = 0;
	for (int i = 0;i < N;i++) {
		if (namae[i] == X) {
			koko = i+1;
			break;
		}
	}
	int count = 0;
	for (int i = koko;i < N;i++) {
		count += jikan[i];
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string a;
  cin>>a;
  ll b=a.size();
  for(ll i=0;i<b;i++){
    if(a.at(i)=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
    
  }
  cout<<"No"<<endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    mat A(H, vec(W, 0));
    REP(i,0,H) {
        REP(j,0,W) {
            cin >> A[i][j];
            A[i][j] %= 2;
        }
    }

    mat Z;
    REP(i,0,H) {
        bool f = false;
        REP(j,0,W-1) {
            vec z = {i+1, j+1, i+1, j+2};
            if(A[i][j] == 1) {
                if(!f) {
                    A[i][j] = 0;
                    f = true;
                }
                else {
                    A[i][j] = 0;
                    f = false;
                }
            }
            if(f) Z.pb(z);
        }
        if(f) A[i][W-1] = 1 - A[i][W-1];
    }

    bool f = false;
    REP(i,0,H-1) {
        vec z = {i+1, W, i+2, W};
        if(A[i][W-1] == 1) {
            if(!f) {
                A[i][W-1] = 0;
                f = true;
            }
            else {
                A[i][W-1] = 0;
                f = false;
            }
        }
        if(f) Z.pb(z);
    }
    if(f) A[H-1][W-1] = 1 - A[H-1][W-1];

    PR(SZ(Z));
    REP(i,0,SZ(Z)) {
        PS(Z[i][0]); PS(Z[i][1]); PS(Z[i][2]); PR(Z[i][3]);
    }

    return 0;
}

/*



*/

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  long count = 0;
  count = (N + 1) / 2;
  if(count >= K)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==1)
    {
        n=14;
    }
    if(m==1)
    {
        m=14;
    }
    if(n==m)
    {
        cout<<"Draw";
    }
    else if(n<m)
    {
        cout<<"Bob";
    }
    else
    {
        cout<<"Alice";
    }
    return 0;
}


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int tab[n+1][3];
    for(int i = 1; i<= n; i++){
        cin >> tab[i][0] >> tab[i][1] >> tab[i][2];
    }
    int dp[n+1][3];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = -INF;
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i][j] = max(dp[i-1][k]+tab[i][j], dp[i][j]);
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,h,hp=0,ans=0;cin>>n>>h;
  vp a(2*n);
  rep(i,0,n){
    cin>>a[2*i].first>>a[i*2+1].first;
    a[2*i].second=MOD;
    a[i*2+1].second=1;
  }
  sort(a.begin(),a.end());reverse(a.begin(),a.end());
  ll i=0;
  while(hp<h&&a[i].second==1){
    hp+=a[i].first*a[i].second;
    i++;
    ans++;
  }
  if(hp<h){
    ll x=(h-hp)/a[i].first;
    ans+=x;
  if((h-hp)%a[i].first!=0)ans++;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;
    vector<long long> B(N);
    for (long long &b: B)
        cin>>b;

    vector<long long> D;
    long long S = 0;
    long long Sn = 0;
    long long Cn = 0;
    for (int i=0; i<N; i++)
    {
        S += A[i]-B[i];
        if (A[i]-B[i] >= 0)
            D.push_back(A[i]-B[i]);
        else
            Sn += A[i]-B[i],
            Cn++;
    }
    long long ans;
    if (S < 0)
    {
        ans = -1;
    }
    else
    {
        ans = Cn;
        sort(D.begin(), D.end());
        for (int i=(int)D.size()-1; Sn < 0 && i>=0; i--)
        {
            Sn += D[i];
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
    char a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if (a == f && b == e && c == d) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

dp = [0 for i in range(max(n+1, 36))]

for i in range(35):
    j = i // 9
    cand = []
    for k in range(j+1):
       _i = i
       _i -= 9*k
       l = _i // 6
       for m in range(l+1):
           __i = _i
           __i -= 6*m
           cand.append(k+m+__i)
    dp[i] = min(cand)
nine_list = [pow(9, i) for i in range(1, 6)]
six_list = [pow(6, i) for i in range(1, 7)]
for i in range(35, n+1):
    max_nine = nine_list[len(nine_list) - 1]
    max_six = six_list[len(six_list) - 1]
    for j in range(len(nine_list)):
        if nine_list[j] > i:
            max_nine = nine_list[j-1]
            break
    for j in range(len(six_list)):
        if six_list[j] > i:
            max_six = six_list[j-1]
            break
    dp[i] = min(dp[i-max_nine]+1, dp[i-max_six]+1)

print(dp[n])

Measured memory_bytes: 4016
import java.util.*;

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    void solve() {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        for (int i = 0; i < M; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean[] connected = new boolean[N + 1];
        for (int i = 0; i < M; i++) {
            if (b[i] == N) {
                connected[a[i]] = true;
            }
        }

        boolean check = false;
        for (int i = 0; i < M; i++) {
            if (connected[b[i]] && a[i] == 1) {
                check = true;
            }
        }

        if (check) System.out.println("POSSIBLE");
        else System.out.println("IMPOSSIBLE");
    }
}

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

int main(){
    ll n,d,a;cin>>n>>d>>a;
    ll x,h,tmp,cnt,ans;
    tmp=cnt=ans=0;
    
    vector<pair<ll,ll>> m(n);
    queue<pair<ll,ll>> q;
    for(int i=0;i<n;i++){
        cin>>x>>h;
        m[i]=make_pair(x,h);
    }    
    sort(m.begin(),m.end());
    for(int i=0;i<n;i++){
        x=m[i].first;
        while(!q.empty()){
            if(q.front().first<x){
                tmp-=q.front().second;
                q.pop();
            }
            else{
                break;
            }
        }
        h=m[i].second-tmp;
        if(h<=0){
            cnt=0;
        }
        else{
            if(h%a==0){
            cnt=h/a;
        }
        else{
            cnt=h/a+1;
        }
        }
        q.push(make_pair(x+2*d,a*cnt));
        tmp+=a*cnt;
        ans+=cnt;
    }
    cout<<ans<<endl;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n), b(n);
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
    if(i > 0){
      b.at(i-1) = a.at(i) - a.at(i-1);
    }
  }
  b.at(n-1) = k + a.at(0) - a.at(n-1);
  sort(b.begin(), b.end());
  cout << k - b.at(n-1) << endl;
}

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

string s;
int memo[310][310][310];

int dp(int l, int r, int k){
    if(l > r){
        return 0;
    }

    if(l == r){
        return 1;
    }

    if(memo[l][r][k] != -1) return memo[l][r][k];

    int ans = 0;
    ans = max(ans, dp(l+1, r, k));
    ans = max(ans, dp(l, r-1, k));

    if(s[l] == s[r]){
        ans = max(ans, dp(l+1, r-1, k)+2);
    }else if(k > 0){
        ans = max(ans, dp(l+1, r-1, k-1)+2);
    }

    return memo[l][r][k] = ans;
}

int main(){
    cin >> s;
    int k;
    cin >> k;
    memset(memo, -1, sizeof(memo));
    cout << dp(0, s.size()-1, k) << endl;
    return 0;
}


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

MOD = 10 ** 9 + 7


def main():
    N, M = map(int, input().split())
    s = []
    mod = []
    ans = 0

    for i in range(M):
        t = list(map(int, input().split()))
        s.append(t[1:])

    mod = list(map(int, input().split()))

    for i in range(0, 2**N):
        switch = [0] * N
        for j in range(N):
            if ((i >> j) & 1):
                switch[j] = 1

        all = 0
        for i in range(M):
            li = s[i]
            total = 0
            for item in li:
                total += switch[item-1]

            if mod[i] != total % 2:
                break
            else:
                all += 1

        if all == M:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

#define MAXN 300000

long long s1[MAXN + 5], s2[MAXN + 5];
long long sx[MAXN + 5], sy[MAXN + 5];
bool visx[MAXN + 5], visy[MAXN + 5];
int main (){
	int n, m, l;
	long long maxx = 0, maxy = 0;
	long long tot1 = 0, tot2 = 0;
	
	scanf ("%d %d %d", &n, &m, &l);
	for (int i = 1; i <= l; i ++) {
		int x, y;
		
		scanf ("%d %d", &x, &y);
		s1[x] ++;
		s2[y] ++;
		sx[i] = x;
		sy[i] = y;
	}
	for (int i = 1; i <= n; i ++) {
		maxx = max (maxx, s1[i]);
	}
	for (int i = 1; i <= m; i ++) {
		maxy = max (maxy, s2[i]);
	}
	for (int i = 1; i <= n; i ++) {
		if (s1[i] >= maxx) {
			visx[i] = 1;
			tot1 ++;
		}
	}
	for (int i = 1; i <= m; i ++) {
		if (s2[i] >= maxy) {
			visy[i] = 1;
			tot2 ++;
		}
	}
	
	long long ans = 0;
	
	for (int i = 1; i <= l; i ++) {
		if (visx[sx[i]] && visy[sy[i]]) {
			ans ++;
		}
	}
	
	if (ans < tot1 * tot2) {
		printf ("%lld", maxx + maxy);
	}
	else {
		printf ("%lld", maxx + maxy - 1);
	}
	
	return 0;
}



Measured memory_bytes: 11640
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A =	sc.nextInt();
	int B =	sc.nextInt();
	if(A % 2 == 0 || B % 2 == 0) {
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vvi adj(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vvi dp(n, vi(2));

    function<void(int, int)> dfs = [&](int v, int p) {
        if (adj[v].empty()) {
            dp[v][0] = 1;
            dp[v][1] = 1;
            return;
        }
        for (int s : adj[v]) {
            if (s != p) {
                dfs(s, v);
            }
        }
        i64 b = 1, w = 1;
        for (int s : adj[v]) {
            if (s != p) {
                b *= dp[s][1];
                b %= MOD;
                w *= dp[s][0] + dp[s][1];
                w %= MOD;
            }
        }
        dp[v][0] = b;
        dp[v][1] = w;
    };
    dfs(0, -1);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl; 
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
#define equals(a,b) (fabs((a)-(b))<EPS)
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//幾何学テンプレート

//点
class Point{
public:
  double x,y;

  Point(double x = 0,double y = 0):x(x), y(y){};

  Point operator + (Point p) {return Point (x+p.x, y+p.y);}
  Point operator - (Point p) {return Point (x-p.x, y-p.y);}
  Point operator * (double a) {return Point(a*x, a*y);}
  Point operator / (double a) {return Point(x/a,y/a);}

  double abs(){return (norm());}
  double norm(){return x*x+y*y;}

  bool operator < (const Point &p)const{
    return x!=p.x ? x<p.x:y<p.y;
  }
  bool operator > (const Point &p)const{
    return x!=p.x ? x>p.x:y>p.y;
  }
  bool operator == (const Point &p)const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};

//ベクトル
typedef Point Vector;

//内積
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

//外積
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

//線分
struct Segment{Point p1,p2;};

//直線
typedef Segment Line;

//円
class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

//多角形
typedef vector<Point> Polygon;

//ある点から、直線/線分に対する射影を求める。
Point project(Segment s, Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/base.norm();
  return s.p1+base*r;
}


signed main(){
  double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  Point p1={x1,y1},p2={x2,y2};
  Segment s={p1,p2};

  int qq;cin>>qq;
  queue<Point>q;
  for(int i=0;i<qq;i++){
    double x,y;cin>>x>>y;
    Point p={x,y};
    Point ans=project(s,p);
    q.push(ans);
  }

  while(!q.empty()){
    Point temp=q.front();q.pop();
    cout<<fixed<<setprecision(10)<<temp.x<<" "<<temp.y<<endl;
  }
  return 0;
}



Measured memory_bytes: 3320
hw_l = gets.chomp.split(" ")
hw = gets.chomp.split(" ")
for i in 0..1
  hw_l[i] = hw_l[i].to_i
  hw[i] = hw[i].to_i
end
puts hw_l[0] * hw_l[1] - (hw_l[0] * hw[1] + hw[0] * hw_l[1] - hw[0] * hw[1])

Measured memory_bytes: 1788
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    A = [int(input()) for i in range(n)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    A = sorted(A)
    Dic = {a:0 for a in set(A)}

    for x in A:
        Dic[x] += 1

    cnt = 0
    for y in Dic:
        if Dic[y] % 2 == 1:
            cnt += 1

    print(cnt)


resolve()

Measured memory_bytes: 64852
N, K = map(int, input().split())
A = []
d = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

count = 0
flag = 0
for i in range(N):
    flag = 0
    for j in range(K):
        if (i+1 in A[j]) is True:
            flag = 1
            break
    if flag == 0:
        count += 1
print(count)

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

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

	ans += a.at(0);
	ans += b.at(1);
	ans += c.at(2);
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
using ll = long long;
using ui = unsigned int;

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

    vector<vector<int>> X(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            int tmp;
            cin >> tmp;
            X[i].push_back(tmp);
        }
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int d = 0;
            for (int k = 0; k < D; k++) {
                d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            double sqrtd = sqrt(d);
            if (sqrtd == double(int(sqrtd))) {
                res++;
            } 
        }
    }
    cout << res << "\n";

}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
	int h, w;

	while (1){
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int j = 0; j < h; j++){//列

			if (j%2==0){//偶数行
				for (int i = 0; i < w; i++){//行
					if (i%2==0){
						cout << '#';
					}
					else{
						cout << '.';
					}

				}
				cout << endl;
			}

			if (j % 2 == 1){//奇数行
				for (int i = 0; i < w; i++){//行
					if (i % 2 == 1){
						cout << '#';
					}
					else{
						cout << '.';
					}

				}
				cout << endl;
			}

		}
		cout << endl;//空行のため
	}
	return 0;
}



Measured memory_bytes: 3080
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long a[N];
	bool b[N];
	f(i, N) {
		a[i] = 0;
		b[i] = true;
	}
	long long m;
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld %lld", &n, &m);
	f(i, m) {
		scanf("%lld", &x);
		b[x] = false;
	}
	a[0] = 1;
	f(i, n) {
		if (b[i + 1])a[i + 1] = (a[i + 1] + a[i]) % MOD;
		if (b[i + 2])a[i + 2] = (a[i + 2] + a[i]) % MOD;
	}
	ans = a[n];
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    string s;
    rep(i,n) {
        char c;
        cin>>c;
        s+=c;
    }
    string t;
    rep(i,n) {
        char c;
        cin>>c;
        t+=c;
    }
    reverse(all(t));
    
    map<pair<string,string>,ll> mp;
    for(int bit=0; bit<(1<<n); bit++) {
        string x,y;
        rep(i,n) {
            if(bit&(1<<i)) x+=t[i];
            else y+=t[i];
        }
        mp[{x,y}]++;
    }
    
    ll ans=0;
    for(int bit=0; bit<(1<<n); bit++) {
        string x,y;
        rep(i,n) {
            if(bit&(1<<i)) x+=s[i];
            else y+=s[i];
        }
        ans+=mp[{x,y}];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 91904
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

LL p[100],cnt;

int main()
{
	LL n;
	cin>>n;
	for(LL i=2;i*i<=n;i++){
		while(n%i==0){
			p[cnt]++;
			n/=i;
		}
		if(p[cnt]) cnt++;
	}
	if(n>1) p[cnt++]++;
	LL ans=0;
	for(int i=0;i<cnt;i++){
		int j=1;
		while(p[i]>=0){
			p[i]-=j;
			j++;
			ans++;
		}
		ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 52016
loop do
	h, w = gets.split.map(&:to_i)
	if h == 0 && w == 0 then
		break
	end
	
	puts "#" * w
	(h - 2).times do
		puts "#" + "." * (w - 2) + "#"
	end
	puts "#" * w
	puts
end



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

int main(){
    int num1;
    int num2;
    int seki;
    cin >> num1;
    cin >> num2;
    seki = num1 * num2;
    if (seki % 2 == 0){
        cout << "Even";
    }
    else { 
        cout << "Odd";
    }
    return 0;
}
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int n,k,x[100],ans;

int ze(int a){
	if(a<=0) return -1*a;
	else return a;
}

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i];
		ans+=(min(x[i],ze(x[i]-k)))*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>


#define rep(i,n) for(int i = 0; i < n; ++i)
#define all(x) x.begin(),x.end()
using namespace std;

int main(void){
  string s;
  cin >> s;
  string t(s);
  reverse(all(t));

  for(int i = 0; i < t.size(); ++i){
    switch(t[i]){
      case 'p':
        t[i] = 'q';
        break;
      case 'q':
        t[i] = 'p';
        break;
      case 'd':
        t[i] = 'b';
        break;
      case 'b':
        t[i] = 'd';
        break;
    }
  }

  if( s == t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
int m[100][100];
int d[100];
int n;
int t;
int Q[1000];
int head,tail;


void enqueue(int n){
  Q[tail] = n;
  tail = (tail+1)%1000;
}
int dequeue(){
  int n;
  n = Q[head];
  head = (head+1)%1000;
  return n;
}



int main (){
  int i,j,k,u,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    d[i] = -1;
    for(j=0;j<n;j++){
      m[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d",&r);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&u);
      m[r-1][u-1] = 1;
    }
  }

  d[0] = 0;
  head = 0;
  tail = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i=0;i<n;i++){
      if(m[u][i] && d[i] == -1){
	d[i] = d[u]+1;
	enqueue(i);
      }
    }
  }


  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}

Measured memory_bytes: 636
import sys
s = tuple(map(str, input().split("><")))
n = len(s)
ans = 0
def calc(x, y):
    return (x*(x-1) + y*(y-1))/2 + max(x, y)
if n == 1:
    a = s[0].count("<")
    b = s[0].count(">")
    print(int(calc(a, b)))
    sys.exit()
for i in range(n):
    if i == 0:
        a = s[i].count("<")
        b = s[i].count(">") + 1
    elif i == n - 1:
        a = s[i].count("<") + 1
        b = s[i].count(">")
    else:
        a = s[i].count("<") + 1
        b = s[i].count(">") + 1
    ans += calc(a, b)

print(int(ans))

Measured memory_bytes: 9392
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll INF = 10000000;
//ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
//struct edge{int to, cost};






//番号ズレ注意！！
int main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    int x = 0;
    P req[M];
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        req[i] = make_pair(b, a);
    }
    sort(req, req + M);
    REP(i, M) {
        if (x >= req[i].second)continue;
        else {
            x = req[i].first - 1;
            ans += 1;
        }
    }
    print(ans);
}


Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    ans = 3 ** N
    excl = 1

    for x in A:
        if x % 2 == 0:
            excl *= 2

    ans -= excl

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61608
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define MAX_N 100000000
#define INF 100000000000000

int main(){
  int n;
  cin >> n;
  int temp;
  vector<int> l;
  for(int i=0;i<n;i++){
    cin >> temp;
    l.push_back(temp);
  }
  sort(l.begin(),l.end());
  int a,b;
  long long ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      a = l[i];
      b = l[j];
      //cout << a << " " << b << endl;
      auto it = lower_bound(l.begin(),l.end(),a+b);
      int s = l.end() - it;
      //cout << n << " " << j << " " << s << endl;
      ans += n - j - s - 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

dp=[0]*(n+1)
for i in range(1,n+1):
    ans=dp[i-1]+1
    j=1
    while i>=6**j:
        ans=min(ans,dp[i-6**j]+1)
        j+=1
    j=1
    while i>=9**j:
        ans=min(ans,dp[i-9**j]+1)
        j+=1
    dp[i]=ans
  
print(ans)


Measured memory_bytes: 3828
#include<stdio.h>

int main(){
  int i,j,k,N;
  
  scanf("%d",&N);
  int A[N];
  char S[N];
  int min=10000000;
  int tmp=0;
  for(i=0;i<N;i++)
    A[i]=0;
  scanf("%s",S);
  for(i=0;i<N;i++){
    if(S[i]=='E'){
      if(i==0)
        A[0]++;
      else
        A[i] = A[i-1]+1;
    }
    else{
      if(i==0)
        A[0]=0;
      else
        A[i]=A[i-1];
    }
  }
  
  for(i=0;i<N;i++){
    if(i==0)
      tmp=(A[N-1]-A[1]);
    else
    tmp = i-A[i-1] + (A[N-1]-A[i]);
    if(min > tmp)
      min=tmp;
  }
  printf("%d",min);
  return 0;
}
    
      
      

Measured memory_bytes: 1664
s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t, reverse=True)
for i in range(min(len(s), len(t))):
  if s[i] > t[i]:
    print("No")
    exit()
  elif s[i] < t[i]:
    print("Yes")
    exit()
else:
  if len(s) < len(t):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 61964
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
int mod=1e9+7;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL fra[100005];
LL inv[100005];
LL pre[100005];
void build(){
    fra[0]=1;
    for(int i = 1;i<100005;i++){
        fra[i]=fra[i-1]*i%mod;
    }
    /*for(int i = 0;i<100005;i++){
        inv[i]=f_pow(fra[i],mod-2);
    }*/
    
    inv[100004]=f_pow(fra[100004],mod-2);
    for(int i = 100003;i>=0;i--){
        inv[i]=(inv[i+1]*(i+1)%mod);
    }
    for(int i = 1;i<100005;i++)
        pre[i]=(pre[i-1]+inv[i]*fra[i-1]%mod)%mod;
}
int main(){
    int n;
    scanf("%d",&n);
    int x[100005];
    for(int i=0;i<n;i++)
        scanf("%d",&x[i]);
    LL ans=0;
    build();
    for(int i = 1;i<n;i++){
        ans+=fra[n-1]*pre[i]%mod*(x[i]-x[i-1])%mod;
       // printf("%d %d %d\n",fra[i],pre[i],inv[i]);
        ans%=mod;
     //   printf("%d\n",ans);
    }
    printf("%lld\n",ans);
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int count=0;
    rep(i,3){
        if(s[i]==t[i]) count ++;
    }
    cout << count << endl;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

vector<ll> adj[M];
ll p[M],d[M],mrk[M];
priority_queue<pi,vector<pi>,greater<pi> > q;

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

	ll n,m,i,u,v,mn = 1e9;

	cin >> n >> m;
	for(i=1;i<=m;++i)
	{
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	q.push({0,1});
	for(i=2;i<=n;++i)
		d[i] = 1e9;

	while(!(q.empty()))
	{
		auto ed = q.top();
		q.pop();
		u = ed.ss;
		if(mrk[u])
			continue;
		mrk[u] = 1;
		for(auto v:adj[u])
		{
			if(d[v]>d[u]+1)
			{
				d[v] = d[u]+1;
				p[v] = u;
				q.push({d[v],v});
			}
		}
	}

	for(i=2;i<=n;++i)
		mn = min(mn,p[i]);
	if(mn == 0)
		cout << "No" << "\n";
	else
	{
		cout << "Yes" << "\n";
		for(i=2;i<=n;++i)
			cout << p[i] << "\n";
	}
}

Measured memory_bytes: 37544
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n&1){
        int ans = b[n/2]-a[n/2]+1;
        cout << ans << endl;
    }
    else{
        int now1 = b[n/2]+b[n/2-1];
        int now2 = a[n/2]+a[n/2-1];
        int ans = now1-now2+1;
        cout << ans << endl;

    }
}



Measured memory_bytes: 4820
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        sc.nextLine();
        int p[] = new int[N];
        for(int i = 0; i < N; i++)
            p[i] = sc.nextInt();

        int sum = 0;
        Arrays.sort(p);

        for(int i = 0; i < K; i++)
            sum += p[i];

        System.out.println(sum);

    }
}

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => int.Parse(i));
            var x = s.Max();
            var y = s.Min();

            Console.WriteLine(x - y);
        }
    }
}


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

int main(){
	string s,t;
	int i,ans = 0;;
	cin >> s;
	cin >> t;

	for(i = 0; i < 3; i++){
		if(s[i]==t[i]){
			ans++;
		}
	}

	cout << ans;

	return 0;
}


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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> donus(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> donus.at(i);
    sum += donus.at(i);
  }
  int min = *min_element(donus.begin(), donus.end());
  int ans = (X - sum) / min + N;
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline
n = int(readline())
A = map(int, readline().split())
mod = 1000000007

caps = [0] * 3
ans = 1
for a in A:
    ans *= caps.count(a)
    # caps[caps.index(a)] += 1
    for i in range(3):
        if caps[i] == a:
            caps[i] += 1
            break
    ans %= mod
print(ans)


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

int main() {
    int n; cin >> n;
    vector<int> p(n); for (auto &x : p) cin >> x;
    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i] != max({p[i-1], p[i], p[i+1]}) && p[i] != min({p[i-1], p[i], p[i+1]})) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int left = 0, right = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '(') {
            left++;
        } else if (S[i] == ')') {
            if (left > 0) left--;
            else if (left == 0) right++;
        }
    }

    for (int i = 0; i < right; i++) cout << '(';
    cout << S;
    for (int i = 0; i < left; i++) cout << ')';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
//ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

const int N = 1e5+5;

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

    int cnt = 0;
    for(int i=min(a,b);i>=1;i--)
    {
        if(a%i==0 && b%i==0) cnt++;// cout<<i<<nl;
        if(cnt == c) return cout<<i<<nl,0;
    }

    return 0;
}



Measured memory_bytes: 256
// <<<<GOD>>>> lET'S gO

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

typedef long long ll;
const int N = 2e5 + 100;

ll n, ans, cnt;
string s;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	n = s.length();
	for (int i = n - 1; ~i; i--) {
		char c = s[i];
		if(c == 'A')
			ans += cnt;
		else if(c == 'B')
			cnt = 0;
		else {
			if(i == 0)
				break;
			if(s[i - 1] == 'B') {
				i--;
				cnt++;
			}
			else
				cnt = 0;
		}
	}
	cout << ans;
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

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

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

string s,t;

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

	cin>>s;
	int idx=0;
	while (idx<s.size()) {
		int num=s.size()-idx;
		if(num>=6&&s.substr(idx,6)=="eraser") idx+=6;
		else if(num>=7&&s.substr(idx,7)=="dreamer") {
			if(num>=8&&s[idx+7]=='a') idx+=5;
			else idx+=7;
		}
		else if(num>=5&&s.substr(idx,5)=="dream"||s.substr(idx,5)=="erase") idx+=5;
		else {
			cout<<"NO"<<endl;
			return 0;
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


Measured memory_bytes: 592
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


def read_matrix(H, W):
    '''return np.ndarray shape=(H,W) matrix'''
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
A = ints()
B = A - np.arange(1, N + 1)
b = int(np.median(B))
print(np.abs(B - b).sum())


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

int main() {
  int N;
  cin>>N;
  int64_t A=0,B=0;
  vector<pair<int64_t,int64_t>> p(N);
  for(int i=0;i<N;i++){
    int64_t a,b;
    cin>>a>>b;
    p.at(i)=make_pair(a+b,a);
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  for(int i=0;i<N;i++){
    int64_t x,y;
    tie(x,y)=p.at(i);
  if(i%2==0){
    A+=y;
  }
    else{
      B+=x-y;
    }
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int x;
  int h,m,s;

  scanf("%d",&x);

  h = x / 3600;
  m = x/60 - 60*h;
  s = x % 60;

  
  printf("%d:%d:%d\n",h,m,s);

  return 0;


}




Measured memory_bytes: 2128
H, W = map(int, input().split())

if H%3==0 or W%3 ==0:
	print(0)
	exit()

Dif = 100000000

for i in range (1, min(H//2+2, H)):
	for j in range (max(1, W//2-2), min(W, W//2+3)):
		A = i*W
		B = (H-i)*j
		C = (H-i)*(W-j)
		D = max(A, B, C) - min(A, B, C)
		if Dif > D:
			Dif = D

for i in range (1, min(W//2+2, W)):
	for j in range (max(1, H//2-2), min(H, H//2+3)):
		A = i*H
		B = (W-i)*j
		C = (W-i)*(H-j)
		D = max(A, B, C) - min(A, B, C)
		if Dif > D:
			Dif = D      

for i in range (1, min(W//3+1, W)):
	A = i*H
	B = ((W-i)//2)*H
	C = W*H-A-B
	D = max(A, B, C) - min(A, B, C)
	if Dif > D:
		Dif = D                  
            
for i in range (1, min(H//3+1, H)):
	A = i*W
	B = ((H-i)//2)*W
	C = W*H-A-B
	D = max(A, B, C) - min(A, B, C)
	if Dif > D:
		Dif = D       
            
print(Dif)

Measured memory_bytes: 74028
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	h := (b - a + 1) / 2

	if k <= h {
		for i := a; i < a+k; i++ {
			fmt.Println(i)
		}
		for i := b - k + 1; i <= b; i++ {
			fmt.Println(i)
		}
	} else { // h < k
		for i := a; i <= b; i++ {
			fmt.Println(i)
		}
	}
}


Measured memory_bytes: 512
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] A = new long[N];

        for(int i = 0; i < N; i++){
             A[i] = sc.nextInt() - i - 1;
        }
        Arrays.sort(A);

        long ans = 0;
        if(N % 2 == 1){
            ans = A[(N-1)/2];
        }
        else{
            ans = ( A[(N - 1) / 2] + A[(N + 1) / 2] ) / 2;
        }
        long res = 0;
        for(int i = 0; i < N; i++){
            res += Math.abs(A[i] - ans);
        }
        System.out.println(res);
    }

    
}

Measured memory_bytes: 64720
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        HashMap<Character, Integer> count = new HashMap<>();
        for(Character c: input.toCharArray()){
            if(count.containsKey(c))
                count.replace(c, count.get(c) + 1);
            else
                count.put(c, 1);
        }
        for(HashMap.Entry<Character, Integer> entry : count.entrySet()){
        	if(entry.getValue()%2==1) {
        		System.out.println("No");
                return;
        	}
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23124
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,n = list(map(int, input().split()))
from collections import defaultdict
xy = defaultdict(list) #y: [x]
for i in range(n):
    x,y = tuple(map(int, input().split()))
    xy[y].append(x)
for k in range(1, w+1):
    xy[k].append(h+1)
    xy[k].sort()
from bisect import bisect_left as bl
v = 1
ans = float("inf")
for y in range(1, w+1):
    val = xy[y][bl(xy[y], v+1)]
    ans = min(ans, val-1)
    if val==v+1:
        break
    if y<w:
        v += 1
        tmp = bl(xy[y+1], v)
        while xy[y+1][tmp]==v:
            v += 1
            tmp += 1
            if v==h+1:
                break
        if v==h+1:
            break
print(ans)

Measured memory_bytes: 119888
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,b=0;
    ll dp[100000];
    memset(dp,0,sizeof(dp));
    cin>>n>>k;
    vi v;
    r(i,0,n)
    {
      cin>>l;
      v.pb(l);
    }
    dp[1]=abs(v[0]-v[1]);
    r(i,2,n)
    {
      dp[i]=abs(v[i]-v[i-1])+dp[i-1];
      j=2;
      while(j<=i && j<=k)
      {    
        dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
        j++;
      }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 2168