akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

ll stepnum(ll k)
{
    queue<ll> q;
    for (ll i = 1; i <= 9; i++)
    {
        q.push(i);
    }
    vector<ll> ans;
    ll count = 1;
    while (!q.empty())
    {
        ll temp = q.front();
        if (count == k)
        {
            return temp;
        }
        else
        {
            count++;
        }
        q.pop();
        if (temp % 10ll == 0)
        {
            q.push(temp * 10ll);
            q.push(temp * 10ll + 1ll);
        }
        else if (temp % 10ll == 9ll)
        {
            q.push(temp * 10ll + 8ll);
            q.push(temp * 10ll + 9ll);
        }
        else
        {
            q.push(temp * 10ll + (temp % 10ll) - 1ll);
            q.push(temp * 10ll + (temp % 10ll));
            q.push(temp * 10ll + (temp % 10ll) + 1ll);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k;
    cin >> k;
    cout << stepnum(k);
}


Measured memory_bytes: 1792
using System;

class ABC075B
{
	static public void Main(string[] args)
	{
		int H, W;
		string[] vals = Console.ReadLine().Split(' ');
		H = int.Parse(vals[0]);
		W = int.Parse(vals[1]);

		string[] S = new string[H+1];
		for(int i=1; i<=H; i++)
		{
			S[i] = Console.ReadLine();
		}
		
		for(int h=1; h<=H; h++)
		{
			for(int w=1; w<=W; w++)
			{
				char c = S[h][w-1];
				if(c == '#')
				{
					Console.Write("#");
				}
				else
				{
					int num = 0;
					if(h-1 >= 1 && w-1 >= 1)
					{
						if(S[h-1][w-1-1] == '#')
							num++;
					}
					if(h-1 >= 1)
					{
						if(S[h-1][w-1] == '#')
							num++;
					}
					if(h-1 >= 1 && w+1 <= W)
					{
						if(S[h-1][w+1-1] == '#')
							num++;
					}
					if(w+1 <= W)
					{
						if(S[h][w+1-1] == '#')
							num++;
					}
					if(h+1 <= H && w+1 <= W)
					{
						if(S[h+1][w+1-1] == '#')
							num++;
					}
					if(h+1 <= H)
					{
						if(S[h+1][w-1] == '#')
							num++;
					}
					if(h+1 <= H && w-1 >= 1)
					{
						if(S[h+1][w-1-1] == '#')
							num++;
					}
					if(w-1 >= 1)
					{
						if(S[h][w-1-1] == '#')
							num++;
					}
					Console.Write(num);
				}
			}
			Console.WriteLine();
		}
			
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, M; cin >> N >> M;
    vector<ii> al[N+1];
    FOR(i,1,N-1){
        al[i+1].emplace_back(i,0);
    }
    FOR(i,1,M){
        int L, R, C; cin >> L >> R >> C;
        al[L].emplace_back(R,C);
    }

    using vv = pair<ll,int>;
    priority_queue<vv, vector<vv>, greater<vv> > pq;
    ll d[N+1]; memset(d,-1,sizeof d);
    pq.emplace(0,1); d[1] = 0;
    while (!pq.empty()) {
        ll w = pq.top().fi, u = pq.top().sc; pq.pop();
        if (w > d[u]) continue;
        for (auto v : al[u]) {
            if (d[v.fi] == -1 || w+(ll)v.sc < d[v.fi]) {
                d[v.fi] = w+(ll)v.sc;
                pq.emplace(d[v.fi],v.fi);
            }
        }
    }
    cout << d[N];
}



Measured memory_bytes: 8440
import java.util.*;

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

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < N; i++) {
            char s = S.charAt(i);
            if (i == K - 1) {
                switch (String.valueOf(s)) {
                    case "A":
                        sb.append("a");
                        break;
                    case "B":
                        sb.append("b");
                        break;
                    case "C":
                        sb.append("c");
                        break;
                    default:
                        continue;
                }
            } else {
                sb.append(String.valueOf(s));
            }
        }

        System.out.println(sb.toString());

    }
}


