akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n; cin >> n;
    vector<int> h(n+1);
    rep(i,n) cin >> h[i+1];
    vector<int> dp(100100,INF);
    dp[0]=0; dp[1]=0; dp[2]=abs(h[2]-h[1]);
    for(int i=1; i<n-1; i++){
        chmin(dp[i+2],dp[i+1]+abs(h[i+2]-h[i+1]));
        chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    //for(int i=1; i<=n; i++) cout<<dp[i]<<' ';
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

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

       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();

        System.out.println(c + " " + a + " " + b);
    }

  
}

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

int main(){
  array<int,3> x;
  cin>>x[0] >>x[1] >>x[2];
  sort(x.begin(),x.end());
  int dif = 2*x[2]-x[0]-x[1];
  cout<<(dif%2==0 ? dif/2 : dif/2+2)<<endl;
}

Measured memory_bytes: 256
import math
x,y=(int(i) for i in input().split(','))
theta=1/2*math.pi
Ansy=0
Ansx=0
while(x!=0 or y!=0):
    Ansy=Ansy+x*math.sin(theta)
    Ansx=Ansx+x*math.cos(theta)
    theta=theta-y/180*math.pi
    x,y=(int(i) for i in input().split(','))
print(int(Ansx))
print(int(Ansy))

Measured memory_bytes: 7964
N = 1723
K = 42 

print(N, K)

ans = []

l = []
for i in range(K):
    z = [1] + list(range(2+(K-1)*i, 2+(K-1)*i+(K-1)))
    l.append(z[1:])
    ans.append(z)
    print(' '.join(map(str, z)))

for i in range(2, K+1):
    for j in range(K-1):
        z = [i] + [ l[1+k][(j+(i-2)*k)%(K-1)] for k in range(K-1) ]
        ans.append(z)
        print(' '.join(map(str, z)))

count = [0 for v in range(N+1)]
for xs in ans:
    for v in xs:
        count[v] += 1

assert(sum(count) == N*K)
for i in range(1, K+1):
    assert(count[i] == K)


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

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

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

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

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

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		double p; cin>>p; p/=100;
		vector<pii> es;
		rep(i,m){
			int u,v; cin>>u>>v; u--,v--;
			es.emplace_back(u,v);
			es.emplace_back(v,u);
		}
		
		vd dp(1<<n,1);
		repi(i,1,1<<n){
			int k=31-__builtin_clz(i);
			for(int j=(i-1)&i;j&1<<k;j=(j-1)&i){
				double q=dp[j];
				for(auto t:es){
					int u,v; tie(u,v)=t;
					if((j>>u&1) && ((i-j)>>v&1))
						q*=p;
				}
				dp[i]-=q;
			}
		}
		printf("%.12f\n",dp.back());
	}
}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
bool palindrome(string s){
	int i = 0;
    int j = s.length()-1;
    while(i < j )
    { 
      if(s[i]!=s[j])
        return false;
      ++i,--j;
    }
  return true;	
}

