akhauriyash/Code-Regression huggingface dataset:
/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define mp(a,b) make_pair(a,b)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

bool sortbysecc(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

int main()
{
    fastio;
    ll t, n, m, a, b, x=0, y=0, p, q, r, i, j, d, f=0;
    cin>>n>>a>>b;
    if((b-a)%2) cout<<"Borys";
    else cout<<"Alice";
}


Measured memory_bytes: 3572
# coding: utf-8
# Your code here!
A=input()
Y=int(A[0])*10+int(A[1])
M=int(A[2])*10+int(A[3])
code=0
if Y<100:
    if M>0 and M<13:
        code=1

if M<100:
    if Y>0 and Y<13:
        if code==1:
            code=3
        else:
            code=2

if code == 0:
    print("NA")
if code ==1:
    print("YYMM")
if code ==2:
    print("MMYY")
if code == 3:
    print("AMBIGUOUS")



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> dp(k+1,0);
    dp[0] = -1;

    // dpテーブルの構築
    // dp[i]として、kの残数がiの時に選ぶべきa[j]の値が入る。
    // dp[i]の時点で負け確定の場合は-1が入る
    // 制約をみるに、a[j]は昇順ソートされているので、先頭から見ていけばいい
    // a[j]がiを上回っているときは、それは選べる
    // これでdp[i-a[j]]が-1だったら、それを選べば勝てるので、dp[i] = a[j]となる
    // 選べる全てのjを見ても,-1に持っていけるのがなかったら、その枚数になった時点で負けなので、-1を入れておく(カードが選べない場合もここになる)
    rep(i, k+1) {
        bool flag = true;
        rep(j, n) {
            if(i >= a[j]) {
                if(dp[i-a[j]] == -1) {
                    dp[i] = a[j];
                    flag = false;
                    break;
                }
            }
        }
        if(flag) dp[i] = -1;

    }

    // dp構築後に、実際に回してみて、どちらが勝つか確かめる
    if(dp[k] != -1) cout << "First" << endl;
    else cout << "Second" << endl;


    return 0;
}


Measured memory_bytes: 640
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    ll a,b,n; cin>>a>>b>>n;
    cout<<a*(min(b-1,n))/b<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> par;
vector<int> size;

void init(int n, int m) {
    par = vector<int>(n + m);
    size = vector<int>(n + m);

    for (int i = 0; i < n; i++) {
        par[i] = i;
        size[i] = 1;
    }
    for (int i = n; i < n + m; i++) {
        par[i] = i;
        size[i] = 1919810;
    }
}

int find(int x) {
    if (par[x] == x)return x;
    else return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)return;

    int sum = size[x] + size[y];
    if (size[x] < size[y]) par[x] = y;
    else par[y] = x;

    size[x] = sum;
    size[y] = sum;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int n, m;
    cin >> n >> m;

    init(1 + n, m); // 1~n -> students n+1~n+m -> clubs

    int k;
    cin >> k;
    bool found = false;
    for (int i = 0; i < k; i++) {
        int query, a, b;
        cin >> query >> a >> b;
        if (query == 1) {
            if (!same(a, b)) {
                if (par[a] > n && par[b] > n) {
                    found = true;
                    cout << i + 1 << endl;
                    break;
                } else {
                    unite(a, b);
                }
            }
        } else {
            b += n;
            if (!same(a, b)) {
                if (par[a] > n) {
                    found = true;
                    cout << i + 1 << endl;
                    break;
                } else {
                    unite(a, b);
                }
            }
        }
    }
    if (!found)cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 4392
import sys
input = sys.stdin.readline
import numpy as np
from math import factorial
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def print_ans(X, Y):
    """Test Case
    >>> print_ans(3, 3)
    2
    >>> print_ans(2, 2)
    0
    >>> print_ans(999999, 999999)
    151840682
    """
    A = np.array([[1, 2],[2, 1]])
    B = np.array([X, Y])
    X = np.linalg.solve(A, B)
    if X[0].is_integer() and X[1].is_integer() :
        # ans1 = factorial(X[0] + X[1])
        # ans2 = factorial(X[0])
        # ans3 = factorial(X[1])
        # mod =  (10**9+7)
        # print((ans1 // ans2 * ans3 ) % mod)
        print(cmb(int(X[0] + X[1]),int(X[0]),mod))
        # print(math.factorial(X[0] + X[1]) // (math.factorial(X[0]) * math.factorial(X[1])))
    else:
        print("0")