Measured memory_bytes: 23252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class APainting {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, N;
        cin >> H >> W >> N;
        if (H < W) swap(H, W);

        int cur = 0;
        int res = 0;
        while (res < W && cur < N) {
            res++;
            cur += H;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    APainting solver;
    solver.solve(in, out);
    return 0;
}


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

const ll m=1000000007;

int main(){
    int x;
    cin>>x;
    if(x==3)cout<<"YES"<<endl;
    else if(x==5)cout<<"YES"<<endl;
    else if(x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;
int main() {
    int H, W;
    cin >> H >> W;
    string a[110][110];
    rep(i, 0, H) {
        string s;
        cin >> s;
        rep(r, 0, W) { a[i][r] = s[r]; }
    }

    rep(i, 0, H) {
        bool all = true;
        rep(r, 0, W) {
            if(a[i][r] == "#") {
                all = false;
            }
        }
        if(all) {
            rep(r, 0, W) { a[i][r] = ""; }
            a[i][W] = "no";
        }
    }
    rep(r, 0, W) {
        bool all = true;
        rep(i, 0, H) {
            if(a[i][r] == "#") {
                all = false;
            }
        }
        if(all) {
            rep(i, 0, H) { a[i][r] = ""; }
        }
    }
    rep(i, 0, H) {
        rep(r, 0, W) { cout << a[i][r]; }
        if(a[i][W] != "no") {
            cout << endl;
        }
    }
}

Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isAsc(ps []int) bool {
	for i := 0; i < len(ps)-1; i++ {
		if ps[i] > ps[i+1] {
			return false
		}
	}
	return true
}

func solve(n int, ps []int) string {
	var m [][]int

	for i := 0; i < len(ps)-1; i++ {
		if ps[i] > ps[i+1] {
			m = append(m, []int{i, i + 1})
		}
	}

	if len(m) == 0 {
		return "YES"
	}

	for _, v := range m {
		for _, v2 := range m {
			ps2 := make([]int, len(ps))
			copy(ps2, ps)

			ps2[v[0]], ps2[v2[1]] = ps2[v2[1]], ps2[v[0]]

			if isAsc(ps2) {
				return "YES"
			}
		}
	}

	return "NO"
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		ps[i] = nextInt()
	}

	fmt.Println(solve(n, ps))
}

Measured memory_bytes: 896
n = gets.split.map &:to_i
t,a = gets.split.map &:to_f
h = gets.split.map &:to_i

min = Float::INFINITY
index = nil

h.each_with_index{ |x, i|
	temp = (a - (t - 0.006 * x)).abs 

	if min > temp then
		min = temp
		index = i + 1
	end
}

puts index


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int n, m, num[100005];
bool red[100005];
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	red[0] = true;
	fill(num, num+n, 1);
	FOR(i, m) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		num[x]--;
		num[y]++;
		if (red[x]) {
			red[y] = true;
			if (num[x] == 0) red[x] = false;
		}
	}
	int cnt = 0;
	FOR(i, n) {
		if (red[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};
main();

function main() {
    let n = next();
    let a = nexts(n);

    let nums = new Map();
    for (let i = 0; i < n; i++) {
        let t = a[i];
        nums.set(t, 1 + (nums.has(t) ? nums.get(t) : 0));
    }
    //console.log("nums:", nums);
    //console.log(nums);
    let C = new Map();
    let sum = 0;
    for (let key of nums.keys()) {
        sum += (nums.get(key) * (nums.get(key) - 1)) / 2;
    }
    //console.log("sum", sum);
    for (let k of nums.keys()) {
        let v = nums.get(k);
        if (C.has(v)) {
            continue;
        }
        if (v > 1) {
            C.set(v, sum - v + 1);
        } else {
            C.set(v, sum);
        }
    }
    //console.log("C", C);
    for (let i of a) {
        console.log(C.get(nums.get(i)));
    }
    return;
}


Measured memory_bytes: 85200
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>

typedef long long int llint;

int main(void){
  llint n;
  std::cin >> n;
  std::vector<llint> A(n);
  llint total_len = 0;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
    total_len += A[i];
  }

  llint idx_center = -1;
  llint now = 0;
  for(int i=0; i<n; i++){
    now += A[i];
    if(total_len < now*2){
      idx_center = i;
      break;
    }
  }

  llint left_len = 0;
  llint right_len = 0;
  llint result = -1;
  for(int i=0; i<idx_center; i++){
    left_len += A[i];
  }
  for(int i=idx_center; i<n; i++){
    right_len += A[i];
  }
  result = std::abs(left_len - right_len);

  left_len += A[idx_center];
  right_len -= A[idx_center];
  llint result2 = std::abs(left_len - right_len);
  result = result>result2?result2:result;
  std::cout << result << std::endl;
  //std::cout << left_len << " " << right_len << std::endl;

  return 0;
}


Measured memory_bytes: 1792
def read():
    return [int(x) for x in str.split(raw_input())]

n, m = read()

def fun(n):
    if (n < 0):
        return 1000000000000
    else: 
        return n

ans = min(fun(m-n), fun(m+n)+1, fun(-m-n)+1, fun(-m+n)+2)

print(ans)


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200055;
inline int read()
{
    int 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;
}
vector<int> G[N];
int n,q,f[N];
void dfs(int u,int fa)
{
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==fa) continue;
		f[v]+=f[u];
		dfs(v, u);
	}
}
int main()
{
	n=read(); q=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		G[u].push_back(v); G[v].push_back(u);
	}
	for(int i=1;i<=q;i++){
		int x=read(),k=read();
		f[x]+=k;
	}
	dfs(1, 0);
	for(int i=1;i<=n;i++){
		printf("%d ",f[i]);
	}
	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int T;
    cin >> T;
    for_(i,0,T) {
        lint n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    vector<int> s(m),c(m);
    rep(i,m){
        cin >> s[i] >> c[i];
    }
    int ans = -1;
    if(n==1){
        for(int i=0;i<10;i++){
            bool ok = 1;
            string t = to_string(i);
            rep(j,m){
                if(t[s[j]-1]- '0' != c[j])ok = 0;
            }
            if(ok){
                ans = i;
                break;
            }
        }
    }else if(n==2){
        for(int i=10;i<100;i++){
            bool ok = 1;
            string t = to_string(i);
            rep(j,m){
                if(t[ s[j]-1 ]- '0' != c[j])ok = 0;
            }
            if(ok){
                ans = i;
                break;
            }
        }
    }else if(n==3){
        for(int i=100;i<1000;i++){
            bool ok = 1;
            string t = to_string(i);
            rep(j,m){
                if(t[ s[j]-1 ] - '0' != c[j])ok = 0;
            }
            if(ok){
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import random
test = False

def solve(c_list, days, now):
    r = sum(c_list[i]*(now-days[i]) for i in range(26))
    return r


if test == True:
    #seed = 94
    #random.seed(seed)
    d = 365
    c = [random.randrange(0, 101) for _ in range(26)]
    s = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(d)]
    c_ = ' '.join(map(str, c))
    s_ = '\n'.join([' '.join(map(str, i)) for i in s])
    with open('./input.txt', 'w') as f:
        f.write('\n'.join([str(d), c_, s_]))
else:
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _i in range(d)]


last_days = [-1 for _i in range(26)]
result = []
score = 0
for today in range(d):
    checker = [c[j]*(today-last_days[j]) for j in range(26)]
    y = sum(checker)

    finder = [s[today][j]-(y-checker[j]) for j in range(26)]
    x = finder.index(max(finder))

    if today < d-1:
        second_checker = [c[j]*(today+1-last_days[j]) for j in range(26)]
        second_finder = [s[today+1][j]-(y-checker[j]) for j in range(26)]
        second_x = second_finder.index(max(second_finder))
        if x == second_finder:
            x = finder.index(sorted(finder)[-2])
    

    last_days[x] = today
    result.append(x+1)
    score += s[today][x] - solve(c, last_days, today)
if test:
    print(score)

def change(problems, days):
    last_days = [-1 for _i in range(26)]
    score = 0
    for i in range(d):
        score += s[i][problems[i]-1]
        last_days[problems[i]-1] = i
        score -= sum([c[j]*(i-last_days[j]) for j in range(26)])
    return score

change_list = result.copy()
for i in range(500):
    if random.randrange(2)<1:
        x, y = random.randrange(0, d), random.randrange(0, d)
        while x == y:
            y = random.randrange(0, d)
        change_list[x], change_list[y] = change_list[y], change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            if test:print(i, score, next_score, abs(next_score-score), 'two')
            score = next_score
            result[x], result[y] = result[y], result[x]
        
        else:
            change_list[x], change_list[y] = change_list[y], change_list[x]
    else:
        x = random.randrange(0, d)
        y = random.randrange(1, 27)
        change_list[x], z = y, change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            if test:print(i, score, next_score, abs(next_score-score), 'one')
            score = next_score
            result[x] = y
        else:
            change_list[x] = z

if test == True:
    with open('./output.txt', 'w') as f:
        f.write('\n'.join(map(str, result)))
else:
    for i in result:
        print(i)

Measured memory_bytes: 84668
#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int>G[1001];
string s[1000];
void dfs(int u,int d)
{
	if(u)
	{
		for(int r=0;r<d;r++)cout<<'.';
		cout<<s[u-1]<<endl;
	}
	for(int v:G[u])dfs(v,d+1);
}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;cin>>a>>s[i];
		G[a].push_back(i+1);
	}
	dfs(0,-1);
}



Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,D,X;cin >> N >> D >> X;
  int count = X;
  D--;
  rep(i,N){
    int a;cin >> a;
    count += D/a + 1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(8):
    s = []
    for j in range(n):
        a = 0
        for k in range(3):
            if i>>k&1:
                a += xyz[j][k]
            else:
                a -= xyz[j][k]
        s.append(a)
    s.sort()
    ans = max(ans,sum(s[n-m:]))
print(ans)


Measured memory_bytes: 3316
n=int(input())
l=[]
dead=0
time=0
for i in range(n):
    a,b=map(int,input().split())
    l.append([b,a])
l.sort()
f=True
for i in l:
    dead=i[0]
    time+=i[1]
    if time>dead:
        print('No')
        f=False
        break
if f:
    print('Yes')


Measured memory_bytes: 38240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<deque>
#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, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int num;
	cin >> num;
	vector<int> num_list(num);
	REP(i, num) {
		cin >> num_list[i];
	}
	deque<int> ans;
	REP(i, num) {
		if (i % 2 == 0) {
			ans.push_back(num_list[i]);
		}
		else {
			ans.push_front(num_list[i]);
		}
	}
	if (num % 2 == 0) {
		REP(i, num) {
			if (i < num - 1) {
				cout << ans[i] << " ";
			}
			else if (i == num - 1) {
				cout << ans[i] << endl;
			}
		}
	}
	else {
		REPR(i, num - 1) {
			if (i > 0) {
				cout << ans[i] << " ";
			}
			else if (i == 0) {
				cout << ans[i] << endl;
			}
		}
	}
	return 0;
}

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

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

    if (d == 25)
    {
        cout << "Christmas" << endl;
    }
    else if (d == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (d == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (d == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
 
    if (u == s)
    {
        cout << --a << " " << b << endl;
    }
    else
    {
        cout << a << " " << --b << endl;
    }
       
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
if n%2==1:
    print('No')
else:
    k=n//2
    for i in range(k):
        if s[i]=='b' and not s[n-1-i]=='d':
            print('No')
            exit()
        if s[i]=='d' and not s[n-i-1]=='b':
            print('No')
            exit()   
        if s[i]=='p' and not s[n-1-i]=='q':
            print('No')
            exit()
        if s[i]=='q' and not s[n-i-1]=='p':
            print('No')
            exit() 
    print('Yes')
        

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

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 9; i++) {
		if (111 * i < N && N <= 111 * (i + 1)) {
			cout << 111 * (i + 1) << endl;
		}
		else {
			continue;
		}
	}
}

Measured memory_bytes: 3628
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    l = []
    for _ in range(n):
        s = input().rstrip()
        s = sorted(s)
        s = ''.join(s)
        l.append(s)
    c = Counter(l)
    res = 0
    for k, v in c.items():
        res += (v-1)*v//2
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64220
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m;

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        vint rem(n);
        for (int i = 0; i < n; ++i) rem[i] = i+1;
        
        int now = n-1;
        for (int j = 0; j < n-1; ++j) {
            now += m;
            now %= rem.size();
            
            //cout << j << " : " << now << ", " << rem[now] << "< ";
            
            rem.erase(rem.begin() + now--);
            
            //cout << rem << endl;
        }
        
        cout << rem[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i=0; i<n; i++){
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();   
        }

        int mx = 0;
        int my = 0;
        int mt = 0;

        for(int i=0; i<n; i++){
            int len = Math.abs(x[i] - mx) + Math.abs(y[i] - my);
            if(len <= t[i] - mt && len%2 == (t[i]-mt)%2){

            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 91312
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string s,t;
    cin>>s>>t;
    reverse(all(t));
    if(s==t){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

namespace ABC109B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int N = ConsoleInput.Int();
            string[] W = new string[N];
            for (int i = 0; i < N; i++)
            {
                W[i] = ConsoleInput.String();
            }

            string WW = W[0];
            Dictionary<string, bool> WL = new Dictionary<string, bool>();
            WL.Add(WW, true);
            for (int i = 1; i < N; i++)
            {
                if (W[i][0] != WW[WW.Length - 1] | WL.ContainsKey(W[i]))
                {
                    Console.WriteLine("No");
                    return;
                }

                WL.Add(W[i], true);
                WW = W[i];
            }

            Console.WriteLine("Yes");
        }
    }

    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = ll(b) - 1; i >= (a); i--)
#define TR(X)                                                  \
    ({                                                         \
        if (1) cerr << "TR: " << (#X) << " = " << (X) << endl; \
    })
#define LL(name) \
    ll name;     \
    cin >> name;
#define VL(name, num) \
    vl name(num);     \
    FOR(INPUT_VL_I, 0, num) { cin >> name[INPUT_VL_I]; }

int main() {
    cin.sync_with_stdio(0);
    LL(N);
    LL(A);
    LL(B);
    LL(C);

    vector<string> ss(N);
    FOR(i, 0, N) cin >> ss[i];

    vector<char> ans;
    FOR(i, 0, N) {
        string s = ss[i];

        ll *first, *second;
        if (s[0] == 'A')
            first = &A;
        else if (s[0] == 'B')
            first = &B;
        else
            first = &C;

        if (s[1] == 'A')
            second = &A;
        else if (s[1] == 'B')
            second = &B;
        else
            second = &C;

        if (*first == 0 && *second == 0){
            break;
        }

        if (*first == 0 || *second > 1) {
            ans.pb(s[0]);
            (*first)++;
            (*second)--;
            continue;
        }
        if (*second == 0 || *first > 1) {
            ans.pb(s[1]);
            (*first)--;
            (*second)++;
            continue;
        }

        if (i == N - 1) {
            ans.pb(s[0]);
            break;
        }

        string next_s = ss[i + 1];

        if (next_s.find(s[0]) != string::npos) {
            ans.pb(s[0]);
            (*first)++;
            (*second)--;
            continue;
        } else {
            ans.pb(s[1]);
            (*first)--;
            (*second)++;
            continue;
        }
    }

    if (sz(ans) == N) {
        cout << "Yes" << endl;
        for (char c : ans) {
            cout << c << endl;
        }
    } else {
        cout << "No" << endl;
    }
}  // cin.tie(0) bei schnellem Wechseln


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

int main()
{
    int N;
    cin >> N;
    char v[N];
    int esum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
        if (v[i] == 'E'){
            esum++;
        }
    }
    int mini = std::min(esum,N-esum),e = 0,w = 0;
    
    for (int i = 0; i < N; i++){
        if (v[i] == 'E'){
            e++;
        }else{
            w++;
        }
        int now = w + (esum - e);
        mini = min(mini,now);
    }
    cout << mini << endl;
}

Measured memory_bytes: 512
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String in[] = new String[3];
		int in_num[] = new int [3];
		try {
			line = br.readLine();
			in = line.split(" ");
			for(int i = 0; i < in.length; i++) {
				in_num[i] = Integer.parseInt(in[i]);
			}
		} catch (IOException e) {
			e.getStackTrace();
		}
		
		int fee = in_num[1] * in_num[0];
		if(fee > in_num[2]) {
			fee = in_num[2];
		}
		
		System.out.println(fee);
	}
} 

