akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
# for debug
pp = pprint.PrettyPrinter(width = 150)
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n, k = MI()
nums = sorted([LI() for _ in range(n)])
cnt = 0
for num, kosuu in nums:
    if cnt + kosuu < k:
        cnt += kosuu
    else:
        print(num)
        exit()


Measured memory_bytes: 24996
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,abdis,acdis,bcdis;
    cin>>a>>b>>c>>d;
    if(a-b<0)
    {
        abdis=b-a;
    }
    else
    {
        abdis=a-b;
    }
    if(b-c<0)
    {
        bcdis=c-b;
    }
    else{
        bcdis=b-c;
    }
    if(a-c<0)
    {
        acdis=c-a;
    }
    else{
        acdis=a-c;
    }
    if(acdis<=d)
    cout<<"Yes"<<endl;
    else if(abdis<=d&&bcdis<=d)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int a,b;
  cin >> a >> b;
  rep(i,10000){
    int za = i*8/100;
    int zb = i*10/100;
    if(za==a&&zb==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *nil;

Node *treeMinimum(Node *x){
    while(x->left != nil) x=x->left;
    return x;
}

Node *find(Node *u, int k){
    while(u != nil && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node *treeSuccessor(Node *x){
    if(x->right != nil) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != nil && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y; // 削除する対象
    Node *x; // yの子

    // 削除する接点を決める
    if(z->left == nil || z->right == nil) y = z;
    else y = treeSuccessor(z);

    // yの子xを決める
    if(y -> left != nil) x = y->left;
    else x = y->right;

    if(x != nil) x->parent = y->parent;

    if(y->parent == nil) root = x;
    else {
        if(y == y->parent->left) y->parent->left = x;
        else y->parent->right = x;
    }

    if(y != z) z->key = y->key;

    delete y; 
}

void insert(int k){
    Node *y = nil; // xの親
    Node *x = root; // 現在の接点
    Node *z; // 挿入する接点

    // zの初期化
    z = new Node;
    z->key = k;
    z->left = nil;
    z->right = nil;

    while(x != nil){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }

    z->parent = y;
    if(y == nil) root = z;
    else{
        if(z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u){
    if(u == nil) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == nil) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    
    int n;
    scanf("%d", &n);

    for(int i=0; i<n; ++i){
        string com; cin >> com;
        if(com == "find"){
            int x;
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != nil) printf("yes\n");
            else printf("no\n");
        }
        else if(com == "insert"){
            int x;
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com == "delete"){
            int x;
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}


Measured memory_bytes: 21984
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
const int MaxN = 1e5;
using namespace std;
map<int, int>cnt;
int n, a[MaxN + 5];
int main()
{
	while(~scanf("%d", &n)){
		cnt.clear();
		for(int i = 1;i <= n;i++){
			scanf("%d", &a[i]);
			cnt[a[i]]++;
		}
		sort(a + 1, a + n + 1);
		long long ans = 0;
		int ok = 0;
		for(int i = n;i >= 1;i--){
			if(ok == 2) continue;
			if(cnt[a[i]] >= 4){
				if(ok == 0) {
					printf("%lld\n" , 1LL * a[i] * a[i]);
					return 0;
				}
				else {
					ans = ans * a[i];
					ok++;
				}
				cnt[a[i]] = 0;
			}
			else if(cnt[a[i]] >= 2){
				if(ok == 0) ans = ans + a[i], ok++;
				else ans = ans * a[i], ok++;
				cnt[a[i]] = 0;
			}
		}
		if(ok == 2) printf("%lld\n" , ans);
		else printf("0\n");
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;

struct edge{
	int from, to, idx;
};

int N, M;
vector<edge> g;
vector<bool> visited;

void dfs(int x, int k){
	visited[x] = true;
	for(edge e : g){
		if(e.idx == k) continue;
		if(e.from == x && !visited[e.to]){
			dfs(e.to, k);
		}
	}
}

bool isbridge(int k){
	visited.resize(N);
	rep(i, N) visited[i] = false;

	dfs(0, k);

	// cout << k << ":";
	// rep(i, N) cout << visited[i];
	// cout << endl;

	rep(i, N) if(!visited[i]) return true;
	return false;
}

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

	cin >> N >> M;

	rep(i, M){
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		g.push_back((edge){a, b, i});
		g.push_back((edge){b, a, i});
	}

	int ans = 0;
	rep(i, M){
		if(isbridge(i)) ans++;
	}

	cout << ans << endl;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    ll n; cin >> n;
    vll l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));
    ll ans = 0;
    for(ll mid=n-1;mid>=0;mid--){
        for(ll low=mid-1;low>=0;low--){
            auto itr = lower_bound(all(l), l[mid]+l[low]);
            ll ng = distance(itr, l.end());
            ans += (n-1-mid) - ng;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int nums = sc.nextInt();
        int sum = 0;
        int[] list = new int[nums];
        for(int i = 0; i < nums; i++){
            int num =  sc.nextInt();
            list[i]= num;
        }
        for(int k = 0; k < list.length; k++){
            for (int i = k+1; i < list.length ; i++) {
                sum += list[k] * list[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21972
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  string a;
  cin>>a;
  int s= a.size();
  if(a[s-1]=='3'){
    cout<<"bon"<<"\n";  
  }
  else if(a[s-1]=='0'||a[s-1]=='1'||a[s-1]=='6'||a[s-1]=='8'){
    cout<<"pon"<<"\n";  
  }
  else{
    cout<<"hon"<<"\n";
  }
  return 0; 
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var datum = cin.ReadIntArray(2);
			int N = datum[0], K = datum[1];
			var A = cin.ReadIntArray(N);
			var left = 0;
			var right = A.Max();
			if(K == 0) {
				Console.WriteLine(right);
				return;
			}
			while(right-left>1) {
				var mid = right - (right - left) / 2;
				if(need(A, mid) > K) {
					left = mid;
				} else {
					right = mid;
				}
			}
			Console.WriteLine(right);
		}
		public int need(int[] A, int aim) {
			return A.Sum(a => (a % aim != 0 ? 1 : 0) + a / aim - 1);
		}

	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}
	
}

Measured memory_bytes: 48408
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli w[N];

lli get(lli x) {
    if(w[x] == x) {
        return x;
    }
    return w[x] = get(w[x]);
}

void merge(lli a, lli b) {

    a = get(a);
    b = get(b);
    if(a == b)
        return ;
    w[b] = a;
    return ;
}

void solve()
{

    lli n, m;
    cin>>n>>m;
    for(int i = 1; i <= n; i ++) {
        w[i] = i;
    }
    for(int i = 0; i < m ; i ++) {
        lli a, b, c;
        cin>>a>>b>>c;
        merge(a, b);
    }

    set<lli> s;

    for(int i = 1; i <= n; i ++) {
        s.insert(get(i));
    }

    cout<<s.size();

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5760
// Written By NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    bool b = 1;
    char c;
    while (!isdigit(c = getChar()))
        if (c == 45)
            b = 0;
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return b ? f : ~f + 1;
}

const int inf = 0x3f3f3f3f;
inline int fabs(int x) { return x >= 0 ? x : ~x + 1; }

int main() {
    int n = read(), L = read(), i, sum = 0, tmp, ans = inf, out;
    for (i = 1; i <= n; ++i)
        sum += i + L - 1;
    for (i = 1; i <= n; ++i)
        if (fabs(sum - (tmp = sum - (i + L - 1))) < ans)
            ans = fabs(sum - tmp), out = tmp;
    printf("%d\n", out);
    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
C = list(map(int, input().split()))
dp = [100000] * (n + 1)
dp[0] = 0
for k in C:
    for j in range(k, n + 1):
        if dp[j] > dp[j - k] + 1:
            dp[j] = dp[j - k] + 1
print(dp[n])

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
struct P{
  int t,s,d;
  P(){t=s=d=0;}
  bool operator < (const P &a) const{return t<a.t;}
};

int main(){
  int n,m;
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    P a[20001];
    for(int i=0;i<m;i++)cin>>a[i].t>>a[i].s>>a[i].d;
    sort(a,a+m);
    
    int used[20001]={},ans=1;
    used[1]=1;
    for(int i=0;i<m;i++){
      ans+=(used[a[i].s]&&!used[a[i].d]);
      used[a[i].d]|=used[a[i].s];
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1484
import sys


def main():
    h = [int(input()) for count in range(6)]
    k = h[5]
    for i in range(len(h) - 1):
        for j in range(len(h) - 1):
            if abs(h[i] - h[j]) > k:
                print(":(")
                sys.exit()
    print("Yay!")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ary[5];
    int idx;
    rep(i,5) {
        cin >> ary[i];
        if (ary[i]==0)
        {
            idx = i;
        }
    }
    cout << idx+1 << endl;

}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
AB=[[0]*2 for i in range(N)]
for i in range(N):
    AB[i][0],AB[i][1]=MAP()

AB.sort()
sm=0
cnt=0
for i in range(N):
    a,b=AB[i]
    if cnt+b<=M:
        cnt+=b
        sm+=a*b
    else:
        sm+=a*(M-cnt)
        cnt=M
    if cnt==M:
        break
print(sm)


Measured memory_bytes: 22452
s1 = input()
s2 = input()
s3 = input()

who = 0
while True:
    if who == 0 and s1 == '':
        print('A')
        break
    if who == 1 and s2 == '':
        print('B')
        break
    if who == 2 and s3 == '':
        print('C')
        break
    if who == 0:
        who = ord(s1[0]) - ord('a')
        s1 = s1[1:]
    elif who == 1:
        who = ord(s2[0]) - ord('a')
        s2 = s2[1:]
    elif who == 2:
        who = ord(s3[0]) - ord('a')
        s3 = s3[1:]




Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define N '\n'
#define S ' '
#define Z '0'
#define RT return
#define elif else if
#define W(a) while(a)
#define RP(a,b,c) for(ll a=(b);a<(c);++a)
#define R(a,b) for(ll a=0;a<(b);++a)
#define RD(a,b) for(ll a=(b);a>=0;++a)
#define LI(a) for(auto &x:a)I(x)
#define P(a) cout<<#a<<N
#define F(a) cout<<fixed<<setprecision(10)<<a
#define D(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define V cin.tie(0);ios::sync_with_stdio(false)
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z;
const int P[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
inline void I(){}
template<class T,class...A>inline void I(T&&t,A&&...a){cin>>t;I(move(a)...);}
template<class T>inline void O(T t){cout<<t<<N;}
template<class T,class...A>inline void O(T t,A...a){cout<<t<<S;O(move(a)...);}
inline ll dig(ll a){ll d=1;W(a/=10)++d;RT d;}
inline ll GCD(ll a,ll b){ll c;W(a){c=a;a=b%a;b=c;}RT b;}
inline bool isp(ll a){if(a<48){RP(i,0,15)if(P[i]==a)RT 1;}
    elif(a<2809)RT GCD(614889782588491410,a)==1;
    else {O("Error:Argument is Over-2808!");exit(1);}RT 0;}

int main(){
    V;
    I(a);
    ll A[a];
    LI(A);
    R(i,a)s+=A[i];
    O(s-a);
















}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    char ch;
    cin >> ch;
    cout << static_cast<char>(ch + 1) << std::endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (X - A <= B && A <= X) cout << "YES";
	else cout << "NO";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int MAX=1e6;
bool AC[MAX];
int times[MAX],ac_num=0,p_num=0; 
int main(){
	fio;
	mem(AC); 
	mem(times);
	rint n,m;
	cin>>n>>m;
	FOR(i,1,m){
		rint x;
		rstring s;
		cin>>x>>s;
		if(s=="AC"&&(!AC[x])){
			ac_num++;
			AC[x]=true;
		}
		if(!AC[x])
			times[x]++;
	}	
	FOR(i,1,n)
		if(AC[i])
			p_num+=times[i];	
	cout<<ac_num<<' '<<p_num<<endl;		
} 

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    ll a[n];
    ll s[n+1];
    s[0] = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        s[i+1] = s[i] + a[i]; 
    }

    for(int i = 0; i < n-1; i++) {
        int j = i + 1;
        ll sum = s[n] - s[j];
        ans = (ans%M + (((a[i]%M) * (sum%M))%M))%M;
    }

    cout << ans;
}

Measured memory_bytes: 6664
#include <stdio.h>

int main(void) {
	int x,y;
	int i;
	int flag = 0;
	
	scanf("%d",&x);
	scanf("%d",&y);
	
	for(i=0; i<(x+1); i++){
		if((x-i)*2 + i*4 == y){
			flag = 1;
			break;
		}
	}
	if(flag){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
	printf("\n");	
	return 0;
}


Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        while(a%2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
long long h, w, m, c, d, mx, my, e, f, l, r, t, k;
long long x[300000];
long long y[300000];
long long z[300000];
long long u[300000];
long long v[300000];
int main() {
	scanf("%lld%lld%lld", &h, &w, &m);
	for (int i = 0; i < m; i++) {
		scanf("%lld%lld", &c, &d);
		c--;
		d--;
		x[c]++;
		y[d]++;
		if (x[c] > mx)mx = x[c];
		if (y[d] > my)my = y[d];
		z[i] = c * 300000 + d;
	}
	std::sort(z, z + m);
	for (int i = 0; i < h; i++) {
		if (x[i] == mx) {
			u[e] = i;
			e++;
		}
	}
	for (int i = 0; i < w; i++) {
		if (y[i] == my) {
			v[f] = i;
			f++;
		}
	}
	if (e * f > m) {
		printf("%lld\n", mx + my);
		return 0;
	}
	for (int i = 0; i < e; i++) {
		for (int j = 0; j < f; j++) {
			l = 0;
			r = m;
			k = u[i] * 300000 + v[j];
			while (r - l - 1) {
				t = (l + r) / 2;
				if (z[t] <= k)l = t;
				else r = t;
			}
			if (z[l] != k) {
				printf("%lld\n", mx + my);
				return 0;
			}
		}
	}
	printf("%lld\n", mx + my - 1);
}

Measured memory_bytes: 13404
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define INF 100100

typedef long long int lli;

// キュー
typedef struct {
  int front;
  int rear;
  int data[MAX][2];
} queue;

queue que;

void initQueue(queue *p) {
  p->front = p->rear = 0;
}

bool emptyQueue(queue *p) {
  return p->front == p->rear;
}

bool fullQueue(queue *p) {
  return (p->front - 1 == p->rear) || (p->front == 0 && p->rear == MAX - 1);
}

void queuePop(queue *p) {
  if (emptyQueue(p)) {
    printf("UnderFlow\n");
    exit(1);
  } else {
    p->front++;
    if (p->front == MAX)
      p->front = 0;
  }
}

void queuePush(queue *p, int x, int y) {
  if (fullQueue(p)) {
    printf("OverFlow\n");
    exit(1);
  } else {
    p->data[p->rear][0] = x;
    p->data[p->rear][1] = y;
    p->rear++;
    if (p->rear == MAX)
      p->rear = 0;
  }
}


int main(void) {
  char s[22][22];
  int h, w;
  scanf("%d %d", &h, &w);
  rep(hi, 0, h) {
    scanf("%s", s[hi]);
  }

  int mx[4] = { 0, 1, 0, -1 };
  int my[4] = { 1, 0, -1, 0 };
  int ans = 0;
  int dist[21][21];
  rep(hi, 0, h) {
    rep(wi, 0, w) {
      if ( s[hi][wi] == '#' ) continue;
      rep(i, 0, h) { 
        rep(j ,0, w) { 
          dist[i][j] = INF; 
        } 
      }
      initQueue(&que);
      dist[hi][wi] = 0;
      queuePush(&que, hi, wi);
      while ( !emptyQueue(&que) ) {
        int x = que.data[que.front][0];
        int y = que.data[que.front][1];
        queuePop(&que);
        rep(mi, 0, 4) {
          int nextX = x + mx[mi];
          int nextY = y + my[mi];
          if ( nextX < 0 || h <= nextX ) continue;
          if ( nextY < 0 || w <= nextY ) continue;
          if ( dist[nextX][nextY] != INF ) continue;
          if ( s[nextX][nextY] == '#' ) continue;
          dist[nextX][nextY] = dist[x][y] + 1;
          queuePush(&que, nextX, nextY);
        }
      }
      rep(i, 0, h) {
        rep(j ,0, w) {
          if ( dist[i][j] == INF ) continue;
          ans = max(ans, dist[i][j]);
        }
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}


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

#define INPUT_LINE_MAX 10
#define INPUT_CHAR_MAX 20
#define COMMAND_MAX 300
#define RUN_LINE_MAX 100
#define RUN_CHAR_MAX 1000

using namespace std;

int main() {
  string input, buffer, result;
  vector<string> editor;
  char command = 0;
  string::size_type cursor = 0;
  vector<string>::size_type line = 0;

  for (int in = 0; in < INPUT_LINE_MAX; in++) {
    getline(cin, input);
    if (input.size() > INPUT_CHAR_MAX)
      return -1;
    if (input == "END_OF_TEXT")
      break;

    editor.push_back(input);
  }

  cursor = 0;
  line = 0;

  for (int com = 0; com < COMMAND_MAX; com++) {
    cin >> command;
    if (command == '-')
      break;

    switch (command) {
    case 'a':
      cursor = 0;
      break;

    case 'e':
      cursor = editor[line].size();
      break;

    case 'p':
      cursor = 0;
      if (line > 0)
        line--;
      break;
    case 'n':
      cursor = 0;
      if (line < editor.size() - 1)
        line++;
      break;
    case 'f':
      if (cursor < editor[line].size())
        cursor++;
      else if (cursor == editor[line].size() && line < editor.size() - 1) {
        cursor = 0;
        line++;
      }
      break;
    case 'b':
      if (cursor > 0)
        cursor--;
      else if (cursor == 0 && line > 0) {
        line--;
        cursor = editor[line].size();
      }
      break;
    case 'd':
      if (cursor < editor[line].size())
        editor[line].erase(editor[line].begin() + cursor);
      else if (cursor == editor[line].size() && line < editor.size() - 1) {
        editor[line] += editor[line + 1];
        editor.erase(editor.begin() + line + 1);
      }
      break;

    case 'k':
      if (cursor < editor[line].size()) {
        buffer = "";
        copy(editor[line].begin() + cursor, editor[line].end(), back_inserter(buffer));
        editor[line].erase(editor[line].begin() + cursor, editor[line].end());
        cursor = editor[line].size();
      }
      else if (cursor == editor[line].size() && line < editor.size() - 1) {
        editor[line] += editor[line + 1];
        buffer = "\n";
        editor.erase(editor.begin() + line + 1);
      }
      break;

    case 'y':
      if (!buffer.empty()) {
        if (buffer == "\n") {
          string tmp;
          copy(editor[line].begin() + cursor, editor[line].end(), back_inserter(tmp));
          editor[line].erase(editor[line].begin() + cursor, editor[line].end());
          editor.insert(editor.begin() + line + 1, tmp);
          cursor = 0;
          line++;
        }
        else {
          if (cursor == editor[line].size()) {
            editor[line] += buffer;
            cursor = editor[line].size();
          }
          else {
            editor[line].insert(editor[line].begin() + cursor, buffer.begin(), buffer.end());
            cursor += buffer.size();
          }
        }
      }
      break;
    }
  }

  for (vector<string>::size_type i = 0; i < editor.size(); i++) {
    result += editor[i];
    result += "\n";
  }

  cout << result;

  return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 50;
int a[N], b[N], c[N];
int dp[N][404][404];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n, ma, mb;
    cin >> n >> ma >> mb;
    FOR(i,1,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    FOR(i,0,n){
        FOR(j,0,400){
            FOR(k,0,400){
                dp[i][j][k] = 5000;
            }
        }
    }
    dp[0][0][0] = 0;
    FOR(i,1,n){
        FOR(j,0,400){
            FOR(k,0,400){
                if(dp[i-1][j][k] == 5000){
                    continue;
                }
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
                dp[i][j+a[i]][k+b[i]] = min(dp[i][j+a[i]][k+b[i]], dp[i-1][j][k] + c[i]);
            }
        }
    }
    int ans = 5000;
    FOR(j,1,400){
        FOR(k,1,400){
            if(j * mb == k * ma){
                ans = min(ans, dp[n][j][k]);
            }   
        }
    }
    if(ans == 5000){
        ans = -1;
    }
    cout << ans;

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 26880
/* 制約のギリギリを狙っていく。
倍数かつ真に大きければ良いので、2倍していけばよい。*/

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

int main(){
    ll x, y, ans = 0;
    cin >> x >> y;
    while(x <= y){
        x *= 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int N;
struct P {
	LL x,y;
	P() {};
	P(LL x,LL y):x(x),y(y) {}
	P operator +(P p) {
		return P(x+p.x,y+p.y);
	}
	P operator -(P p) {
		return P(x-p.x,y-p.y);
	}
	LL dot(P p) {
		return x*p.x+y*p.y;
	}
	LL det(P p) {
		return x*p.y-y*p.x;
	}
	bool operator ==(P p) {
		return x==p.x&&y==p.y;
	}
	double len() {
		return sqrt(x*x+y*y);
	}
};
P ps[105];
P po[105];
double pro[105];

bool cmp_x(const P &p,const P &q) {
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}
vector<P> convex_hull(P *ps,int n) {
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> qs(n*2);
	for(int i=0; i<n; i++) {
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k; i>=0; i--) {
		while(k>t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}
void calcPro(int i,P a,P b) {
//	printf("#%d\n",a.dot(b));
//	printf("#a=(%d,%d) b=(%d,%d)\n",a.x,a.y,b.x,b.y);
//	printf("#%f\n",a.len()*b.len());
//	printf("#%f\n",a.dot(b)/a.len()/b.len());
//	printf("#%f\n",acos(a.dot(b)/a.len()/b.len()));
	double x=a.dot(b)/a.len()/b.len();
	if(x<=-1) pro[i]=0.5;
	else if(x>=1) pro[i]=0.0;
	else pro[i]=acos(x)/(2*3.14159265358979);
//	printf("#pro=%f\n",pro[i]);
}
int main() {
	scanf("%d",&N);
	int x,y;
	for(int i=0; i<N; i++) {
		scanf("%d%d",&x,&y);
		po[i].x=ps[i].x=x;
		po[i].y=ps[i].y=y;
	}
	if(N==1) {
		printf("1\n");
		return 0;
	}
	if(N==2) {
		printf("0.50000000000000000000\n0.5000000000000000000\n");
		return 0;
	}
	vector<P> qs=convex_hull(ps,N);
	int n=qs.size();
	calcPro(0,qs[0]-qs[n-1],qs[1]-qs[0]);
	for(int i=1; i<n-1; i++) {
		calcPro(i,qs[i]-qs[i-1],qs[i+1]-qs[i]);
	}
	calcPro(n-1,qs[n-1]-qs[n-2],qs[0]-qs[n-1]);
	//print
	bool isok=false;
	for(int i=0; i<N; i++) {
		isok=false;
		for(int j=0; j<n; j++) {
			if(po[i]==qs[j]) {
				printf("%.20f\n",pro[j]);
				isok=true;
			}
		}
		if(!isok) printf("0.00000000000000000000000000\n");
	}
	return 0;
}





Measured memory_bytes: 640
n,q = map(int,input().split())
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    tree[a].append(b)

ans = [0 for i in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

#入力

stack = [0]
append = stack.append
while len(stack) > 0:
    now = stack.pop()
    for i in tree[now]:
        ans[i] += ans[now]
        append(i)

for i in range(n):
    print(ans[i],end=" ")
print()

Measured memory_bytes: 91412
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string A,B;
  cin >> A >> B;
  rep(i, A.size()){
  if(A[i]!=B[i]){
  cout << "No" << endl;
    return 0;
  }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include<bits/stdc++.h>
using namespace std;
class Shop{
  public:
    int cost;
    int num;
  Shop(int a, int b){
    cost = a;
    num = b;
  }
  bool operator<(const Shop &another) const
  {
    return cost < another.cost;
  };
};
int main(){
  double N,M,m = 0;
  long long ans = 0;
  cin >> N >> M;
  vector<Shop> shopList;
  int tempA, tempB;
  for(int n=0;n<N;n++){
    cin >> tempA >> tempB;
    shopList.push_back(Shop(tempA, tempB));
  }
  std::sort(shopList.begin(),shopList.end());
  for(int n=0;n<N;n++){
    //cout << shopList[n].cost << " "<<shopList[n].num << endl;
    int buy = shopList[n].num;
    if(m + buy > M){
      buy = M - m;
      ans += buy * (long long)shopList[n].cost;
      break;
    }
    m += buy;
    ans += buy * (long long)shopList[n].cost;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 1400
def divisable_number(x)
  1.upto(x).select{ |_x| (x % _x).zero? }
end

a, b, k = gets.chomp!.split(" ").map(&:to_i)

a_p = divisable_number(a)
b_p = divisable_number(b)

puts (a_p & b_p).reverse[k - 1]


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#define TRUE 0
#define FALSE 1
#define SIZE 5
#define LEN 6
#define MAX 5000

int Min( int a, int b){
  if( a < b ) return a;
  else        return b;
}

void String_Sort( int size , int len, char data[size][len]){
  /* Using Comb Sort Algorithm */
  int i;
  int h = size;
  int Is_Swapped = FALSE;
  char tmp[LEN];
  
  while( h > 1 || Is_Swapped == TRUE ){
    if( h > 1 ) h = (h * 10) / 13;
    
    for( Is_Swapped = FALSE, i=0; i + h < size; i++){
      if( strcmp(data[i], data[i+h]) > 0 ){
        /* Swap data[i] and data[i+h] */
        strcpy( tmp , data[i] );
        strcpy( data[i] , data[i+h] );
        strcpy( data[i+h] , tmp );
        
        Is_Swapped = TRUE;
      }
    }
  }
}

int main(void){
  int i,n,w,sslen,K;
  char s[MAX];
  char ss[MAX*5][LEN];
  
  scanf("%s",s);
  scanf("%d",&K);
  
  /* Make SubString List */
  for( sslen=0 ,n=1; n<=Min(strlen(s),5); n++){
    for( i=0; i <= strlen(s) - n; sslen++, i++){
      for( w=0; w < n; w++){
        ss[sslen][w] = s[i+w];
        ss[sslen][w+1] = '\0';
      }
    }
  }
  
  String_Sort( sslen, LEN, ss);
  for( i=0, n=sslen, w=0; i < n; i++){
    if( strcmp( ss[i], ss[i+1] ) == TRUE ) sslen--;
    else{
      strcpy( ss[w], ss[i]);
      w++;
    }
  }
  
  printf("%s",ss[K-1]);  
  
  return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	p = readline() |> split |> parseMap
	f = 0
	for i in 1:n
		if p[i]!=i
			f += 1
		end
	end
	println(f<=2?"YES":"NO")
end

main()

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

struct Seg{
	int l, r;
	bool operator < (const Seg& x) const{
		if(l != x.l) return l < x.l;
		return r > x.r;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int H, W, N;
	cin >> N >> W >> H;
	deque<Seg> deq;
	for(int i = 0; i < N; i++){
		int x, y;
		char c;
		cin >> x >> y >> c;
		int l, r;
		if(c == 'W') l = y - x, r = y + x;
		if(c == 'N') l = H + x - (H - y), r = H + x + (H - y);
		if(c == 'E') l = W + H + (H - y) - (W - x), r = W + H + (H - y) + (W - x);
		if(c == 'S') l = W + 2 * H + (W - x) - y, r = W + 2 * H + (W - x) + y;
		if(l < 0){
			l += 2 * (H + W);
			r += 2 * (H + W);
		}
		deq.push_back({ l, r });
	}
	sort(deq.begin(), deq.end());

	int ans = 1e9;
	for(int i = 0; i < N; i++){
		queue<Seg> q;
		for(int i = 0; i < N; i++){
			q.push(deq[i]);
		}

		int sum = 0;
		while(q.size()){
			Seg s = q.front();
			q.pop();
			int l = s.l, r = s.r;
			while(q.size()){
				int ll = q.front().l, rr = q.front().r;
				if(l <= ll && ll <= r){
					l = max(l, ll);
					r = min(r, rr);
					q.pop();
				}
				else break;
			}
			sum++;
		}
		ans = min(ans, sum);

		Seg s = deq.front();
		s.l += 2 * (H + W), s.r += 2 * (H + W);
		deq.pop_front();
		deq.push_back(s);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3224
#include <stdio.h>

#define N 10
#define M 12

int h[M][N];

void initial(){
	int i,j;
	for(j=0;j<M;j++){
		for(i=0;i<N;i++) h[j][i]=0;
	}
}

void PrintHotel(){
	int i,j,k;
	for(j=0;j<M;j++){
		for(i=0;i<N;i++){
			printf(" %d",h[j][i]);
		}
		printf("\n");
		if(j%3==2&&j!=11){
			for(k=0;k<20;k++) printf("#");
			printf("\n");
		}
	}
}

int main(void){
	int n,b,f,r,v; //nは入退去情報数、bは何棟目か、fは何階か、rは何番目の部屋か、vは人数
	int x;
	initial();
	scanf("%d",&n);
	for(x=0;x<n;x++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		h[(b-1)*3+(f-1)][r-1]+=v;
	}
	PrintHotel();
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

const int INF = 0x3f3f3f3f;

int dp[15][1 << 15];
int n, m;
vector <int> from[20];
int dist[20][20];
int vvv[1 << 15];
int num[1 << 15];
int val[15][1 << 15];

void chmin(int &a, int b) {
	a = a > b ? b : a;
}

int main () {
	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, c; cin >> u >> v >> c;
		u--, v--;
		from[u].push_back(v);
		from[v].push_back(u);
		dist[u][v] = dist[v][u] = c;
	}
	for (int m1 = 1; m1 < (1 << n); m1++) {
		for (int i = 0; i < n; i++) {
			if (m1 >> i & 1) continue;
			for (int j = 0; j < n; j++) {
				if (m1 >> j & 1) val[i][m1] += dist[i][j];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		num[1 << i] = i;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0][1 << 0] = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		int other = (1 << n) - 1 ^ mask;
		for (int i = 0; i < n; i++) {
			if (dp[i][mask] == INF) continue;
			int tmp = dp[i][mask];
			for (int j = 0; j < from[i].size(); j++) {
				int v = from[i][j];
				if (mask >> v & 1) continue;
				chmin(dp[v][mask | 1 << v], tmp + val[v][mask ^ 1 << i]);
			}
			for (int m = other; m; m = m - 1 & other) {
				int x = num[(other ^ m) & -(other ^ m)];
				if (m != other) vvv[m] = vvv[m ^ 1 << x] - val[x][mask ^ 1 << i];
				else {
					vvv[m] = 0;
					for (int j = 0; j < n; j++) {
						if (m >> j & 1) vvv[m] += val[j][mask ^ 1 << i];
					}
				}
				chmin(dp[i][mask | m], tmp + vvv[m]);
			}
		}
	}
	printf("%d\n", dp[n - 1][(1 << n) - 1]);
	return 0;
}


Measured memory_bytes: 4096
n=int(input())
c,d=1,n+1
s=[input()for i in range(n)]
t=input()
for i in range(n):
    if s[i]!=t:
        p,q=s[i].replace("?","a"),s[i].replace("?","z")
        if p>t:
            d-=1
        elif q<t:
            c+=1
print(*[i for i in range(c,d+1)])

Measured memory_bytes: 4084
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,menu[3002],a,b,c,ans;
vector<P> v;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        for(int j=m-1;j>=0;j--){
            if(menu[j]!=0||j==0){
                int L=min(m+1,j+v[i].first);
                menu[L]=max(menu[L],menu[j]+v[i].second);
            }
        }
    }
    for(int i=0;i<=m+1;i++)ans=max(ans,menu[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

map< ll, int > primeFactor(ll n) {
    map< ll, int > ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
	ll N;
	SL(N);
	map<ll, int> m = primeFactor(N);
    int ans = 0;
    for (auto x : m) {
        int e = 1;
        while (x.second - e >= 0) {
            ans++;
            x.second -= e;
            e++;
        }
    }
    P(ans);
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

template<typename T>
class CumulativeSum {
	vector<T> a;
	public:
	CumulativeSum(vector<T>& x) : a(x.size() + 1,0) {
		rep(i,x.size()){
			a[i + 1] = a[i] + x[i];
		}
	}
	T get(int l, int r){ // [l, r]の区間の合計を求める
		return a[r + 1] - a[l];
	}
	T operator [] (const int i) const {
		return a[i];
	}
};

int main(){
	string s, t;
	int q;
	cin >> s >> t >> q;

	vector<int> a(s.size()), b(t.size());
	rep(i,s.size()) a[i] = s[i] == 'A' ? 1 : -1;
	rep(i,t.size()) b[i] = t[i] == 'A' ? 1 : -1;

	CumulativeSum<int> asum(a), bsum(b);

	rep(i,q){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		if( (asum.get(a,b) - bsum.get(c,d)) % 3 == 0 ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	deque<int> A(N);
	rep(i, N) cin >> A[i];

	sort(all(A));

	deque<int> B;
	B.push_back(A[0]);
	A.pop_front();

	int ret = 0;
	while (!A.empty()) {
		int front = A.front();
		int back = A.back();

		int maxDiff = 0;
		int diffFF = abs(front - B.front());
		int diffFB = abs(front - B.back());
		int diffBB = abs(back - B.back());
		int diffBF = abs(back - B.front());
		
		maxDiff = max(maxDiff, diffFF);
		maxDiff = max(maxDiff, diffFB);
		maxDiff = max(maxDiff, diffBF);
		maxDiff = max(maxDiff, diffBB);

		if (maxDiff == diffFF) {
			A.pop_front();
			B.push_front(front);
			ret += diffFF;
		} else if (maxDiff == diffFB) {
			A.pop_front();
			B.push_back(front);
			ret += diffFB;
		} else if (maxDiff == diffBF) {
			A.pop_back();
			B.push_front(back);
			ret += diffBF;
		} else {
			A.pop_back();
			B.push_back(back);
			ret += diffBB;
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
int n;

int main()
{
	scanf("%d",&n);
	rep(i,1,9)
	{
		int x=i+i*10+i*100;
		if(x>=n) return printf("%d\n",x),0;
	}
	return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int n = a * 100 + b * 10 + c;
  if(n % 4 == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256