akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> p;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1000000000000000000LL;//1e18
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
rep(s,100000000){
    int n,x;cin >> n >> x;
    if(n==0&&x==0)return 0;
    int cnt=0;
    rep2(i,1,n-1)rep2(j,i+1,n)rep2(k,j+1,n+1){
        if(i+j+k==x)cnt++;
    }
    cout << cnt << endl;
}
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=400 && x<=599)
  {cout<<"8";}
  else if(x>=600 && x<=799)
  {cout<<"7";}
  else if(x>=800 && x<=999)
  {cout<<"6";}
  else if(x>=1000 && x<=1199)
  {cout<<"5";}
  else if(x>=1200 && x<=1399)
  {cout<<"4";}
  else if(x>=1400 && x<=1599)
  {cout<<"3"<<endl;}
  else if(x>=1600 && x<=1799)
  {cout<<"2";}
  else if(x>=1800 && x<=1999)
  {cout<<"1";}
  
return 0;
}

Measured memory_bytes: 3628
def main():
  from bisect import bisect
  n,k,*a=map(int,open(0).read().split())
  a.sort()
  i=bisect(a,0)
  a,b=a[i:],a[i-1::-1]
  n,m=len(a),len(b)
  ok=10**18
  ng=-ok
  while ok-ng>1:
    x=(ok+ng)//2
    s=0
    if x>=0:
      s+=n*m
      t=0
      i=n
      for y in a:
        while i and a[i-1]*y>x:i-=1   
        t+=i
        if y*y<=x:t-=1
      s+=t//2
      t=0
      i=m
      for y in b:
        while i and b[i-1]*y>x:i-=1
        t+=i
        if y*y<=x:t-=1
      s+=t//2
    else:
      i=m
      for y in a:
        while i and b[i-1]*y<=x:i-=1
        s+=m-i
    if s>=k:ok=x
    else:ng=x
  print(ok)
main()

Measured memory_bytes: 98056
n=int(input())
A=list(map(int, input().split()))
A=sorted(A)

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

half=max(A)/2
MAX=max(A)
now=MAX
ans=0
for a in A:
    if now>abs(a-half):
        now=abs(a-half)
        ans=a

print(MAX,ans)


Measured memory_bytes: 14052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int i, j, k, l, len;
	long long T;
	char S[15], temp[20], num[15];
	scanf("%s", &S);
	T = 0;
	len = strlen(S);
	for (i=0;i<len;i++) {
		temp[2*i] = S[i];
		temp[2*i+1] = 0;
	}
	for (j=0;j<(1<<(len-1));j++) {
		k = j;
		l = 0;
		for (i=0;i<len;i++) temp[2*i+1] = 0;
		while (k) {
			if (k&1) temp[2*l+1] = '+';
			l++; k >>= 1;
		}
		l = 0;
		for (i=0;i<2*len;i++) {
			if (temp[i] == '+') {
				memmove(num, S+(l/2), (i+1-l)/2);
				T += atoll(num);
				l = i+1;
				memset(num, 0, 10);
			}
		}
		memmove(num, S+(l/2), (i+1-l)/2);
		T += atoll(num);
		memset(num, 0, 15);
	}
	printf("%lld\n", T);

	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**5)
t = int(input())
l = [list(map(int,input().split())) for _ in range(t)]

