akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    let a: u64 = sc.cin();
    let b: u64 = sc.cin();
    put!(
        if a > b || (n == 1 && a != b) {
            0
        } else if n <= 2 {
            1
        } else {
            (n - 2) * (b - a) + 1
        }
    );
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <stdio.h>
char str[8][9];
int main() {
	int i, j;
	for(i = 0; i < 8; ++ i) scanf("%s", str[i]);
	printf("90\n");
	for(i = 0; i < 8; ++ i) {
		for(j = 0; j < 8; ++ j) {
			printf("%c", str[7 - j][i]);
		}
		printf("\n");
	}
	printf("180\n");
	for(i = 0; i < 8; ++ i) {
		for(j = 0; j < 8; ++ j) {
			printf("%c", str[7 - i][7 - j]);
		}
		printf("\n");
	}
	printf("270\n");
	for(i = 0; i < 8; ++ i) {
		for(j = 0; j < 8; ++ j) {
			printf("%c", str[j][7 - i]);
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<pair<string, int>> v(N);
  for(int i = 0; i < N; i++) {
    cin >> v[i].first >> v[i].second;
  }
  string X; cin >> X;
  int sum = 0;
  bool sleep = false;
  for(int i = 0; i < N; i++) {
    if(sleep) sum += v[i].second;
    if(v[i].first == X) sleep = true;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=0,a=0,b=0;
  char S[4];
  scanf("%s",S);
  rep(i,3){
    if(S[i]=='A')a=1;
    else b=1;
  }
  if(a==1&&b==1)ans=1;
  Yn(ans);

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


Measured memory_bytes: 256
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans = 0
for i,j in itertools.combinations_with_replacement(range(len(S)),2):
    if all([x in 'ACGT' for x in S[i:j+1]]):
        ans = max(ans,j+1-i)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[2000007],finv[2000007],inv[2000007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<2000007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll x, y;
    cin >> x >> y;
    if(x > y * 2 || y > x * 2 || (x + y) % 3){
    	cout << 0 << endl;
    	return 0;
    }
    if(x > y){
    	swap(x, y);
    }
    ll le = 0, ri = 1000000000LL, mid;
    while(ri - le > 1LL){
    	mid = (le + ri) / 2LL;
    	if(y - mid * 2LL >= x - mid) le = mid;
    	else ri = mid;
    }
    ll num = x - le;
    num /= 3LL;
    cout << com(le + num * 2, num) << endl;
    return 0;
}


Measured memory_bytes: 47232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        boolean[] snuke = new boolean[n];
        for(int i=0; i<k; i++) {
            int d = in.nextInt();
            for(int j=0; j<d; j++) {
                int a = in.nextInt()-1;
                snuke[a] = true;
            }
        }
        int ans = 0;
        for(int i=0; i<n; i++) {
            if(!snuke[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 46340
#include  <stdio.h>
int main()
{
	int m[10],high[3]={0,0,0},i,j,max;
	for(i=0;i<10;i++)
	scanf("%d",&m[i]);
	for(j=0;j<3;j++)
	{
	for(i=0;i<10;i++)
	{
		if(high[j]<m[i])
		high[j]=m[i];
	}
	for(i=0;i<10;i++)
	{
		if(high[j]==m[i])
		{
		m[i]=0;
	    break;
		}
	}
	}
	printf("%d\n%d\n%d\n",high[0],high[1],high[2]);
return(0);
}

Measured memory_bytes: 600
def des(n,D):
    if n%10 in D:
        return False
    elif n>=10 and (n//10)%10 in D:
        return False
    elif n>=100 and (n//100)%10 in D:
        return False
    elif n>=1000 and (n//1000)%10 in D:
        return False
    elif n>=10000 and n//10000 in D:
        return False
    return True

N,K=map(int,input().split())
D=list(map(int,input().split()))

while not des(N,D):
    N+=1
print(N)

Measured memory_bytes: 39792
n = int(input())
a = [int(i) for i in input().split()]
cnt = [0]*(n+1)
cnt[-1] = 3
mod = 1000000007
ans = 1
for i in range(n):
    ans *= cnt[a[i]-1]
    ans %= mod
    cnt[a[i]-1] -= 1
    cnt[a[i]] += 1
print(ans)

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){

  int N;cin>>N;
    ll A,B;cin>>A>>B;
    vector<ll> S(N);
    ll ans=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(i){
            ans+=min((S[i]-S[i-1])*A,B);
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main(void){
  int n,m,q,train[505][505]={};
  cin>>n>>m>>q;
  for(int i=0;i<m;i++){
    int tl,tr;
    cin>>tl>>tr;
    train[tl][tr]++;
  }
  for(int i=1;i<=n;i++){
    for(int j=2;j<=n;j++){
      train[i][j]+=train[i][j-1];
    }
  }
  for(int i=0;i<q;i++){
    int tp,tq;
    cin>>tp>>tq;
    ll ans=0;
    for(int j=tp;j<=tq;j++){
      ans+=(train[j][tq]-train[j][tp-1]);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1920
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
ll a,b;
cin	>> a>>b;
  cout << a*b - a -b +1 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int kol[7];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    kol[a]++, kol[b]++, kol[c]++, kol[d]++, kol[e]++, kol[f]++;
    int odd = 0;
    for (int i = 1; i <= 4; i++) if (kol[i] % 2 == 1) odd++;
    if (odd == 2) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from itertools import accumulate
    from bisect import bisect_right

    n, m, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    a = [0] + list(accumulate(a))
    b = list(accumulate(b)) + [float('inf')] * 2
    ans = 0
    for i, aa in enumerate(a):
        if k < aa:
            break
        memo = bisect_right(b, k - aa)
        if b[memo + 1] == k - aa:
            memo += 1
        ans = max(ans, memo + i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 127940
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,k,r,s,p,i,ans=0;
    string str;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> str;
    i=k;
    while(str[i]) {
    	if(str[i]==str[i-k]) str[i]='$';
    	i++;
    }
    i=0;
    while(str[i]) {
    	if(str[i]=='r') ans+=p;
    	else if(str[i]=='p') ans+=s;
    	else if(str[i]=='s') ans+=r;
    	i++;
    }
    cout << ans << "\n";
    return 0;
}



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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> pixel(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> pixel.at(i).at(j);
        }
    }
    for(int i = 0; i < H; i++) {
        for (int k = 0; k < 2; k++) {
            for (int j = 0; j < W; j++) {
                cout << pixel.at(i).at(j);
                if (j == W - 1){
                    cout << endl;
                }
            }
        }
    }
}

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

struct Data{
	char s[4];
	int a,b;
}t[200];

int main(void){
	int i,j;
	int n,h,ans;
	char used[504];

	while(scanf("%d%d",&n,&h) && (n||h)){
		ans = n * n * n;

		for(i=0;i<h;i++){
			scanf("%s%d%d",t[i].s,&t[i].a,&t[i].b);

			memset(used,0,sizeof(used));
			ans -= n;

			if(!strcmp(t[i].s,"xy")){
				for(j=0;j<i;j++){
					if(!strcmp(t[j].s,"xz") && t[j].a == t[i].a && !used[t[j].b]){
						ans++;
						used[t[j].b] = 1;
					}
					else if(!strcmp(t[j].s,"yz") && t[j].a == t[i].b && !used[t[j].b]){
						ans++;
						used[t[j].b] = 1;
					}
				}
			}
			else if(!strcmp(t[i].s,"xz")){
				for(j=0;j<i;j++){
					if(!strcmp(t[j].s,"xy") && t[j].a == t[i].a && !used[t[j].b]){
						ans++;
						used[t[j].b] = 1;
					}
					else if(!strcmp(t[j].s,"yz") && t[j].b == t[i].b && !used[t[j].a]){
						ans++;
						used[t[j].a] = 1;
					}
				}
			}
			else{
				for(j=0;j<i;j++){
					if(!strcmp(t[j].s,"xy") && t[j].b == t[i].a && !used[t[j].a]){
						ans++;
						used[t[j].a] = 1;
					}
					else if(!strcmp(t[j].s,"xz") && t[j].b == t[i].b && !used[t[j].a]){
						ans++;
						used[t[j].a] = 1;
					}
				}
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

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

    if((s-a) == a or (s-b) == b or (s-c) == c){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, a, b, s, x;
int main()
{
    ll i, j;
//    freopen ("input.txt", "r", stdin);
    cin >> n >> a >> b;
    cin >> x;
    s = 0;
    j = x;
    for (i = 1; i < n; i++) {
        scanf ("%lld", &x);
        s += min((x - j) * a, b);
        j = x;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
vector<pair<int,int>> hen[100000];
int iro[100000]={};
void dfs(int a,int k){
    int j=1;
    if(j==k)j++;
    for(int i=0;i<hen[a].size();i++){
        if(iro[hen[a][i].second]!=0)continue;
        iro[hen[a][i].second]=j;
        dfs(hen[a][i].first,j);
        j++;
        if(j==k)j++;
    }

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

}
signed hm=0,q;
for(int i=0;i<n;i++){
    q=hen[i].size();
    hm=max(hm,q);
}
dfs(0,0);
cout<<hm<<endl;
for(int i=0;i<n-1;i++){
   cout<< iro[i]<<endl;
}
return 0;
}


Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] h = new int[n + 1];
        h[0] = Integer.MIN_VALUE;
        
        for (int i = 1; i <= n; i++) {
            h[i] = sc.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            String parent = (i/2 > 0)      ? ", parent key = " + h[i/2]     : "";
            String right  = (2*i + 1 <= n) ? ", right key = "  + h[2*i + 1] : ""; 
            String left   = (2*i <= n)     ? ", left key = "   + h[2*i]     : ""; 
            
            System.out.println("node " + i + ": key = " + h[i] + parent + left + right + ", ");
        }
    }
}



Measured memory_bytes: 27844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

typedef long long ll;

typedef pair<ll,ll>P;
#define F first
#define S second

int main(){
  ll n,m,ans=0;
  P p[100005];
  scanf("%lld %lld",&n,&m);
  for(ll i=0;i<n;i++){
    ll a,b;
    scanf("%lld %lld",&a,&b);
    p[i]=(P(a,b));
  }

  sort(p,p+n);

  for(ll i=0;m>0;i++){
    if(m<p[i].S){
      ans+=m*p[i].F;
      m=0;
    }else{
      ans+=p[i].F*p[i].S;
      m-=p[i].S;
    }
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N)cin >> vec[i];
    ll ans = 0;
    rep(i,N){
        if(vec[i] % 2 == 1 && i % 2 == 0)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll res = a + b;
    res = min(res, a + c);
    res = min(res, b + c);
    cout << res << endl;
}


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

namespace aziz
{
    class Program
    {
        static void Main(string[] args)
        {
          char a = Convert.ToChar(Console.ReadLine());
          
        if (char.IsUpper(a))
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
          
        }
    }
}

Measured memory_bytes: 25924
MOD = 10 ** 9 + 7
def mod_comb(n, k, mod):
    return fact[n] * fact_inv[n-k]%mod * fact_inv[k]%mod

X, Y = map(int, input().split())
if X > Y:
    X, Y = Y, X
if (X + Y) % 3 != 0:
    print(0)
else:
    N = (X + Y) // 3
    M = Y - X
    if M > N:
        print(0)
    else:
        # 計算結果自体はcomb(N, (N-M)//2) % MODになる
        # これの高速化
        fact = [1]
        fact_inv = [1]
        for i in range(N):
            new_fact = fact[-1] * (i+1) % MOD
            fact.append(new_fact)
            fact_inv.append(pow(new_fact, MOD - 2, MOD))
        print(mod_comb(N, (N-M)//2, MOD))


Measured memory_bytes: 95668
//
// Created by yamunaku on 2019/09/07.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int a,b;
    cin >> a >> b;
    for(int i=0;i<1000000;i++){
        if((a-1)*i+1>=b){
            cout << i<< endl;
            return 0;
        }
    }
    return 0;
}


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

ll ar[100005];
ll a, b,q, c, d;

int main(){
	scanf("%lld", &a);
	ll jum = 0;
	for(int k = 1; k<= a; k++){
		scanf("%lld", &b);
		ar[b]++;
		jum+=b;
	}
	scanf("%lld", &q);
	for(int k = 1; k<= q; k++){
		scanf("%lld %lld", &c, &d);
		if(ar[c]!=0){		
		jum+= ar[c]*(d-c);
		ar[d] +=ar[c];
		ar[c] = 0;
		}
		printf("%lld\n", jum);
	}
}

Measured memory_bytes: 4492
#include <iostream>

int main() {
  int a,b,c,d;
  std::cin>>a>>b>>c>>d;
  while(1) {
    c -= b;
    if(c<=0) {
      std::cout<< "Yes" <<std::endl;
      break;
    }
    a -= d;
    if(a<=0) {
      std::cout<< "No" <<std::endl;
      break;
    }
  }
}

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

int main()
{

    long long total=0,c,n,m,x,i,d;
    cin>>n;
    long long a[n+5];
    d=1;
    for(i=1; i<=n; i++)cin>>a[i];
    a[0]=0;
    a[n+1]=0;
    for(i=1; i<=n+1; i++){
        total+=(abs(a[i-1]-a[i]));
    }
    while(d<=n){
        int total1;
        total1=total-(abs(a[d-1]-a[d])+abs(a[d]-a[d+1]));
        total1=total1+abs(a[d-1]-a[d+1]);
        cout<<total1<<endl;
        d++;
    }
    return 0;
}

Measured memory_bytes: 2048
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, m, u, v, ans = 0;
    cin >> n >> m;
    
    int arr[n+5][n+5];
    memset(arr, 0x00, sizeof(arr));
    while (m--) cin >> u >> v, arr[u][v] = arr[v][u] = 1;
    
    int seq[n];
    iota(seq, seq + n, 1);
    
    do {
        int fl = 1;
        for (int i = 1; i < n; ++i) fl &= arr[seq[i-1]][seq[i]];
        ans += fl;
    } while (next_permutation(seq + 1, seq + n));
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
  li <- getLine
  let [n,m] = map read $ words li
  li <- getLine
  let as = map read $ words li
  let ans = compute n m as
  putStrLn (if ans then "Yes" else "No")

{-
total / 4M <= am が条件
total <= 4M * am
-}

compute :: Int -> Int -> [Int] -> Bool
compute n m as = total <= 4 * m * am
  where
    as1 = reverse $ sort as
    am = as1 !! pred m
    total = sum as


Measured memory_bytes: 1020
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    
    char check = true;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')
                continue;
            else{
                check = false;
                break;
            }
                
        } else{
            if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
                continue;
            else{
                check = false;
                break;
            }   
        }
    }
    
    if(check)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
int odd,even1,even2;
int main() {
    cin >> N;
    A.resize(N);
    for (auto &val : A){
        cin >> val;
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < A.size(); i++){
        if (A[i] % 2 != 0){
            odd++;
        }else if(A[i] % 4 == 0){
            even2++;
        }else if(A[i] % 2 == 0){
            even1++;
        }
    }
    if (odd == 0){
        cout << "Yes"<< endl;
        return 0;
    }
    if (odd - even2 > 1){
        cout << "No" << endl;
        return 0;
    }
    even2 -= (odd - 1);
    if (even2 > 0){
        cout << "Yes" << endl;
        return 0;
    }
    if (even1 == 0){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
   return 0;
 }


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

int main(){
    int n,a,m=0,ms=0,im;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>m){
            ms=m;
            m=a;
            im=i;
        }
        else if(a<=m && a>ms) ms=a;
    }
    for(int i=0;i<n;i++) cout<<(i!=im?m:ms)<<endl;
    return 0;
}

Measured memory_bytes: 1664
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();

		out.println(numC >= numA && numC <= numB ? "Yes" : "No");

	}

	private void solveB() {
		int numN = nextInt();
		int numM = nextInt();

		int[] wk = new int[numN];

		for (int i = 0; i < numM; i++) {
			int a = nextInt();
			int b = nextInt();
			wk[a - 1]++;
			wk[b - 1]++;
		}

		Arrays.stream(wk).forEach(i -> out.println(i));
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 26196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');

                int y = int.Parse(temp[0]);
                int m = int.Parse(temp[1]);
                int d = int.Parse(temp[2]);

                int ymd = y * 10000 + m * 100 + d;

                if (ymd < 18680908)
                {
                    sb.AppendLine("pre-meiji");
                }
                else if (ymd < 19120730)
                {
                    int tempY = y - 1868 + 1;
                    sb.AppendLine("meiji " + tempY + " " + m + " " + d);
                }
                else if (ymd < 19261225)
                {
                    int tempY = y - 1912 + 1;
                    sb.AppendLine("taisho " + tempY + " " + m + " " + d);
                }
                else if (ymd < 19890108)
                {
                    int tempY = y - 1926 + 1;
                    sb.AppendLine("showa " + tempY + " " + m + " " + d);
                }
                else
                {
                    int tempY = y - 1989 + 1;
                    sb.AppendLine("heisei " + tempY + " " + m + " " + d);
                }
            }
            Console.Write(sb);
        }
    }
}

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

int main() {

	ll n, k; cin >> n >> k;
	
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(),greater<ll>());

	ll ans = 9223372036854775807LL;
	for (int i = 0; i < n - k + 1; i++) {
		ll tmp = h[i] - h[i + k - 1];
		ans = min(ans, tmp);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<((int)(n));i++)
using namespace std;typedef vector<int> V;typedef vector<V> U;int inf=(1<<30)-1;int main(){int h,w;cin>>h>>w;U m(10,V(10));rep(i,10)rep(j,10){cin>>m[i][j];}rep(k,10)rep(i,10)rep(j,10){m[i][j]=min(m[i][j],m[i][k]+m[k][j]);}int A=0;rep(i,h)rep(j,w){int p;cin>>p;if(~p)A+=m[p][1];}cout<<A<<'\n';}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int h,w,i,j;
        Scanner s = new Scanner(System.in);
        while(true){
            h = s.nextInt();
            w = s.nextInt();
            if(h==0&&w==0)break;
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
System.out.println();
        }
    }
}


Measured memory_bytes: 37848
#include<stdio.h>

long long int gcd(long long int a,long long int b){
  if(b==0) return a;
  return gcd(b,a%b);
}
long long int lcm(long long int a,long long int b){
  long long int res;
  res = gcd(a,b);
  return a/res*b;
}

int main(void){
  int n,i;
  long long int t,ans;  
  scanf("%d",&n);
  scanf("%lld",&t);
  ans = t;
  for(i=0;i<n-1;i++){
    scanf("%lld",&t);
    ans = lcm(ans,t);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MN=100100;
int n,m,a[MN];
LL k[2*MN]={0},b[2*MN]={0},sum=0,mx=0;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<n;i++)
    {
        int u=a[i],v=a[i+1];
        if(u>v)v+=m;
        sum+=(v-u);
        k[u+1]++;k[v+1]--;
        b[u+1]+=(a[i]+1);b[v+1]-=(a[i]+1);
    }
    for(int i=2;i<=2*m;i++)k[i]+=k[i-1],b[i]+=b[i-1];
    for(int i=1;i<=m;i++)
    {
        mx=max(mx,k[i]*i+k[i+m]*(i+m)-b[i]-b[i+m]);
    }
    printf("%lld\n",sum-mx);
    return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i * 4 <= n; i++) {
		if ((n - i*4) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    string s = " ";

    while(n != 0){
        int x = n % 2;
        if(x < 0) x += 2;
        n = (n - x) / (-2);
        s += (char)('0' + x);
    }
    REVERSE(s);
    if(s == " ") s = "0";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
o = input()
e = input()

ans = ''

if len(o) == len(e):
    for i in range(len(o)):
        ans += o[i] + e[i]
else:
    for i in range(len(o) - 1):
        ans += o[i] + e[i]
    ans += o[-1]

print(ans)

Measured memory_bytes: 3060
import math

def factors(n):
    l = int(math.sqrt(n)) + 1
    ret = {}
    nf2 = 0
    while n % 2 == 0:
        nf2 += 1
        n //= 2
    if nf2 != 0:
        ret[2] = nf2
    nf3 = 0
    while n % 3 == 0:
        nf3 += 1
        n //= 3
    if nf3 != 0:
        ret[3] = nf3
    # n = append_factors(n, ret, 2)
    # n = append_factors(n, ret, 3)
    i = 6
    while i*i <= n + 1:
        p1, p2 = i - 1, i + 1
        nfp1 = 0
        while n % p1 == 0:
            nfp1 += 1
            n //= p1
        if nfp1 != 0:
            ret[p1] = nfp1
        nfp2 = 0
        while n % p2 == 0:
            nfp2 += 1
            n //= p2
        if nfp2 != 0:
            ret[p2] = nfp2
        # n = append_factors(n, ret, i - 1)
        # n = append_factors(n, ret, i + 1)
        i += 6
    if n != 1:
        ret[n] = 1

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n(n+1) <= 2x < (n+1)(n+2)

    n = int(math.sqrt(2 * x))
    while n*(n + 1) > 2*x:
        n -= 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Mapping{
	string key,value;
	vector<Mapping> children;
	Mapping(string k):key(k){}
	Mapping(string k,string v):key(k),value(v){}
};

pair<Mapping,int> Parse(const vs& yaml,int i)
{
	int indent=yaml[i].find_first_not_of(' ');
	
	string key;
	int j=indent;
	for(;yaml[i][j]!=':';j++) key+=yaml[i][j];
	j+=2;
	
	if(j<=yaml[i].size()){ // string
		string value=yaml[i].substr(j);
		return mp(Mapping(key,value),i+1);
	}
	else{
		Mapping m(key);
		for(i++;i<yaml.size() && yaml[i].find_first_not_of(' ')>indent;){
			auto p=Parse(yaml,i);
			m.children.push_back(p.first);
			i=p.second;
		}
		return mp(m,i);
	}
}
Mapping Parse(const vs& yaml)
{
	Mapping m("(root)");
	for(int i=0;i<yaml.size();){
		auto p=Parse(yaml,i);
		m.children.push_back(p.first);
		i=p.second;
	}
	return m;
}

void print(const Mapping& m,int i=0)
{
	if(i) cout<<string(i,' ');
	cout<<m.key<<"("<<m.children.size()<<"): ";
	if(m.children.empty())
		cout<<m.value<<endl;
	else{
		cout<<endl;
		for(const auto& c:m.children)
			print(c,i+1);
	}
}

string query(const Mapping& m,const string& q)
{
	vs keys;
	for(int i=0;i<q.size();){
		int j=q.find('.',i+1);
		keys.push_back(q.substr(i+1,j-(i+1)));
		i=j;
	}
	
	const Mapping* x=&m;
	string res="no such property";
	for(int i=0;i<keys.size();i++){
		bool found=false;
		for(const auto& c:x->children)
			if(c.key==keys[i]){
				x=&c;
				found=true;
				break;
			}
		if(!found) return "no such property";
	}
	
	if(x->children.empty())
		return "string \""+x->value+"\"";
	else
		return "object";
}

int main()
{
	for(string q;getline(cin,q);){
		vs yaml;
		for(string s;getline(cin,s) && s!="";)
			yaml.push_back(s);
		
		Mapping m=Parse(yaml);
		cout<<query(m,q)<<endl;
	}
}

Measured memory_bytes: 1412
a = gets.split.map(&:to_i)
s = "%d+%d%d+%d%d%d==%d%d%d"
nums = (1..9).to_a - a.select {|x| x != -1}
if nums.empty?
    p eval(sprintf(s, *a)) ? 1 : 0
else
    k = 0
    nums.permutation(nums.size) do |perm|
        d = a.dup
        perm.each do |k|
            d[d.index{|x| x < 0}] = k
        end
        k += 1 if eval(sprintf(s, *d))
    end
    p k
end



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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2) {
        for (int i = 0; i < n; ++i) {
            if ((s[i] - '0') % 2 == 0) {
                ans += i + 1;
            }
        }
    }else if (p == 5) {
        for (int i = 0; i < n; ++i) {
            if ((s[i] - '0') % 5 == 0) {
                ans += i + 1;
            }
        }
    }else {
        map<int, int> mp;
        ++mp[0];
        int t = 0, p2 = 1;
        for (int i = n - 1; ~i; --i) {
            t = (t + (s[i] - '0') * p2) % p;
            ans += mp[t];
            mp[t]++;
            p2 = p2 * 10 % p;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define endl "\n"
typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int a[ N ];

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        int n;
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >>a[i];
        sort( a+1 , a+n+1 );
        int mx = a[n];
        int tot = 0;
        for( int i = 1; i < n; i++ ) tot += a[i];
        if( mx < tot ) cout << "Yes" <<endl;
        else cout << "No" <<endl;
        return 0;
}













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

int main() {
    int S, h, m, s, x;
    cin >> S;
    h = S / 3600;
    x = S % 3600;
    m = x / 60;
    x = x % 60;
    s = x;
    
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
    
}


Measured memory_bytes: 3096
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "queue"

using namespace std;

#define REP(i,j) for(int i = 0;i < j; i++)

enum kind {
	left,
	right,
	top,
	bottom
};

vector<int> cube_swap(vector<int> cube, kind k);


int main(void) {

	vector<int> g_prog = vector<int>();
	g_prog.push_back(0);
	REP(i, 9) {
		int a = pow(4,i);
		int sum = a;
		REP(j, g_prog.size()) {
			sum += g_prog[j];
		}
		g_prog.push_back(sum);
	}

	int n = 0;
	cin >> n;
	REP(i, n) {
		//盤面
		vector<int> cube = vector<int>();
		queue<vector<int>> que = queue<vector<int>>();
		REP(j, 30) {
			int a = 0;
			cin >> a;
			cube.push_back(a);
		}
		int count = 0;
		que.push(cube);
		while (que.size() > 0) {
			vector<int> now_cube = que.front();
			que.pop();
			bool isFinished = false;
			REP(j, 30) {
				if (j == 0 || j == 9 || j == 12 || j == 15 || j == 18 || j == 21)
					continue;

				if (now_cube[j] != now_cube[j - 1]) break;
				if (j == 29) isFinished = true;
			}

			if (isFinished) break;
			else count++;

			que.push(cube_swap(now_cube, kind::left));
			que.push(cube_swap(now_cube, kind::right));
			que.push(cube_swap(now_cube, kind::top));
			que.push(cube_swap(now_cube, kind::bottom));
		}
		int ans = 0;
		REP(j, 9) {
			if (count < g_prog[j + 1]) {
				ans = j;
				break;
			}
		}
		cout << ans << endl;
	}
}

vector<int> cube_swap(vector<int> cube, kind k) {
	vector<int> copied_v(30);
	copy(cube.begin(), cube.end(), copied_v.begin());
	switch (k) {
	case kind::left:
		iter_swap(cube.begin(), cube.begin() + 23);
		iter_swap(cube.begin()+3, cube.begin() + 26);
		iter_swap(cube.begin()+6, cube.begin() + 29);
		iter_swap(cube.begin()+9, cube.begin() + 20);
		iter_swap(cube.begin() + 15, cube.begin() + 17);
		break;
	case kind::right:
		iter_swap(cube.begin()+2, cube.begin() + 21);
		iter_swap(cube.begin() + 5, cube.begin() + 24);
		iter_swap(cube.begin() + 8, cube.begin() + 27);
		iter_swap(cube.begin() + 11, cube.begin() + 18);
		iter_swap(cube.begin() + 12, cube.begin() + 14);
		break;
	case kind::top:
		iter_swap(cube.begin(), cube.begin() + 27);
		iter_swap(cube.begin() + 1, cube.begin() + 28);
		iter_swap(cube.begin() + 2, cube.begin() + 29);
		iter_swap(cube.begin() + 14, cube.begin() + 15);
		iter_swap(cube.begin() + 18, cube.begin() + 20);
		break;
	case kind::bottom:
		iter_swap(cube.begin()+6, cube.begin() + 21);
		iter_swap(cube.begin() + 7, cube.begin() + 22);
		iter_swap(cube.begin() + 8, cube.begin() + 23);
		iter_swap(cube.begin() + 12, cube.begin() + 17);
		iter_swap(cube.begin() + 9, cube.begin() + 11);
		break;
	}
	return cube;
}




Measured memory_bytes: 15748
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

h, w = getInts()
ans = ['#' *(w+2)]
for _ in range(h):
    line = '#'
    line += input()
    line += '#'
    ans.append(line)
ans.append('#'*(w+2))
print(*ans, sep='\n')

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

int main(){
  
  int N, L;
  cin >> N >> L;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
  	cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  string sum="";
  for (int i = 0; i < N; i++) {
   sum += vec.at(i);
  } 
  cout << sum << endl;
}
	

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

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

  std::vector<size_t> a(n);
  for (auto& ai: a) scanf("%zu", &ai), --ai;

  std::vector<size_t> res;
  for (size_t i = n; i--;) {
    bool erased = false;
    for (size_t j = i+1; j--;) {
      if (j == a[j]) {
        erased = true;
        a.erase(a.begin()+j);
        res.push_back(j+1);
        break;
      }
    }
    if (!erased) return puts("-1"), 0;
  }

  std::reverse(res.begin(), res.end());
  for (auto ri: res) printf("%zu\n", ri);
}


Measured memory_bytes: 256