akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll x;
  cin >> x;
  ll orig = 100;
  int cnt = 0;
  while (orig < x)
    orig = orig + ll(orig / 100), cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
	int H,N;
	scanf("%d %d",&H,&N);
	int A[N];
	int i=0;
	int ll=0;
	while(i<N)
	{
		scanf("%d", &A[i]);
		ll +=A[i];
		i+=1;
	}
	if(ll>=H)
		printf("Yes");
	else
		printf("No");
	
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main() {
  V<int> g = {1,3,1,2,1,2,1,1,2,1,2,1};
  int x, y;
  cin >> x >> y;
  YesorNo(g[x-1] == g[y-1]);
}

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main(){
   int ans = 0;
   int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
   if(a + b > 2 * c){
    ans = min(x,y) * 2 * c;
    if(x > y){
      if(a * (x-y) > 2 * c*(x-y))
        ans += 2*c*(x - y);
      else
        ans += a*(x-y);
    }
    else{
      if(b * (y-x) > 2 * c*(y-x))
        ans += 2 * c*(y - x);
      else
        ans += b * (y - x);
    }
   }
   else
     ans = x * a + y * b;
  
  cout << ans;
      
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    string s;
    cin >>s;
    int S = s.size();

    int ct = 0;
    rep(i,S-1) ct+=(s[i]!=s[i+1]);

    cout << (ct%2?'o':s[0]) << endl;
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
constexpr int IINF = numeric_limits<int>::max();
constexpr long LINF = numeric_limits<long>::max();
constexpr int MOD = (int)1e9 + 7;
// constexpr int MOD = 998244353;

int main()
{
    double a, b, n;
    cin >> a >> b >> n;

    long max_v = 0;
    double x = 0.0;
    double w = b / a;
    for (size_t i = 0; i < (size_t)a; i++)
    {
        double y = ceil(x);
        if (y > n) {
            break;
        }
        x += w;
        long v = (long)floor(a * y / b) - (long)a * (long)floor(y / b);
        max_v = max(max_v, v);
    }
    cout << max_v << "\n";
}

Measured memory_bytes: 3756
N, M = map(int, input().split())

ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1 and M > 1:
    ans = M - 2
elif M == 1:
    ans = N -2
else:
    ans = (N - 2) * (M - 2)

print(ans)

Measured memory_bytes: 2940
sx, sy, tx, ty = map(int, input().split())

ans = ""
ans += "R" * (tx - sx)
ans += "U" * (ty - sy)
ans += "L" * (tx - sx)
ans += "D" * (ty - sy + 1)
ans += "R" * (tx - sx + 1)
ans += "U" * (ty - sy + 1)
ans += "L"
ans += "U"
ans += "L" * (tx - sx + 1)
ans += "D" * (ty - sy + 1)
ans += "R"

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int G[50][50];
int n, m;
void dfs(int s, int v){
    G[s][v] = 1;
    if(v!=s)G[v][s] = -1;
    rep(u, 0, n){
        if(G[v][u]==1){
            dfs(s, u);
        }
    }
}
int main() {


    cin >> n >> m;
    rep(i,0,n) rep(j,0,n) G[i][j]=0;
    rep(i, 0, m) {
        int x, y; cin >> x >> y;
        x--;
        y--;
        G[x][y] = 1;
        G[y][x] = -1;
    }
    bool checked[50];
    rep(i,0,n) rep(j,0,n) {
            if(G[i][j]==1){
                dfs(i, j);
            }
            checked[i] = false;
        }
    vector<int> v;

    bool update=true;
    while(update){
        update = false;

        if(v.size()==n) break;
        rep(i,0,n){
            if(checked[i]) continue;
            bool judge = true;
            rep(j,0,n){
                if(checked[j]) continue;
                if(G[i][j]==-1) judge= false;
            }

            if(judge){
                update = true;
                v.push_back(i+1);
                checked[i] = true;
                rep(j,0,n) G[j][i]=1, G[i][j]=1;
                break;
            }
        }

    }

    for(auto e: v) cout << e << endl;

    return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  const auto v {[](){
    array<char, 26> v {};
    iota(v.begin(), v.end(), 'a');
    return v;
  }()};
  auto s {get_value<string>(cin)};
  sort(s.begin(), s.end());

  vector<char> res {};
  set_difference(v.begin(), v.end(), s.begin(), s.end(), back_inserter(res));

  if (res.empty())
    cout << "None\n";
  else
    cout << res.front() << '\n';
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,i,j,l,k,s,y,z,a,b,c,x;
int main(){
  cin>>a>>b>>c>>x;
  for(;i<=a;i++)for(j=0;j<=b;j++)for(k=0;k<=c;k++)if(i*500+j*100+k*50==x)n++;
  cout<<n;
}

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

//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;

//function
template<typename T>
istream& operator>>(istream& stream,vector<T> &v){
  for(int i=0;i<v.size();i++) cin>>v[i];
  return stream;
}
template<typename T>
ostream& operator<<(ostream& stream,vector<T> &v){
  for(int i=0;i<v.size();i++) cout<<v[i]<<endl;
  return stream;
}

const ll MOD=1e9+7;

int main(){  
	int n;
	cin>>n;
	vector<ll> x(n);
	cin>>x;
	ll res=1;
	ll space=0;
	ll goaled=0;
	for(int i=0;i<n;i++){
		space=x[i]-(i+1-goaled);
		if(space<i-goaled){
			res*=(i+1-goaled);
			goaled++;
		}
		res%=MOD;
	}
	for(int i=0;i<(n-goaled);i++){
		res*=(i+1);
		res%=MOD;
	}
	cout<<res<<endl;

  	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#define rgi register int
using namespace std;
int n;
double ans;
priority_queue<double>q;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(rgi i=1;i<=n;++i)
	{
		double t;
		cin>>t;
		q.push(-t);
	}
	while(q.size()>1)
	{
		double a=q.top();
		q.pop();
		double b=q.top();
		q.pop();
		q.push((a+b)/2.0);
	}
	cout<<-q.top()<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

# 飴の入った配列を受け取り、飴の最大個数を返す
def numcandy(mat):
    numcandymat = np.zeros((mat.shape[0],mat.shape[1]))
    numcandymat[0,0] = mat[0,0]
    for i in range(1, mat.shape[0]):
        numcandymat[i,0] = numcandymat[i-1,0]+mat[i,0]
    for i in range(1, mat.shape[1]):
        numcandymat[0,i] = numcandymat[0,i-1]+mat[0,i]
    for y in range(1,mat.shape[0]):
        for x in range(1,mat.shape[1]):
            numcandymat[y,x] = max(numcandymat[y-1,x],numcandymat[y,x-1])+mat[y,x]
    return numcandymat[mat.shape[0]-1,mat.shape[1]-1]
  
def B():
  N = int(input())
  mat = np.zeros((2,N))
  mat[0] = np.array([int(i) for i in input().split()])
  mat[1] = np.array([int(i) for i in input().split()])
  print(int(numcandy(mat)))
    
B()

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

int main() {
    int N; cin >> N;
    long long sum=0;
    for(int i=1; i<N+1; i++){
        if(i%3!=0 && i%5!=0){
            sum=sum+i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3640
while 1:
    count, times = [int(a) for a in input().split()]
    hanahuda = [i+1 for i in range(count)]
    if count == times == 0:break
    for i in [0]*times:
        p,c = [int(i) for i in input().split()]
        for i in [0]*c:hanahuda.append(hanahuda.pop(count-(p+c)+1))
    print(hanahuda.pop())

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    count++;
  }
  
  if (count <= K) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#define M 10000

typedef struct NN{
    int p,r,l;
}Node;

Node T[M];
int n;

void pre(int  u);
void in(int u);
void post(int u);

int main(void){
    int i,n,k,root,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++)T[i].p=-1;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&k,&l,&r);
        T[k].l=l;
        T[k].r=r;
        if(l != -1)T[l].p=k;
        if(r != -1)T[r].p = k;
    }
    for(i=0;i<n;i++){
        if(T[i].p== -1)root =i;
    }
    printf("Preorder\n");
    pre(root);
    printf("\n");
    printf("Inorder\n");
    in(root);
    printf("\n");
    printf("Postorder\n");
    post(root);
    printf("\n");
    return 0;
}

void pre(int root){
    if(root == -1)return ;
    printf(" %d",root);
    pre(T[root].l);
    pre(T[root].r);
}

void in(int root){
    if(root == -1)return ;
    in(T[root].l);
    printf(" %d",root);
    in(T[root].r);
}

void post(int root){
    if(root == -1)return ;
    post(T[root].l);
    post(T[root].r);
    printf(" %d",root);
}



Measured memory_bytes: 2068
n = int(input())
w = [input() for i in range(n)]
x = 0

for i in range(n-1):
    if w.count(w[i]) == 1 and w[i][-1] == w[i+1][0]: #条件を満たしている
        continue
    else: #条件を満たしていない
        x = 1
        print("No")
        break

if x == 0:
    print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cinm(int, n, a);
    int amin = min_element(Range(a))->first;
    int amax = max_element(Range(a))->first;

    if(amax - amin >= 2) Return("No");
    if(amax - amin == 1) Return((a[amin] < amax && n - a[amin] >= 2*(amax-a[amin])) ? "Yes" : "No");
    CoutYn(amin == n-1 || n % amin == 0);
}


Measured memory_bytes: 4388
<?php
fscanf(STDIN, "%d %d %d", $n, $m,$c);
$baseList = explode(" ", trim(fgets(STDIN)) );

$dataList = [];
for( $i=0; $i<$n; $i++ )
{ $dataList[] = explode(" ", trim(fgets(STDIN)) ); }

$result = 0;
foreach( $dataList as $data )
{
  $sum = 0;
  for( $i=0; $i<$m; $i++ )
  {
    $sum += (int)$baseList[$i]*(int)$data[$i];
  }
  
  if( $sum + $c > 0 ) { $result++; }
}

echo $result;
?>

Measured memory_bytes: 4604
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);

    let mut vec = vec![0usize; n];
    let mut d = 0;
    for e in a {
        vec[e] += 1;
        d = max!(e, d);
    }

    let center = (d + 1) / 2;

    for i in 0..center {
        if vec[i] > 0 {
            println!("Impossible");
            return;
        }
    }

    for i in center + 1..d + 1 {
        if vec[i] < 2 {
            println!("Impossible");
            return;
        }
    }

    if d % 2 == 0 {
        if vec[center] != 1 {
            println!("Impossible");
            return;
        }
    } else {
        if vec[center] != 2 {
            println!("Impossible");
            return;
        }
    }

    println!("Possible");
}