def f(n):
    if n in memo:
        return memo[n]
    else:
        temp = min(
            d*n,
            d*(n-(n//2)*2)+a+f(n//2),
            d*(((n+1)//2)*2-n)+a+f((n+1)//2),
            d*(n-(n//3)*3)+b+f(n//3),
            d*(((n+2)//3)*3-n)+b+f((n+2)//3),
            d*(n-(n//5)*5)+c+f(n//5),
            d*(((n+4)//5)*5-n)+c+f((n+4)//5)
        )
        memo[n] = temp
        return temp

for i in range(t):
    n,a,b,c,d = l[i]
    memo = {}
    memo[1] = d
    memo[0] = 0
    print(f(n))

Measured memory_bytes: 10900
function Main(input) {
        input = input.split(' ');
        var items = input.map(function(item) {
            return parseInt(item, 10)
        });
        var a = items[0];
        var b = items[1];
        var result;
        if(b%a === 0) {
            result = a + b;
        }else{
            result = b - a
        }


        console.log(result)
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	
	ll n;cin>>n;
	// if(n==1 || n==2){
	// 	cout<<"No"<<endl;
	// 	return 0;
	// }

	bool triangular = 0;
	ll x = 0;
	For(i,1,n+1){
		x += i;
		if(x==n) {triangular = 1;x=i;break;}
	}

	if(!triangular){
		cout<<"No"<<endl;return 0;
	}
	x++;
	vector<ll> ans[x];
	ll c = 0;
	ll index = 0;
	ll next_index = 1;

	while(c<n){
		// cout<<index<<" "<<next_index<<endl;
		ans[index].pb(c);
		ans[next_index++].pb(c++);
		if(ans[index].size()==x-1) {
			index++;
			next_index=index+1;
			if(next_index>=x) next_index=0;
		}
	}

	cout<<"Yes"<<endl;
	cout<<x<<endl;
	For(i,0,x){
		cout<<ans[i].size()<<" ";
		For(j,0,ans[i].size()){
			cout<<ans[i][j]+1<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
    #define ll  long long
    #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define rep(i,a,b)  for(ll i=a;i<b;i++)
    #define per(i,a,b)  for(ll i=b-1;i>=a;i--)
    #define pb push_back
    #define Max(x,y,z) max(x,max(y,z))
    #define f first
    #define s second
    #define lbd lower_bound
    #define sz(x)       (ll)x.size()
    #define pi 3.1415926536
    #define mod 1000000007
    #define MOD 998244353
    #define maxi 100000000000000000
    using namespace std;
    const int N=5005;
/*    vector<ll> adj[N];
    bool real_vis[N];
    ll dfs(ll x,bool vis[],bool rec[])
{   //cout<<x<<" ";
    vis[x]=1;
    rec[x]=1;
    for(auto y:adj[x])
        if(!vis[y] && dfs(y,vis,rec)) return true;
        else if(rec[y]) return true;
    rec[x]=false;
    return false;
}*/
    /*bool isprime(ll x)
    {
        for(ll i=2;(i*i)<=x;i++)
        {
            if(x%i==0) return 0;
        }
        return 1;
    }*/
    /*ll power(ll x,ll n)
    {
        ll res=1;
        while(n>0){
        if(n%2) res=(res*x)%mod;
        x=(x*x)%mod;
        n=n/2;}
        return res;
    }*/
    void solve()
    {
                ll n,m,z,h,a,b,c,d,e,x=0,y=0;
                cin>>n;
                ll ar[n],br[n],cr[n-1];
                rep(i,0,n) cin>>ar[i];
                rep(i,0,n) cin>>br[i];
                rep(i,0,n-1) cin>>cr[i];
                ll ans=br[ar[0]-1];
                //cout<<ans<<" ";
                rep(i,1,n)
                {
                    ans+=br[ar[i]-1];
                    if(ar[i]-ar[i-1]==1)
                        ans+=cr[ar[i-1]-1];
                        //cout<<ans<<" ";
                }
                cout<<ans;








    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 2 * n;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i]){
            ans--;
        }
        if(a[i] == b[i] && b[i] == c[i]){
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}

int main(){
    int A[3];

    scanf("%d%d%d", &A[0], &A[1], &A[2]);

    qsort(A, 3, sizeof(int), cmp);

    int cost = 0;
    for (int i = 1; i < 3; ++i){
        cost += A[i] - A[i-1];
    }

    printf("%d", cost);

    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

type dish struct{ a, b, sum int }
type dishes []dish

func (d dishes) Len() int           { return len(d) }
func (d dishes) Swap(i, j int)      { d[i], d[j] = d[j], d[i] }
func (d dishes) Less(i, j int) bool { return d[i].sum > d[j].sum }

func main() {
	n := scanInt()
	ds := dishes(make([]dish, n))
	for i := range ds {
		a, b := scanInt(), scanInt()
		ds[i].a, ds[i].b, ds[i].sum = a, b, a+b
	}
	sort.Sort(ds)

	ans := 0
	for i := 0; i < n; {
		ans += ds[i].a
		i++
		if i < n {
			ans += -ds[i].b
			i++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
 
#define Komachi is retarded
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define bcnt __builtin_popcount
#define clz __builtin_clz
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define LB lower_bound
#define UB upper_bound
#define IN insert
#define lp (p<<1)
#define rp (p<<1|1)
#define lson l,mid,lp
#define rson mid+1,r,rp
#define LL long long
#define uLL unsigned long long
#define DB double 
#define INF 1000000000
#define EPS 1e-6
#define debug(a,p) cerr<<a<<p;
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;i--)
 
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0;}
 
#define M 500007

int n,Ans;
string s;
int main(){
	cin>>s;
    n=s.length();
    REP(i,0,n) REP(j,i+1,n) if(!(i==0 && j==n-1) && (j-i+1)%2==0){
        bool Can=1;
        int mid=(j-i>>1)+1;
        REP(k,0,mid) Can&=s[i+k]==s[i+mid+k];
        if(Can)Ans=max(Ans,j-i+1);
    }
    printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int MOD = 1e9 + 7;



int main() {
   ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
   int n;
   cin >> n;
   string s , t;
   cin >> s >> t;
   string res = "";
   for(int i = 0 ; i < n ; ++i)
      res.pb(s[i]) , res.pb(t[i]);
   cout << res << "\n";
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    vector<int> first;
    vector<int> second;
    int ans = INT_MAX;
    for (int t = 0; t < N; t++) {
        int s1 = 0;
        int s2 = 0;

        for (int k = 0; k <= t; k++) {
            s1 += arr[k];
        }
        for (int j = t + 1; j < N; j++) {
            s2 += arr[j];
        }
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <bitset>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int X[15][15];

  for (int ii=0; ii<15; ++ii)
    for (int jj=0; jj<15; ++jj)
      X[ii][jj] = 9;

  for (int n=0; n<N; ++n) {
    int A;
    cin >> A;
    for (int a=0; a<A; ++a) {
      int x, y;
      cin >> x >> y;
      X[n][--x] = y==1 ? 1 : 0;
    }
  }

  int max_count = 0;
  
  for (int pattern = (1<<N)-1; pattern>=0; --pattern) {
    bitset<15> bs(pattern);
    int bit_count = bs.count();
    if (max_count >= bit_count)
      continue;
    
    bool flag = true;
    for (int n=0; n<N && flag; ++n) {
      if (!bs[n])
	continue;
      for (int x=0; x<N && flag; ++x) {
	if (x==n)
	  continue;
	bool x_state = bs[x];
	if (X[n][x]==0 && x_state)
	  flag = false;
	else if (X[n][x]==1 && !x_state)
	  flag = false;
      }
    }
    if (!flag)
      continue;
      
    max_count = bit_count;
  }

  cout << max_count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    c = collections.Counter(s)
    if len(c) == 1:
        if len(s) == 1:
            return 'YES'
        return 'NO'
    if len(c) == 2:
        if len(s) <= 2:
            return 'YES'
        return 'NO'
    if max(c.values()) - min(c.values()) <= 1:
        return 'YES'

    return 'NO'



print(main())




Measured memory_bytes: 6340
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int S, W;
    cin >> S >> W;
    cout << (W >= S ? "unsafe" : "safe") << endl;
    return 0;
}



Measured memory_bytes: 3624
const SIZE: usize = 51;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let b: Vec<usize> = sc.vec(n);

    if !is_ok(&a, &b, SIZE, &[]) {
        println!("-1");
        return;
    }

    let mut ans = vec![];
    for i in (1..SIZE).rev() {
        if !is_ok(&a, &b, i, &ans) {
            ans.push(i);
        }
    }

    let ans = ans.into_iter().map(|a| 1 << a).sum::<usize>();
    println!("{}", ans);
}

fn is_ok(a: &Vec<usize>, b: &Vec<usize>, k: usize, ans: &[usize]) -> bool {
    let mut map = vec![vec![false; SIZE]; SIZE];
    for i in 0..SIZE {
        map[i][i] = true;
    }

    for &ans in ans.iter() {
        for from in 0..SIZE {
            let to = from % ans;
            map[from][to] = true;
        }
    }
    for ans in 1..k {
        for from in 0..SIZE {
            let to = from % ans;
            map[from][to] = true;
        }
    }

    for k in 0..SIZE {
        for i in 0..SIZE {
            for j in 0..SIZE {
                map[i][j] |= map[i][k] && map[k][j];
            }
        }
    }

    a.iter().zip(b.iter()).all(|(&a, &b)| map[a][b])
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>s;
	x=0;
	FORR(c,s) {
		if(c=='+') x++;
		else x--;
	}
	cout<<x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
start = n-1
for i in range(n-1):
  if a[i]<a[i+1]:
    start = i
    break
#print(start)
money = 1000
kabu = 0
l = [a[start]]
high = 1
for i in range(start+1,n-1):
  if high==1:
    if a[i]<a[i+1]:
      continue
    else:
      l.append(a[i])
      high = 0
  else:
    if a[i]>a[i+1]:
      continue
    else:
      l.append(a[i])
      high = 1
if high==1 and a[-2]<a[-1]:
  l.append(a[-1])
if high==0 and a[-2]>a[-1]:
  l.append(a[-1])
#print(l)
if len(l)%2==0:
  for i in range(len(l)):
    if i%2==0:
      kabu += money//l[i]
      money -= (money//l[i])*l[i]
    else:
      money += kabu*l[i]
      kabu = 0
   # print(money,kabu)
  print(money)
else:
  l.pop()
  for i in range(len(l)):
    if i%2==0:
      kabu += money//l[i]
      money -= (money//l[i])*l[i]
    else:
      money += kabu*l[i]
      kabu = 0
    #print(money,kabu)
  print(money)

Measured memory_bytes: 9324
n = int(input())


def factorization(n):
    arr = []
    tmp = n 
    for i in range(2, int(n**0.5)+1):
        if tmp%i == 0:
            cnt = 0 
            while tmp%i == 0:
                cnt += 1
                tmp //= i
            arr.append([i, cnt])
    if tmp!=1:
        arr.append([tmp, 1]) # n is prime
    if arr == []: 
        arr.append([n, 1]) # n==1 only
    return arr 


p_list=factorization(n)


N=n
cnt=0
while N!=1:
    for i in range(len(p_list)):
        p=p_list[i][0]
        for e in range(1,p_list[i][1]+1):
            z=p**e
            if z > N:
                break
            else:
                if N%z==0:
                    N=N//z
                    cnt+=1
    N=1    
print(cnt)


Measured memory_bytes: 9384
import copy
n = int(input())
alist = [int(input()) for i in range(n)]
blist = copy.deepcopy(alist)

alistmax = max(alist)
blist.remove(alistmax)
alist2max = max(blist)

for i in range(n):
    if alist[i] == alistmax:
        print(alist2max)
    else:
        print(alistmax)

Measured memory_bytes: 14568
import java.util.*;
  public class Main{
    public static void main(String[]args){
      Scanner scn = new Scanner(System.in);
      int a = scn.nextInt();
      int b = scn.nextInt();
      
      if((a+b)%2==0){
        System.out.println((a+b)/2);
      }else {
        System.out.println("IMPOSSIBLE");
      }
    }
  }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int K,X;
    cin>>K>>X;
    for(int i=X-K+1; i<X+K; i++){
        cout<<i<<" ";
    }


}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



Measured memory_bytes: 2100
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pri = lambda x: print(*x, sep='\n')

a, b, c, d = map(int, input().split())

direct = abs(a-c) <= d

chk1 = abs(a-b)<=d
chk2 = abs(b-c)<=d
indirect = chk1 and chk2

if direct or indirect:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n; cin >> n;
    ll money = 1000;
    ll stock = 0;
    ll A[100];
    rep(i,n){
        cin >> A[i];
    }
    rep(i,n-1){
        if(A[i] < A[i+1]){
            stock += money / A[i];
            money = money - stock * A[i];
            money += stock * A[i+1];
            stock = 0;
        }
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

struct Group{  //aからbまでのトランプカード郡。最初のカードは上からc枚目
	int a;
	int b;
	int c;
	int d;
};

Group make_G(int a,int b,int c,int d){
	Group ret;
	ret.a=a; ret.b=b; ret.c=c; ret.d=d;
	return ret;
}

int main(){
while(1){
	int n,m,x,y,p,q,r;
	vector<Group> CG;
	scanf("%d",&n); if(n==0)break; scanf("%d",&m);
	scanf("%d%d%d",&p,&q,&r);
	CG.push_back(make_G(1,n,1,n));
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		int s=CG.size();
		for(int j=0;j<s;j++){
			Group g=CG[j];
			if(g.c<=x&&g.d>x){
				CG.push_back(make_G(g.a,g.a+x-g.c,n-x+g.c,n));
				g.a+=x-g.c+1;
				g.c+=x-g.c+1;
			}
			if(g.c<=y&&g.d>y){
				CG.push_back(make_G(y+1-g.d+g.b,g.b,1,g.d-y));
				g.b-=g.d-y;
				g.d-=g.d-y;
			}
			if(g.d<=x)g.c+=n-x;
			else if(g.d<=y)g.c+=n-y-x;
			else g.c-=y;
			CG[j].a=g.a; CG[j].b=g.b; CG[j].c=g.c; CG[j].d=CG[j].c-CG[j].a+CG[j].b;
		}
		s=CG.size();
		for(int j=0;j<s;j++){
			Group g=CG[j];
			//cout<<g.a<<" "<<g.b<<" "<<g.c<<" "<<g.d<<endl;
		}
	}
	int s=CG.size(),sum=0;
	for(int i=0;i<s;i++){
		Group g=CG[i];
		//cout<<g.a<<g.b<<g.c<<endl;
		int b=g.c,e=min(g.d,g.c+r-g.a);
		sum+=max(min(q,e)-max(p,b)+1,0);
	}
	printf("%d\n",sum);
}
}

Measured memory_bytes: 1320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(long N)
        {
            long sum = 0;
            for (long i = 1; i * i < N - i; ++i)
            {
                if ((N - i) % i == 0) { sum += (N - i) / i; }
            }
            return sum;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve(ReadLong()));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    vector<int> V(101);
    vector<int> S;
    while(scanf("%d,%d", &a, &b), a){
        V[a] = b;
        S.emplace_back(b);
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    reverse(S.begin(),S.end());
    while(cin >> a){
        cout << lower_bound(S.begin(),S.end(), V[a], greater<>()) - S.begin()+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
	ll n,i,j,p,k,m,ans=0;
    cin>>n;
    vector<pair<ll,ll> > a(n);
    for(i=0;i<n;i++)
    {
        cin>>p>>k;
        a[i]={k,p};
    }
    sort(a.begin(),a.end());
    ll TIME = 0;ans=0;
    for(i=0;i<n;i++)
    {
        if(TIME+a[i].S>a[i].F)
        {
            ans=-1;break;
        }
        TIME+=a[i].S;
        
    }
    if(ans==-1)
    {
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    
    
	return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
#pragma GCC optimize(2)
bool G[705][705];
int n,col[706];
bool a[2][705];
int m;
int cnt1 = 0,cnt2 = 0;
int doit(int n)
{
	return (n * (n - 1)) / 2;
}
bool dfs(int x,int c)
{
	if(col[x] == 0)
	{
		col[x] = c;
		if(c == 1)
		{
			cnt1++;
		}
		else
		{
			cnt2++;
		}
	}
	else
	{
		return col[x] == c;
	}
	for(int i = 0;i < n; ++i)
	{
		if(x != i && !G[x][i])
		{
			if(!dfs(i,-c))
			{
				return 0;
			}
		}
	}
	return 1;
}
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i = 0;i < m; ++i)
	{
		int x,y;
		cin>>x>>y;
		--x,--y;
		G[x][y] = G[y][x] = 1;
	}
	a[0][0] = 1;
	bool flag = 0;
	for(int i = 0;i < n; ++i)
	{
		if(col[i] == 0)
		{
			cnt1 = 0,cnt2 = 0;
			if(!dfs(i,1))
			{
				printf("-1\n");
				return 0;
			}
			bool cur = flag ^ 1;
			memset(a[cur],0x00,sizeof(a[cur]));
			for(int j = 0;j <= n; ++j)
			{
				if(a[flag][j])
				{
					a[cur][j + cnt1] = a[cur][j + cnt2] = 1;
				}
			}
			flag ^= 1;
		}
	}
	for(int i = n / 2;i >= 0; --i)
	{
		if(a[flag][i])
		{
			printf("%d\n",doit(i) + doit(n - i));
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 768
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define MAXI (int)(1e17+100)
#define N 200005

int n, in[N];


// Driver code to test above functions
int32_t main()
{
    
 
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;

    if(n==1 or m==1)
    {
        cout << 1;
        return 0;
    }

    int ans = n*m;

    cout << ans/2 + (ans%2==1);

    return 0;
    
}  




Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

s=sum(a)
ans=abs(s-2*a[0])
s=s-2*a[0]

if n>3: 
 for i in range(1,n-1):
  ans=min(abs(s-2*a[i]),ans)
#  print(ans)
  s=s-2*a[i]
  
print(ans)

Measured memory_bytes: 24832
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int n, q, command, x;
  cin >> n >> q;
  vector<int> v[n];

  int t;
  for(int i = 0; i < q; i++) {
    cin >> command >> t;
    switch(command) {
      case 0:
        cin >> x;
        v[t].push_back(x);
        break;
      case 1:
        for(int i = 0; i < v[t].size(); i++) {
          cout << v[t][i];
          if(i + 1 < v[t].size())
            cout << " ";    
        }
        cout << endl;
        break;
      case 2:
        v[t].clear();
        break;
    }
  }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> cur;

    for(int i = 0; i < n; ++i) {
        int ai = a[i];
        auto it = lower_bound(cur.begin(), cur.end(), ai);
        
        if(it == cur.end() || *it >= ai) {
            if(it == cur.begin()) {
                cur.insert(cur.begin(), ai);
                continue;
            } else {
                it--;
            }
        }

        *it = ai;
    }

    cout << cur.size() << endl;
    
    return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
 
typedef long long int value_type; /* ソートするキーの型 */
 
value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}
 
void quicksort(value_type a[],long long int left, long long int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
    if (left < right) {
        long long int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            i++; j--;
        }
        quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}
 
 
int main(void){
    long long int n,i,l,count;
 
    scanf("%lld",&n);
 
    long long int h[n];
 
    for(i=0; i<n; i++){
        scanf("%lld",&h[i]);
    }
 
    quicksort(h,0,n-1);

    count = 0;

    for(l=0;l<n;l++){
        if(h[l]==h[l+1]){
            count++;
        }
    }

    if(count==0){
        printf("YES");
    }

    else{
        printf("NO");
    }
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=new int[n];
		var b=new int[n];
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			a[i]=e[0];
			b[i]=e[1];
		}
		Array.Sort(a);
		Array.Sort(b);
		if(n%2==1){
			Console.WriteLine(b[n>>1]-a[n>>1]+1);
		}
		else{
			Console.WriteLine(b[(n>>1)-1]+b[n>>1]-a[(n>>1)-1]-a[n>>1]+1);
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 42204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    string word;
    int m, h;
    while(true)
    {
        cin >> word;
        if (word == "-")
            break;
         
        cin >> m;
        for (int i = 0; i < m; i++) 
        {
            scanf("%d", &h);
            word += word.substr(0, h);
            word.erase(0, h);
        }
        cout << word << endl;
    }
}


Measured memory_bytes: 3220
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import statistics
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)

def main():
  S = input()
  Q = int(input())
  TFC = list(list(input().split()) for _ in range(Q))
  rev = 0
  q = deque(S)
  for i in range(Q):
    if TFC[i][0] == '1':
      rev ^= 1
    else:
      if TFC[i][1] == '1':
        if rev == 0:
          q.appendleft(TFC[i][2])
        else:
          q.append(TFC[i][2])
      else:
        if rev == 0:
          q.append(TFC[i][2])
        else:
          q.appendleft(TFC[i][2])
  ans = ''.join(q)
  print(ans if rev==0 else ans[::-1])
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 46276
def main():
    import sys,heapq
    input = sys.stdin.buffer.readline
 
    h,w = map(int,input().split())
    cx,cy = map(int,input().split())
    dx,dy = map(int,input().split())
    cx -= 1
    cy -= 1
    dx -= 1
    dy -= 1
 
    start = cx*w + cy
    goal = dx*w + dy
 
 
    s = []
    for _ in range(h):
        s.append(list(input()))
 
    dg = 10**7
 
 
    edge = [[] for _ in range(h*w)]
    for xy in range(h*w):
        x,y = divmod(xy,w)
        if s[x][y] == 35:
            continue
        for i in range(-2,3):
            for j in range(-2,3):
                if i == 0 and j == 0:
                    continue
                if 0 <= x+i < h and 0 <= y+j < w and s[x+i][y+j] == 46:
                    #上下左右/ワープ
                    if (i == 0 and abs(j) == 1) or (j == 0 and abs(i) == 1):
                        edge[xy].append( (x+i)*w + y+j )
                    else:
                        edge[xy].append(dg + (x+i)*w + y+j )
 
    d = [float("inf")]*(h*w)
    d[start] = 0
 
    tank = []
 
    for e in edge[start]:
        heapq.heappush(tank,e)
 
 
    while tank:
        now = heapq.heappop(tank)
        cost,xy = divmod(now,dg)
        if d[xy] != float("inf"):
            continue
        d[xy] = cost
        if xy == goal:
            break
        for nxt in edge[xy]:
            if nxt >= dg:
                if d[nxt-dg] == float("inf"):
                    heapq.heappush(tank,(cost+1)*dg + nxt-dg)
            else:
                if d[nxt] == float("inf"):
                    heapq.heappush(tank,cost*dg + nxt)
 
    if d[goal] == float("inf"):
        print(-1)
    else:
        print(d[goal])
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 220584
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):

    for j in range(B+1):

        for k in range(C+1):

            if i*500 + j*100 + k*50 == X:

                ans += 1

print (ans)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> a(n),x(n),y(n);
  rep(i,n)cin>>a[i]>>x[i]>>y[i];
  rep(i,n){
      int t=abs(x[i])+abs(y[i]);
      if(a[i]<t||a[i]%2!=t%2){
          cout<<"No"<<endl;
          return 0;
      }
  }
  cout<<"Yes"<<endl;
  return 0;
  }


Measured memory_bytes: 1408
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll c[3][3];

  for (int i = 0; i < 9; i++) {
    ll tmp;
    cin >> tmp;
    c[i / 3][i % 3] = tmp;
  }

  ll a[3] = {0, 0, 0};
  ll b[3] = {0, 0, 0};

  b[0] = c[0][0] - a[0];
  b[1] = c[0][1] - a[0];
  b[2] = c[0][2] - a[0];

  a[1] = c[1][0] - b[0];
  a[2] = c[2][0] - b[0];

  string ans = "Yes";
  for (int i = 0; i < 9; i++) {
    if( c[i / 3][i % 3] != a[i/3] + b[i%3]){
      ans = "No";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int n,  m;  cin >> n >> m;
    vector<vector<ll>> vec(n);
    vector<pair<ll, ll>> city(m);

    for(int i=0; i<m; i++){
        int a, x; cin >> a >> x; 
        vec.at(a-1).push_back(x);

        city.at(i).first = a-1;
        city.at(i).second = x;
    }

    for(int i=0; i<n; i++) sort(vec[i].begin(), vec[i].end());

    for(int i=0; i<m; i++){
        ll index = city.at(i).first;
        ll key = city.at(i).second;
        auto num = lower_bound(vec[index].begin(), vec[index].end(), key) - vec.at(index).begin();
        cout << setfill('0') << right << setw(6) << index+1;
        cout << setfill('0') << right << setw(6) << num+1 << endl;

    }

}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N=6;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const string op="RDLU";
enum{RIGHT=0,DOWN,LEFT,UP};
int m[N][N];
bool e[N][N][N];


string solve(){
  int y=0,x=1,r=RIGHT;
  string ret="";
  do{
    bool a=true;
    if (!e[y][x][(r+1)%4])r=(r+1)%4;
    while(e[y][x][r])ret+=op[r],r=(r+3)%4;
    if (e[y][x][(r+1)%4])ret+=op[r];
    y+=dy[r];
    x+=dx[r];
  }while(y != 0 || x != 1);
  return ret;
}

main(){
  rep(i,N)rep(j,N)rep(k,4)e[i][j][k]=false;
  rep(i,5){
    string tmp;
    cin>>tmp;
    rep(j,4)if (tmp[j] == '1')e[i][j+1][DOWN]=e[i+1][j+1][UP]=true;
    if (i == 4)break;
    cin>>tmp;
    rep(j,5)if (tmp[j] == '1')e[i+1][j][RIGHT]=e[i+1][j+1][LEFT]=true;
  }
  cout << solve() << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 100005;

struct Edge {
	int a, b, w;
	bool operator < (const Edge &e) const {
		return w < e.w;
	}
};

struct DSU {
	int N, pa[MAXN], sz[MAXN];
	LL sum[MAXN];
	vector<int> who[MAXN];
	
	void init(int _N, int *x) {
		N = _N;
		for (int i = 1; i <= N; i++) {
			pa[i] = i;
			sz[i] = 1;
			sum[i] = x[i];
		}
	}
	
	int find(int x) {
		return x == pa[x] ? x : find(pa[x]);
	}
	
	void merge(int x, int y) {
		x = find(x);
		y = find(y);
		if (sz[x] < sz[y]) swap(x, y);
		if (x == y) {
			who[x].push_back(-1);
		}
		else {
			who[x].push_back(y);
			sum[x] += sum[y];
			sz[x] += sz[y];
			pa[y] = x;
		}
//		cout << "AFTER " << x << " " << sum[x] << '\n';
	}
	
	void undo(int x) {
		x = find(x);
		if (who[x].back() != -1) {
			int y = who[x].back();
			pa[y] = y;
			sum[x] -= sum[y];
			sz[x] -= sz[y];
		}
		who[x].pop_back();
	}
} dsu;

int N, M, x[MAXN];
Edge es[MAXN];

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

	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		es[i] = {a, b, w}; 
	}
	
	dsu.init(N, x);
	sort(es, es + M);
	for (int i = 0; i < M; i++) {
		dsu.merge(es[i].a, es[i].b);
	}
	
	int ans = 0;
	for (int i = M - 1; i >= 0; i--) {
		int root = dsu.find(es[i].a);
		if (dsu.sum[root] < es[i].w) {
			ans++;
//			cout << "UNDO " << es[i].a << " " << es[i].b << " " << es[i].w << " due to " << root << " " << dsu.sum[root] << "\n";
			dsu.undo(root);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
      int A, B;
      cin >> A >> B;

      int i[3]={A+B, A-B, A*B};

      int max = -2000;
      for (int j=0; j<3; j++)
            if (max < i[j])
                  max=i[j];
      cout << max << endl;
      return 0;
}

      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI atan(1) * 4
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
std::vector<int> g[N];
int vis[N], par[N];
void bfs(int s) {
  vis[s] = 1;
  std::queue<int> q;
  q.push(s);
  while(!q.empty()) {
    int from = q.front();
    q.pop();
    for(auto to : g[from]) {
      if(vis[to]) continue;
      vis[to] = 1;
      par[to] = from;
      q.push(to);
    }
  }
}
void sol() {
  int n, m, u, v;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> u >> v;
    g[u].pb(v); g[v].pb(u);
  }
  bfs(1);
  cout << "Yes\n";
  for(int i=2; i<=n; i++) {
    cout << par[i] << "\n";
  }
  //cout << ans << "\n";
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sol();
  }
  return 0;
}


Measured memory_bytes: 34972
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// main function
int main()
{
	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll ans = 0;

	cin >> N >> A >> B;
	vector<ll> X(N);
	Rep(i, N) {
		cin >> X[i];
	}

	Rep(i, N - 1) {
		ll diff = X[i + 1] - X[i];
		ans += min(diff * A, B);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
if x in g1 and y in g1:
    ans = "Yes"
elif x in g2 and y in g2:
    ans = "Yes"
else:
    ans = "No"

print(ans)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;

    if (B != 1)
    {
        ans = 1;
        int sum = A;
        while (sum < B)
        {
            ans++;
            sum += A - 1;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())

count = 0
while True:
    if a == b == c and a%2 == 0:
        count = -1
        break

    if a%2 == 0 and b%2 == 0 and c%2 == 0:
        count += 1
        a, b, c = (b + c)//2, (a + c)//2, (a + b)//2
    else:
        break

print(count)


Measured memory_bytes: 3060
import sys, math,os
from io import BytesIO, IOBase
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


def main():

    a,b=mdata()
    out(a*b)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9476