akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s; cin >> s;
    rep(i, 3){
        if (s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;


}



Measured memory_bytes: 3624
#include <cstdio>
int main(){
	bool b[4];
	b[1] = false;
	b[2] = false;
	b[3] = false;
	int x, y;
	scanf("%d %d", &x, &y);
	b[x] = true;
	b[y] = true;
	for (int i = 1; i <= 3; i++){
		if (!b[i]){
			printf("%d\n", i);
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string hitachi;
  for (int i; i < s.size(); i++){
  	hitachi += "hi";
	if (hitachi == s) {
      cout << "Yes" << endl;
      exit (0);
  }
 }
  cout << "No" << endl;
}

Measured memory_bytes: 256
// hima.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>


using namespace std;



int main() {

	int A,B,C;

	cin >>A>>B>>C;

	int nokori=A-B;

	int nokori2=C-nokori;
	if(nokori2<0){
		nokori2=0;
	}
	cout <<nokori2<<endl;
}





Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while(true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using pii   = std::pair<int, int>;
using vi    = std::vector<int>;
using vd    = std::vector<double>;
using vc    = std::vector<char>;
using vb    = std::vector<bool>;
using vs    = std::vector<std::string>;
using vpii  = std::vector<pii>;
using vvi   = std::vector<vi>;
using vvb   = std::vector<vb>;
using vvpii = std::vector<vpii>;
template<typename A> using fn = std::function<A>;
constexpr int INF   = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD   = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;
// clang-format on

template<typename T>
struct Monoid {
  T id;
  std::function<T(T, T)> op;
  Monoid(T e, std::function<T(T, T)> f)
    : id(e), op(f) {
  }
};

template<typename T>
class SegTree {
private:
  vector<T> data;
  Monoid<T> monoid;
  int size = 1;

public:
  SegTree(const int &n, const Monoid<T> &m)
    : monoid(m) {
    while (size < n) size *= 2;
    data = vector<T>(2 * size, monoid.id);
  }

  void update(int i, const T &x) {
    i += size;
    data[i]                = x;
    while (i /= 2) data[i] = monoid.op(data[i * 2], data[i * 2 + 1]);
  }

  // fold [a, b) by monoid.op
  T fold(const int &a, const int &b, const int &k = 1, const int &l = 0, int r = -1) {
    if (r == -1) r = size;
    if (r <= a || b <= l) return monoid.id;
    if (a <= l && r <= b) return data[k];
    return monoid.op(fold(a, b, k * 2, l, (l + r) / 2),
                     fold(a, b, k * 2 + 1, (l + r) / 2, r));
  }

  const T &operator[](const int &i) const {
    return data[i + size];
  }
};

template<int inf>
Monoid<int> minMonoid = {inf, [](int a, int b) { return min(a, b); }};

main {
  int n, q;
  cin >> n >> q;
  SegTree<int> t(n, minMonoid<2147483647>);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << t.fold(x, y + 1) << endl;
    } else {
      t.update(x, y);
    }
  }
}

Measured memory_bytes: 4852
#[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 mut $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 main() {
    input!{
        n: usize,
        mut x: [i64;n],
    }
    x.sort();
    let s = x[0] as usize;
    let e = x[n-1] as usize +1;
    let mut ans:i64 = 1_000_000_000_000_000;
    for i in s..e {
        // println!("{}", i);
        let mut res:i64 = 0;
        for j in 0..n {
            res += (x[j] - i as i64)*(x[j] - i as i64);
        }
        ans = std::cmp::min(ans, res);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
        print('Bad')
    else:
        print('Good')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
function Main(input) {
  const arr = input.split('\n');
  const m = arr[0].split(' ')[1];
  const votes = arr[1].split(' ').map(x => Number(x));
  const sum = votes.reduce((a,c) => a + c);
  const border = sum / (4 * m);

  const f = votes.filter(x => {
    return x >= border;
  });

  if (f.length >= m) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
n = input()
count = 0

for i in range(len(n)):
    if i % 2 ==0 and n[i] == "L":
        count += 1
    elif i % 2 ==1 and n[i] == "R":
        count += 1

if count >= 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
import numpy as np

N = int(input())

XY = np.zeros((2, N))
H = np.zeros(N)
x_s, y_s, h_s = 0, 0, 0

# input
for i in range(N):
    x_tmp, y_tmp, h_tmp = map(int, input().split())

    if h_tmp > 0:
        x_s, y_s, h_s = x_tmp, y_tmp, h_tmp
    XY[:, i] = x_tmp, y_tmp
    H[i] = h_tmp

is_break = False
for c_x in range(0, 101):
    for c_y in range(0, 101):
        h_tmp = h_s + abs(x_s - c_x) + abs(y_s - c_y)
        xy = XY.copy()
        h = H.copy()
        h_tmp2 = xy - np.array([[c_x], [c_y]])
        h_tmp2 = h_tmp - np.abs(h_tmp2).sum(axis=0)
        h_tmp2 = np.clip(h_tmp2, 0, None)
        if (h == h_tmp2).all():
            print(c_x, c_y, h_tmp)
            is_break = True
            break
    if is_break:
        break

Measured memory_bytes: 21776
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string S;
    cin >> S;
    rep(i, S.size()) {
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        x: u32,
    };
    let mut count = 0;

    for na in 0..=a {
        let va = na * 500;
        for nb in 0..=b {
            let vb = va + 100 * nb;
            for nc in 0..=c {
                let vc = vb + 50 * nc;
                if vc == x {
                    count += 1;
                }
                if vc > x {
                    break;
                }
            }
            if vb > x {
                break;
            }
        }
        if va > x {
            break;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 2096
#include<stdio.h>
int a,b,c,d[3001],e[3001],f[3001][3001],i,j,m=0,k;
int main(void)
{
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<a;i++){
		scanf("%d %d",&d[i],&e[i]);
	}
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			f[i][j]=-1;
		}
	}
	f[0][0]=0;
	for(i=0;i<a;i++){
		for(j=0;j<=b;j++){
			if(f[i][j]!=-1){
				if(j<c && c<e[i]+j){
					if(b>=c+e[i]){
						if(f[i+1][c+e[i]]<f[i][j]+d[i]){
							f[i+1][c+e[i]]=f[i][j]+d[i];
						}
					}
					if(f[i][j]>f[i+1][j]){
						f[i+1][j]=f[i][j];
					}
				}
				else{
					if(f[i][j]+d[i]>f[i+1][j+e[i]]){
						if(j+e[i]<=b){
							f[i+1][j+e[i]]=f[i][j]+d[i];
						}
					}
					if(f[i][j]>f[i+1][j]){
						f[i+1][j]=f[i][j];
					}
				}
			}
		}
	}
	for(i=0;i<=b;i++){
		if(m<f[a][i]){
			m=f[a][i];
		}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 36228
function Main(input) {
	input = input.split("\n")
	const a = input[0]
    const b = input[1]
    
    if (a === b.slice(0, -1)) {
      console.log('Yes')
    } else {
      console.log('No')
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	vll ans(n,0);
	for(ll i=1;i<n;i++) cin>>a[i];

	ans[0] = a[1];

	for(ll i=1;i<n-1;i++) ans[i] = min(a[i],a[i+1]);

	ans[n-1] = a[n-1];
	cout<<accumulate(all(ans),0);
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  long long  int A;
  double B;
  cin >> A >> B;

  
  long long int C = B*100+0.1;

  
  A = A * C;
  A /= 100;
  
  cout << A << endl;
  
 	
  
}


Measured memory_bytes: 3640
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N, K; cin >> N >> K;

	cout << dig(N, K) << endl;
}

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

ll knapsack(int weight[], int value[], int n, int w){
    if(n == 0)
        return 0;
    vector<ll> dp(w+1, 0);
    for(int i=1; i<=n; i++){
        for(int j=w; j>=0; j--){
            if(j-weight[i-1] >= 0)
                dp[j] = max(dp[j], dp[j-weight[i-1]]+value[i-1]);
        }
    }
    return dp[w];
}

int main()
{
 int n, w;
 cin>>n>>w;
 int weight[n], value[n];
 for(int i=0; i<n; i++)
    cin>>weight[i]>>value[i];
 ll ans = knapsack(weight, value, n, w);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 4024
import sys

def main():
    sys.setrecursionlimit(1000000) # recursion limit hack
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    h = list(map(int, buflist))
    done = []
    height = []
    for i in range(N):
        if h[i] == 0:
            done.append(True)
        else:
            done.append(False)
        height.append(0)
    print(recursion_water(h, done, height, 0))

def recursion_water(h, done, height, count):
    for i in range(len(h)):
        if done[i]:
            continue
        else:
            count += 1
            for j in range(i, len(h)):
                if not done[j]:
                    height[j] += 1
                    if height[j] == h[j]:
                        done[j] = True
                else:
                    break
            return recursion_water(h, done, height, count)
    return count

if __name__ == '__main__':
    main()


Measured memory_bytes: 7404
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ans=[1]+[0]*(n-1)
if n==1:
    ans=[0]
for s,t in l:
    if s==1 and t==0 and n>1:
        print(-1)
        quit()
    if s>n:
        print(-1)
        quit()
    ans[s-1]=t
for s,t in l:
    if ans[s-1]!=t:
        print(-1)
        quit()
print("".join(map(str,ans)))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <string>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define W_MAX 10000

int main(void)
{
  int i,j,k,l;
  int N,W;
  int valid[50005] = {1,0,};
  int value[W_MAX+5] = {0};
  cin >> N >> W;
  rep(i,N) {
    int v,w;
    cin >> v >> w;
    for(j=W-w;j>-1;j--) {
      if(value[j+w] < value[j] + v) {
        value[j+w] = value[j] + v;
      }
    }
  }
  cout << value[W] << endl;
  return 0;
}

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

dict = {}
for n in range(N):
    k_a = [int(_) for _ in input().split()]
    for k in range(k_a[0]):
        if k_a[k+1] in dict:
            dict[k_a[k+1]] += 1
        else:
            dict[k_a[k+1]] = 1

count = 0
for key in dict:
    if dict[key] == N:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
using namespace std;
struct node
{
    ll x;
    ll y;
}a[200009];
int n;
ll c[200009],ans=0,m,d,t[200009];
int cmp(node a,node b)
{
    return a.x<b.x;
}
void add(ll x,ll d)
{
    while(x<=(ll)n)
    {
        c[x]+=d;
        x+=x&-x;
    }
}
ll query(ll x)
{
    ll res=0;
    while(x)
    {
        res+=c[x];
        x-=x&-x;
    }
    return res;
}
int findl(ll x)
{
    return lower_bound(t+1,t+n+1,x)-t;
}
int main()
{
    scanf("%d%lld%lld",&n,&d,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&a[i].x,&a[i].y),t[i]=a[i].x;
    sort(a+1,a+n+1,cmp);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        //printf("%lld\n",query(i));
        a[i].y+=query(i);
        if(a[i].y<=0)
            continue;
        //printf("%d\n",i);
        ll tmp=a[i].y%m==0?a[i].y/m:a[i].y/m+1;
        ans+=tmp;
        add(i,-tmp*m);
        add(findl(a[i].x+2*d+1),tmp*m);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 6528
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<pair<ld, ld>> p(N);
  REP(i, N) {
    ll x, y;
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  vec<ll> q(N);
  iota(ALL(q), 0);
  ld answer = 0;
  ll d = 0;
  do {
    for (ll i = 0; i < N - 1; i++) {
      answer += hypot(p[q[i + 1]].first - p[q[i]].first,
                      p[q[i + 1]].second - p[q[i]].second);
    }
    d++;
  } while (next_permutation(ALL(q)));
  answer /= static_cast<ld>(d);
  cout << answer << endl;
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 1e5+34;
int a[N], b[N];

void solve() {
	int n; scanf("%d", &n);
	int firstNonZero = n;
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
		if (a[i] && firstNonZero == n) firstNonZero = i;
	}
	if (firstNonZero == n) {
		cout << (long long)n*(n+1)/2;
		return;
	}
	// neg 1st
	long long s = 0, ans = 0;
	for (int i = 0; i < n; ++i) {
		s += a[i];
		if (i % 2 == 0) { // neg
			ans += s<0?0:(s+1);
			s -= s<0?0:(s+1);
		} else {
			ans += s>0?0:(-s+1);
			s += s>0?0:(-s+1);
		}
		debug(s);
	}
	// pos 1st
	long long cur = s = 0;
	for (int i = 0; i < n; ++i) {
		s += a[i];
		if (i % 2 == 0) { // pos
			cur += s>0?0:(-s+1);
			s += s>0?0:(-s+1);
		} else {
			cur += s<0?0:(s+1);
			s -= s<0?0:(s+1);
		}
	}
	cout << min(cur, ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
const int INF = 1e9 + 7;
const int MAX_V = 100;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V;

int prim() {
    for (int i = 0; i < V; ++i) {
        mincost[i] = INF;
        used[i] = false;
    }

    mincost[0] = 0;
    int res = 0;

    while (true) {
        int v = -1;
        for (int u = 0; u < V; u++) {
            if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }

        if (v == -1) break;
        used[v] = true;
        res += mincost[v];

        for (int u = 0; u < V; u++) {
            if (cost[v][u] < mincost[u]) {
                mincost[u] = cost[v][u];
            }
        }
    }
    return res;
}

int main() {
    cin >> V;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            cin >> cost[i][j];
            if (cost[i][j] == -1) cost[i][j] = INF;
        }
    }
    cout << prim() << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    double a, b, c;
    while(cin >> a >> b >> c){
        printf("%.8lf\n%.8lf\n%.8lf\n",a * b * sin(c*M_PI / 180) / 2, sqrt(a * a + b * b - (2 * a * b * cos(c*M_PI / 180))) + a + b, b * sin(c*M_PI/180));
    }
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    }
    else if (A == C) {
        cout << B << endl;
    }
    else {
        cout << A << endl;
    }
}

Measured memory_bytes: 256
from math import sin, cos, sqrt, acos
PI = acos(-1)
A, B, H, M = map(int,input().split())
t = H*60+M
Ht, Mt = t*PI/360, t*PI/30
Hx, Hy = A*cos(Ht), A*sin(Ht)
Mx, My = B*cos(Mt), B*sin(Mt)
print(round(sqrt((Hx-Mx)**2+(Hy-My)**2),15))

Measured memory_bytes: 62328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int p,n[6];
int price[]={1,5,10,50,100,500};

int f(int a,int b,int c,int d,int e){
	int pr=p+a+b*5+c*10+d*50+e*100;
	int i;
	int res=0;
	int nn[6];
	for(i=0;i<6;i++)nn[i]=n[i];
	for(i=5;i>=0;){
//cout<<i<<" "<<pr<<endl;
		if(nn[i]==0){i--;continue;}
		if(pr<price[i]){i--;continue;}
		pr-=price[i];
		nn[i]--;
		res++;
	}
//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<res<<endl;
	if(pr)return 100100100;
	return a+b+c+d+e+res;
}

int main() {
	while(cin>>p>>n[0]>>n[1]>>n[2]>>n[3]>>n[4]>>n[5],p){
		int a,b,c,d,e,res=100100100;
		for(a=0;a<5;a++){
			for(b=0;b<2;b++){
				for(c=0;c<5;c++){
					for(d=0;d<2;d++){
						for(e=0;e<5;e++){
							chmin(res,f(a,b,c,d,e));
						}
					}
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	q*=4;h*=2;
	s=min(s,min(q,h));
	ll ans =0;
	if(n&1) {
		ans=min((n/2)*d+s,n*s);
	} else ans=min((n/2)*d,s*n);
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
using namespace std;

int main()
{
	int a, b;
	int ans;

	cin >> a >> b;

	ans = a;
	if( a > b ) {
		ans--;
	}

	cout << ans << endl;

	return 0;
}


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

vector<ll> g[200000];
ll cnt[200000];

void dfs(int idx,int par)
{
	for(auto i:g[idx])
	{
		if(i==par)continue;
		cnt[i]+=cnt[idx];
		dfs(i,idx);
	}
}

int main()
{
	int n,q;
	cin >> n >> q;
	for(int i = 0;i<n-1;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	while(q--)
	{
		int x,y;
		cin >> x >> y;
		x--;
		cnt[x] += y;
	}
	dfs(0,-1);
	for(int i =0 ;i<n;i++)cout<<cnt[i]<<' ';cout<<endl;
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  array< array<int, 9>, 9> cum;
  for (int i = 0; i < 8; ++i) for (int j = 0; j < 8; ++j) {
    cum[i + 1][j + 1] = cum[i + 1][j] + cum[i][j + 1] - cum[i][j] + !(~i & 1 and j & 1);
  }
  while (q--) {
    int a, b, c, d; cin >> a >> b >> c >> d, --a, --b;
    // [a, c), [b, d)
    int res = cum[c][d] - cum[c][b] - cum[a][d] + cum[a][b];
    cout << res << '\n';
  }
}


Measured memory_bytes: 3236
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def tmp(m):
  c = 0
  s = 0
  for i in range(1,m+1):
    if s + i > m:
      return c
    c = c + 1
    s = s + i
  
  return c

def main():
  N = int(input())
  c = collections.Counter(prime_factorize(N))
  multupliyer_list = c.values()
  count = 0
  for m in multupliyer_list:
    t = tmp(m)
    count = count + t

  print(count)


if __name__ == "__main__":
  main()

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define f first
#define s second
 
using namespace std;
const int MAXN=3e3+5;
pair<int,int> dp[MAXN][MAXN];
 
int S,T;
string s,t;
 
int main(){
    cin>>s>>t;
    S=s.size();
    T=t.size();
    for(int i=0;i<=S;i++)dp[i][T]={0,-1};
    for(int i=0;i<=T;i++)dp[S][i]={0,-1};
    for(int i=S-1;i>=0;i--)
        for(int j=T-1;j>=0;j--){
            dp[i][j]={dp[i+1][j].f,0};
            if(dp[i][j].f<dp[i][j+1].f)dp[i][j]={dp[i][j+1].f,1};
            if(s[i]==t[j]&&dp[i][j].f<dp[i+1][j+1].f+1)dp[i][j]={dp[i+1][j+1].f+1,2};
        }
        int i=0,j=0;
        string st="";
        while(i!=S&&j!=T){
            if(dp[i][j].s==0)i++;
            else if(dp[i][j].s==1)j++;
            else st+=s[i],i++,j++;
        }
        cout<<st;
}

Measured memory_bytes: 70784
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; 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;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long 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;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
/*input
1
11 11
*/

#include <bits/stdc++.h>

using namespace std;

int f(int b, int d) {
  return b / d;
}

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

  int k, a, b;
  cin >> k >> a >> b;

  cout << (f(b, k) - f(a - 1, k) ? "OK" : "NG") << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		
		int x = 100 * r + 10 * g + b;
		
		if(x % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}


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

int main()
{
	while(1)
	{
		int H, W;
		cin >> H>> W;

		if(H == 0 && W == 0)
		{
			break;
		}
		char map[200][200];
		/*for(int i = 0; i < 200; i++)
		{
			for(int j = 0; j < 200; j++)
			{
				map[i][j] = -1;
			}
		} */
		for(int iy = 0; iy < H; iy++)
		{
			for(int jx = 0; jx < W; jx++)
			{
				cin >> map[iy][jx];
			}
		}

		int px = 0;
		int py = 0;
		int count = 0;
		while(count < 10001)
		{
			if(map[py][px] == '>')
			{
				px++;
			}
			else if(map[py][px] == '<')
			{
				px--;
			}
			else if(map[py][px] == '^')
			{
				py--;
			}
			else if(map[py][px] == 'v')
			{
				py++;
			}
			else
			{
				cout << px << " " << py << endl;
				break;
			}
			count++;
		}
		if(count >= 10001)
		{
			cout << "LOOP" << endl;
		}

	}
	

}

Measured memory_bytes: 3028
A=[]
B=["a"]
N=int(input())
if N>1:
 for i in range(N-1):
  A=B
  B=[]
  C=len(A)
  for j in range(C):
   F=len(A[j])
   D=0
   for f in range(F):
    D=max(ord(A[j][f])-95,D)
   for k in range(D):
    E=A[j]+chr(97+k)
    B.append(E)
for i in range(len(B)):
 print(B[i])

Measured memory_bytes: 14172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n,cnt=0;
	string s;
	cin >> n >> s;
	s += "*";
	for (ll i = 0; i < n; i++) {
		if (s[i] != s[i + 1])cnt++;
		else continue;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 512
#include <iostream>
#define endl '\n'

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    bool flag = false;
    while(N--)
    {
        char ch; cin >> ch;
        if(ch == 'Y')
            flag = true;
    }
    if(flag)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
V,E = map(int,input().split())
edge = []
for _ in range(E):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,-c])

inf = float('inf')

d = [inf]*V
d[0] = 0
for i in range(V):
    update = False
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
            update = True
    if not update:
        break
ans = -d[V-1]
for i in range(V):
    update = False
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
            update = True
    if not update:
        break
if ans != -d[V-1]:
    print('inf')
else:
    print(ans)

Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = A + B;
	if((ans % 2))
		cout << "IMPOSSIBLE";
	else
		cout << ans / 2;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
    int a,b;
    a=1;
    b=1;
    for (a = 1; a<=9; a++)
    {
        for (b = 1; b<=9; b++)
        {
            printf("%dx%d=%d\n",a,b,a*b);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include<map>
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
struct P{ int x,y; P(){} P(int X,int Y):x(X),y(Y){} };

map<int,int> dp[24];
int adj[24][4][23],deg[24][4],house_num;

int dfs(int id,int picked){
	if(dp[id].find(picked)!=dp[id].end()) return dp[id][picked];

	if(picked==(1<<(house_num+1))-1){
		rep(k,4) rep(a,deg[id][k]) if(adj[id][k][a]==house_num) return 1;
		return 0;
	}

	int ans=0;
	rep(k,4) rep(a,deg[id][k]) {
		int next_id=adj[id][k][a];
		if((picked&(1<<next_id))==0){
			ans+=dfs(next_id,picked|(1<<next_id));
			break;
		}
	}

	if(dp[id].size()<10000) dp[id][picked]=ans;
	return ans;
}

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int field[10][10],charch_x,charch_y,f[10][10];
		house_num=0;
		rep(i,m) rep(j,n) {
			scanf("%d",field[i]+j);
			if(field[i][j]==1) f[i][j]=house_num++;
			if(field[i][j]==2) charch_x=j,charch_y=i;
		}
		f[charch_y][charch_x]=house_num;

		rep(i,m) rep(j,n) if(field[i][j]!=0) {
			int id=f[i][j];
			dp[id].clear();
			rep(k,4){
				deg[id][k]=0;
				int x=j+dx[k],y=i+dy[k];
				while(0<=y && y<m && 0<=x && x<n){
					if(field[y][x]!=0) adj[id][k][deg[id][k]++]=f[y][x];
					x+=dx[k],y+=dy[k];
				}
			}
		}

		printf("%d\n",dfs(house_num,1<<house_num));
	}

	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int i, v; };

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	double ma = -1;
	int ans1, ans2;
	for (int x = 1; x * a * 100 <= f; x++)
		for (int y = 0; x * a * 100 + y * b * 100 <= f; y++)
			for (int z = 0; x * a * 100 + y * b * 100 + z * c <= f; z++)
				for (int w = 0; x * a * 100 + y * b * 100 + z * c + w * d <= f; w++) {
					int A = x * a * 100 + y * b * 100;
					int B = z * c + w * d;
					if (A * e >= B * 100) {
						if ((double)B / (A + B) > ma) {
							ma = (double)B / (A + B);
							ans1 = A + B;
							ans2 = B;
						}
					}
				}
	cout << ans1 << ' ' << ans2 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
void dfs(int k,vector<int> ar[],int *dp,int *vis)
{
    vis[k]=1;

    for(int i=0;i<ar[k].size();i++)
    {
        if(vis[ar[k][i]]==0)
        dfs(ar[k][i],ar,dp,vis);

        dp[k]=max(dp[k],1+dp[ar[k][i]]);
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> ar[n];
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        int y;
        cin>>y;
        ar[x-1].push_back(y-1);
    }
    int dp[n]={0};
    int vis[n]={0};
    for(int i=0;i<n;i++)
    {
        if(vis[i]==0)
        dfs(i,ar,dp,vis);
    }
    int c=0;
    for(int i=0;i<n;i++)
    c=max(c,dp[i]);
    cout<<c;
    return 0;
}

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

#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define int long long int
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 500001
#define MAXL 20
#define INF 200001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  if (!(n & 1))
  {
    cout << -1 << endl;
    return 0;
  }
  int num = 7, i = 1;
  for (int i = 0; i <= 10000000; i++)
  {
    if (num % n == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
    num *= 10;
    num += 7;
    num %= n;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  vector<vector<int>> a(3, vector<int>(3, 0));
  vector<vector<bool>> bingo(3, vector<bool>(3, false));
  rep(i, 3) rep(j, 3) cin >>a.at(i).at(j);

  int n; cin >>n;
  rep(abc, n){
    int b; cin >>b;
    rep(i, 3){
      rep(j, 3){
        if (b == a.at(i).at(j)) bingo.at(i).at(j) = true;
      }
    }
  }
  bool ok = false;
  if (bingo[0][0] && bingo[0][1] && bingo[0][2]) ok = true;
  if (bingo[1][0] && bingo[1][1] && bingo[1][2]) ok = true;
  if (bingo[2][0] && bingo[2][1] && bingo[2][2]) ok = true;
  if (bingo[0][0] && bingo[1][0] && bingo[2][0]) ok = true;
  if (bingo[0][1] && bingo[1][1] && bingo[2][1]) ok = true;
  if (bingo[0][2] && bingo[1][2] && bingo[2][2]) ok = true;
  if (bingo[0][0] && bingo[1][1] && bingo[2][2]) ok = true;
  if (bingo[0][2] && bingo[1][1] && bingo[2][0]) ok = true;

  cout <<(ok ? "Yes" : "No") <<endl;
}


Measured memory_bytes: 256
// AtCoder Beginners Selection
// ABC175A - Rainy Season
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int sum = 0;
  
  //loop
    if (S.find("RRR") < 10){
      cout << "3" << endl;
    } else if (S.find("RR")< 10){
      cout << "2" << endl;
    } else if (S.find("R")< 10){
      cout << "1" << endl;
    } else {
      cout << "0" << endl;
    }
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n;
	cin>>n;
	double a=log(n);
	double b=log(2);
	b=floor(a/b);
    a=0;
    for(ll i=0;i<b;i++)
        a=a+pow(2,i);
    ll d=pow(2,b) + a;
	cout<<d;
}


Measured memory_bytes: 512
s = list(map(int,input()))

ans = 0
for i in range(len(s) - 1):
    if s[i] == s[i+1]:
        ans += 1
        if s[i+1] == 0:
            s[i+1] = 1
        else:
            s[i+1] = 0
print(ans)

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

int main(){
    int x, y, tmp;
    while(1){
        cin >> x >> y;
        if ( !(x + y) ) break;
        if ( x > y ){
            tmp = x;
            x = y;
            y = tmp;
        }
            cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 3104
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << pPpfixed << setprecision(10);

    string s;
    cin >> s;
    if (s <= "2019/04/30")
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[1000][1000];
ll x[200000] = {};
ll y[200000] = {};
ll x2[200000] = {};
ll y2[200000] = {};

int main() {
	ll h, w, v;
	scanf("%d %d", &h, &w);
	rep(i, 0, h)rep(j, 0, w) {
		scanf("%d", &v);
		a[i][j] = v % 2;
	}

	ll cnt = 0;
	rep(i, 0, h) {
		rep(j, 0, w - 1) {
			if (a[i][j] & 1) {
				a[i][j + 1]++;

				y[cnt] = i + 1;
				x[cnt] = j + 1;
				y2[cnt] = i + 1;
				x2[cnt] = j + 2;
				cnt++;
			}
		}

		if (i != h - 1) {
			if (a[i][w - 1] & 1) {
				a[i + 1][w - 1]++;

				y[cnt] = i + 1;
				x[cnt] = w;
				y2[cnt] = i + 2;
				x2[cnt] = w;
				cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	rep(i, 0, cnt)	printf("%d %d %d %d\n", y[i], x[i], y2[i], x2[i]);

	return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string n;
    cin >> n;

    int sum = 0;
    for (int i = 0; i < n.size(); i++)
    {
        sum += (int)(n[i] - '0');
    }
    
    cout << ((stoi(n) % sum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int A,B;cin>>A>>B;
	cout<<A*B;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

struct edge { long long to, cost;};
typedef pair<long long, long long> P_dij;

vector<long long> dijkstra(const long long s, const long long n, vector< vector<edge> > const &G){
vector<long long> d = {};
  d.resize(n);
  for(int i=0; i<n; i++){
    d[i] = INF;
  }
  priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;
  d[s] = 0;
  que.push(P_dij(0, s));
  while (!que.empty()) {
    P_dij p = que.top();
    que.pop();
    long long v = p.second;
    if(d[v] < p.first)continue;
    for(int i=0;i<G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P_dij(d[e.to], e.to));
      }
    }
  }
  return d;
}

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  ll MAX = 10e14, mmax = -1;
  vector<vector<edge> > yen(n + 1), snuuk(n + 1);
  rep(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    yen[u].push_back({v, a});
    yen[v].push_back({u, a});

    snuuk[u].push_back({v, b});
    snuuk[v].push_back({u, b});
  }
  vector<ll> d1, d2, ans;
  d1 = dijkstra(s, n + 1, yen);
  d2 = dijkstra(t, n + 1, snuuk);
  for (int i = n; i > 0; --i) {
    ll t = MAX - (d1[i] + d2[i]);
    mmax = max(t, mmax);
    ans.push_back(mmax);
  }

  for (int i = n - 1; i >= 0; --i) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 19964
n, m, x, y = gets.split.map(&:to_i)
xi = gets.split.map(&:to_i)
yi = gets.split.map(&:to_i)
if !(xi.max < yi.min) || (yi.min <= x) || (xi.max >= y)
    puts "War"
else
    puts "No War"
end


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

typedef long long ll;
typedef long double ld;


#define debug(a)         cerr<<#a<<": "<<a<<endl;
#define pb               push_back
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               " "
#define nln              "\n"
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(int i=(int)a;i<(int)b;i++)
#define forn(i,a,b)      for(int i=(int)a;i>(int)b;i--)
#define mod              1000000007
#define inf              9223372036854775807



///knight moves:
///int dx[]= {-2,-1,1,2,2,1,-1,-2};
///int dy[]= {1,2,2,1,-1,-2,-2,-1};

void fileio()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

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

    cout<<fixed<<setprecision(10);
    
    int n;
    cin>>n;
    ld tot=0;
    
    while(n--)
    {
    	int x;
    	cin>>x;
    	tot=tot+1.0/x;
    }
    cout<<1.0/tot;

    return 0;
}

Measured memory_bytes: 256