int main(){
  	string s;
    cin >> s;
    int n = s.length();
	if(palindrome(s) && palindrome(s.substr(0,((n-1)/2)))
       && palindrome(s.substr(-1 + ((n+3)/2))))
      cout <<"Yes\n";
    else 
      cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
b = [int(_) for _ in input().split()]
a = [0] * n
a[0] = b[0]

for i in range(n-1):
    if a[i] > b[i]:
        a[i] = b[i]
    a[i+1] = b[i]

print(sum(a))


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

int main(){
    int N;
    cin >> N;
    int A[N+10];
    A[0] = 0;
    A[N+1] = 0;
    for (int i = 1; i <= N; ++i) cin >> A[i];
    int len = 0;
    for (int i = 1; i <= N+1; ++i){
        len += abs(A[i] - A[i-1]);
    }
    for (int j = 1; j <= N; ++j){
        int tr_len = 0;
        tr_len = len - abs(A[j] - A[j-1]) - abs(A[j+1] - A[j]) + abs(A[j+1] - A[j-1]);
        cout << tr_len << endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  N = N%10;
  string str;
  if(N == 3) str = "bon";
  else if(N == 0 || N == 1 || N == 6 || N == 8) str = "pon";
  else str = "hon";
  cout << str << endl;
}

Measured memory_bytes: 3628
n = raw_input()
ais = map(int , raw_input().split())
i = 0
j = 0
cumul = 0
r = 0
while(i < len(ais)):
	while(j < len(ais) and (cumul & ais[j] == 0)):
		cumul |= ais[j]
		j += 1
	r += j - i
	cumul ^= ais[i]
	i += 1
print r

Measured memory_bytes: 89920
from operator import mul
from functools import reduce
def combinations(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


N, M = map(int, input().split())
result = 0
if N >= 2:
    result += combinations(N, 2)
if M >= 2:
    result += combinations(M, 2)
print(int(result))

Measured memory_bytes: 3700
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function bsearch(a,x);l,r=1,length(a);while l<=r;m=l+div(r-l,2);if a[m]<x;l=m+1;else;r=m-1;end;end;return(l-1);end

function main()
	s = chomp(readline())
	n = length(s)
	a = 0
	b = 0
	for i in 1:n
		if i%2==0
			if s[i]=='0'
				a += 1
			else
				b += 1
			end
		else
			if s[i]=='1'
				a += 1
			else
				b += 1
			end
		end
	end
	println(min(a,b))
end
main()


Measured memory_bytes: 116744
using System;
using System.Collections.Generic;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var dic = new Dictionary<string, int>();

            var result = 0L;
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();

                var array = s.ToCharArray();
                Array.Sort(array);
                s = new string(array);

                if (dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic[s] = 0;
                }

                result += dic[s];
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 31192
import java.util.*;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in);){
			int chash =  sc.nextInt();
			int coin500 = chash / 500;
			int tmp = chash % 500;
			int coin5 = tmp / 5;
			System.out.println((coin500 * 1000) + (coin5 * 5));
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
const int N=1<<7;
int a[N];
int main()
{IOS;
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i];
	int ans=1<<30;
	for(int k=-100;k<=100;++k)
	{
		int tp=0;
		for(int i=0;i<n;++i)
			tp+=(k-a[i])*(k-a[i]);
		ans=min(ans,tp);
	}
	cout<<ans<<Endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
 
N,M = map(int,input().split())
A = list(map(int,input().split()))

BC =  [[int(i) for i in input().split()] for M in range(M)]



A.sort()
#BC.sort()
BC = sorted(BC, key=lambda x:x[1])
BC.reverse()

now = 0
end = 0

for i in range(M):
    for j in range(BC[i][0]):
        if now+j >= N:
            end = 1
            break
        if A[now+j] < BC[i][1]:
            A[now+j] = BC[i][1]
        else:
            end = 1
            break
    
    if end == 1:
        break
    now = now + BC[i][0]

print(sum(A))

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, w;
  while (cin >> n >> w, n) {
    vector<int> v(n), cnt(11, 0);
    int x = 0, y = 0;
    for (int j = 0; j < n; j++) {
      cin >> v[j];
      x = max(x, v[j] / w);
      y = max(y, ++cnt[v[j] / w]);
    }
    
    double ans = 0.01;
    for (int j = 0; j <= x; j++) {
      ans += (double)(x - j) / x * cnt[j] / y;
    }
    printf("%.10f\n", ans);
  }

  return 0;
}


Measured memory_bytes: 3032
number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
suuji = int(input())
print(number[suuji-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin>>s>>n;
  int a=s[0]-'0',c=s[0]-'0',b=0;
  for(int i=1;i<s.size();i+=2){
    int p=s[i+1]-'0';
    if(s[i]=='+')a+=p,b+=c,c=p;
    else a*=p,c*=p;
  }
  b+=c;
  if(b==n&&a!=n)cout<<'M';
  else if(a==n&&b!=n)cout<<'L';
  else if(a==b&&a==n)cout<<'U';
  else cout<<'I';
  cout<<endl;
  return 0;
}

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

using namespace std;

typedef long long LL;
#define N 6200

LL n,mod,f[N][N],g[N][N],ans;

void upd(LL &x,LL y){x=(x+y)%mod;}

LL C2(LL x){return x*(x-1)%mod;}

int main(){
	scanf("%lld%lld",&n,&mod);
	f[0][0]=1;;
	for (LL i=0;i<=n*3;++i){
		upd(f[i][0],g[i][0]);
		g[i][0]=f[i][0];
		for (LL j=0;j<=n*3;++j){
			upd(f[i+3][j],C2(n*3-i-1)*f[i][j]);
			upd(f[i+2][j+1],f[i][j]*(n*3-i-1));
			if (j) upd(f[i+1][j-1],f[i][j]);
			if (j) upd(g[i+3][j],C2(n*3-i-1)*g[i][j]);
			if (j) upd(g[i+2][j-1],g[i][j]*(n*3-i-1));
			upd(g[i+1][j+1],g[i][j]);
		}
	}
	for (LL i=0;i<=n*3;++i) upd(ans,g[n*3][i]);
	printf("%lld\n",ans);
	
	return 0;
}
			

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

using namespace std;

const int maxn = 100010;

typedef long long ll;

priority_queue<ll> pq;
map<ll, int> mp;

int n, l[maxn], dep[maxn], sz[maxn], w[maxn], vis[maxn], e_u[maxn], e_v[maxn], tot, e = 0;
ll D[maxn], S[maxn];

struct Edge {
	int v, x;
} E[maxn];

inline void addEdge(int u, int v) {
	E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs1(int u) {
	sz[u] = 1;
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		dep[v] = dep[u] + 1;
		dfs1(v);
		sz[u] += sz[v];
	}
}

void dfs2(int u) {
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		S[v] = S[u] + n - 2 * sz[v];
		dfs2(v);
	}
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &D[i]);
	for (int i = 1; i <= n; i++) {
		mp[D[i]] = i;
		pq.push(D[i]);
		w[i] = 1;
	}
	vis[0] = 1;
	while (pq.size() > 1) {
		ll v = pq.top(); pq.pop();
		int u = mp[v];
		vis[u] = 1;
		if (!vis[mp[v + 2 * w[u] - n]]) {
			int t = mp[v + 2 * w[u] - n];
			w[t] += w[u];
			addEdge(t, u);
			++ tot;
			e_u[tot] = t; e_v[tot] = u;
		} else {
			puts("-1");
			return 0;
		}
	}
	int r = mp[pq.top()];
	dfs1(r);
	for (int i = 1; i <= n; i++) S[r] += dep[i];
	dfs2(r);
	for (int i = 1; i <= n; i++) {
		if (S[i] != D[i]) {
			puts("-1");
			return 0;
		}
	}
	for (int i = 1; i <= tot; i++) printf("%d %d\n", e_u[i], e_v[i]);
	return 0;
}

