akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
  long long a;
  long long b;
  int c = -1;
  int e;
  int f;
  cin >> a >> b;
  for (int i = 0; i < 1300; i++) {
    e=i * 0.08;
    f= i*0.1;
    if (e == a and f == b) {
      if (c == -1) c = i;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

K = str(N)
cnt = 0
for k in K:
    cnt += int(k)
if cnt % 9 == 0:
    print("Yes")
else:
    print("No")
    

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

using namespace std;
const int INF=1e9+5;
typedef long long ll;
const int MOD=1e9+7;
int main(){
	ll n;
	cin>>n;
//	cout<<n<<endl;
	ll g=100;
	ll count=0;
	ll r;
//	int rr=200;
	while(n>g){
		r=g/100;
		g+=r;
	//	cout<<g<<endl;
		count++;
	//	rr--;
		//if(rr==0)  break;
	}
	cout<<count<<endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main(){
  int N, ans; cin>>N >> ans;
  
  for(int i=0;i<N;i++){
    int x;cin>>x;
    ans=GCD(ans,x);
  }
  cout<<ans<<endl;
}

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

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

using namespace std;

char S[25][25];
int H,W;

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

int calc(int x,int y){
    int res = 0;
    vector<vector<int>> d(H,vector<int>(W));
    d[x][y] = 1;
    queue<pair<int,int>> q;
    q.push({x,y});
    while(!q.empty()){
        pair<int,int> now = q.front();q.pop();
        rep(i,4){
            int nx = now.first + dx[i];
            int ny = now.second+ dy[i];
            if(nx<0 || ny<0 || nx>=H || ny>=W)continue;
            if(S[nx][ny]=='.' && d[nx][ny]==0){
                d[nx][ny] = d[now.first][now.second] + 1;
                q.push({nx,ny});
                res = max(res,d[nx][ny]);
            }
        }
    }
    return res;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin >> H >> W;
    rep(i,H)cin >> S[i];
    int ans = 0;
    rep(i,H)rep(j,W){
        if(S[i][j]=='.'){
            ans = max(ans,calc(i,j));
        }
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 256
/**
 * A - Traveling Budget
 */

#include <iostream>

using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int ans = 1 << 29;
    ans = min(ans, A + C);
    ans = min(ans, A + D);
    ans = min(ans, B + C);
    ans = min(ans, B + D);
    cout << ans << endl;
}

Measured memory_bytes: 888
N, M = map(int, input().split())
students = [[int(i) for i in input().split()] for j in range(N)]
check = [[int(i) for i in input().split()] for i in range(M)]

ans_list = []
for i in range(N):
    a, b = students[i]
    min_d = float("inf")
    ans = -1
    for j in range(M):
        x, y = check[j]
        d = abs(a-x) + abs(b-y)
        if d < min_d:
            min_d = d
            ans = j
    ans_list.append(ans)
    
for i in range(N):
    print(ans_list[i]+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( a > b ) cout << a - 1 << endl;
	else cout << a << endl;
	
	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(void){

  long n,h,w;
  scanf("%ld %ld %ld", &n, &h, &w);
  long a[n],b[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  long count = 0;
  for (long i = 0; i < n; i++) {
    if (a[i] >= h && b[i] >= w) {
      count++;
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e2 + 5;
int a[maxn],b[maxn];
 int main()
 {
 	 int n,m,X,Y,flag = 0;
 	 scanf("%d %d %d %d",&n,&m,&X,&Y);
 	 for(int i = 1; i <= n; i++)
 	 	 scanf("%d",&a[i]);
 	 	 for(int i = 1; i <= m ; i++)
 	 	 	 scanf("%d",&b[i]);
 	 	 	 sort(a + 1, a + 1 + n);
 	 	 	 sort(b + 1, b + 1 + m);
 	 	 	 if ( X <= Y ){
			 	 for( int i = X + 1; i <= Y; i++){
				 	 if ( a[n] < i && b[1] >= i ) 
				 	 	 flag = 1;
				 }
			 }
			 if ( flag ) printf("No War\n");
			 else printf("War\n");
 	 return 0;
 }

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0, bob = 0;
  for (int i = 0; i < N - 1; i += 2) {
    alice += a.at(i);
    bob += a.at(i + 1);
  }
  
  if (N % 2 == 1)
    alice += a.at(N-1);
  
  cout << alice - bob << endl;
    
}

Measured memory_bytes: 764
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def check(A, operations):
    c = A[:]
    for o in operations:
        if o == 1:
            A = A[1:]
        elif o == len(A):
            A = A[:len(A) - 1]
        else:
            o -= 1
            A = A[:o - 1] + [A[o - 1] + A[o + 1]] + A[o + 2:]

    if len(A) != 1:
        print(c)
        print(operations)
    assert(len(A) == 1)
    return A[0]


def solve(N, A):

    if max(A) < 0:
        ans = max(A)
        idx = A.index(ans)
        operations = []
        for i in range(N, idx + 1, -1):
            operations.append(i)
        for i in range(1, idx + 1):
            operations.append(1)
        return ans, operations

    ans = 0
    middle = []
    start, end = None, None
    for i in range(0, N, 2):
        if A[i] >= 0:
            ans += A[i]
            if start is None:
                start = i
            end = i
        else:
            if start is not None:
                middle.append(i)

    operations = []
    num = 0
    for i in range(end + 1, N):
        operations.append(N - num)
        num += 1

    for i in middle[::-1]:
        if start < i < end:
            operations.append(i + 1)
            num += 2

    for i in range(start):
        operations.append(1)
        num += 1

    for i in range((N - num) // 2):
        operations.append(2)

    return ans, operations


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

    ans1, ope1 = solve(N, A[:])
    ans2, ope2 = solve(N - 1, A[1:])
    ope2 = [1] + ope2

    if ans1 > ans2:
        print(ans1)
        print(len(ope1))
        print(*ope1, sep="\n")
    else:
        print(ans2)
        print(len(ope2))
        print(*ope2, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4204
object Main extends App {
  val A = Scanner.nextInt
  val B = Scanner.nextInt
  val C = Scanner.nextInt
  if (A <= C && C <= B) println("Yes")
  else println("No")
}

object Scanner {
  private val buf = new Array[Byte](1024)
  private var ptr = 0
  private var len = 0

  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte: Boolean = if (ptr >= len) {
      ptr = 0
      len = System.in.read(buf)
      len > 0
    } else {
      true
    }
  @inline private def hasNext: Boolean = {
    while (hasNextByte && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte
  }
  @inline private def readByte: Byte = {
    if (hasNextByte) {
      val res = buf(ptr)
      ptr += 1
      res
    } else {
      -1
    }
  }

  def next: String = {
    if(!hasNext) ???
    val sb = new StringBuilder
    var b = readByte
    while (isPrintableChar(b)) {
      sb.append(b.toChar)
      b = readByte
    }
    sb.toString
  }
  def nextInt: Int = {
    val n = nextLong
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong: Long = {
    if(!hasNext) ???
    var minus = false
    var b = readByte
    if (b == '-') {
      minus = true
      b = readByte
    }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') go(readByte, n * 10 + b - '0')
      else if (minus) -n
      else n
    go(b)
  }
  def nextDouble: Double = next.toDouble
}

Measured memory_bytes: 25392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define F first
#define S second
const int INF = 1 << 30, MAX_M = 10000;
typedef pair<int, int> P;

int dp[501][MAX_M + MAX_M];
int p[MAX_M + 1];
int main(){
  int n, m, ans = 0;
  vector<int> vec, vec2;
  P c[MAX_M + 1];
  for (int i = 1; i<501; i++)
    fill(dp[i] + 1, dp[i] + MAX_M + MAX_M, INF);
  cin >> m >> n;
  for (int i = 1; i <= m; i++){
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < n; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    c[i] = P(a, b);
  }
  sort(p + 1, p + m + 1, greater<int>());
  sort(c, c + n);
  for (int i = 2; i <= m; i++){
    p[i] += p[i - 1];
  }
  vec.push_back(0);
  for (int i = 0; i < n; i++){
    for (int j = 0; j < vec2.size(); j++){
      vec.push_back(vec2[j]);
    }
    vec2.clear();
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for (int j = 0; j < vec.size(); j++){
      if (vec[j]<m){
        dp[i + 1][c[i].F + vec[j]] = min(dp[i][vec[j]] + c[i].S, dp[i + 1][c[i].F + vec[j]]);
        if (dp[i][c[i].F + vec[j]])
          dp[i + 1][c[i].F + vec[j]] = min(dp[i + 1][c[i].F + vec[j]], dp[i][c[i].F + vec[j]]);
        dp[i + 1][vec[j]] = min(dp[i][vec[j]], dp[i + 1][vec[j]]);
        vec2.push_back(c[i].F + vec[j]);
      }
      else{
        if (dp[i][vec[j]])
          dp[i + 1][vec[j]] = min(dp[i + 1][vec[j]], dp[i][vec[j]]);
      }
    }
  }
  for (int j = 0; j < vec2.size(); j++){
    vec.push_back(vec2[j]);
  }
  vec2.clear();
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < vec.size(); i++){
    int a = vec[i];
    if (vec[i]>m) a = m;
    ans = max(ans, p[a] - dp[n][vec[i]]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 40700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl

const int inf=1e9+7;
const int maxn=1e5+10;

inline bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
	if(a.first != b.first)
		return a.first < b.first;
	else
		return a.second > b.second;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	
	vector<pair<int,int>>v;
	int x,y;
	
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	
	sort(v.begin(),v.end(),cmp);
	
	ll int ans=0,cur=0;
	
	priority_queue<int>q;
	
	for(int i=m;i>=0;i--)//m天 
	{
		while(cur<n&&i+v[cur].first<=m)//获取当前能够得到奖励的物品 
		{
			q.push(v[cur].second);//将得分导入优先队列 
			cur++;//往后找 
		}
		
		if(q.size())//队列不为空 
		{
			ans+=q.top();//得一件最大物品的分 
			q.pop();//出队 
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
  string S; cin >> S;
  int y = stoi(S.substr(0,4)),
      m = stoi(S.substr(5,2)),
      d = stoi(S.substr(8,2));
  string ans;
  if (y>2019) ans = "TBD";
  else if (y<2019) ans = "Heisei";
  else if (m>=5) ans = "TBD";
  else ans = "Heisei";
  cout << ans << endl;
}


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

int main() {
  int L, R, A, B, C, D;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if(L>R)
    cout << "Left" << endl;
  else if(L==R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        s: chars,
    );

    let mut p = '{';

    let s: Vec<char> = s;

    let mut ans = 0;

    for i in 0..n {
        if s[i] != p {
            ans += 1;
            p = s[i];
        }
    }

    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
int main() {
    std::cout.precision(10);
    int N;
    cin >> N;
    vector<double> dp(N+1);
    vector<double> dpp(N+1);
    dp[0] = 1;
    for (int n=0; n<N; n++) {
        dpp.swap(dp);
        double p;
        cin >> p;
        for (int i=0; i<N+1; i++) {
            double c0 = (1-p) * dpp[i];
            double c1 = i > 0 ? p * dpp[i-1] : 0;
            dp[i] = c0 + c1;
        }
    }
    double ans = 0;
    for (int i=N/2+1; i<N+1; i++) {
        ans += dp[i];
    }
    cout << ans << '\n';
    return 0;
}

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

bool isPrime(int i){
    for (int j = 2;j<=sqrt(i);j++){
        if ( i %j == 0 )return false;
    }
    return true;
}


void solve(int N){
    vector<int> primes;
    for (int i=2;i<N;i++){
        if (isPrime(i)){
            primes.push_back(i);
        }
    }
    vector<pair<int,int>> prime_count;
    for (const auto& prime:primes){
        int count =0 ;
        int base = prime;
        while(base<=N){
            count+= N/base;
            base*=prime;
        }
        prime_count.push_back(make_pair(prime,count));
    }
    //x^74
    long long count=0;
    for (const auto&count_tuple:prime_count){
        if(count_tuple.second>=74) count+=1;
    }
    //x^2*y^24
    for (int i=0;i<prime_count.size();i++){
        if(prime_count[i].second>=24){
            for (int j=0;j<prime_count.size();j++){
                if (i!=j && prime_count[j].second>=2){
                    count++;
                }
            }
        }
    }
    //x^4*y*14
    for (int i=0;i<prime_count.size();i++){
        if(prime_count[i].second>=14){
            for (int j=0;j<prime_count.size();j++){
                if (i!=j && prime_count[j].second>=4){
                    count++;
                }
            }
        }
    }
    //x^2*y^4*y^4
    for (int i=0;i<prime_count.size();i++){
        if(prime_count[i].second>=2){
            for (int j=0;j<prime_count.size();j++){
                if (i!=j && prime_count[j].second>=4){
                    for (int k=j+1;k<prime_count.size();k++){
                        if(i!= k && prime_count[k].second>=4){
                            count++;
                        }
                    }
                }
            }
        }
    }
    printf("%lld\n",count);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int N;
    scanf("%d",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
def f():
  A=[list(raw_input()) for _ in range(h)]
  x,y=0,0
  while 1:
    s,A[y][x]=A[y][x],'x'
    if s==">": x+=1
    elif s=="<": x-=1
    elif s=="v": y+=1
    elif s=="^": y-=1
    elif s==".": return x,y
    else: return []
   
while 1:
  h,w=map(int,raw_input().split())
  if h==w==0: break
  x=f()
  if x==[]: print "LOOP"
  else: print x[0],x[1]

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

using namespace std;

int main()
{
	string S;
	cin >> S;
	if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct  UndirectedGraph{
    vector<vector<int>> g;
    vector<int> clr;
    vector<int> dis;
    int V;

    UndirectedGraph(int V) : V(V),
    g(vector<vector<int>>(V)),
    clr(vector<int>(V,0))
    {}

    //don't add (v,u) after adding (u,v)
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }


    //二部グラフ判定
    bool dfs_nib(int v,int c){
        clr[v]=c;
        for(auto x:g[v]){
            if(clr[x]==c) return false;
            if(clr[x]==0 && !dfs_nib(x,-c) ) return false;
        }
        return true;
    }
    bool isNib(){
        bool ret=true;
        for(int i=0;i<V;i++)if(clr[i]==0){
            if(!dfs_nib(i,1)){
                ret=false;break;
            }
        }
        return ret;
    }

    //distance
    void bfs(int st){
        dis=vector<int>(V,INF);
        vector<bool> checked(V,false);
        dis[st]=0;
        queue<int> q;
        q.push(st);
        while(!q.empty()){
            auto now=q.front();q.pop();
            //ここでもcontinueしないとダブる
            if(checked[now]) continue;
            checked[now]=true;
            for(auto x:g[now]){
                if(checked[x]) continue;
                dis[x]=dis[now]+1;
                q.push(x);
            }
        }
    }
};

signed main(){
    int n;
    cin>>n;
    UndirectedGraph g(n);
    char s[n][n];
    rep(i,n){
        rep(j,n){
            char t;cin>>t;
            s[i][j]=t;
            if(t=='1'&&i>j){
                g.add_edge(i,j);
            }
        }
    }
    if(!g.isNib()){
        cout<<-1<<endl;
        return 0;
    }

    int ans=0;
    rep(i,n){
        g.bfs(i);
        int x=*max_element(ALL(g.dis));
        ans=max(x,ans);
    }   
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#pragma warning(disable: 4996)
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)

using namespace std;

class Point {
public:
	double x, y;

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

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

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

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

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

typedef Point Vector;

///Program 16.3 表示线段的结构体
struct Segment {
	Point p1, p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

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


///内积
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}
///外积
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) {//printf("COUNTER_CLOCKWISE\n");
		return 1;
	}///p2位于p0-->p1的逆时针方向
	if (cross(a, b) < -EPS) {//printf("CLOCKWISE\n");
		return -1;
	}///p2位于p0-->p1的顺时针方向
	if (dot(a, b) < -EPS) {//printf("ONLINE_BACK\n");
		return 2;
	}///p2位于线段p0p1后方
	if (a.norm() < b.norm()) { //printf("ONLINE_FRONT\n");
		return -2;
	}///p2位于线段p0p1前方

//  printf("ON_SEGMENT\n");///p2位于线段p0p1的中间
	return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

double norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return sqrt(norm(p)); }

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	//   return s.p1 + (base*r);
	Point ans;
	ans.x = s.p1.x + (base * r).x;
	ans.y = s.p1.y + (base * r).y;
	return ans;
}

double arg(Vector p) { return atan2(p.y, p.x); }
Vector polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); }

pair<Point, Point> getCrossPoints(Circle c1, Circle c2) {
	double d = abs(c1.c - c2.c);
	double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	double t = arg(c2.c - c1.c);
	return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}

int main()
{
	Circle c1, c2;
	scanf("%lf%lf%lf", &c1.c.x, &c1.c.y, &c1.r);
	scanf("%lf%lf%lf", &c2.c.x, &c2.c.y, &c2.r);
	pair<Point, Point> p = getCrossPoints(c1, c2);
	if ((p.first.x < p.second.x) || (p.first.x == p.second.x && p.first.y < p.second.y))
		printf("%.8f %.8f %.8f %.8f\n", p.first.x, p.first.y, p.second.x, p.second.y);
	else
		printf("%.8f %.8f %.8f %.8f\n", p.second.x, p.second.y, p.first.x, p.first.y);

	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int time=0,sum=0,m=0,s=0;
	for(int i=0;i<4;i++){
		scanf("%d",&time);
		sum=sum+time;
	}
	m=sum/60;
	sum=sum-m*60;
	s=sum;
	printf("%d\n%d\n",m,s);
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();


int main () { _read(); 

      int D,S,T;
      cin >> D >> T >> S;
      int k = (D/S) + !!(D%S);
      cout << ( k <= T ? "Yes" : "No");
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 3612
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
dst = [{} for i in range(n+1)]
for i in range(m):
    a,b = inm()
    dst[a][b] = dst[b][a] = 1
used = [False]*(n+1)
v = 1
used[v] = True
a = []
b = []
while True:
    found = False
    for u in dst[v]:
        if used[u]:
            continue
        used[u] = True
        a.append(u)
        found = True
        v = u
        break
    if not found:
        break
v = 1
while True:
    found = False
    for u in dst[v]:
        if used[u]:
            continue
        used[u] = True
        b.append(u)
        found = True
        v = u
        break
    if not found:
        break
b.reverse()
b.append(1)
b.extend(a)
print(len(b))
print(*b)


Measured memory_bytes: 112440
import sys

n, x = map(int, input().split())

donut = [int(input()) for i in range(n)]

donut_cnt = n
x -= sum(donut)

donut_min = min(donut)

while x - donut_min >= 0:
    x -= donut_min
    donut_cnt += 1

print("{}".format(donut_cnt))

Measured memory_bytes: 3060
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int a;
        cin >> a;
        cout << a + a*a + a*a*a << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main()
{

    //input
  int N, swap, cnt=0;
  scanf("%d", &N);
  int A[N];
  for(int i=0; i<N; i++) scanf("%d", &A[i]);
  //calc
  for(int i=0; i<N; i++)
    {
      for(int j=N-1; j>=i+1; j--)
	{
	  if(A[j] < A[j-1])
	  {
	    swap=A[j];
	    A[j] = A[j-1];
	    A[j-1] = swap;
	    cnt++;
	  }
	}
    }

  for(int i=0; i<N; i++)
  {
    printf("%d", A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n%d\n", cnt);
  return 0;

}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <cstring>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 1e5 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e5 + 5;
LL dis[maxn];
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    LL res = 0,A,B;
    int n;
    cin >> n >> A >> B;
    for(int i = 0 ; i < n ; i++) {
        cin >> dis[i];
    }
    for(int i = 1; i < n; i++) {
        res = res + min((dis[i] - dis[i - 1]) * A , B);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 1000000
#define MODD 1000000007
#define ll long long
using namespace std;

int N,W;

ll weights[111];
ll values[111];

map<pair<int,int>,ll> hashed;

ll Solve(int pos, int curr_wt) {
    
    if (pos == N+1)
        return 0;
    
    if (hashed.find(make_pair(pos,curr_wt)) != hashed.end())
        return hashed[make_pair(pos,curr_wt)];
    
    ll ans = 0;
    
    if (curr_wt+weights[pos] <= W) {
        ans = max(ans, values[pos]+Solve(pos+1,curr_wt+weights[pos]));
    }
    
    ans = max(ans,Solve(pos+1,curr_wt));
    return hashed[make_pair(pos,curr_wt)]=ans;
}

int main() {
    cin>>N>>W;
    
    for(int i=1;i<=N;i++)
        cin>>weights[i]>>values[i];
    
    cout << Solve(0,0) << endl;
    
    
    
    
    
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int a,b,q; 
int main()
{
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&a,&b);
		long long mul=(long long)a*b,res,ans;
		res=sqrt(mul);
		ans=res*2-1;
		if(res*res==mul&&(a^b)) --ans;
		if(res*(res+1)>=mul) --ans;
		cout<<ans<<endl; 
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string a, b;
	cin >> a >> b;
	rep(i, b.size()) {
		cout << a[i] << b[i];
	}
	if (a.size() != b.size())cout << a[b.size()];
	cout << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[60];
int main()
{
    ll n,i,s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]!=i)
            s++;
    }
    if(s>2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;

}



Measured memory_bytes: 256
"use strict";

function Main(input) {
  let lines = input.trim().split("\n");
  let colors = lines[0].split(" ");
  let nums = lines[1].split(" ").map(x=> x*1);
  let U = lines[2];
  if(U == colors[0]){
  	nums[0] =  nums[0] - 1;
  }else {
    nums[1] =  nums[1] - 1;
  }
  console.log(`${nums[0]} ${nums[1]}`);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>

using namespace std;
const int N = 100010;
const int INF = 0x3f3f3f3f;
int n,ans;
int h[N];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&h[i]);
	}
	int last=0,tmp=0;
	for(int i=1; i<=n; i++){
		if(h[i]<=last){
			last=h[i];
			tmp++;
		}
		else{
			ans=max(ans, tmp);
			last=h[i];
			tmp=1;
		}
	}
	ans=max(ans, tmp);
	printf("%d\n",ans-1);
	return 0;
}



Measured memory_bytes: 640
#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 inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 2000006;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

vpii v[100050];
int a[nn];
void solve()
{
    ll i,j,n,m;
    cin>>n>>m;
    rep(i,n)
        cin>>a[i];

    ll ans = 1e17,tmp = 0,cnt=0;
    for(i=1;i<n;i++)
    {
        v[a[i-1]].pb(mp(a[i],1));
        v[a[i]].pb(mp(a[i-1],-1));
        if(a[i]<a[i-1])
        {
            tmp+=(2+a[i]-1);
            cnt++;
        }
        else
        {
            tmp+=(a[i]-a[i-1]);
        }
    }

    for(i=1;i<=m;i++)
    {
        tmp-=cnt;
        ans = min(ans,tmp);
        for(auto u:v[i])
        {
            if(u.ss==1)
            {
                if(u.ff>i)
                {
                    tmp-=(u.ff-i);
                    tmp+=(1+u.ff-i);
                    cnt++;
                }
                else if(u.ff<i)
                {
                    tmp-=(m-i+u.ff);
                    tmp+=(1+m-i+u.ff);
                    cnt++;
                }
            }
            else if(u.ss=-1)
            {
                if(u.ff<i)
                {
                    tmp--;
                    tmp+=(i-u.ff);
                    cnt--;
                }
                else
                {
                    tmp--;
                    tmp+=(m-u.ff+i);
                    cnt--;
                }
            }
        }
    }
    cout<<ans<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 7424
#include<iostream>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<vector>
#include<iterator>

int main() {
  using namespace std;

  auto n = 0;
  cin >> n;

  vector<int> balls;
  multimap<int, int> mballs;
  for(int i = 0; i < n; i++)
  {
    int num = 0;
    cin >> num;
    balls.push_back(num);
    mballs.emplace(num, i);
  }

  unordered_set<int> uniqueBalls(balls.begin(),balls.end());
  unordered_map<int, int> countBalls;
  long long cxcm1A = 0;
  for (const auto &b : uniqueBalls)
  {
    const auto c = mballs.count(b);
    countBalls.emplace(b, c);
    cxcm1A += c * (c - 1);
    mballs.erase(b);
  }

  for(int i = 0; i < n; i++)
  {
    const int kCount = countBalls.at(balls[i]);
    const long long && count = -(2 * kCount - cxcm1A - 2) / 2;
    cout << count << endl;
  }
}

Measured memory_bytes: 20376
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL rd() {
	char ch=getchar(); LL i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=getchar();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=getchar();}
	return i*f;
}

const int N=2e5+50, mod=1e9+7;
int n,m,vis[N];
int cnt[N][2],type[N];
vector <int> edge[N];
char ch[N];

int main() {
	n=rd(), m=rd();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++) type[i]=(ch[i]=='A') ? 0 : 1;
	for(int i=1;i<=m;i++) {
		int x=rd(), y=rd();
		if(x!=y) {
			edge[x].push_back(y);
			edge[y].push_back(x);
		}
		++cnt[x][type[y]];
		++cnt[y][type[x]];
	}
	queue <int> q; int cc=0;
	for(int i=1;i<=n;++i) if(!cnt[i][0] || !cnt[i][1]) q.push(i), vis[i]=1;
	while(!q.empty()) {
		int u=q.front(); q.pop();  ++cc;
		for(auto e:edge[u]) if(!vis[e]) {
			cnt[e][type[u]]--;
			if(!cnt[e][0] || !cnt[e][1]) q.push(e), vis[e]=1;
		}
	}
	if(cc==n) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 13952
#include <stdio.h>
int main ()
{
    int a,b,s,jg,i;
    while(scanf("%d %d",&a,&b)==2)
    {
        s=a*b;
        if (s%2==0)
            printf ("Even\n");
        else
            printf ("Odd\n");
            jg=1;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//二分探索
ll b_search(vll &l, ll i, ll j, ll min, ll max) {
  if (min == max) {
    return max;
  }
  if (min + 1 == max) {
    if (l[max] < l[i] + l[j]) return max;
    if (l[min] < l[i] + l[j]) return min;
  }
  ll n = (min + max) / 2;
  if (l[n] < l[i] + l[j]) {
    return b_search(l, i, j, n, max);
  }
  else {
    return b_search(l, i, j, min, n);
  }
}

int main() {
  ll n;
  cin >> n;
  vll l(n);
  for (ll i = 0; i < n; i++) cin >> l[i];
  sort(all(l));
  ll cnt = 0;
  for (ll i = 0; i < n - 2; i++) {
    for (ll j = i + 1; j < n - 1; j++) {
      ll min = j + 1, max = n - 1;
      if (l[min] >= l[i] + l[j]) continue;
      cnt += b_search(l, i, j, min, max) - min + 1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
w, a, b = STDIN.gets.chomp.split(' ').map{|s| s.to_i}
a_center = a + w/2
b_center = b + w/2

if a_center + w < b_center
  puts b_center - (a_center + w)
elsif b_center < a_center - w
  puts (a_center - w) - b_center
else
  puts 0
end

Measured memory_bytes: 1788
from collections import deque

def process_command(dll, commands):
    for cmd in commands:
        # print(cmd)
        if cmd.startswith('insert') or cmd.startswith('delete '):
            t = cmd.split(' ')
            cmd = t[0]
            num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            if int(num_str) in dll:
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64)


if __name__ == '__main__':
    # ??????????????\???
    commands = []
    num = int(input())
    for i in range(num):
        commands.append(input())

    # ??????
    dll = deque()
    process_command(dll, commands)

    # ???????????????
    # dll.reverse()
    print('{0}'.format(' '.join(map(str, dll))))

Measured memory_bytes: 190684
a = input()
if a == "SUN":
    print("7")
elif a == "MON":
    print("6")
elif a == "TUE":
    print("5")
elif a == "WED":
    print("4")
elif a == "THU":
    print("3")
elif a == "FRI":
    print("2")
else:
    print("1")

Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int b, f, r, v;
    
    // 部屋4棟3階建10部屋
    int rooms[4][3][10];
    
    // 初期化
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                rooms[i][j][k] = 0;
            }
        }
    }
    
    while(cin >> b >> f >> r >> v) {
        rooms[b - 1][f - 1][r - 1] += v;
        if (rooms[b - 1][f - 1][r - 1] < 0) {
            rooms[b - 1][f - 1][r - 1] = 0;
        }
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << rooms[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) {
            cout << "####################" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3104
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  vector<int>last(n);
  int R_count=1;
  int L_count;
  int r;
  int l;
  for(int i=0;i<n-1;i++){
    if(s[i]=='R'&& s[i+1]=='R')R_count++;
    if(s[i]=='R'&& s[i+1]=='L'){
      L_count=1;
      r=i+1;
      l=i;
    }
    if(s[i]=='L'&& s[i+1]=='L')L_count++;
    if(s[i]=='L'&& s[i+1]=='R'){
      last[r]=R_count/2+(L_count-L_count/2);
      last[l]=L_count/2+(R_count-R_count/2);
      R_count=1;
    }
  }
  last[r]=R_count/2+(L_count-L_count/2);
  last[l]=L_count/2+(R_count-R_count/2);
  for(int i=0;i<n-1;i++)cout<<last[i]<<" ";
  cout<<last[n-1]<<endl;
}
      
      
      
    

Measured memory_bytes: 1024
from collections import deque
N=int(input())
A=[0 for i in range(N-1)]
B=[0 for i in range(N-1)]
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    A[i],B[i]=a,b
    G[a].append(b)
    G[b].append(a)
j=0
for i in range(N):
    if len(G[i])>len(G[j]):
        j=i
c=sorted([int(i) for i in input().split()])
d=[-1 for i in range(N)]
q=deque([j])
while(len(q)>0):
    r=q.popleft()
    d[r]=c.pop()
    for p in G[r]:
        if d[p]==-1:
            q.append(p)
M=0
for i in range(N-1):
    M+=min(d[A[i]],d[B[i]])
print(M)
print(" ".join([str(i) for i in d]))


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

int main(void)
{
    char w[100];
    int i,x,j=1,k,z;
    gets(w);
    x=strlen(w);

    for(i=1;i<=100;i++)
    {
        if(w[i-1]>='a'&&w[i-1]<='z')
        {
                if(x%2==0&&x!=0){
                    for(k=0;k<=100;k++)
                    {
                        if(w[i-1]==w[k+1])
                            j=j+1;
                    }
                }
                if(j%2==0){
                    printf("Yes\n"); break;
                }
                else
                    printf("No\n"); break;
        }
        else{
            printf("No\n"); break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=2e5+100;
map <int,int> mp;
int32_t main(){
    ll n;
    cin >> n;
    vector <int> a;
    for (int i=0;i<n;i++){
        ll x;
        cin >> x;
        mp[x]++;
        a.pb(x);
    }
    sort(a.begin(),a.end());
    ll h=0,w=0;
    for (int i=a.size()-1;i>-1;i--){
        ll z=a[i];
        if (mp[z]>1){
            if (h==0){
                h=z;
            }
            else{
                w=max(w,z);
            }
            mp[z]-=2;
        }
    }
    cout << h*w;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

const int mod = 2019;

int L, R;
using pii = pair<int,int>;

signed main() {
	cin >> L >> R;

	set<pii> l, r;
	for (int i = L; i <= min(L+4000, R); i++) {
		l.insert({i%mod, i});
	}
	for (int i = R; i >= max(R-4000, L); i--) {
		r.insert({i%mod, i});
	}

	set<pii> cand;
	for (pii x : l) {
		cand.insert(x);
	}
	for (pii x : r) {
		cand.insert(x);
	}


	vec<int> C;
	for (pii x : cand) {
		C.push_back(x.second);
		// dbg2(x.first, x.second)
	}

	int ans = 1e18;
	rep (i, C.size()) {
		repp (j, i+1, C.size()) {
			chmin(ans, C[i] * C[j] % mod);
		}
	}

	cout << ans << endl;


/*
	int cnt = 0;
	vec<int> ans;
	for (pii x : cand) {
		ans.push_back(x.first);
		if (ans.size() >= 2) {
			break;
		}
	}

	dbg2(ans[0], ans[1])
	cout << ans[0] * ans[1] % mod << endl;
	*/

	return 0;
}

Measured memory_bytes: 1408
main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn $ if solve n then "Yes" else "No"

solve :: Int -> Bool
solve n = 0 < length [1 | x <- [0..(div n 4)], y <- [0..(div n 7)], 4 * x + 7 * y == n]


Measured memory_bytes: 508
(N, M), *AB = [list(map(int, s.split())) for s in open(0)]
A = sorted(AB[0])
D = []
for b, c in sorted(AB[1:], key=lambda x: (-x[1], x[0])):
    D.extend([c] * b)
    if len(D) >= N:
        D = D[:N]
        break
D = D[::-1]
for i in range(N):
    if not D or D[-1] <= A[i]:
        break
    A[i] = D.pop()

print(sum(A))

Measured memory_bytes: 44792
import math
def j(n):
    return math.factorial(n) // (2*math.factorial(n-2))
n,m = map(int,raw_input().split())
if (n == 1 and m == 1)or(n == 0 and m == 0): 
    print 0
elif n == 1 or n == 0:
    print j(m)
elif m == 1 or m == 0:
    print j(n)
else:
    print j(n)+j(m)

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

int main() {
  int N,t;
  cin >> N;
  int c = 0;
  for(int a = 0;a < 26;++a) {
  	for(int b = 0;b < 15;++b) {
      t = 4*a + 7*b;
      if(N == t) {
        ++c;
      }
    }
  }
  if(c >= 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600