if __name__ == '__main__':
    X, Y = map(int, input().rstrip().split())
    print_ans(X, Y)


Measured memory_bytes: 133640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int d=max(a,max(b,c));
  int ans=(d-a)/2+(d-b)/2+(d-c)/2;
  int p=(d-a)%2+(d-b)%2+(d-c)%2;
  if(p==1)ans+=2;
  if(p==2)ans+=1;
  if(p==0)ans+=0;
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int s;
double w,h;
char t;

int main(){
	while(cin>>s>>t>>w>>t>>h){
		if(w/(h*h)>=25) cout<<s<<endl;
	}
}

Measured memory_bytes: 1228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  ll N=S.size();
  ll count=0;
  vector<int> checked(N,1);
  rep(i,N){
    count++;
    if(i>0&&S[i]==S[i-1]&&checked[i-1]){
      if(i<N-1) {checked[i+1]=0; i++;}
      else count--;
    }
  }
  
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = a[n - 1] - a[0];
	cout << ans << endl;
	return 0;
}


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



int main() 
{
  ll N; cin>>N;
  ll time=0;
  vector<pair<ll,ll>> list(N);
  rep(i,N)
  {
    cin>>list.at(i).second>>list.at(i).first;
  }
  sort(list.begin(),list.end());
  rep(i,N)
  {
    time+=list.at(i).second;
    if(time>list.at(i).first) {cout<<"No"<<endl; return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> H;

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

    cin >> N;
    H.resize(N);
    REP(i, N) {
        cin >> H[i];
    }

    ll ans = 0;
    ll cur = 1;
    REP(i, N - 1) {
        if(H[i] >= H[i+1]) {
            cur++;
        }
        else {
            ans = max(ans, cur);
            cur = 1;
        }
    }
    ans = max(ans, cur);

    printf("%lld\n", ans - 1);

    return 0;
}


Measured memory_bytes: 1024
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 1000  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

n, m = MAP()
ans = cmb(n, 2) + cmb(m, 2)
print(ans)

Measured memory_bytes: 61804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	priority_queue<long,vector<long>,greater<long>> pq1;
	priority_queue<long> pq2;
	int Q = rei()-1;
	rei();
	long f = rei();
	long t = f;
	pq2.push(f);
	pq1.push(f);
	long minv = rei();
	for(int i=0;i<Q;i++){
		int q = rei();
		if(q == 2){
			cout << f << " " << minv << "\n";
		}
		else{
			long a = rei();
			long b = rei();
			minv += b;
			if(a < f){
				pq2.push(a);
				pq2.push(a);
				long v = pq2.top();
				minv += v-a;
				pq1.push(v);
				pq2.pop();
			}
			else if(a > t){
				pq1.push(a);
				pq1.push(a);
				long v = pq1.top();
				minv += a-v;
				pq2.push(v);
				pq1.pop();
			}
			else{
				pq1.push(a);
				pq2.push(a);
			}
			f = pq2.top();
			t = pq1.top();
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 4588
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  while(true){
    if((N / 100 == (N % 100 / 10)) && (N % 100 / 10 == N % 10)){
      cout << N << "\n";
      return 0;
    }

    N++;
  }
  
  return 0;
}


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

using namespace std;

const int Nmax = 2e5+5;

int n, m, i, x, y;
bool ok, used1[Nmax], used2[Nmax];

int main()
{
   // freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=1; i<=m; ++i)
    {
        cin >> x >> y;
        if(x == 1) used1[y] = 1;
        if(x == n) used2[y] = 1;
        swap(x, y);

        if(x == 1) used1[y] = 1;
        if(x == n) used2[y] = 1;
    }

    for(i=1; i<=n; ++i)
        if(used1[i] && used2[i])
        {
            cout << "POSSIBLE\n";
            return 0;
        }

    cout << "IMPOSSIBLE\n";

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s;
  cin >> s;
  string y,m,d;
  y = "2018";
  for (int i=0; i < s.size(); ++i) {
    if (i>=5 && i<7) {
      m += s[i];
    }
    if (i>=8) {
      d += s[i];
    }
  }
  cout << y << '/' << m << '/' << d << "\n";
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let (s, t): (String, String);
    input!(s, t);
    let s = s.to_charvec();
    let t = t.to_charvec();

    let mut i = 0;
    while i < n {
        print!("{}{}", s[i], t[i]);
        i += 1;
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll N,X,M;
  cin >> N >> X >> M;
  if (N < ll(1e6)) {
    ll ans = X;
    for (ll i = 2; i <= N; ++i) {
      X = (X*X)%M;
      ans += X;
    }
    cout << ans << endl;
    return 0;
  }


  ll ans = X;
  ll i = 2;
  while (i <= M) {
    X = (X*X)%M;
    ans += X;
    ++i;
  }

  map<ll,array<ll,2>> prev_sum;

  while (i <= N) {
    if (prev_sum.count(X)) {
      auto& [pi, p_sum] = prev_sum[X];
      ll cycle_len = i - pi;
      ll steps_remain = N+1 - i; // TODO should this be N?
      ll cycle_remain = steps_remain / cycle_len;
      ans += (ans-p_sum)*cycle_remain;
      i += cycle_len*cycle_remain;
      break;
    }
    prev_sum[X] = {i, ans}; // TODO should this be i-1
    X = (X*X)%M;
    ans += X;
    ++i;
  }

  while (i <= N) {
    X = (X*X)%M;
    ans += X;
    ++i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6688
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
int main(){
    char an[100];
    char bn[100];
    while(~scanf("%s%s",an,bn)){
        for(int i=0;i<strlen(an);i++){
            printf("%c",an[i]);
            if(i<strlen(bn)) printf("%c",bn[i]);
        }
        if(strlen(bn)>strlen(an)) printf("%c",bn[strlen(bn)-1]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache

import heapq


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,M,Q = inputIL()
A = inputILL(Q)

l = []
count = 0
for i_1 in range(1,M+1):
  for i_2 in range(i_1,M+1):
    for i_3 in range(i_2,M+1):
      for i_4 in range(i_3,M+1):
        for i_5 in range(i_4,M+1):
          for i_6 in range(i_5,M+1):
            for i_7 in range(i_6,M+1):
              for i_8 in range(i_7,M+1):
                for i_9 in range(i_8,M+1):
                  for i_10 in range(i_9,M+1):
                    l.append([i_1,i_2,i_3,i_4,i_5,i_6,i_7,i_8,i_9,i_10])
                    

best = 0 
for item in l:
  score = 0
  for q in A:
    a,b,c,d = q
    if item[b-1] - item[a-1] == c:
      score += d
  best = max(score,best)
  
print(best)

Measured memory_bytes: 98084
# -*- coding: utf-8 -*-

def comp_word(w1, w2, len):
    cnt = len
    for i,w in enumerate(w1):
        if w == w2[i]:
            cnt -= 1
    
    return cnt


def main(S, T):
    T_len = len(T)
    cnt_min = T_len
    for i in range(len(S)-T_len+1):
        sub_S = S[i:i+T_len]
        if len(sub_S) == T_len:
            cnt = comp_word(sub_S, T, T_len)
            if cnt < cnt_min:
                cnt_min = cnt 

    print(cnt_min)


S = input()
T = input()
main(S, T)


Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

bool isfb(ll n)
{
    return ((n%3 != 0) and (n%5 != 0));
}

int main()
{
    int N;
    cin >> N;
    ll sum = 0;
    rep(i, 1, N+1) {
        if (isfb(i)) {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
   int n, b, f, r, v;
   cin >> n;
   int a[4][3][10] = {};
   for (int i=0; i < n; i++) {
       cin >> b >> f >> r >> v;
       a[b-1][f-1][r-1] += v;
   }
   for (int j=0; j < 4; j++){
       for (int k=0; k < 3; k++) {
           for (int l=0; l < 10; l++) {
               cout << " " << a[j][k][l];
           }
           cout << endl;
       }
       if (j<=2) {
           for (int c=0; c<20; c++){
               cout << "#";
           }
           cout << endl;
       }
   }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

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

ll H,W,K,X1,Y1,X2,Y2;

bool inrange(ll x,ll y){
   return 0 <= x && x < H && 0 <= y && y < W;
}

/*char field[110][110];
ll d[110][110];*/

int main(){
   /*vector<vector<char>> field(H,vector<char>(W));
   vector<vector<ll>> d(H+10,vector<ll>(W+10));
   vector<vector<ll>> last(H+10,vector<ll>(W+10));*/
   queue<pair<ll,ll>> Q;

   

   cin >> H >> W >> K >> X1 >> Y1 >> X2 >> Y2;
   FOR(i,1,7){
      if(pow(10,i-1) <= H && H < pow(10,i)){
         ll h = pow(10,i) + 10,w = pow(10,7-i) + 10;
         vector<vector<char>> field(h,vector<char>(w));
         vector<vector<ll>> d(h,vector<ll>(w));
         vector<vector<ll>> last(h,vector<ll>(w));
         rep(i,H) rep(j,W) cin >> field[i][j];
         rep(i,H) rep(j,W) d[i][j] = INF;
         d[X1-1][Y1-1] = 0;
         Q.emplace(X1-1,Y1-1);
         while(Q.size()){
            ll x,y;
            tie(x,y) = Q.front();Q.pop();
            rep(i,4){
               FOR(j,1,K+1){
                  ll nx = x + dx[i] * j,ny = y + dy[i] * j;
                  if(!inrange(nx,ny)) break;
                  if(field[nx][ny] == '@') break;
                  if(d[nx][ny] <= d[x][y]) break;
                  if(d[nx][ny] > d[x][y] + 1){
                     Q.emplace(nx,ny);
                     d[nx][ny] = d[x][y] + 1;
                  }
                 
               }
            }
         }
         if(d[X2-1][Y2-1] == INF) cout << -1 << endl;
         else cout << d[X2-1][Y2-1] << endl;
         return 0;
      }
   }

   /*rep(i,H) rep(j,W) cin >> field[i][j];

   rep(i,H) rep(j,W) d[i][j] = INF;
   d[X1-1][Y1-1] = 0;
   Q.emplace(X1-1,Y1-1);

   while(Q.size()){
      ll x,y;
      tie(x,y) = Q.front();Q.pop();
      rep(i,4){
         FOR(j,1,K+1){
            ll nx = x + dx[i] * j,ny = y + dy[i] * j;
            if(!inrange(nx,ny)) continue;
            if(field[nx][ny] == '@' || d[nx][ny] != INF && last[nx][ny] != d[x][y]) break;
            d[nx][ny] = d[x][y] + 1;
            last[nx][ny] = d[x][y];
            Q.emplace(nx,ny);
         }
      }
   }

   rep(i,H){
      rep(j,W){
         if(d[i][j] != INF)cout << d[i][j];
         else cout << '#';
      }
      cout << endl;
   }


   if(d[X2-1][Y2-1] == INF) cout << -1 << endl;
   else cout << d[X2-1][Y2-1] << endl;*/

}


Measured memory_bytes: 343668
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL X, D;
LL M[55];
int P[55];

struct Data {
    LL sum;
    int sz;
    int i;
    bool operator<(const Data &y) const {
	return sum * y.sz < y.sum * sz;
    }
} H[55];

const int SIZE = 100011;
LL dp[SIZE];

void MAIN() {
    scanf("%d%lld%lld", &N, &X, &D);
    scanf("%lld", M);
    for (int i=1; i<N; i++) {
	scanf("%lld%d", M+i, P+i);
	P[i]--;
    }

    for (int i=N; i--;) {
	H[i].sum += M[i];
	H[i].sz += 1;
	H[i].i = i;
	if (i) {
	    int p = P[i];
	    H[p].sum += H[i].sum;
	    H[p].sz += H[i].sz;
	}
    }

    sort(H, H+N);

    LL GETA = min(D, 50LL);
    while ((D - GETA) % 50) GETA++;
    LL block = (D-GETA)/50;

    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    REP (i, N) {
	int rest = (H[i].i? GETA: 50LL);
	auto update = [&](int k) {
	    for (int j=SIZE-1; j>=H[i].sz*k; j--) {
		amin(dp[j], dp[j-H[i].sz*k] + H[i].sum*k);
	    }
	};
	int k = 1;
	while (k <= rest) {
	    update(k);
	    rest -= k;
	    k += k;
	}
	if (rest > 0) update(rest);
    }

    LL ans = 0;
    REP (j, SIZE) if (dp[j] <= X) {
	LL weight = X - dp[j];
	LL tmp = j;

	REP (i, N) {
	    LL k = weight / (H[i].sum*50);
	    if (H[i].i != 0) {
		amin(k, block);
	    }
	    weight -= k * H[i].sum * 50;
	    tmp += k * H[i].sz * 50;
	}
	amax(ans, tmp);
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

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

ll mod = 1e9+7;
ll N,M;

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

    cin >> N >> M;

    ll fecN,fecM;
    fecN = fecM = 1;

    for (int i = 1;i <= N;i++){
        fecN = fecN*i%mod;
    }
    for (int i = 1;i <= M;i++){
        fecM = fecM*i%mod;
    }

    if(N == M){
        cout << fecN*fecM*2%mod << endl;
    }else if(abs(N-M) == 1){
        cout << fecN*fecM%mod << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;

}

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


double area(double x1, double x2, double x3, double y1, double y2, double y3){
	double a, b, c, z;
	
	a = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	c = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	z = (a+b+c)/2.0;
	
	return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(void){
	double x[20], y[20];
	int n;
	double s;
	
	for (n=0; scanf("%lf,%lf",&x[n], &y[n])!=EOF; n++)
	;
	s=0;
	for (int i=2; i<n; i++){
		s += area(x[0],x[i-1],x[i],y[0],y[i-1],y[i]);
//		printf("(0,%d,%d) -> %f\n",i-1,i,area(x[0],x[i-1],x[i],y[0],y[i-1],y[i]));
	}
	printf("%f", s);
	return 0;
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    set<int> st;
    for (int i = 0; i < 3000; i++) {
        int x = i * c;
        if (x > f) {
            break;
        }
        if (x == 0) {
            x += d;
        }
        while (x < f) {
            st.insert(x);
            x += d;
        }
    }
    vector<int> v;
    for (auto &el : st) {
        v.push_back(el);
    }
    reverse(v.begin(), v.end());
    int ans = a, e_ans = 0;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            int x = a * i + b * j;
            if (x == 0 || x * 100 > f) {
                continue;
            }
            for (int i = 0; i < sz(v); i++) {
                if (v[i] <= x * e && v[i] + x * 100 <= f &&
                    1.0 * v[i] / x > 1.0 * e_ans / ans) {
                    ans = x, e_ans = v[i];
                }
            }
        }
    }
    cout << ans * 100 + e_ans << " " << e_ans << "\n";
}

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

# print(n, s)

def is_triangle(a, b, c):
	nums = []
	if a > b:
		if a > c:
			n_max = a
			nums = [b, c]
		else:
			n_max = c
			nums = [a, b]
	elif b > c:
		n_max = b
		nums = [a, c]
	else:
		n_max = c
		nums = [a, b]
	return(n_max < sum(nums))

ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			num_1 = s[i]
			num_2 = s[j]
			num_3 = s[k]
			if (num_1 == num_2) or (num_1 == num_3) or (num_2 == num_3):
				continue
			if is_triangle(num_1, num_2, num_3):
				ans += 1
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)
#define LL long long
#define pb push_back
#define mp make_pair
#define K 300001

int n, m;
vector<int> nxt[K];

vector<pair<int, int> > res;

int visited[K];
int deg[K];

int DFS(int u, int par) {
    visited[u] = 1;
    deg[u] = 0;
    
    FOR(i, 0, nxt[u].size()) {
        int t = nxt[u][i];
        
        if (t == par) continue;
        if (visited[t]) {
            if (u > t) {
                deg[u]++;
                res.pb(mp(u, t));
            }
        } else {
            int sol = DFS(t, u);
            
            if (sol % 2) {
                res.pb(mp(t, u));
            } else {
                deg[u]++;
                res.pb(mp(u, t));
            }
        }
    }
    
    return deg[u] % 2;
}

int main() {
    scanf("%d%d", &n, &m);
    
    FOE(i, 1, m) {
        int u, v; scanf("%d%d", &u, &v);
        
        nxt[u].pb(v);
        nxt[v].pb(u);
    }
    
    if (m % 2) {
        puts("-1");
        return 0;
    }
    
    DFS(1, -1);
    
    FOE(i, 1, m) printf("%d %d\n", res[i - 1].first, res[i - 1].second);
}

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

#define ll long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(b <= a){
	b *= 2;
	cnt++;
    }
    while(c <= b){
	c*=2;
	cnt++;
    }	
    if(cnt <= k)
	cout << "Yes\n";
    else
	cout << "No\n";
    return 0;
}


Measured memory_bytes: 3632
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int ans = 0;
  for(int i=1; i <N+1; i++){
    if(i % 2 == 1){
      int count = 0;
      for(int j=1; j<i+1; j++){
        if(i % j == 0) count++;
      }
      if(count == 8){
        ans++;
      }
    }
  }

  cout << ans << endl;

}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  ll N,K;
  cin >> N >> K;
  if(K%2==1){
    cout << (N/K)*(N/K)*(N/K) << endl;
  }
  else{
    ll t=N/K;
    ll S=2*N/K;
    cout << t*t*t+(S-t)*(S-t)*(S-t) << endl;
  }
}

Measured memory_bytes: 256
n, k, l = map(int, input().split())


class UnionFind():
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(n)
uf2 = UnionFind(n)

for _ in range(k):
    p, q = map(int, input().split())
    uf.unite(q-1, p-1)
for _ in range(l):
    r, s = map(int, input().split())
    uf2.unite(s-1, r-1)

#table = [[0]*n for _ in range(n)]
table = dict()

for i in range(n):
    #table[uf.root(i)][uf2.root(i)] += 1
    table[(uf.root(i), uf2.root(i))] = table.get(
        (uf.root(i), uf2.root(i)), 0)+1
for i in range(n):
    print(table[(uf.root(i), uf2.root(i))], end=' ')

exit(0)
for i, j in [(uf.root(i), uf2.root(i)) for i in range(n)]:
    table[i][j] += 1
for i, j in [(uf.root(i), uf2.root(i)) for i in range(n)]:
    print(table[i][j], end=' ')


exit(0)
for i in range(n):
    ans = 0
    for j in range(n):
        if uf.same(i, j) and uf2.same(i, j):
            ans += 1
    print(ans, end=' ')


Measured memory_bytes: 52784
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


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

	ll N = X.size();

	ll ans = 0;

	ll c = 0;

	rep(i, N) {
		if (X[i] == 'T') { c--; }
		else { c++; }

		if (c == -1) { c = 0; ans++; }
	}

	ans += c;

	cout << ans;


	system("PAUSE");

}





Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{ll s,t,d; Edge(ll s,ll t,ll d):s(s),t(t),d(d){}};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

int main() {
  ll N; cin>>N;
  vi A(N),B(N); REP(i,N) cin>>A[i]>>B[i];
  ll cnt=0;
  for(ll i=N-1;i>=0;i--)
    cnt+=((cnt+A[i]+B[i]-1)/B[i])*B[i]-A[i]-cnt;
  cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll m, f, r;
    while (cin >> m >> f >> r)
    {
        if (m == -1 && f == -1)
        {
            break;
        }
        else if (m == -1 || f == -1)
        {
            cout << "F" << endl;
            continue;
        }
        else if (m + f >= 80)
        {
            cout << "A" << endl;
        }
        else if (m + f >= 65)
        {
            cout << "B" << endl;
        }
        else if (m + f >= 50)
        {
            cout << "C" << endl;
        }
        else if (m + f >= 30)
        {
            if (r >= 50)
            {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
        }
        else
        {
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    D, T, S = readnums()
    print("Yes" if D / S <= T else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
		int n,m,k;
		cin>>n>>m>>k;
		vector<int> v,u,a(n+1),b(m+1);
		rep(i,0,n){
			int t;
			cin>>t;
			v.pub(t);
			a[i+1]=a[i]+t;
		}
		rep(i,0,m){
			int t;
			cin>>t;
			u.pub(t);
			b[i+1]=b[i]+t;
		}
		int i=0,j=m;
		int ans=0;
		while(i<=n&&j>=0){
			if(a[i]>k)break;
			while(a[i]+b[j]>k)j--;
			ans=max(ans,i+j);
			i++;
		}
		cout<<ans<<"\n";
   return 0;
}

Measured memory_bytes: 11092
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
}

func main() {
	s := ReadLine()
	var c int

	if string(s[0]) == "1" {
		c += 1
	}
	if string(s[1]) == "1" {
		c += 1
	}
	if string(s[2]) == "1" {
		c += 1
	}
	fmt.Println(c)
}

/*------ scan ------*/

func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


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

int main(){
   int c[5][5][15];
   int n, b, f, r, v;
   
   for(int i = 1; i <= 4; i++){
       for(int j = 1; j <= 3; j++){
           for(int t = 1; t <= 10; t++){
               c[i][j][t] = 0;
           }
       }
   }
   
   cin >> n;
   for(int i = 0; i < n; i++){
       cin >> b >> f >> r >> v;
       c[b][f][r] += v;
   }
   
   for(int i = 1; i <= 4; i++){
       for(int j = 1; j <= 3; j++){
           for(int t = 1; t <= 10; t++){
               cout << ' ' << c[i][j][t];
           }
           cout << endl;
       }
       if(i != 4)  cout << "####################"<<endl;
   }
   return 0;
}


Measured memory_bytes: 3096
# Wrote in Mar 28, 2020 21:13 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

k,m = inp
a = inp

sences = []

a.size.times do |n|
  if n==0
    sences.push(k-a[a.size-1]+a[0])
  else
    sences.push(a[n]-a[n-1])
  end
end

puts k-sences.max



Measured memory_bytes: 18496
#include <cstdio>

int main()
{
  for(;;){
    int n,m;
    scanf("%d %d",&n,&m);
    if(n==0)return 0;
    int count[m];
    for(int i=0;i<m;i++)
      count[i]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	int tmp;
	scanf("%d",&tmp);
	if(tmp==1)count[j]++;
      }
    }


    int max =0;
    int max_no=-1;
    for(int j=0;j<m;j++){
      for(int i=0;i<m;i++){
	if(count[i]<0)continue;
	if(count[i]>max){
	  max=count[i];
	  max_no=i;
	}else if(count[i]==max && i < max_no){
	  max=count[i];
	  max_no=i;
	}
      }
      printf("%d",max_no+1);
      max=0;
      count[max_no]=-1;
      if(j!=m-1)printf(" ");
      /*for(int i=0;i<m;i++)
	printf("%d ",count[i]);
	printf("\n");*/
    }
    printf("\n");
  }
    

}

Measured memory_bytes: 1032
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int s[100] = {};
int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	REP(i, 3) {
		if (s[i] == 'a')a++;
		if (s[i] == 'b')b++;
		if (s[i] == 'c')c++;
	}
	if (a == 1 && b == 1 && c == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
   int a,b,i,c[5];
    
   for (i=1;i<=4;i++) c[i]=0;
   for (i=0;i<3;i++) {
      scanf("%d %d",&a,&b);
      c[a]++;c[b]++;
   }
   if (c[1]==0 || c[2]==0 || c[3]==0 || c[4]==0) puts("NO");
   else if (c[1]==3 || c[2]==3 || c[3]==3 || c[4]==3) puts("NO");
   else  puts("YES");
   return 0;
}


Measured memory_bytes: 128
#include "ctype.h"
#include <iostream>
#include <string>

int main(int argc, char const* argv[])
{
	std::string str;
	int i = 0;

    std::getline(std::cin, str);

	while (str[i] != 0)
	{
		if (isupper(str[i]) && str[i] != ' ')
		{
			str[i] = tolower(str[i]);
			std::cout <<  str[i];
		}
		else if (islower(str[i]) && str[i] != ' ')
		{
			str[i] = toupper(str[i]);
			std::cout << str[i];
		}
		else
			std::cout << str[i];
        i++;
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 1176