Measured memory_bytes: 15092
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=1e5+10;
int N,H;
int a[MAXN];
int b[MAXN];
int orda[MAXN];
int ordb[MAXN];
bool cmpa(int u,int v){
    return a[u]>a[v];
}
bool cmpb(int u,int v){
    return b[u]>b[v];
}
void solve(){
    ios::sync_with_stdio(false);
    cin>>N>>H;
    for(int u=0;u<N;u++){
        cin>>a[u]>>b[u];
        orda[u]=u;
        ordb[u]=u;
    }
    sort(orda,orda+N,cmpa);
    sort(ordb,ordb+N,cmpb);
    int ia=orda[0],ans=0;
    if(b[ia]>=H||a[ia]>=H){
        cout<<1;
        return;
    }
    int remain=H;
    for(int id=0;id<N&&b[ordb[id]]>a[ia]&&remain>0;id++){
        remain-=b[ordb[id]];
        ans++;
    }
    if(remain>0){
        if(remain%a[ia])ans+=1+remain/a[ia];
        else ans+=remain/a[ia];
    }
    cout<<ans;
}
int main()
{
    // freopen("in.txt","r",stdin);
    solve();
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

// 最小公倍数
ll lcm(ll a, ll b){
	
	ll x = a * b;
	  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
	  /* ユークリッドの互除法 */
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return x/b;

}

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	/*
	ll cntc = b/c - ceil((double)a/c);
	ll cntd = b/d - ceil((double)a/d);
	ll cntlcm = b/lcm(c,d) - ceil((double)a/lcm(c,d));
	
	cout << (b-a+1) - cntc - cntd + cntlcm << endl;
	*/
	
	// b以下
	ll resb = b - b/c - b/d + b/lcm(c,d);
	
	// a未満
	ll resa = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c,d);
	
	cout << resb - resa << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      int T = sc.nextInt();
      if(N%X==0){
        System.out.println(N/X*T);
      }else{
        System.out.println((N/X+1)*T);
      }
    }
}

Measured memory_bytes: 35640
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();

    let mut prev:String = s[0].to_string();
    let mut crt:String = String::new();
    let mut ans:u32 = 1;
    for i in 1..s.len() {
        crt.push(s[i as usize]);
        if prev != crt {
            prev = crt;
            crt = String::new();
            ans += 1;
        }
    }

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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
    int H, W;

void f() {
    for(int i = 0; i <= W+1; i++) cout << "#";
    cout << endl;
}
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    f();
    while(H--) {
        cout << "#";
        string s;
        cin >> s;
        cout << s;
        cout << "#" << endl;
    }
    f();
    return 0;
}


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