Measured memory_bytes: 8572
R, C, K = map(int, input().split())
xy = [[0] * (C + 1) for _ in range(R + 1)]
for _ in range(K) :
  r, c, v = map(int, input().split())
  xy[r - 1][c - 1] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for cy in range(R + 1) :
  for cx in range(C + 1) :
    if cx < C :
      dp[0][cy][cx + 1] = max(dp[0][cy][cx + 1], dp[0][cy][cx])
      dp[1][cy][cx + 1] = max(dp[1][cy][cx + 1], dp[0][cy][cx] + xy[cy][cx], dp[1][cy][cx])
      dp[2][cy][cx + 1] = max(dp[2][cy][cx + 1], dp[1][cy][cx] + xy[cy][cx], dp[2][cy][cx])
      dp[3][cy][cx + 1] = max(dp[3][cy][cx + 1], dp[2][cy][cx] + xy[cy][cx], dp[3][cy][cx])
    if cy < R :
      dp[0][cy + 1][cx] = max(dp[i][cy][cx] for i in range(3)) + xy[cy][cx]
      dp[0][cy + 1][cx] = max(dp[0][cy + 1][cx], dp[3][cy][cx])

print(max(dp[i][-1][-1] for i in range(4)))

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

int main(){
    
    int n;
    
    while(true){
        int x = 0;
        cin >> n;
        if(n == 0) break;
        for(int i = 5;i<=20000;i *= 5){
            x += n/i;
        }

        cout << x << endl;
        
    }
    
    return 0;
    
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int n , m ;
int arr[MAX] ;
string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	int cnt = 0 ;
	while(n > 0)
	{
		n /= m ;
		cnt++ ;
	}
	return cout<<cnt<<"\n" , 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int N , A , B , C ;
vector<int>L;
const int MAX_N = 8;
int l[MAX_N];
int dfs(int num, int a, int b, int c, int cost){
    if(num == N){
        if(a==0 || b==0 || c==0) return 1000000009;
        else return abs(a-A)+abs(b-B)+abs(c-C) + cost;
    }
 
    int ret0 = dfs(num+1, a, b, c, cost);
    int ret1 = dfs(num+1, a+l[num], b, c, cost+10);
    int ret2 = dfs(num+1, a, b+l[num], c, cost+10);
    int ret3 = dfs(num+1, a, b, c+l[num], cost+10);
 
    int ret = min(ret0, ret1);
    ret= min(ret, ret2);
    ret = min(ret, ret3);
 
    return ret;
}


int main () {
    cin >> N >> A >> B >> C;
 
    for(int i=0; i<N; i++){
        cin >> l[i];
    }
 
    int ans = dfs(0,0,0,0,-30);
 
    cout << ans << endl;
    

    return 0 ;
}

 


Measured memory_bytes: 256
import queue
n,m = map(int,input().split())
way = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    way[a-1].add(b-1)
    way[b-1].add(a-1)
    
guide = [-1]*n
guide[0] = 0
q = queue.Queue() #[room_number,cost]
q.put((0,0))
while not q.empty():
    room,cost = q.get()
    for k in way[room]: #roomと道が繋がっている部屋を列挙
        if guide[k] == -1:
            guide[k] = room
            q.put((k,cost+1))
            way[k].discard(room)
            
if -1 in guide:
    print('No')
else:
    print('Yes')
    for i in guide[1:]:
        print(i+1)

Measured memory_bytes: 65744
// https://atcoder.jp/contests/abc144/tasks/abc144_d

#include <iomanip>
#include "algorithm"
#include "cmath"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

float to_deg(long double r) {
  return (long double)r * 180.0 / ((long double)atanf(1.0) * 4.0);
}

void solve() {
  ll a, b, x;
  cin >> a >> b >> x;

  long double res;
  if (x >= a * a * b / 2) {
    res = to_deg(atan2f(2 * a * a * b - 2 * x, a * a * a));
  } else {
    res = to_deg(atan2f(a * b * b, 2 * x));
  }

  cout << setprecision(10);
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int a2;
	a2 = a % 1000;
	if (a2 == 0) {
		cout << "0" << endl;
	}
	else {
		cout << (1000 - a2) << endl;
	}
	return 0;
}



Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        	
				
		if(n<=9) {
			System.out.println(n);
		}else if(n<=99){
			System.out.println(9);
		}else if(n<=999) {
			System.out.println(n-90);
	    }else if(n<=9999) {
	    	System.out.println(909);
	    }else if(n<=99999) {
	    	System.out.println(n-9090);
	    }else{
	    	System.out.println(90909);
	    }
		
	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
long long a[100010],lis[100010];
long long ans[100010];
int main(){
	int n;cin>>n;
	long long sum=0;
	long long  within=n,surf=0,pnt=0;
	lol(i,n){
		cin>>a[i];
		lis[i]=a[i];
		sum+=a[i];
	}
	sort(lis,lis+n);
	int cur=-1;
	lol(i,n){
		if(a[i]<=cur)goto loop;
		
		cur=a[i];
		while(true){
			if(pnt==n)break;
			if(lis[pnt]>a[i])break;
			sum-=(lis[pnt]-surf);
			within--;
			pnt++;
		}
		sum-=within*(a[i]-surf);
		surf=a[i];
		
		loop:
		ans[i]=sum;
	}
	sum=0;
	lol(i,n)sum+=a[i];
	
	lol(i,n){
		if(i==0)cout<<sum-ans[0]<<endl;
		else cout<<ans[i-1]-ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

vector<ll>lay;
ll n, k;

ll fun(ll n, ll x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	ll p = (1LL << n)- 1;
	if (x <= lay[n - 1] + 1)return fun(n - 1, x - 1);
	return p + 1 + fun(n - 1, x - 2 - lay[n - 1]);
}

int main(){
	cin >> n >> k;
	lay.push_back(1);
	for (int i = 1; i <= n; i++){
		ll l = lay[i - 1] * 2 + 3;
		lay.push_back(l);
	}
	cout << fun(n, k) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,A[2000];

int solve(int ,int);

int main()
{
  int q,m,i;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);

  for(i = 0;i < q;i++)
    {
      scanf("%d",&m);
      if(solve(0,m) == 1) printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

int solve(int i,int m)
{
  int res;
  
  if(m == 0) return 1;
  if(i >= n) return 0;

  res = solve(i + 1, m) || solve(i + 1,m - A[i]);
    return res;
}

  

  



Measured memory_bytes: 2104
#coding:utf-8
 
import sys
import copy
 
def main():
    line = sys.stdin.readline()
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return
 
def analy(line):
    field = [int(n) for n in line.split()]
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        data.append(b)
    print (compute(field, data))
 
def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
                if i == 0 :
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
  cin>>n>>m;
  int l[m], r[m];
  for(int i=0; i<m; i++){
    cin>>l[i]>>r[i];
  }
  int k=*max_element(l, l+m);
  int q= *min_element(r, r+m);
  cout<<max(0,q-k+1);
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

right = 0
total = 0
ans = 0
for left in range(N):  
  while right < N and (total^A[right]) == (total+A[right]):
    total += A[right]
    right += 1
  ans += right - left  
  if left == right:
    right += 1
  else:
    total -= A[left]
print(ans)    

Measured memory_bytes: 24840
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    S=input()
    days=['SUN','MON','TUE','WED','THU','FRI','SAT']
    print(7-days.index(S))


if __name__ == "__main__":
    main()

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    ll n,k,r;
    sll(n,k);
    r=n/k;
    if(n%k!=0)
        r++;
    cout<<r;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
vector<LL> A(51, 0);
vector<LL> P(51, 0);

LL eat(int Lv,LL& X) {
	LL ret = 0;
	if (X == 0) {
		return ret;
	}
	if (X >= A[Lv]) {
		X -= A[Lv];
		ret = P[Lv];
		return ret;
	}
	///
	X--;
	ret += eat(Lv - 1, X);
	if (X) {
		X--;
		ret++;
	}
	ret += eat(Lv - 1, X);
	if (X) {
		X--;
	}
	return ret;
}
void solve() {
	LL N, X;
	cin >> N >> X;
	A[0] = 1;
	P[0] = 1;
	for (int i = 1; i <= N; ++i) {
		A[i] = 2 * A[i - 1] + 3;
		P[i] = 2 * P[i - 1] + 1;
	}
	LL ans = eat(N,X);
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double half =(w*h)/2;
    cout<<half;
    if(2*x==w && 2*y==h) cout<<" "<<1<<endl;
    else cout<<" "<<0<<endl;
 
    return 0;
    
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;
int main(){

  int k,x;cin>>k>>x;

  if(k*500>=x){
    out("Yes");
  }else out("No");


  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int sum = 700;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (s.at(i) == 'o')
        {
            sum += 100;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int n, m, t;
	fscanf(stdin, "%d%d%d", &n, &m, &t);
	int a,b,c,d=0;
	S(d, a);
	b = a - m,c = a + m,n--;
	while (n--) {
		S(d, a);
		if (a > c + m) d += c - b, b = a - m;
		c = a + m;
	}
	if (c < t) d += c - b;
	else d += t - b;
	P(d, t - d);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<vector<int>>e(n,vector<int>(n,-1));
  rep(i,n){
    int a;
    cin>>a;
    rep(j,a){
      int x,y;
      cin>>x>>y;
      x--;
      e[i][x]=y;
    }
  }
  int ans=0;
  rep(bits,1<<n){
    bool ok=true;
    rep(i,n){
      if(bits>>i&1){
        rep(j,n){
          if(e[i][j]==-1)continue;
          if((bits>>j&1)!=e[i][j])ok=false;
        }
      }
    }
    if(ok){
      ans=max(ans,__builtin_popcount(bits));
    }
  }
  cout<<ans<<endl;
  return(0);
}


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

def search(t0, t1):
    t = [t0, t1]
    for i in range(1, n+1):
        if t[i] == 'S':
            if s[i % n] == 'o':
                t.append(t[i-1])
            else:
                if t[i-1] == 'S':
                    t.append('W')
                else:
                    t.append('S')
        else:
            if s[i % n] == 'o':
                if t[i-1] == 'S':
                    t.append('W')
                else:
                    t.append('S')
            else:
                t.append(t[i-1])

    if t[0] == t[-2] and t[1] == t[-1]:
        return t[:-2]
    else:
        return None

flg = True
for i, j in [('W', 'W'), ('S', 'S'), ('S', 'W'), ('W', 'S')]:
    if not search(i, j) is None:
        ans = search(i, j)
        print(*ans, sep='')
        flg = False
        break

if flg:
    print(-1)

Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e4+5, inf = 1e9+7;
int n, k, i, j;
int A[N], dp[N][2][101], d;
string v;

int dfs(int id, int is, int rem){
    if(id==sz(v)) return (rem==0);
    int& ans = dp[id][is][rem], lim;
    if(ans!=-1) return ans;
    ans = 0;
    if(is) lim = 9;
    else lim = v[id]-'0';
    for(int i=0; i<=lim; i++) ans += dfs(id+1, is|(i<v[id]-'0'), (rem+i)%d);
    return ans%=inf;
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>v>>d;
    memset(dp, -1, sizeof dp);
    cout<<(dfs(0, 0, 0)+inf-1)%inf;
}

Measured memory_bytes: 32640
#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}
int bits_count(unsigned int u)
{
     unsigned int uCount;

     uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) & 011111111111);
     return ((uCount + (uCount >> 3)) & 030707070707) % 63;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	int n;
	cin>>n;
	
    vector<vector<ll>>f(4,vector<ll>(n));
    
    for(int i=0;i<n;++i)
    {
    	int x,y;
    	cin>>x>>y;
    	f[0][i]= x+y;
    	f[1][i]= x-y;
    	f[2][i]=-x+y;
    	f[3][i]=-x-y;
    }
    
    for(int i=0;i<4;++i)
    {
    	sort(all(f[i]));
    }
    
    ll mx=-1;
    
    for(int i=0;i<4;++i)
    mx=max(mx,abs(f[i][0]-f[i][n-1]));
	
	cout<<mx<<endl;
	






}



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

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


Measured memory_bytes: 11056
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)

signed main(){
    int n,x;
    cin >> n >> x;
    if(x == 1 or x == 2 * n -1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        int A[2 * n] = {};
        A[n-1] = x;
        A[n-2] = 1;
        A[n] = 2 * n -1;
        int vis[2 * n] ={};
        vis[x] = 1;
        vis[1] = 1;
        vis[2*n-1] = 1;
        if( x != 2 * n-2){
            A[n-3] = 2 * n-2;
            vis[2 * n -2] = 1;
        }
        else{
            A[n+1] = 2;
            vis[2] = 1;
        }



        int id = 2;
        REP(i,2 * n-1){
            while(vis[id] ==1) id ++;
            if(A[i] != 0) continue;

            A[i] = id;
            vis[id] = 1;
        }




        REP(i,2 * n -1){
            printf("%lld ",A[i]);
        }
        cout << endl;
    }




}


Measured memory_bytes: 4608
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	string a;
	cin >> a;
	sort(a.begin(), a.end());
	if (a[0] == a[1] && a[1] != a[2] && a[2] == a[3]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 3540
N = int(input())
S = input()
S_rep = S.replace('W', '1').replace('E', '0') 

lst1 = [int(S_rep[0])]
for s in S_rep[1:]:
    lst1.append(lst1[-1] + int(s))
ans = [N - lst1[-1] + int(S_rep[0]) - 1]
for i in range(1, N):
    ans.append(lst1[i-1] + N - i - 1 - lst1[-1] + lst1[i])

print(min(ans))

Measured memory_bytes: 27956
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n1,n2;
  string str1,str2,str;
  cin>>str1>>str2;
  cin>>n1>>n2;
  cin>>str;
  if(str1==str)
    cout<<n1-1<<" "<<n2;
  else 
    cout<<n1<<" "<<n2-1;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n,k = [int(i) for i in input().split()]
    group = defaultdict(list)
    ans = 0
    for i in range(1,n+1):
        group[i%k].append(i)
    ans += len(group[0])**3
    if k%2==0:
        ans += len(group[k//2])**3
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24868
sum[3<<17],cnt[3<<17];
N,i,acc,t,k,x;
char f[10];
char buf[2200000];
sz;
main()
{
	read(0,buf,2200000);
	for(;;)
	{
		k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(i=0;i<N;i++)
	{
		x=0;
		for(;;)
		{
			k=buf[sz++];
			if(k<'0')break;
			x=x*10+k-'0';
		}
		++sum[cnt[x]++];
	}
	i=sz=0;
	for(t=N;t;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)
	{
		if(!cnt[i])
		{
			buf[sz++]='0';
		}
		else
		{
			if(cnt[i-1]!=cnt[i])
			{
				k=0;
				t=cnt[i];
				while(t)
				{
					f[k++]=t%10;
					t/=10;
				}
				acc=k;
			}
			else k=acc;
			while(k--)buf[sz++]=f[k]+'0';
		}
		buf[sz++]='\n';
	}
	write(1,buf,sz);
}

Measured memory_bytes: 5248
program main
implicit none
integer :: i, j, k
integer :: w, h, n, p, q, r, s
integer , allocatable :: a(:), x(:), y(:)

read(*,*) w, h, n
allocate( a(n), x(n), y(n) )
p = 0
q = w
r = 0
s = h
do i = 1, n
   read(*,*) x(i), y(i), a(i)
   if( a(i) == 1 .and. x(i).ge.p ) then
      p = x(i)
   end if
   if( a(i) == 2 .and. x(i).le.q ) then
      q = x(i)
   end if
   if( a(i) == 3 .and. y(i).ge.r ) then
      r = y(i)
   end if
   if( a(i) == 4 .and. y(i).le.s ) then
      s = y(i)
   end if
end do
if( p.ge. q .or. r.ge.s ) then 
   write(*,'(i0)') 0
else
   write(*,'(i0)') (q-p)*(s-r)
end if


end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){


  ll n,m;cin>>n>>m;
  ll s[n],t[m];
  REP(i,n){
    cin>>s[i];
  }
  REP(i,m){
    cin>>t[i];
  }

  ll ans = 1;

  ll dp[n][m];
  ll sumDP[n][m];
  REP(i,n){
    REP(j,m){
      dp[i][j] = 0;
      sumDP[i][j] = 0;
    }
  }

  REP(i,n){
    REP(j,m){
      if(s[i]==t[j]){
        if(i==0||j==0){
          dp[i][j] = 1;
        }else{
          dp[i][j] = sumDP[i-1][j-1] + 1;
          dp[i][j] %= MOD;
        }
      }
      if(i==0){
        if(j==0){
          sumDP[i][j] = dp[i][j];
        }else{
          sumDP[i][j] = sumDP[i][j-1] + dp[i][j];
        }
        
        sumDP[i][j] %= MOD;
      }else if(j==0){
        sumDP[i][j] = sumDP[i-1][j] + dp[i][j];
        sumDP[i][j] %= MOD;
      }else{
        sumDP[i][j] = (sumDP[i-1][j] + sumDP[i][j-1] - sumDP[i-1][j-1] ) % MOD + dp[i][j];
        sumDP[i][j] %= MOD;
      }
      //cout<<sumDP[i][j]<<" "<<i<<" "<<j<<endl;
    }
  }

  /*REP(i,n){
    REP(j,m){
      cout<<sumDP[i][j]<<"  ";
    }
    cout<<endl;
  }
  cout<<endl;
  REP(i,n){
    REP(j,m){
      cout<<dp[i][j]<<"  ";
    }
    cout<<endl;
  }*/

  ans += sumDP[n-1][m-1];
  ans %= MOD;
  while(ans<0){
    ans += MOD;
    ans %= MOD;
  }

  cout<<ans<<endl;



 

  return 0;
}

Measured memory_bytes: 62720
n, m, x = gets.split.map(&:to_i)
cs = []
as = []
n.times do
  t = gets.split.map(&:to_i)
  cs << t[0]
  as << t[1..-1]  
end

ans = 10 ** 20
(0...2**n).each do |y|
  temp_ans = 0
  temp_arr = Array.new(m, 0)
  (0..(n-1)).each do |i|
    if (y & (1<<i)) != 0
      temp_ans += cs[i]
      aaa = as[i]
      (0..m-1).each do |j|
        temp_arr[j] += aaa[j]
      end
    end
  end
  if temp_ans < ans && temp_arr.all? { |a| a >= x }
    ans = temp_ans
  end
end
if ans == 10 ** 20
  puts -1
else
  puts ans
end


Measured memory_bytes: 14384
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;

	ll n;
	cin >> n;
	ll bill = 1000;
	ll ret = ceil(n / 1000.0);
	// cout << ret << endl;
	cout << abs(n - (1000 * ret));

	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int N = 105, K = 1E5 + 1;
int dp[K], a[N];
int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        for (int i = 1; i <= n; i++) scanf("%d", a + i);
        dp[0] = 0;
        for (int j = 1; j <= k; j++) {
                for (int i = 1; i <= n; i++) {
                        if (j - a[i] >= 0) dp[j] |= !dp[j - a[i]];
                }
        }
        printf("%s", (dp[k] ? "First" : "Second"));
}

Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int temp=n;
	int add=0;
	while (temp>0){
		add+=temp%10;
		temp/=10;
	}
	if (n%add==0)printf ("Yes\n");
	else printf ("No\n");
}

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

int main() {
	std::string s;
	std::cin >> s;
	
	int ans = 0;
	for (int i = 1; i <= 3; i++) {
		if (s.find(std::string(i, 'R')) != std::string::npos) {
			ans = i;
		}
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	
	double r,s,ar;
	cin >> r;
	s=r*r*3.141592653589;
	ar=2*r*3.141592653589;
	printf("%.6lf %.6lf",s,ar);
};
//?°???°?????\???6??????

Measured memory_bytes: 1240
var i,n:longint;
    a,b:array[1..100000] of longint;
begin
	readln(n); b[1]:=0;
	for i:=1 to n do read(a[i]);
	for i:=1 to n do 
	  if i mod 2 = 0 then b[1]:= b[1] - a[i]
	  else b[1]:=b[1] + a[i];
	for i:=2 to n do
          b[i]:= (a[i-1] - b[i - 1] div 2) * 2;
	for i:=1 to n do write(b[i],' ');
end. 

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    map<int,int> a;
    int ans;
    rep(i,n)
    {
        int at;
        cin>>at;
        a[at]++;
    }
    int total=0;
    for(auto v:a)
    {
        total+=v.second-1;
    }
    if(total%2==0)
    {
        ans=n-total;
    }
    else
    {
        ans=n-total-1;
    }
    cout<<ans;
}


Measured memory_bytes: 8116
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

int main() {
  int x,y,z;
  cin >> x >> y >> z;

  int temp = 0;
  temp = x;
  x = y;
  y = temp;

  temp = x;
  x = z;
  z = temp;

  cout << x << " " << y << " " << z << endl;

  return 0;
}

Measured memory_bytes: 256