Measured memory_bytes: 21076
N,M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

A = sorted(A,reverse=True)
#print(A)
X = M
for i in range(M):
    A[0] //= 2
    X -= 1
    count = 0
    for j in range(min(N-1,M)):
        if A[j] < A[j+1]:
            x = A[j]
            A[j] = A[j+1]
            A[j+1] = x
            count += 1
        else:
            break
            
    if count >= X:
        for j in range(X):
            A[j] //= 2
        break
    else:
        for j in range(count):
            A[j] //= 2
        X -= count
        A = sorted(A,reverse=True)
        
        
ans = 0
for i in A:
    ans += i

print(ans)




Measured memory_bytes: 14480
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
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; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int extgcd(int a, int b, int &x, int &y) {
  int g = a;
  x = 1, y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

main {
  int a, b, x, y;
  cin >> a >> b;
  extgcd(a, b, x, y);
  cout << x << ' ' << y << endl;
}



Measured memory_bytes: 3120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    
    int n,m;
    cin >> n;
    bool Open = 0;
    string c;
    vector<string> str;
    
    for(int i=0;i<n ;i++){
        
                cin >> c;
                str.push_back(c);
    }
    
    cin >> m;
    for(int i=0;i<m;i++){
        bool f = 1;
        string c;
        cin >> c;
        for(int j=0;j<n;j++){
        
            if(str[j] == c && Open == 0){
                cout << "Opened by " << c << endl;
                Open = 1;
                f = !f;
                break;
            }
            if(str[j] == c && Open == 1){
                cout << "Closed by " << c << endl;
                Open = 0;
                f = !f;
                break;
            }
        }
        if(f){
            cout << "Unknown " << c << endl;
            f = !f;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1224
import sys
class Lazysegtree:
    #RAQ
    def __init__(self, A, intv, initialize = True, segf = min):
        #区間は 1-indexed で管理
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        self.lazy = [0]*(2*self.N0)
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)

    def _ascend(self, k):
        k = k >> 1
        c = k.bit_length()
        for j in range(c):
            idx = k >> j
            self.data[idx] = self.segf(self.data[2*idx], self.data[2*idx+1]) \
            + self.lazy[idx]
            
    def _descend(self, k):
        k = k >> 1
        idx = 1
        c = k.bit_length()
        for j in range(1, c+1):
            idx = k >> (c - j)
            ax = self.lazy[idx]
            if not ax:
                continue
            self.lazy[idx] = 0
            self.data[2*idx] += ax
            self.data[2*idx+1] += ax
            self.lazy[2*idx] += ax
            self.lazy[2*idx+1] += ax
    
    def update(self, k, x):
        k = k + self.N0
        self.data[k] = x
        self._ascend(k)
    
    def query(self, l, r):
        L = l+self.N0
        R = r+self.N0
        Li = L//(L & -L)
        Ri = R//(R & -R)
        self._descend(Li)
        self._descend(Ri - 1)
        
        s = self.intv                                                              
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def add(self, l, r, x):
        L = l+self.N0
        R = r+self.N0

        Li = L//(L & -L)
        Ri = R//(R & -R)
        
        while L < R :
            if R & 1:
                R -= 1
                self.data[R] += x
                self.lazy[R] += x
            if L & 1:
                self.data[L] += x
                self.lazy[L] += x
                L += 1
            L >>= 1
            R >>= 1
        
        self._ascend(Li)
        self._ascend(Ri-1)

N, M = map(int, input().split())
LA = [[] for _ in range(N)]
for _ in range(M):
    l, r, a = map(int, sys.stdin.readline().split())
    LA[r-1].append((l-1, a))

dp = Lazysegtree([0]*(N+1), -10**16, True, max)

for i in range(N):
    res = 0
    t = dp.data[1]
    for l, a in LA[i]:
        res += a
        dp.add(l, i, a)
    dp.update(i, res + t)
print(dp.data[1])


Measured memory_bytes: 107348
N, C = map(int, input().split())
xv = [list(map(int, input().split())) for i in range(N)]

A1 = [0, 0]
X1 = [0]
A2 = [0, 0]
X2 = [0]
for x, v in xv:
  A1[-1] += v - x
  A1.append(A1[-1] + x)
  X1.append(x)
A1.pop()

xv = xv[::-1]
for x, v in xv:
  A2[-1] += v - (C-x)
  A2.append(A2[-1] + (C-x))
  X2.append(C-x)
A2.pop()

max_1 = []
max_2 = []
now = -1
for i, a in enumerate(A1):
  if a > now:
    max_1.append(i)
    now = a
  else:
    max_1.append(max_1[-1])

now = -1
for i, a in enumerate(A2):
  if a > now:
    max_2.append(i)
    now = a
  else:
    max_2.append(max_2[-1])

ans = 0
for i, a in enumerate(A1):
  idx = max_2[-i-1]
  calory = max(a, a + A2[idx] - X1[i])
  ans = max(ans, calory)

for i, a in enumerate(A2):
  idx = max_1[-i-1]
  calory = max(a, a + A1[idx] - X2[i])
  ans = max(ans, calory)

print(ans)

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

namespace ABC165
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_A();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            //飛距離をKの倍数にすること
            var k = Ex.ReadInt;
            var l = Ex.ReadIntArray();
            //飛距離の範囲はA以上B以下
            var a = l[0];
            var b = l[1];
            bool ans = false;

            for (int i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    ans = true;
                    break;
                }
            }

            var str = ans ? "OK" : "NG";
            str.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 19072
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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();
		sc.close();

		Set<Integer> set = new HashSet<>();
		set.add(1);
		set.add(2);
		set.add(3);
		set.remove(a);
		set.remove(b);
		System.out.println(set.iterator().next());
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
const int MAX_V = 1e+4, INF = 1e+9;
struct edge {int to, cost;};
typedef pair<int, int> P;
int n, d[MAX_V]; vector<edge> G[MAX_V];

void dijkstra(int s) {
  fill(d, d+n, INF); d[s] = 0;
  priority_queue<P, vector<P>, greater<P>> q;
  q.push(P(0, s));
  while(!q.empty()) {
    P p = q.top(); q.pop();
    int now = p.second;
    if(d[now] < p.first) continue;
    for(int i = 0; i < G[now].size(); ++i) {
      edge e = G[now][i];
      if(d[e.to] > d[now] + e.cost) {
        d[e.to] = d[now] + e.cost;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for(int i = 0, u, k; i < n; ++i) {
    scanf("%d %d", &u, &k);
    for(int j = 0, v, c; j < k; ++j) {
      scanf("%d %d", &v, &c);
      edge e = {v, c};
      G[u].push_back(e);
    }
  }
  dijkstra(0);
  for(int i = 0; i < n; ++i) {
    printf("%d %d\n", i, d[i]);
  }
}


Measured memory_bytes: 7652
#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(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int n,k;
  cin >> n >> k;
  if(n%k==0)cout<< 0 <<endl;
  else cout<< 1 <<endl;
}


Measured memory_bytes: 256
a,b,x = list(map(int,input().split()))
from math import acos
from math import sqrt
from math import degrees
if (x/(a*a))*2 <= b:
    S = x/a
    y = 2*x/(a*b)
    c = sqrt(y*y + b * b)
    z = (b*b + c*c - y*y)/(2*c)
    theta = degrees(acos(z/b))
else:
    S = x/a
    y = (2*S)/a - b
    y = b - y
    c = sqrt(a * a + y * y)
    z = (y*y - a*a + c*c)/(2*c)
    if y == 0:
        y = 0.00000000001
    theta = degrees(acos(z/y))
print(90-theta)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(a+n);i++)
#define var auto
using namespace std;
using ll = long long;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,0,n) cin >> p[i];

  // 累積和
  vector<int> s(n+1, 0);
  rep(i,0,n) {
    s[i+1] = s[i] + p[i];
  }

  // 最大を探す
  int i_max = 0;
  int s_max = 0;
  rep(i, 0, n-k+1) {
    if (s_max < (s[i+k] - s[i])) {
      i_max = i;
      s_max = s[i+k] - s[i];
    }
  }

  double m = 0;
  rep(i,i_max,k) {
    m += (double)(1+p[i])/2;
  }
  cout << fixed << setprecision(12) << m << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	if(s[0] == s[2]) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int K = int.Parse(strs[1]);
            bool[] sunuke = new bool[N];
            for (int i = 0; i < N; i++) sunuke[i] = false;
            for(int i = 0; i < K; i++)
            {
                line = Console.ReadLine();
                var d = int.Parse(line);
                line = Console.ReadLine();
                strs = line.Split(' ');
                for (int j = 0; j < d; j++)
                {
                    sunuke[int.Parse(strs[j])-1] = true;
                }
            }
            Console.WriteLine(sunuke.ToList().Where(x => x == false).Count());
        }
    }
}


Measured memory_bytes: 28500