function multiplier2(x)
    ret = 0
    while mod2(x) == 0
        x /= 2
        ret += 1
    end
    return(ret)
end

function main()
    n = parseInt(readline())
    a = parseMap(split(readline()))

    ans = 0
    for i in 1:n
        ans += multiplier2(a[i])
    end

    println(ans)
end

main()


Measured memory_bytes: 124348
#include<iostream>
using namespace std;
int main() {
  int north,west,top,i,t;
  string s;
  while(1){
    cin>>i;
    north=2,west=3,top=1;
    if(i==0) break;
    for(int j=0; j<i; j++) {
      cin>>s;
      if(s=="north")t=north,north=top,top=7-t;
      if(s=="south")t=top,top=north,north=7-t;
      if(s=="west")t=top,top=7-west,west=t;
      if(s=="east")t=top,top=west,west=7-t;
    }
    cout<<top<<"\n";
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define X first
#define Y second
#define N 200010
#define M 3000010
typedef long long ll;
typedef pair<int,int> pii;

const int Mod=1000000007;
const ll INF=1ll<<60;


int n,t,ans=1;
int lis[N];

int main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);

	
	scanf("%d",&n);
	for (int i=1;i<=n;i++) 
	{
		int x;
		scanf("%d",&x);
		if (x<2*t+1) ans=1ll*ans*(t+1)%Mod;
		else lis[++t]=x;
	}
	while (t) ans=1ll*ans*t%Mod,t--;
	printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 640
n = [0,1,2]
d = dict(zip(["A","B","C"],[0,1,2]))
d_ = dict(zip([0,1,2],["A","B","C"]))
while(1):
    try:
        a,b = input().split(",")
        temp = n[d[a]]
        n[d[a]] = n[d[b]]
        n[d[b]] = temp
    except EOFError:
        print(d_[n.index(0)])
        break



Measured memory_bytes: 5564
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int> a(N), b(N);
    for(int i=0;i<N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    ll suma = 0, sumb=0;
    for (int i = 0; i < N; i++) {
        suma+=a[i];
        sumb+=b[i];
    }
    if(sumb>suma){
        cout<<-1<<endl;
        return 0;
    }

    vector<int> plus, minus;
    for (int i = 0; i < N; i++) {
        if(a[i]>=b[i]){
            plus.push_back(a[i]-b[i]);
        }else{
            minus.push_back(a[i]-b[i]);
        }
    }
    sort(all(plus));
    sort(all(minus));
    reverse(all(plus));

    int pos=0;
    ll res=0, rest=0;
    for(auto m : minus){
        if(rest+m<0){
            rest+=plus[pos];
            pos++;
            res++;
        }
        rest+=m;
        res++;
    }

    cout<<res<<endl;
    

    return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>

int main(void)
{
char s[3][3];
int i;
int j;
for(i=0;i<3;i++){
	for(j=0;j<3;j++){
		
		scanf("%c",&s[i][j]);
		if(j==2){
			scanf("%*c");
		}
	}
	
}
printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int func(int x) {
  if (x < 10) return x;
  else return x % 10 + func(x/10);
}

int main() {
  int n;
  cin >> n;
  int s = func(n);
  if (n % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int n, m, k, a[505][505], b[505][505];
char s[3][3]; 

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	s[0][0] = 'R', s[1][0] = 'G', s[0][1] = 'Y', s[1][1] = 'B';
	for(int op = 0, cnt = 0, i = -m - 1; i <= n; i++, cnt++)
	{
		if(cnt >= k) cnt = 0, op ^= 1; 
		for(int j = 1; j <= m; j++)
			if(i + j >= 1 && i + j <= n) a[i + j][j] = op; 
	}
	for(int op = 0, cnt = 0, i = n + m + 1; i >= 1; i--, cnt++)
	{
		if(cnt >= k) cnt = 0, op ^= 1; 
		for(int j = 1; j <= m; j++)
			if(i - j <= n && i - j >= 1) b[i - j][j] = op; 
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++) printf("%c", s[a[i][j]][b[i][j]]);
		puts("");
	}
	return 0; 
}


Measured memory_bytes: 5736
#include<bits/stdc++.h>
using namespace std;
 
const int N=200010;
int a[N],b[N],n;
 
int main(){
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	reverse(b+1,b+1+n);
	int l=0,r=0,t=0,L=0,R=0;
	for(int i=1;i<=n;i++) if(a[i]==b[i]) {
		if(!l) l=i,r=i,t=a[i];
		else r++;
	}
	if(!l){
		printf("Yes\n");
		for(int i=1;i<=n;i++) printf("%d ",b[i]);
		return 0;
	}
	for(int i=1;i<=n;i++) if(a[i]==t || b[i]==t) {L=i-1;break;}
	for(int i=n;i>=1;i--) if(a[i]==t || b[i]==t) {R=i+1;break;}
	if(L+n-R+1<(r-l+1)) printf("No\n");
	else{
		for(int i=1;i<=min(L,r-l+1);i++) swap(b[i],b[l+i-1]);
		for(int i=1;i<=r-l+1-min(r-l+1,L);i++) swap(b[n-i+1],b[r-i+1]);
		printf("Yes\n");
		for(int i=1;i<=n;i++) printf("%d ",b[i]);
	}
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n), b(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) scanf("%d", &b[i]);
	
	i64 tmp = 0, count = 0;
	std::vector<int> vec;
	for(int i = 0; i < n; i++) {
		if(a[i] < b[i]) {
			tmp += b[i] - a[i];
			count++;
		} else if(a[i] > b[i]) {
			vec.push_back(a[i] - b[i]);
		}
	}
	sort(begin(vec), end(vec)); reverse(begin(vec), end(vec));
	
	for(auto v : vec) {
		if(tmp <= 0) break;
		tmp -= v;
		count++;
	}
	if(tmp > 0) printf("-1\n");
	else printf("%d\n", count);
	return 0;
}


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

constexpr int MAX_N = 1e5+9;

int N;
vector<vector<int>> edges(MAX_N+1), costs(MAX_N+1);
int colors[MAX_N+1];

void dfs(int cur) {
  queue<int> que;
  que.push(cur);

  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i{}; i < edges[u].size(); ++i) {
      int v = edges[u][i];
      int w = costs[u][i];
      if (colors[v] >= 0)
        continue;
      colors[v] = w % 2 == 0 ? colors[u] : !colors[u];
      que.push(v);
    }
  }
}

