akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_as_vec<T: FromStr>(&mut self) -> Vec<T> {
    self.iter.clone().map(|v| v.parse().ok().unwrap()).collect()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  sc.new_line();
  let cap = sc.get_line();
  let mut red = 0;
  let mut blue = 0;
  for c in cap.chars() {
    match c {
      'R' => red  += 1,
      'B' => blue += 1,
      _   => ()
    }
  }
  println!("{}", if red > blue { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  int a[100];
  int ans=BIG;
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  repi(i,1,n){
    a[i]+=a[i-1];
  }
  rep(i,n){
    ans=min(ans,a[i]/(i+1) );
  }
  cout<<ans<<endl;

  return 0;
}






Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
map<long long,long long>v;
long long a[100010]={0};
int main()
{
    long long n, m;
    scanf("%lld %lld", &n, &m);
    long long s = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld",&a[i]);
        a[i] = (a[i] + a[i-1]) % m;
        if(a[i] == 0)
            s++;
        s += v[a[i]];
        v[a[i]]++;
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 4992
#
# abc072 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    AN = [0] * 100002  # -1 <= X <= 10^5+1

    for a in A:
        AN[a] += 1
        AN[a+1] += 1
        AN[a+2] += 1
    print(max(AN))


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 28448
from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()



Measured memory_bytes: 69732
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s, t;

	cin >> s >> t;

	vector<ll> v(26, 0);

	REP(i, s.size()) {
		v[s[i] - 'a']++;
	}

	REP(i, t.size()) {
		if (v[t[i] - 'a'] == 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<vector<pair<bool, ll>>> vv(s.size(), vector<pair<bool, ll>>(26, make_pair(false, 0)));
	vector<pair<bool, ll>> vvv(26, make_pair(false, 0));
	vvv[s[s.size() - 1] - 'a'] = make_pair(true, s.size() - 1);

	RREP(i, s.size() - 1) {
		REP(j, 26) {
			if (vvv[j].first) {
				vv[i][j] = make_pair(true, vvv[j].second);
			}
		}

		vvv[s[i] - 'a'] = make_pair(true, i);
	}

	ll cnt = 0;
	ll pc = 0;
	ll ans = 0;
	ll pre = 0;

	while (true) {
		if (t[cnt] == s[0]) {
			cnt++;
		}
		while (cnt < t.size() && vv[pre][t[cnt] - 'a'].first) {
			pre = vv[pre][t[cnt] - 'a'].second;
			cnt++;
			if (cnt == t.size()) {
				break;
			}
		}
		if (cnt != t.size()) {
			ans += s.size();
		}
		else {
			ans += pre + 1;
			break;
		}
		pre = 0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 45056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define MOD 1000000007
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INFll (1LL << 60)

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    //string s,t;
    //cin>>s>>t;
    vector<char> s(3);
    vector<char> t(3);
    rep(i,3){
        cin>>s[i];
    }
    for(int i=0;i<3;i++){
        cin>>t[i];
    }
    int ans=0;
    rep(i,3){
        if(s[i]==t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	int a = 0, b = 0;
	rep(i, n) {
		if ((i + 1) % k == 0)a++;
		else if (k % 2 == 0 && (i + 1) % k == k / 2)b++;
	}
	cout << a * a*a + b * b*b << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    S = list(accumulate(A))

    # small[i] = A[1],A[2],...,A[N + i]から小さい順にi個選んだときの和
    small = [0] * (N + 1)
    q = []
    for i in range(1, N + 1): heappush(q, A[i])
    for i in range(1, N + 1):
        heappush(q, A[N + i])
        v = heappop(q)
        small[i] = small[i - 1] + v

    # large[i] = A[3N],A[3N-1],...,A[2N+1-i]から大きい順にi個選んだときの和
    large = [0] * (N + 1)
    q = []
    for i in range(2 * N + 1, 3 * N + 1): heappush(q, -A[i])
    for i in range(1, N + 1):
        heappush(q, -A[2 * N + 1 - i])
        v = -heappop(q)
        large[i] = large[i - 1] + v

    ans = -10**18
    for i in range(N, 2 * N + 1):
        """
        A[1],A[2],...,A[i]から小さい順に(i - N)個除いたものが前半
        A[i+1],A[i+2],...,A[3N]から大きい順に(2N - i)個除いたものが後半
        """
        pre = S[i] - small[i - N]
        post = (S[-1] - S[i]) - large[2 * N - i]
        ans = max(ans, pre - post)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	P now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

char area[50][50];
int h, w;
int brack = 0;


int solve(){
	bool put[50][50] = {};
	data start;
	start.now = P(0,0);
	start.cost = 0;
	P finish(h-1, w-1);
	queue<data> q;
	q.push(start);
	while(q.size()){
		data nowPos = q.front(); q.pop();
		if(nowPos.now == finish){
			return h*w - nowPos.cost - brack -1;
		}

		for(int i = 0; i < 4; i++){
			data next;
			next.now = P(nowPos.now.first + nw[i], nowPos.now.second + nh[i]);
			next.cost = nowPos.cost+1;
			if(next.now.first < 0 || next.now.second < 0 || next.now.first >= h || next.now.second >= w) continue;
			if(put[next.now.first][next.now.second]) continue;
			if(area[next.now.first][next.now.second] == '#') continue;
			put[next.now.first][next.now.second] = true;
			q.push(next);
		}
	}
	return -1;
}

int main(){
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> area[i][j];
			if(area[i][j] == '#') brack++;
		}
	}

	cout << solve() << endl;

	return 0;
}

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

int main() {
    string str;
    cin >> str;
    int sum = 700;

    REP(i, 3)
        if (str[i] == 'o') {
            sum += 100;
        }
    cout << sum << "\n";
}

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

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

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(s,t);
  Vi sv;
  Vi tv;
  map<char,int> sm;
  map<char,int> tm;
  REP(i,s.size()){
    sm[s[i]]++;
    tm[t[i]]++;
  }
  for(auto p: sm){
    sv.pb(p.second);
  }
  for(auto p: tm){
    tv.pb(p.second);
  }
  SORT(sv);
  SORT(tv);
  Yes(sv==tv);
}

Measured memory_bytes: 916
#include "bits/stdc++.h"
using namespace std; 
#define LIM 3003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";


ll n, dp[LIM][LIM], pref[LIM];
char s[LIM];

int main() {
	int i, j, t;
	scl(n);
	scanf("%s", 1+s);
	dp[1][1] = 1;
	for(i=1; i<=n; i++)
		pref[i] = 1;
	for(i=2; i<=n; i++) {
		
		for(j=1; j <= i; j++) {
			if (s[i-1] == '<') {
				dp[i][j] = pref[j-1];
			} else {

				dp[i][j] = (pref[i] - pref[j-1] + M)%M;
			}
			//debug3(i, j, dp[i][j]);	
		}
		for(j=1; j<=n; j++) {
			pref[j] = (pref[j-1] + dp[i][j])%M;
		}
	}



	cout << pref[n] << endl;
	return 0;
}




Measured memory_bytes: 69120
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        Stack<String> st=new Stack<String>();
        while(sc.hasNext()){
            
            String input=sc.next();
            //if(input.equals("-1")) break;
            String a,b;
            switch (input) {
                case "+":
                    a=st.pop();
                    b=st.pop();
                    st.push((Integer.parseInt(b)+Integer.parseInt(a))+"");
                    break;
                case "-":
                    a=st.pop();
                    b=st.pop();
                    st.push((Integer.parseInt(b)-Integer.parseInt(a))+"");
                    break;
                case "*":
                    a=st.pop();
                    b=st.pop();
                    st.push((Integer.parseInt(b)*Integer.parseInt(a))+"");
                    break;
                case "/":
                    a=st.pop();
                    b=st.pop();
                    st.push((Integer.parseInt(b)/Integer.parseInt(a))+"");
                    break;
                default:
                    st.push(input);
                    break;
            }
        }
        System.out.println(st.pop());
    }
}


Measured memory_bytes: 26368
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
a = list(map(int, input().split()))

q = []
for t in a:
    # heappush(q, (-t, 0))
    heappush(q, -t)
# print(q)

for m in range(M):
    val = heappop(q)
    val = (-val)//2
    heappush(q, -val)

print(-sum(q))


Measured memory_bytes: 60952
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool a[256] = {};
  for (char c : s) {
  	a[c] = true;
  }
  for (char c = 'a'; c <= 'z'; c++) {
    if (!a[c]) {
      cout << s << c << endl;
      return 0;
    }
  }
  while (!s.empty()) {
    char sb = s.back();
    a[sb] = false;
    s.pop_back();
    for (char c = sb + 1; c <= 'z'; c++) {
      if (!a[c]) {
        cout << s << c << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

vint calc(vint old){
  int n = old.size();
  vint ans(n);
  rep(i,0,n){
    int MIN = max((int)0,i - old[i]);
    int MAX = min(n-1,i + old[i]);
    ans[MIN]++;
    if(MAX+1 < n)ans[MAX+1]--;
  }
  rep(i,0,n-1){
    ans[i+1] += ans[i];
  }
  return ans;
}

signed main(){
  int n,k;
  cin >> n >> k;
  vint A(n);
  rep(i,0,n) cin >> A[i];
  int s = log(n)/log(2);
  int num = min(s*10,k);
  rep(i,0,num){
    A = calc(A);
  }
  rep(i,0,n) cout << A[i] << " ";
}

Measured memory_bytes: 8240
#include <stdio.h>

int main(void)
{
	int n, i, s1, s2;
	int x[365], y[365], b[365], p[365];
	
	scanf("%d", &n);
	for (i=0; i<n; i++){
		scanf("%d %d %d %d",&x[i], &y[i], &b[i], &p[i]);
	}
	
	for (i=0; i<n; i++){
		s1 = x[i]*b[i] + y[i]*p[i];
		if ((b[i] >= 5) && (p[i] >= 2)) {
			s2 = s1 * 0.8;
		}
		else if ((b[i] >= 5) && (p[i] < 2)) {
			s2 = (x[i]*b[i]+y[i]*2)*0.8;
		}
		else if ((b[i] < 5) && (p[i] >= 2)) {
			s2 = (x[i]*5+y[i]*p[i])*0.8;
		}
		else if ((b[i] < 5) && (p[i] < 2)) {
			s2 = (x[i]*5+y[i]*2) * 0.8;
		}

		if (s1 < s2) printf("%d\n", s1);
		else printf("%d\n", s2);
	}
						
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <utility>
#include <algorithm>
#include <math.h>
#include <cmath>

using namespace std;
typedef long long ll;
int n=0;
int wtot=0;

ll dp[105][100005];
ll val[100005];
ll wt[100005];
ll knapsack(int n,int wet)
{
	if(dp[n][wet]!=-1)
		return dp[n][wet];
	if(n==0 || wet == 0)
		return dp[n][wet]=0;
	if(wt[n-1]>wet)
		return dp[n][wet]=knapsack(n-1,wet);
	else
		return dp[n][wet]=max(val[n-1] + knapsack(n-1,wet-wt[n-1]), knapsack(n-1,wet) );
}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin>>n>>wtot;
	memset(dp,-1, sizeof dp);
	int i;
	for(i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	cout<<knapsack(n,wtot)<<endl;
	return 0;
}

Measured memory_bytes: 82304
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]
# not_good_list = []
not_good_set = set()
not_good_count = 0
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

for t in AB_list :
    A = t[0]
    B = t[1]

    if (A not in not_good_set) :
        if (H_list[A-1] <= H_list[B-1]) :
            not_good_set.add(A)
            not_good_count += 1

    if (B not in not_good_set) :
        if (H_list[B-1] <= H_list[A-1]) :
            not_good_set.add(B)
            not_good_count += 1
            continue

print(N - not_good_count)

Measured memory_bytes: 32340
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		parent = -1;
		depth = num_of_children = 0;
	}
	int parent;
	int depth;
	vector<int> children;
	int num_of_children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

int main(){
	int n,id,k,child_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d",&id,&k);
		for(int j = 0; j < k; j++){
			scanf("%d",&child_id);
			nodes[id].children.push_back(child_id);
			nodes[id].num_of_children++;
			nodes[child_id].parent = id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	calcDepth(nodes,root_id);

	for(int i = 0; i < n; i++){
		if(nodes[i].parent == -1){
			printf("node %d: parent = -1, depth = 0, root, ",i);
		}else if(nodes[i].num_of_children == 0){
			printf("node %d: parent = %d, depth = %d, leaf, ",i,nodes[i].parent,nodes[i].depth);
		}else{
			printf("node %d: parent = %d, depth = %d, internal node, ",i,nodes[i].parent,nodes[i].depth);
		}
		printf("[");
		for(int j = 0; j < nodes[i].num_of_children-1; j++){
			printf("%d, ",nodes[i].children[j]);
		}
		if(nodes[i].num_of_children > 0){
			printf("%d",nodes[i].children[nodes[i].num_of_children-1]);
		}
		printf("]\n");
	}
}

Measured memory_bytes: 5752
S = int(input())
x = 0
a = S//100
b = S%100
if a>=1 and a<=12:
    x+=1
if b>=1 and b<=12:
    x+=1
if x == 0:
    print("NA")
elif x == 2:
    print("AMBIGUOUS")
if x == 1:
    if a>=1 and a<=12:
        print("MMYY")
    else:
        print("YYMM")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    int ans = -1;
    for ( int i = 1; i <= 2000; ++i ) {
        if ( i * 108 / 100 - i == a && i * 110 / 100 - i == b ) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b.at(i);
    vector<int> a(n,0);
    a.at(0) = b.at(0);
    a.at(n-1) = b.at(n-2);
    for(int i = 0; i < n - 2;i++){
        int t = 0;
        if(b.at(i) <= b.at(i+1)) t = b.at(i);
        else t = b.at(i+1);
        a.at(i+1) = t;
    }
    int ans = 0;
    rep(i,n) ans += a.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
#define MAX 100005
#define NIL -1 
struct Node{ int p, l, r;};
struct Node T[MAX];

void inorder(int u){
  if(u != NIL){
    inorder(T[u].l); 
    printf(" %d",u);    
    inorder(T[u].r);  
  }
}
void preorder(int u){
  if(u != NIL){
    printf(" %d",u);   
    preorder(T[u].l);
    preorder(T[u].r); 
  }
}

void postorder(int u){
  if(u != NIL){
    postorder(T[u].l);
    postorder(T[u].r);
    printf(" %d",u);
  }
}

int main(){
  int i, v,n;     
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
      T[i].p = T[i].l = T[i].r = NIL; 
    } 
    for ( i = 0; i < n; i++ ){ 
      scanf("%d",&v);
      scanf("%d %d",&T[v].l,&T[v].r);    
      T[T[v].l].p = v;
      T[T[v].r].p = v; 
    } 
    
    
    printf("Preorder\n");
     for(i=0; i<n; i++){
     if(T[i].p == NIL)
	preorder(i);
    }
    printf("\nInorder\n");
    for(i=0; i<n; i++){
      if(T[i].p == NIL)
	inorder(i);
    }
    printf("\nPostorder\n");
    for(i=0; i<n; i++){  
      if(T[i].p == NIL)
	postorder(i);
    }
    printf("\n");
   
    return 0;   
}

Measured memory_bytes: 616
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
P projection(const L& l, const P& p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0]-p), abs(s[1]-p));
}
bool intersectCS(const C &c, const L &s){
    return (abs(c.p -s[0])+EPS > c.r || abs(c.p -s[1])+EPS > c.r)
        && distanceSP(s, c.p) < c.r +EPS;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<C> c(n);
        for(int i=0; i<n; i++){
            int x,y,r;
            cin >> x >> y >> r;
            c[i] = C(P(x,y), r);
        }

        int m;
        cin >> m;
        for(int i=0; i<m; i++){
            int sx,sy,tx,ty;
            cin >> sx >> sy >> tx >> ty;
            L s(P(sx,sy), P(tx,ty));
            bool safe = false;
            for(int j=0; j<n; j++){
                if(intersectCS(c[j], s)){
                    safe = true;
                    break;
                }
            }
            if(safe){
                cout << "Safe" << endl;
            }else{
                cout << "Danger" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3028
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

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

const int INF = 1 << 29;
const double EPS = 1e-10;

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<<']';
}


bool has_finished(vi &b) {
	rep(i, 8) if (b[i] != i) return false;
	return true;
}

int hash(vi &b) {
	int res = 0;
	int e = 1;
	rep(i, 8) {
		res += b[i] * e;
		e *= 10;
	}
	return res;
}
int bits_of(int dat, int msb, int lsb) {
	int x = dat >> lsb;
	int m = 1 << msb - lsb + 1;
	return x & m - 1;
}

int swap(int n, int a, int b) {
	int x = bits_of(n, 2 + a * 3, a * 3);
	int y = bits_of(n, 2 + b * 3, b * 3);
	int _z = ~(n ^ (x << a * 3));
	int z = ~(_z ^ (y << b * 3));
	return z | x << b * 3 | y << a * 3;
}


int main() {
		queue<pii> q;
		q.push(mp(0, 01234567));
		map<int, int> visited;
		
		while(!q.empty()) {
			pii st = q.front();
			int b = st.snd;
			q.pop();
			
			if (visited[b] != 0) continue;
			visited[b] = st.fst + 1;
			
			int p = 0;
			int t = b;
			while(t != 0) {
				if (t == (t >> 3) << 3) break;
				t >>= 3;
				p++;
			}
			int d[] = {-1, 1, -4, 4};
			rep(i, 4) {
				if (p == 3 && i == 1) continue;
				if (p == 4 && i == 0) continue;
				int tp = p + d[i];
				if (tp < 0 || tp >= 8) continue;
				b = swap(b, p, tp);
				q.push(mp(st.fst + 1, b));
				b = swap(b, p, tp);
			}
		}
	
		for(string s; getline(cin, s); ) {
			int board = 0;
			rep(i, 8) {
				board = board << 3 | s[i * 2] - '0';
			}
			cout << visited[board] - 1 << endl;
		}
    
    return 0;
}

Measured memory_bytes: 2152
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();

    System.out.println(x + y/2);


    
    
    
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
using namespace std;
#define MOD 1000000007
#define rrep(i,m,n) for(int (i)=(int)(m);(i)>=(int)(n);(i)--)
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define M_PI 3.1415926535897932LL;
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long double EPS = 1e-10;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
n >>= 1;
	}
	return res;
}

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}

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

	ll n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	if (p == 2 || p == 5) {
		ll ans = 0;
		REP(i, n) {
			ll a = s[i] - '0';
			if (a % p == 0)ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}
	map<ll, ll> mp;
	ll sum = 0;
	mp[0] = 1;
	ll ans = 0;
	ll inv = 1;
	REP(i, n) {
		ll a = s[i] - '0';
		a = a * inv % p;
		sum = (sum + a) % p;
		ll t = sum % p;
		ans += mp[t];
		mp[sum]++;
		(inv *= mod_inv(10, p)) %= p;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1044
'use strict'
const main = function (input) {
const strData = input.split(`\n`);
const split = strData[0].split(` `).map(v => parseInt(v));
const numOfFriends = split[0];
const regulatedHeight = split[1];
const friendsHeightData = strData[1].split(` `).map(v => parseInt(v));
const allowedNumOfFriends = friendsHeightData.filter(v => v >= regulatedHeight).length;
console.log(allowedNumOfFriends);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 28608
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),r=sc.nextInt();
        if(n>=10){
            System.out.println(r);
        }else{
            System.out.println(r+(100*(10-n)));
        }
    }
}

Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func convertToInt(s []string, len int) []int {
	ret := make([]int, len)
	for i := 0; i < len; i++ {
		ret[i], _ = strconv.Atoi(s[i])
	}
	return ret
}

var MAX = 50

func isSame(a, b, c int) bool {
	if a == b && b == c {
		return true
	}
	return false
}

func solve(n []int) int {
	count := 0

	for !isSame(n[0], n[1], n[2]) {
		sort.Ints(n)
		if n[1] == n[2] {
			n[0] += 2
		} else {
			n[0] += 1
			n[1] += 1
		}
		count = count + 1
	}

	return count
}

func main() {
	line := nextLine()
	cols := strings.Split(line, " ")

	fmt.Println(solve(convertToInt(cols, 3)))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int n;
    for(int i=0;i<k;i++){
        if(a%2==0){
            b+=a/2;
            n=a/2;a=b;b=n;
        }
        else{
            a-=1;
            b+=a/2;
            n=a/2;a=b;b=n;
        }
    }
    if(k%2==0) cout<<a<<" "<<b;
    else cout<<b<<" "<<a;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a,b;char[] c;
        while(true){
            a=sc.nextInt();c=sc.next().toCharArray();b=sc.nextInt();
            if(c[0]=='?')break;
            if(c[0]=='+')System.out.println(a+b);
            else if(c[0]=='-')System.out.println(a-b);
            else if(c[0]=='*')System.out.println(a*b);
            else System.out.println(a/b);
        }
}
}


Measured memory_bytes: 26308
N, K = map(int, input().split())
As = list(map(int, input().split()))

Visit = [None] * N
now = 0
n = 0
while Visit[now] is None:
    Visit[now] = n
    now = As[now]-1
    n += 1
    if n == K:
        print(now+1)
        exit()

for _ in range((K-Visit[now]) % (n-Visit[now])):
    now = As[now]-1
print(now+1)


Measured memory_bytes: 92228
x, y = (int(x) for x in input().split())

ans = ''

tsuru = (4 * x - y) / 2
kame = x - tsuru

if tsuru >= 0 and kame >= 0 and tsuru % 1 == 0 and kame % 1 == 0 :
    ans = 'Yes'
else :
    ans = 'No'

# print(tsuru)
# print(kame)

print(ans)

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

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

    string s;
    cin>>s;
    if(s.size() <= 3 || s.substr(0, 4) != "YAKI") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


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

const int maxn = 1005;

char s[maxn];

int f(char c)
{
    if(c=='N')
        return 0;
    if(c=='S')
        return 1;
    if(c=='W')
        return 2;
    return 3;
}

bool vis[4];
int main()
{
    scanf("%s",s);
    for(int i=0;s[i];i++)
        vis[f(s[i])]=1;
    if(vis[0]==vis[1]&&vis[2]==vis[3])
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if a+b > c+d {
		fmt.Println("Left")
	} else if a+b < c+d {
		fmt.Println("Right")
	} else {
		fmt.Println("Balanced")
	}
}


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

char  str[100005];
int main(){
    while(scanf("%s", str + 1) == 1){
        int len = strlen(str+1);
        for(int i = 1; i <= len; i+= 2)
            printf("%c", str[i]);
        cout <<"\n";
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct BIT{
	vector<T> dat;

	BIT(int sz) : dat(sz,0){}

	void add(int i,T x){
		for(;i < dat.size();i += i & -i) dat[i] += x;
	}

	T sum(T i){
		T ret = 0;
		for(;i;i -= i & -i) ret += dat[i];
		return ret;
	}
};

signed main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	vector<BIT<int>> bit(26,BIT<int>(n + 5));
	for(int i = 0;i < n;i++){
		bit[s[i] - 'a'].add(i + 1,1);
	}
	for(int i = 0;i < q;i++){
		int t;
		cin >> t;
		if(t == 1){
			int x;
			string c;
			cin >> x >> c; x--;
			bit[s[x] - 'a'].add(x + 1,-1);
			bit[c[0] - 'a'].add(x + 1,1);
			s[x] = c[0];
		}else{
			int l,r;
			cin >> l >> r; l--;r--;
			int ans = 0;
			for(int j = 0;j < 26;j++){
				if(bit[j].sum(r + 1) - bit[j].sum(l)) ans++;
			}
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 106372
S = list(input())
num = len(S)//2
count = 0

if  len(S)%2 == 0:
    a = S[:num]
    b = S[num:]
else:
    a = S[:num]
    b = S[num + 1:]
b.reverse()

for i in range(num):
    if not a[i] == b[i]:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#define p 1000000007LL
#define ll long long int
#define rep(i, a, b) for(int i = (a); i <= (b); ++ i)
#define dwn(i, a, b) for(int i = (a); i >= (b); -- i)
using namespace std;
const int maxn = 84;


bool f[maxn][maxn][6400 + 20];
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn];
int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, 1, n)
        rep(j, 1, m)
            cin >> a[i][j];
    rep(i, 1, n)
        rep(j, 1, m)
            cin >> b[i][j];
    rep(i, 1, n)
        rep(j, 1, m)
            if(a[i][j] > b[i][j])
                c[i][j] = a[i][j] - b[i][j];
            else
                c[i][j] = b[i][j] - a[i][j];
    memset(f, false, sizeof(f));
    f[0][1][0] = f[1][0][0] = true;
    rep(i, 1, n)
        rep(j, 1, m)
        {
            rep(k, 0, 6400)
            {
                if(k + c[i][j] <= 6400)
                    f[i][j][k] = f[i][j][k] | f[i - 1][j][k + c[i][j]],
                    f[i][j][k] = f[i][j][k] | f[i][j - 1][k + c[i][j]];
                f[i][j][k] = f[i][j][k] | f[i - 1][j][abs(k - c[i][j])];
                f[i][j][k] = f[i][j][k] | f[i][j - 1][abs(k - c[i][j])];
            }
        }
    //rep(i, 0, 10) cout << i << ' ' << f[1][2][i] << endl;
    
    rep(k, 0, 6400)
        if(f[n][m][k])
        {
            cout << k << endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 44544
import math

nn,m=map(int,input().split())

mod=10**9+7

yak=[]

p=1
ind=0
for i in range(2,int(m**0.5)+1):
    if m%i==0 :
        yak.append(0)
        while m%i==0 :
            m=m//i
            yak[ind]+=1
            p=0
        ind+=1

if m!=1 :
    yak.append(1)


ka=[1] # 階乗(mod)のリスト
for i in range(1,10**5*2):
    ka.append((ka[i-1]*i)%mod)

def inv(x): # mod上のxの逆数を求める関数（フェルマーの小定理）
    res=1
    k=mod-2
    y=x
    while k>0 :
        if k%2 == 1 :
            res = (res*y) % mod
        y = (y*y) % mod
        k //= 2
    return res

def modcomb(n,k): # mod上でのコンビネーションを求める関数(nCk)
    a=ka[n]
    b=ka[n-k]
    c=ka[k]

    bc=(b*c)%mod

    return a*inv(bc)%mod



ans=1

for i in range(len(yak)):
    if yak[i]>0 :
        n=nn+yak[i]-1
        k=yak[i]

        ans=(ans*modcomb(n,k))%mod

print(ans)


Measured memory_bytes: 11056
from functools import reduce
from itertools import combinations
N = int(input())
S = {"M": [], "A": [], "R": [], "C": [], "H": []}
for _ in range(N):
    i = input()
    head = i[0]
    if head == "M":
        S["M"].append(i)
    elif head == "A":
        S["A"].append(i)
    elif head == "R":
        S["R"].append(i)
    elif head == "C":
        S["C"].append(i)
    elif head == "H":
        S["H"].append(i)
counter = [len(S[head]) for head in list("MARCH") if len(S[head]) != 0]
combs = list(combinations(counter, 3))
ans = sum([reduce(lambda x, y: x * y, e) for e in combs])
print(ans)


Measured memory_bytes: 10720
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {

  val input = readLine.trim.toList
  val bob = readLine.trim.toInt
  val multiplicationFirst = input match {
    case m MultiplicationFirst Nil ⇒ m
    case _ ⇒ None
  }
  val left = input match {
    case l Left Nil ⇒ l
    case _ ⇒ ???
  }
  println(
    if (bob == multiplicationFirst && bob != left) 'M'
    else if (bob != multiplicationFirst && bob == left) 'L'
    else if (bob == multiplicationFirst && bob == left) 'U'
    else 'I'
  )

  object MultiplicationFirst {
    def unapply(str: List[Char]): Option[(Long, List[Char])] = {
      str match {
        case l Factor t ⇒
          t match {
            case '+':: (r MultiplicationFirst rest) ⇒ Some(l + r, rest)
            case Nil ⇒ Some(l, t)
            case _ ⇒ ???
          }
        case _ ⇒ ???
      }
    }
    private object Factor {
      def unapply(str: List[Char]): Option[(Long, List[Char])] = {
        str match {
          case l Number t ⇒ Some(takeAll(t, l))
          case _ ⇒ None
        }
      }
    }
    @tailrec private[this] def takeAll(str: List[Char], left: Long): (Long, List[Char]) = {
      str match {
        case '*'::(r Number rest) ⇒ takeAll(rest, left * r)
        case _ ⇒ (left, str)
      }
    }
  }
  object Left {
    def unapply(str: List[Char]): Option[(Long, List[Char])] = {
      str match {
        case l Number t ⇒ Some(takeAll(t, l), Nil)
        case _ ⇒ ???
      }
    }
    @tailrec private[this] def takeAll(str: List[Char], left: Long): Long = {
      str match {
        case '+'::(r Number rest) ⇒ takeAll(rest, left + r)
        case '*'::(r Number rest) ⇒ takeAll(rest, left * r)
        case Nil ⇒ left
        case _ ⇒ ???
      }
    }
  }
  object Number {
    def unapply(str: List[Char]): Option[(Long, List[Char])] = {
      str.span(_.isDigit) match {
        case (Nil, _) ⇒ None
        case (n, t) ⇒ Some(n.foldLeft(0L){(a, b) ⇒ a * 10 + b.asDigit }, t)
      }
    }
  }
  implicit class Extension[T](val value: T) extends AnyVal {
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
    @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 44084
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
 int a[101];

int main()
{
    int n, m;
    cin >> n >> m;
    int br = 0;
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s = s + a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i]*4*m >= s)
            br++;
    }
    if(br >= m)
        cout << "Yes";
    else    
        cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) begin(x),end(x)
using LL=long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const int INF = numeric_limits<int>::max();
int main()
{
    int N;
    cin >> N;
    cout << ( N * 800 ) - ( ( N / 15 ) * 200 ) << endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  cout << fixed << setprecision(10);
  if ((a*a*b)/2 < x) {
    x = a*a*b - x;
    double k = atan((2*x)/double(a*a*a));
    cout << (k*180.0/M_PI) << endl;
  } else {
    double k = atan((2*x)/double(a*b*b));
    cout << (90.0-k*180.0/M_PI) << endl;
  }

  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Five_Antennas
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] antennas = new int[5];
            for (int n = 0; n <= 4; ++n)
            {
               antennas[n] = int.Parse(Console.ReadLine());
            }
            int judge = int.Parse(Console.ReadLine());
            int sub = 0;
            string ans = "Yay!";

            for (int n = 0; n < 4;++n)
            {
                for (int nn = n+1; nn <= 4; ++nn)
                {
                    sub = antennas[nn] - antennas[n];
                    if (sub > judge)
                    {
                        ans = ":(";
                    }
                }
                if (ans == ":(")
                {
                    break;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	ll n, k; cin >> n >> k;
	ll x=n%k;

	cout << min(x, k - x) << endl;
	return 0;
}

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

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

int main() {
	vector<int> a(4);
	rep(i, 4) cin >> a[i];
	sort(a.begin(), a.end());
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256