int main() {
  fill_n(colors, MAX_N+1, -1);

  cin >> N;

  for (int i{}; i < N - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[u].push_back(v);
    costs[u].push_back(w);
    edges[v].push_back(u);
    costs[v].push_back(w);
  }

  colors[1] = 0;
  dfs(1);
  for (int i{1}; i <= N; ++i) {
    cout << colors[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 11904
#include <iostream>
        #include <vector>
        #include <set>
        #include <queue>
        #include <algorithm>
        #include <string>
        #include <cmath>
        using namespace std;
        #define MAX 100
        int is[MAX];
        int h, w;
        string s[8];
        
        // ある1行の終了位置を探すメソッド
        int searchRowEnd(int start, int row) {
            int endCol = -1;     // 終了位置。初期は未設定状態として-1を使用。
            bool onLoad = false; // 現在開始位置～終了位置の間の列かどうか（路上判定と呼んでおく）
            for (int col = 0; col < w; col++) {
                // 終了位置が未設定の時のみ路上判定をする。
                // なぜなら終了位置確定後もtrueになったら困るから
                if (endCol == -1) { 
                    onLoad = col >= start;
                }
                // 路上以外で#がある時　||　開始位置でいきなり#が無い時　例外を返す。
                if (!onLoad && s[row][col] == '#' || col == start && s[row][col] != '#') {
                    return -1;
                }
                // 路上で#がついていれば、道が続いてるということでとりあえず終了位置更新
                if (onLoad && s[row][col] == '#') {
                    endCol = col;
                } else {
                    // 道が続いてなかったら路上ではなくなったとする。
                    // これ以降は終了位置は更新されないため終了位置確定とも言える。
                    onLoad = false;
                }
            }
            // 終了位置確定したものを返す。
            return endCol;
        }
        
        bool judge() {
            // 最初は左上
            int start = 0;
        	for (int row = 0; row < h; ++row) {
        	    // ある行の#の連続の終了位置が次の行の開始位置になるはずだよね　のロジックなので
        	    // 今の行の終了位置を探して、次の行の開始位置にセットしてループ。
        	    // -1が帰って来たときは何かしら条件を満たしてないとする。
        	    start = searchRowEnd(start, row);
        	    if (start == -1) {
        	        return false;
        	    }
        	}
        	// 一番最後は右下の位置じゃないとだめよね
        	return start == w - 1;
        }
        
        int main(void) {
        	cin >> h >> w;
        	for (int i = 0; i < h; ++i) {
        		cin >> s[i];
        	}
        	bool f = judge();
        	cout << (f ? "Possible" : "Impossible") << endl;
        	return 0;
        }

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

int main(void){
        int a,sum=0;
        cin>> a;
	int arr[3010];
	for(int i=0;i<a;i++){
		cin>>arr[i];
		sum+=arr[i]-1;
	}
	cout<<sum<<endl;
        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
vector<int>G[100005];
int dist[100005];
void dfs1(int x,int p){
	for(int i:G[x])if(i!=p){
		dist[i]=dist[x]+1;
		dfs1(i,x);
	}
}
int dfs2(int x,int p){
	int res=0,mn=inf;
	for(int i:G[x])if(i!=p){
		int j=dfs2(i,x);
		res+=max(1ll,j);chmin(mn,j);
	}
	if(mn==0)res--;
	return res;
}
signed main(){
	cin>>N;
	rep(i,N-1){
		int a,b;cin>>a>>b;
		G[a].pb(b);G[b].pb(a);
	}
	dfs1(0,0);
	int par,mx=0;
	rep(i,N)if(chmax(mx,dist[i]))par=i;
	cout<<dfs2(par,par)+1<<endl;
}


Measured memory_bytes: 16032
#include<bits/stdc++.h>
using namespace std;
deque<int> que;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int x;
		scanf("%d",&x);
		if(x == 0)
		{
			int y, z;
			scanf("%d%d",&y,&z);
			if(y == 0) que.push_front(z);
			else que.push_back(z);
		}
		else if(x == 1) 
		{
			int y;
			scanf("%d",&y);
			printf("%d\n",que[y]);
		}
		else if(x == 2) 
		{
			int y;
			scanf("%d",&y);
			if(y == 0) que.pop_front();
			else que.pop_back();
		}
	}
	return 0;
}


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

int main()
{
    ll n,W,i,j,sum=0;
    cin>>n>>W;

    ll A[n+1][2];
    for(i=1;i<=n;i++)
    {
        cin>>A[i][0]>>A[i][1];
        sum+=A[i][1];
    }

    ll dp[sum+1][n+1];

    for(i=1;i<=sum;i++)
        dp[i][0]=999999999999999;

    for(i=0;i<=n;i++)
        dp[0][i]=0;

    for(j=1;j<=n;j++)
    {
        for(i=1;i<=sum;i++)
        {
            if(i>=A[j][1])
                dp[i][j]=min(dp[i][j-1],dp[i-A[j][1]][j-1]+A[j][0]);
            else
                dp[i][j]=dp[i][j-1];
        }
    }
    for(i=sum;i>=0;i--)
    {
        if(dp[i][n]<=W)
        {
            cout<<i<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 79104
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

vector <int> g[maxn];
int a[maxn];
int k, res = 0;

int dfs (int v, int parent = -1) {
	int mx = 0;
	for (auto u : g[v]) 
		if (u - parent) {
			int cur = dfs(u, v);
			if ((v == 0 && cur == k) || (v != 0 && cur == k - 1))
				res++;
			else
				mx = max(mx, cur + 1);
		}
	return mx;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		--a[i];
		if (i)
			g[a[i]].push_back(i);
		else
		if (a[i])
			res++;
	}
	dfs(0);
	cout << res << "\n";
}



Measured memory_bytes: 10752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

// https://yamakasa.net/atcoder-abc-130-c/

int main(void) {

    ll w,h,x,y;
    cin >> w >> h >> x >> y;

    // double mid_x = w/2, mid_y = h/2;
    double area = (double)w*h/2;

    short check = 0;

  if (w % 2 == 1 || h % 2 == 1) {
   check = 0;
  } else 
    // if (((double)x == mid_x && (double)y == mid_y)||((double)y == mid_x && (double)x == mid_y)) {
    if ((x == w/2 && y == h/2)||( y == w/2 && x == h/2)) {
        check = 1;
    }

    cout << area << " " << check << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int maxn=2e3+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,a[maxn],k,ans[maxn],wmh[maxn];
inline int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ans;
}
signed main(){
	n=read();k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	int tot=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[i]>a[j])wmh[i]++,ans[i]++;
		}
		for(int j=1;j<i;j++){
			if(a[i]>a[j])ans[i]++;
		}
	}
	for(int i=1;i<=n;i++){
		ans[i]=(ans[i]*(k-1)%mod+wmh[i])%mod;
	}
	for(int i=1;i<=n;i++){
		ans[i]=(ans[i]+wmh[i])*k%mod;
		//printf("%d %d\n",i,ans[i]);
		tot=(tot+ans[i])%mod;
	}
	printf("%lld\n",tot*ksm(2,mod-2)%mod);
	return 0;
}
/*
3 3
2 4 1
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(k>((n-2)*(n-1))/2)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    vector< pair<ll,ll> > v;
    for(int i=2;i<=n;i++)
    {
        v.pb(mp(1,i));
    }
    ll t=((n-2)*(n-1))/2;
    ll one=2,two=3;
    while(t!=k)
    {
        v.pb(mp(one,two));
        two++;
        t--;
        if(two==n+1)
        {
            one++;
            two=one+1;
        }
    }
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    lld a[5] = {0};
    rep(i, 0, n){
        char s[11];
        scanf("%s", s);
        if(s[0] == 'M'){
            a[0]++;
        }
        if(s[0] == 'A'){
            a[1]++;
        }
        if(s[0] == 'R'){
            a[2]++;
        }
        if(s[0] == 'C'){
            a[3]++;
        }
        if(s[0] == 'H'){
            a[4]++;
        }
    }
    lld x = 0;
    rep(i, 0, 3){
        rep(j, i+1, 4){
            rep(k, j+1, 5){
                x += a[i] * a[j] * a[k];
            }
        }
    }
    printf("%lld", x);

    return 0;
}

Measured memory_bytes: 128
// AOJ 0615 Cake 2
// 2018.2.27 bal4u

#include <stdio.h>

int a[2002];
long long dp[2002][2002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, f, i, j, l, r, nl, nr;
	long long k, ans;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();

	f = (n-1) & 1;
	for (i = 0; i < n; i++, f = !f) {
		l = -1, nl = 0, r = i-1, nr = i-2;
		j = n; while (j--) {
			l++;
			if (++ r == n)  r = 0;
			if (++nl == n) nl = 0;
			if (++nr == n) nr = 0;

			if (f) {
				if (a[l] > a[r]) dp[l][r] = dp[nl][r];
				else             dp[l][r] = dp[l][nr];
	        } else {
				dp[l][r] = dp[nl][r] + a[l];
				k = dp[l][nr] + a[r];
				if (k > dp[l][r]) dp[l][r] = k;
			}
		}
	}

	ans = 0;
	j = n-2; for (i = 0; i < n; i++) {
		if (++j == n) j = 0;
		if (dp[i][j] > ans) ans = dp[i][j];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 33048
//ΔARC095B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111111;
int n,a[N];
int main()
{
	int i,x=0,y=-1,z;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+1){
		scanf("%d",a+i);
		if(a[i]>x)
			x=a[i],z=i;
	}
	for(i=1;i<=n;i=i+1)
		if(i!=z&&min(a[i],x-a[i])>min(y,x-y))
			y=a[i];
	printf("%d %d",x,y);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define int long long

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

  vector<int> a(50);
  rep(i,50) a[i] = i;

  int div = k/50;
  int mod = k%50;

  rep(i,50) a[i] += div;
  rep(i, mod) {
    a[i] += 50;
    rep(j, 50) {
      if(j == i) continue;
      a[j]--;
    }
  }
  cout << 50 << endl;
  rep(i,50) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 3616
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M = [int(x) for x in input().split()]
INF = float('inf')
edges = []
d = [[INF]*N for _ in range(N)]
for _ in range(M):
    a,b,c = [int(x) for x in input().split()]
    a-=1
    b-=1
    d[a][b]=c
    d[b][a]=c
    edges.append([a,b,c])

warshall_floyd(d,N)
cnt = 0
for e in edges:
    if(d[e[0]][e[1]]!=e[2]):
        cnt+=1
print(cnt)


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

 using namespace std;
 int main() {
   string N;
   cin >> N;
   if (N.at(0) == N.at(1) && N.at(1) == N.at(2)) cout << "Yes" << endl;
   else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


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

int main(){
    string s;
    cin >> s;
    int scount = 0;
    int rem = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'S') scount++;
        else if(scount > 0){
            scount--;
            rem += 2;
        }
    }
    cout << s.size()-rem << endl;
}

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

const int len = 100005;
//プロセスを表す構造体
typedef struct pp{
    char name[100];
    int t;
} P;

P Q[len];
int head=0, tail=0;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % len;
}
P dequeue(){
    P x = Q[head];
    head = (head + 1) % len;
    return x;
}

int main(){
    int n, q, fintime = 0, index=0;
    cin >> n >> q;
    P outdata[n];
    for(int i=0; i<n; i++){
        P x;
        cin >> x.name >> x.t;
        enqueue(x);
    }

    while(head != tail){
        P x = dequeue();
        if(x.t <= q){
            fintime += x.t;
            strcpy(outdata[index].name, x.name);
            outdata[index].t = fintime;
            index += 1;
        }
        else{
            fintime += q;
            x.t -= q;
            enqueue(x);
        }
    }

    for(int i=0; i<n; i++){
        cout << outdata[i].name << " " << outdata[i].t << endl;
    }

    return 0;
}


Measured memory_bytes: 18304
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [0] * N 
for i in range(N):
    b[i] = int(input())
A = [A1,A2,A3]
B = [[0]*3,[0]*3,[0]*3]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                B[i][j] = 1
if B[0] == [1,1,1]:
    print("Yes")
elif B[1] == [1,1,1]:
    print("Yes")
elif B[2] == [1,1,1]:
    print("Yes")
elif B[0][0] == 1 and B[1][0] == 1 and B[2][0] == 1:
    print("Yes")
elif B[0][1] == 1 and B[1][1] == 1 and B[2][1] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][2] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    print("Yes")
else:
    print("No")

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

#define     ll          long long
#define     sz(s)       s.size()
#define     pb          push_back
#define     ff          first
#define     ss          second
#define     mk          make_pair
#define     pii         pair<int, int>
#define     pll         pair<long long int, long long int>
#define     ALL(s)      (s).begin(), (s).end()
#define     rALL(s)     (s).rbegin(), (s).rend()
#define     fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     show(x)     cout << #x << " : "<< x << endl;
#define     fr(n)       for(int i=0; i<n; i++)
#define     M           100005
#define     limit       -pow(2, 32)
#define     fuck        return 0;

using namespace std;




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

 ll ans = 1000 * (n/500);
 ans += 5*((n%500) / 5);

 cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		
		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		if(x>=a&&x<=a+b) out.println("YES"); else out.println("NO");
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 20564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var list = new List<int>() {1, 2, 3};
            list.Remove(A);
            list.Remove(B);
            Console.WriteLine(list.FirstOrDefault());
        }
    }
}

Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }


signed main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	while (true)
	{
		C -= B;
		if (C <= 0)
		{
			Yes();
			return 0;
		}

		A -= D;
		if (A <= 0)
		{
			No();
			return 0;
		}
	}
}




Measured memory_bytes: 3600
#include <stdio.h>

int main()
{
	long A, B;
	scanf("%d %d", &A, &B);
	
	if(A > B){
		int temp = A;
		A = B;
		B = temp;
	}
	
	int multiple = 1;
	while(true){
		long X = A * multiple;
		if(X % B == 0){
			break;
		}
		multiple ++;
	}
	
	printf("%ld\n", A * multiple);
	
	return 0;
}



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

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n, w; cin >> n >> w;
    vector<ll> dp[n+1];
    vector<ll> tmp(w+1, -1);
    rep(i, n+1) {
        dp[i] = tmp;
    }
    vector<ll> values(n);
    vector<ll> weights(n);
    rep(i, n) {
        cin >> values[i] >> weights[i];
    }
    rep(i, n+1) {
        rep(j, w+1) {
            if(i == 0){
                dp[i][j] = 0;
                continue;
            // }
            // if(i == 1) {
            //     if(j < weights[i]) {
            //         dp[i][j] = 0;
            //     } else {
            //         dp[i][j] = dp[i][j-weights[i]] + values[i];
            //     }
            } else {
                if(j < weights[i-1]) {
                    dp[i][j] = dp[i-1][j];
                } else {
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]] + values[i-1]);
                }
            }
        }
    }
    cout << dp[n][w] << endl;
}



Measured memory_bytes: 10996
import numpy as np

N = int(input())
xyh = []
xx = []
yy = []
hh = []
for i in range(N):
    X, Y, H = (int(i) for i in input().split())  
    xx.append(X)
    yy.append(Y)
    hh.append(H)
bes = hh.index(max(hh))

for x in range(101):
  for y in range(101):
    h = abs(x - xx[bes]) + abs(y - yy[bes]) + hh[bes]
    ok = True

    for xi, yi, hi in zip(xx, yy, hh):
      if hi != max(h - abs(x - xi) - abs(y - yi), 0):
        ok = False
    
    if ok:
      print('{} {} {}'.format(x, y, h))
      exit()
      

Measured memory_bytes: 13692
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> pii;
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false);
int main(){
	int a, b; cin>>a>>b;
	cout<<(a + b < 24 ? a + b : a + b - 24)<<endl;
}


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

function main()
	s = readline() |> chomp
	t = readline() |> chomp
	k = 0
	for i in 1:3
		if s[i]==t[i]
			k += 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 165532