akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<vector<int>> G;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    G.assign(N,vector<int>());
    for (int i = 0; i < M; i++)
    {
        int a,b; cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
}

int ans=0;
void dfs(int u, int bit){
    bit |= (1<<u);
    if(bit==((1<<N)-1)) ans++;
    for(auto v:G[u]){
        if((bit>>v)&1) continue;
        dfs(v,bit);
    }
}

int solve(){
    int bit=0;
    dfs(0,bit);
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
// Optimization
 
//#pragma GCC optimize("O3")
#define endl '\n'
 
// Shortcut
 
#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)
 
// I/O & Debug
 
#define PrintV(a) Fora(iiii, a) cout << iiii << ' ';
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/
 
// Functions
 
//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
 
// Data Structure
 
#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;
 
const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
 
int n, m, k;
int q = 1;
int ans, tmp, cnt, idx, mx, mn, sum;
int x, y, z;
int a[N], b[N];
string s, t;
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//cin >> q;
while (q--){
    cin >> n;
    mn = inf;
    ForE(i, 1, n){
        cin >> a[i];
        if (a[i] < mn){
            mn = a[i];
            ans++;
        }
    }
    cout << ans;
}
}
 
/*
==================================+
INPUT:                            |
------------------------------    |
 
------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |
 
------------------------------    |
==================================+
*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   
//int r,c,k,dp[maxn][4];
//vector<pair<pii,int>>v(maxn);

// int solve2(int pos,int take){
//     if(pos > k)return 0;
//     int &ans = dp[pos][take];
//     if(ans != -1)return ans;
//     int r = v[pos].f.f,c = v[pos].f.se;
//     if(take == 0){
//         if(pos == k)return 0;
//         pair<pii,int>p = {{r+1,c},0};
//         int i = v.lower_bound(v.begin()+1,v.begin()+k+1,p)-v.begin();
//         return solve2(i,3);
//     }   
//     pair<pii,int>p = {{r,c+1},0};
//     int i = v.lower_bound(v.begin()+1,v.begin()+k+1,p)-v.begin();
//     if(i <= k){
//         if(v[i].f.f == r)ans = v[pos].se+solve2(i,take-1);
//         else {
//             p = {{r+1,c+1},0};
//             i = v.lower_bound(v.begin()+1,v.begin()+k+1,p)-v.begin();
//             if(i <= k)ans = v[pos].se+solve2(i,3);
//         }
//     }
//     if(pos < k){
//         if(v[pos+1].f.f == r)ans = max(ans,solve2(pos+1,take));
//         else {

//         }
//     }
// }
int mat[3002][3002],dp[3005][3005][4];
int r,c,k;

int solve2(int i,int j,int rem){
    if(i > r || j > c)return 0;
    int &ans = dp[i][j][rem];
    if(ans != -1)return ans;
    if(rem > 0){
        ans = mat[i][j];
        ans += max(solve2(i+1,j,3),solve2(i,j+1,rem-1));
    }
    ans = max(ans,max(solve2(i+1,j,3),solve2(i,j+1,rem)));
    return ans;
}

void solve(){
    cin >> r >> c >> k;
    // FOR(i,1,k+1)cin >> v[i].f.f >> v[i].f.se >> v[i].se;
    // sort(v.begin()+1,v.begin()+k+1);
    // memset(dp,-1,sizeof dp);
    // cout << solve2(1,3) << "\n";
    FOR(i,1,k+1){
        int r1,c1,v1;
        cin >> r1 >> c1 >> v1;
        mat[r1][c1] = v1;
    }
    memset(dp,-1,sizeof dp);
    cout << solve2(1,1,3) << "\n";
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 



Measured memory_bytes: 356448
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=1000010;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


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

int main()
{
  fastio;
  int  i, n, g=0, c=0;
  
  cin>>n;
  vector<int>ar(n);
  vector<int>cnt(sz);
  
  for(i=0; i<n; i++)
  {
      cin>>ar[i];
      cnt[ar[i]]++;
      g=gcd(g,ar[i]);
  }
  
 for(i=2; i<=sz; i++)
 {
     c=0;
     for(int j=i; j<=sz; j+=i)
     {
         c+=cnt[j];
     }
     if(c>1)break;
 }
  if(i==sz+1)
  {
      printf("pairwise coprime\n");
  }
  else if(g==1)
  {
      printf("setwise coprime\n");
  }
  else printf("not coprime\n");
  
  return 0;
}


Measured memory_bytes: 11116
#include<iostream>
#include<vector>
#include<limits>
using namespace std;
 
int N, K;
 
int main() {
  scanf("%d%d", &N, &K);
  vector<int> x(N);
 
  for (int n = 0; n < N; ++n) scanf("%d", &x[n]); 
  
  int minval = numeric_limits<int>::max();
  for (int n = 0; n + K <= N; ++n) {
    int l = x[n], r = x[n + K - 1];
    int maxpos = max(0, r);
    int maxneg = max(0, -l);
    minval = min(minval, maxpos + maxneg + min(maxpos, maxneg));
  }
 
  printf("%d\n", minval);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    map<char, string> cards;
    cards['A'] = s1;
    cards['B'] = s2;
    cards['C'] = s3;
    char turn = 'A';
    while (cards[turn].size() > 0) {
        char current = toupper(cards[turn].at(0));
        cards[turn].erase(0, 1);
        turn = current;
    }
    cout << turn << endl;
    return 0;

}

Measured memory_bytes: 256
use std::cmp::max;
use std::fmt::Debug;
use std::io::stdin;
use std::str::FromStr;

fn read<T>() -> Vec<T>
where
	T: FromStr,
	<T as FromStr>::Err: Debug,
{
	let mut s = String::new();
	stdin().read_line(&mut s).unwrap();
	s.trim()
		.split_whitespace()
		.map(|c| T::from_str(c).unwrap())
		.collect()
}

#[derive(Clone)]
struct Review {
	x: i64,
	y: i64,
	z: i64,
}

impl Review {
	fn new(r: &[i64]) -> Review {
		Review {
			x: r[0],
			y: r[1],
			z: r[2],
		}
	}

	fn dot(&self, o: &Review) -> i64 {
		o.x * self.x + o.y * self.y + o.z * self.z
	}
}

fn main() {
	let x: Vec<usize> = read();
	let mut select: Vec<Review> = Vec::new();
	for i in 0..8 {
		let v: Vec<i64> = vec![i & 0x4, i & 0x2, i & 0x1]
			.iter()
			.map(|&i| if i == 0 { -1 } else { 1 })
			.collect();
		select.push(Review::new(v.as_slice()));
	}

	let mut reviews: Vec<Review> = Vec::new();
	for _ in 0..x[0] {
		let r: Vec<i64> = read();
		reviews.push(Review::new(r.as_slice()));
	}
	println!(
		"{}",
		select
			.iter()
			.map(|sel| {
				let mut biased_points: Vec<i64> = reviews.iter().map(|v| v.dot(&sel)).collect::<Vec<i64>>();
				biased_points.sort_by(|a, b| b.cmp(a));
				biased_points
					.iter()
					.take(x[1])
					.fold(0, |sum, item| sum + item)
					.abs()
			})
			.fold(0, |sum, item| max(sum, item))
	)
}


Measured memory_bytes: 4352
#include <cstdio>

int main()
{
    int N, K;
    scanf("%d %d", &N, &K);
    double p = 1.0 / N;
    double ans = 0.0;
    for (int i = 1; i <= N; ++i)
    {
        double tempprob = p;
        int q = i;
        while (q < K)
        {
            q *= 2;
            tempprob *= 0.5;
        }
        ans += tempprob;
    }
    printf("%.12f\n", ans);
    return 0;
}


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

int main() {
	string s;
	int i;
	cin>>s;
	for(i=0;i<4;i++){
		cout<<s[i];
	}
	cout<<" ";
	for(i=4;i<12;i++){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
r,c,i,j,R[101],C[101],t;
main(){
    for(scanf("%d%d",&r,&c),i=0;i<=r;i++)
        for(j=0;j<=c;j++){
            if(i<r&&j<c){
                scanf("%d",&t);
                R[i]+=t,C[j]+=t,C[c]+=t;
            }
            printf("%d%s",i==r?C[j]
                         :j==c?R[i]
                         :t,
                          j==c?"\n"
                         :" ");
        }
}

Measured memory_bytes: 1808
K, A, B = list(map(int, input().split()))
# K,A,B = 1,2,2


cnt = 1

if K < A + 1:
    cnt += K
    print(cnt)
    exit()

rest = K - (A - 1)
cnt += (A - 1)

if (B - A) > 2:
    if (rest%2 == 0):
        cnt += (B - A) * rest // 2
    else:
        cnt += (B - A) * ((rest - 1) // 2)
        cnt += 1
else:
    cnt += rest

print(cnt)


Measured memory_bytes: 3060
loop do
    n = gets.to_i
    break if n== 0
    a = n.times.map{gets.to_i}
    max = -Float::INFINITY
    for i in 0...n
        sum = 0
        for j in i...n
            sum += a[j]
            max = [sum, max].max
        end
    end
    puts max
end

Measured memory_bytes: 6120
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const R = args[0],
        D = args[1],
        X = args[2];
  let pre = X; //前年度の苔の量
  
  for (let i = 0; i < 10; i++) {
    pre = (R * pre) - D;
    console.log(pre);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30680
// https://atcoder.jp/contests/abc123/tasks/abc123_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<long> v(5), w(5, 0);
    long n, minv = INT64_MAX;
    cin >> n;
    for (int i = 0; i < 5; i++) {
        cin >> v[i];
        minv = min(minv, v[i]);
    }
    // 各地点から最大人数を乗せて次へ行く
    long ans = 1;
    w[0] = n;
    // 最初に終着点についた人数と増加人数を求める
    while (w[4] == 0) {
        for (int i = 4; i >= 1; i--) {
            int t = min(w[i - 1], v[i]);
            w[i] += t;
            w[i - 1] -= t;
        }
        ans++;
    }
    // cout << ans << ":" << w[4] << endl;
    cout << (long)ceil((double)n / minv) + ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n, counter;
vector<int> arr;
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0, z;i <n;i++) {
        cin >> z;
        arr.pb(z);
    }
    for (int i = 1; i<n-1;i++) {
        int maxi = max(arr[i], max(arr[i-1], arr[i+1]));
        int mini = min(arr[i], min(arr[i-1], arr[i+1]));
        if (arr[i] != mini && arr[i] != maxi) {
            counter += 1;
        }
    }
    cout << counter << "\n";

}

Measured memory_bytes: 256
// ロジック一部修正の上, 再提出.
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using T3 = tuple<int, int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
int c[505050]; // 石情報.
int q[505050]; // クエリ回答.
// handmade04, random06 で, WA版 となったため, ロジック変更.
// int b[505050]; // 良い玉.
map<int, int> b; // 良い玉.

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i & -i) d[i] += x;
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i & -i) x += d[i];
        return x;
    }
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }
};

int main(){
    
    // 1. 入力情報.
    int N, Q, x, y;
    scanf("%d %d", &N, &Q);
    rep(i, N) scanf("%d", &c[i]);
    vector<T3> v;
    rep(i, Q){
        scanf("%d %d", &x, &y);
        x--, y--;
        v.emplace_back(x, y, i);
    }
    
    // 2. sort.
    // https://www.geeksforgeeks.org/sorting-vector-tuple-c-ascending-order/
    sort(all(v), [](const T3 &a, const T3 &b){
        return get<1>(a) < get<1>(b);
    });
    // for(auto &p : v) printf("l=%d r=%d i=%d\n", get<0>(p), get<1>(p), get<2>(p));
    
    // 3. クエリの回答を作成.
    BIT<int> ft(N + 1);
    int bef = 0, cur = 0;
    assert(v.size() == Q);
    rep(j, Q){
        int l = get<0>(v[j]);
        int r = get<1>(v[j]);
        int i = get<2>(v[j]);
        
        // 今回分更新.
        cur = r;
        
        // 良い玉の集合を更新.
        repx(k, bef, cur + 1){
            // 前回以前に, 良い玉をチェック済か否か.
            if(b.count(c[k])){
                int at = b[c[k]];
                if(at < k){
                    // 良い玉の場所を解除.
                    int tSum = ft.sum(at, at + 1);
                    assert(tSum <= 1);
                    if(tSum) ft.add(at, -1);
                    
                    // 良い玉の出現位置を更新.
                    b[c[k]] = k;
                    
                    // 良い玉の場所を更新.
                    ft.add(k, 1);
                    // printf("k=%d tSum=%d c[k]=%d b=%d at=%d\n", k, tSum, c[k], b[c[k]], at);
                    // puts("----------");
                    // rep(m, N + 1) printf("%d ", ft.sum(m, m + 1));
                    // puts("\n----------");
                }
            }else{
                // 良い玉の出現位置を更新.
                b[c[k]] = k;
                
                // 良い玉の場所を更新.
                ft.add(k, 1);
            }
        }
        
        // クエリ回答.
        q[i] = ft.sum(l, r + 1);
        
        // 前回分更新.
        bef = cur;
        
    }
    
    // 4. 出力.
    rep(i, Q) printf("%d\n", q[i]);
    return 0;
    
}

Measured memory_bytes: 38980
#include <stdio.h>

int main(){

    int a, b, fee;

    scanf("%d", &a);
    scanf("%d", &b);

    if(a>=13){
        fee =b;
    }else if(a>=6){
        fee =b/2;
    }else{
        fee =0;
    }

    printf("%d", fee);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll dp[100001][4]={0};
int N;


ll seno(ll prev_idx, ll level,ll C[][4])
{


ll ans=0;




if (level==N)
{
for (int i=0;i<3;i++)
{
if (i!=prev_idx)
ans=max(ans,C[level][i]);

}

 
return dp[level-1][prev_idx]=ans;
}



if (dp[level-1][prev_idx]!=INT_MAX)
return dp[level-1][prev_idx];  


for (int i=0;i<3;i++)
{
if (i!=prev_idx)
ans=max(ans, seno(i, level+1, C)+C[level][i]);

}  


return dp[level-1][prev_idx]=ans;
}


int main() 
{ 



fastio();
int T;


cin>>N;

ll A[N+1][4];

for(int i=1;i<=N;i++)
{
for(int j=0;j<3;j++)
cin>>A[i][j];  

}


for (int i=0;i<=100000;i++)
{
  for(int j=0;j<4;j++)
  dp[i][j]=INT_MAX;  
}  

ll x=seno(3, 1, A);



cout<<x;
  return 0 ; 
} 




Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, r, g, b, n);
    int ans = 0;
    For(i, n+1) For(j, n+1){
        int a = r*i + g*j;
        if(a <= n && (n-a) % b == 0) ans ++;
    }
    Cout(ans);
}





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

string day[7] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};

int main(){
    int m, d;
    while(cin >> m >> d, m != 0){
        int y = 2004;
        if(m == 1 || m == 2){
            y--;
            m += 12;
        }
        int h = (d + 26*(m+1)/10 + (y%100) + ((y%100)/4) + 5*(y/100) + (y/100)/4) % 7;
        cout << day[h] << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int A[59], B[59], C[59];

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

	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) cin >> B[i];
	for (int i = 1; i <= N - 1; i++) cin >> C[i];

	int ans = 0;
	for (int i = 1; i <= N; i++) ans += B[i];
	for (int i = 1; i <= N - 1; i++) {
		if (A[i + 1] == A[i] + 1) ans += C[A[i]];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rep1(i,N) for(int i=1;i<=(int)N;++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using int64 = long long;
using i64 = long long;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}

template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
   os << "[";
   for(auto &e : v) os << e << ", ";
   os << "]";
   return os;
}

i64 gcd(i64 a, i64 b) {
   return (b == 0) ? a : gcd(b, a % b);
}

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

const int inf = 1 << 30;
const int64 inf64 = 1ll << 60;

//#define int long long

const int mod = 1e9 + 7;

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

int main() {
   int n, m; cin >> n >> m;
   vector<vector<int>> G(n);
   vector<int> indeg(n);
   rep(i, m) {
      int a, b; cin >> a >> b, a--, b--;
      G[a].emplace_back(b);
      indeg[b]++;
   }

   bool exist = false;
   int c = 0;
   rep(i, n) {
      if(indeg[i] == 0 && c != 0) exist = true;
      else if(indeg[i] == 0) c++;
   }
   
   vector<int> res;
   vector<int> used(n);
   for(int i=0; i<n; ++i) {
      if(indeg[i] == 0 && !used[i]) {
         queue<int> que;
         que.emplace(i);
         while(!que.empty()) {
            int idx = que.front(); que.pop();
            used[idx] = 1;
            res.emplace_back(idx);
            int c = 0;
            for(auto &e : G[idx]) {
               indeg[e]--;
               if(indeg[e] == 0) {
                  que.emplace(e);
                  c++;
               }
            }
            if(c >= 2) exist = true;
         }
      }
   }

   rep(i, n) cout << res[i] + 1 << endl;
   cout << exist << endl;
}



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

int main()
{
    int A, B;
    string op;
    cin >> A >> op >> B;
    if (op == "+")
    {
        cout << A + B << endl;
    }
    else
    {
        cout << A - B << endl;
    }
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7
#define MAX_V

int main(){
    int n, k;
    cin>>n>>k;
    int h[n];
    int ans = 0;
    REP(i, n){
        cin>>h[i];
        if(h[i] >= k){
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

ll comb(ll n, ll r){
    ll child = 1, mother = 1;
    if(r<n/2){
        for(ll i = 1; i <= r; i++){
            ll a = n-i+1, b = i;
            child = child * a;
            mother = mother * b;
            //cout << child << " " << mother << endl;
            if(child%mother==0){
                child /= mother;
                mother = 1;
            }
        }
    }
    else if(r>=n/2){
        for(ll i = 1; i <= n-r; i++){
            ll a = n-i+1, b = i;
            child = child * a;
            mother = mother * b;
            //cout << child << " " << mother << endl;
            if(child%mother==0){
                child /= mother;
                mother = 1;
            }
        }
    }
    ll ans = child / mother;
    return ans;
}

int main(void){
    ll n, p;
    cin >> n >> p;
    ll a = 0, b = 0;
    for(ll i = 0; i < n; i++){
        ll c;
        cin >> c;
        if(c%2==0) a++;
        else b++;
    }
    //cout << a << " " << b << endl;
    ll ans = 0;
    if(p==1){
        for(ll i = 1; i <= b; i+=2){
            for(ll j = 0; j <= a; j++){
                ans+=comb(b, i)*comb(a, j);
                //cout << i << " " << j  << " " << comb(b,i) << " " << comb(a, j) << endl;
            }
        }
    }
    if(p==0){
        for(ll i = 0; i <= a; i++)
            for(ll j = 0; j <= b; j+=2)
                ans+=comb(a, i)*comb(b, j);
    }
    cout << ans << endl;
    //cout << comb(50, 25) << endl;
    return 0;
}


Measured memory_bytes: 256
// abc059.a

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,x;
    cin >> n >> x;

    vector<LL> a(n);

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

    vector<LL> best(n);

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

    LL min = 0;

    for(int i = 0; i < n; i++){
        min += best[i];
    }

    for(LL k = 1; k < n; k++){
        for(int i = 0; i < n; i++){
            int j = i - k;
            if(j < 0){
                j += n;
            }
            if(best[i] > a[j]){
                best[i] = a[j];
            }
        }

        LL sum = 0;
        for(int i = 0; i < n; i++){
            sum += best[i];
        }
        sum += k*x;
        if(sum < min){
            min = sum;
        }
    }
    
    cout << min << endl;

    return 0;
}

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

int main(){
  int N,x,j=0;
  long long count=0;
  cin>>N>>x;
  int num[N];
  for(int i=0;i<N;i++){
    cin>>num[i];
  }
  while(j+1<N){
    if(x<num[j]+num[j+1]){
      int a=num[j]+num[j+1]-x;
      if(num[j]>=x){
          count+=num[j+1];
          num[j+1]=0;
      }else{
          if(a<=num[j+1]){
            count+=a;
            num[j+1]-=a;
          }else{
            count+=num[j+1];
            num[j+1]=0;
          }
      }if(x<num[j]){
        count+=num[j]-x;
        num[j]-=num[j]-x;
      }
    }j++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N, M;
	cin >> N >> M;

	cout << N * (N - 1) / 2 + M * (M - 1) / 2;

	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
table = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h):
    for j in range(w):
        if table[i][j] % 2 == 0:  # 偶数の時は何もしない
            pass
        elif i == h-1 and j == w-1:  # 隅っこの時も何もしない
            pass
        else:
            table[i][j] -= 1
            if j != w - 1:  # 右が端ではないとき
                table[i][j+1] += 1  # 右に1たす
                ans.append([i+1, j+1, i+1, j+2])
            elif i != h - 1:  # 下が端ではないとき
                table[i+1][j] += 1  # 下に1たす
                ans.append([i+1, j+1, i+2, j+1])
print(len(ans))

for i in ans:
    print(*i)

Measured memory_bytes: 30276
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int N=1e5;
int n,a[N+1],b[N+1];
struct point {
    int id,val;
    bool isA;
};
point p[N*2+1];
int posA[N+1],posB[N+1];
long long sumA,sumB,sumN,res;
int read()
{
    int ret=0;
    char c=getchar();
    while(!isdigit(c)) {
        c=getchar();
    }
    while(isdigit(c)) {
        ret=ret*10+c-'0';
        c=getchar();
    }
    return ret;
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) {
        a[i]=read(),b[i]=read();
    }
    for(int i=1;i<=n;++i) {
        sumA+=a[i],sumB+=b[i];
        p[i*2-1]=point{i,a[i],true},p[i*2]=point{i,b[i],false};
    }
    sort(p+1,p+n*2+1,[](const point x,const point y) {
        return x.val<y.val;
    });
    for(int i=1;i<=n*2;++i) {
        (p[i].isA?posA:posB)[p[i].id]=i;
    }
    for(int i=1;i<=n;++i) {
        sumN+=p[i].val;
    }
    res=min(sumA,sumB);
    for(int i=1;i<=n;++i) {
        if((posA[i]<=n)&&(posB[i]<=n)) {
            res=min(res,sumN);
            break;
        } else {
            if(posA[i]<=n) {
                res=min(res,sumN+b[i]-p[posA[i]==n?n-1:n].val);
            } else {
                if(posB[i]<=n) {
                    res=min(res,sumN+a[i]-p[posB[i]==n?n-1:n].val);
                } else {
                    res=min(res,sumN+a[i]+b[i]-p[n-1].val-p[n].val);
                }
            }
        }
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 5508
import sys
n=int(input())
print(0)
l=input()
L=0
if l=='Vacant':
  sys.exit()
print(n-1)
r=input()
R=n-1
if r=='Vacant':
  sys.exit()

while True:
  print((L+R)//2)
  x=input()
  X=(L+R)//2
  if x=='Vacant':
    sys.exit()
  if ((X-L)%2==1 and x==l) or ((X-L)%2==0 and x!=l):
    r=x;R=X
  else:
    l=x;L=X

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <typeinfo>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;
typedef vector<vector<string>> vvs;

constexpr int dir[4][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };



int main()
{
	int n;
	cin >> n;
	vi a(n), b(n);

	rep(i, n) cin >> a[i];

	int p1, p2;
	p1 = p2 = n / 2;
	p2--;

	rep(i, n)
	{
		if (i % 2 == 0)
		{
			b[p1] = a[i];
			p1++;
		}
		else
		{
			b[p2] = a[i];
			p2--;
		}
	}

	if (n % 2 == 1) reverse(b.begin(), b.end());
	rep(i, n)
	{
		cout << b[i] << " ";
	}

	return 0;
}


Measured memory_bytes: 3712
import numpy as np
import sys
input = sys.stdin.readline


def main():
    h, w, k = map(int, input().split())
    values = np.zeros((h, w), dtype=np.int64)
    items = np.array([list(map(int, input().split())) for _ in range(k)])
    ys, xs, vs = items[:, 0] - 1, items[:, 1] - 1, items[:, 2]
    values[ys, xs] = vs

    DP = np.zeros(w + 1, dtype=np.int64)
    for line in values:
        DP[1:] += line
        DP = np.maximum.accumulate(DP)
        for _ in range(2):
            DP[1:] = np.maximum(DP[:-1] + line, DP[1:])
            DP = np.maximum.accumulate(DP)
    print(DP[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 105332
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

X = In.int()

there = dict()

B = 0
B5 = 0

while B5<10**12:
    B5 = B**5
    there[B5] = B
    if B5 != 0:
        there[-B5] = -B
    B+=1

A = 0
A5 = 0

while A5<10**12:
    A5 = A**5
    
    if A5-X in there:
        Out.ints([A, there[A5-X]])
        break
    A+=1

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68116
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
C = [0 for i in range(N)]
A.sort()
i = 0
while i < N - 1:
    C[A[i] - 1] = C[A[i] - 1] + 1
    i += 1

for i in C:
    print(i)

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 1e6;
const ll LINF = (ll) 1e18 + 1e9;
const ld EPS = (ld) 1e-7;
const ll MOD = (ll) 998244353;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; ++(i))
#define per(i, f, t) for (auto i = (f); i >= (t); --(i))

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

void add(ll &x, ll y) {
    x += y;
    if (x >= MOD) x -= MOD;
    if (x < 0) x += MOD;
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = (int) 2e5 + 123;
const int L = 29;

int n;
int a[N], b[N];
int q[N];

int f(int l, int r) {
    if (l > r) return 0;
    return (int) (upper_bound(q, q + n, r) - lower_bound(q, q + n, l));
}

void run() {
    cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    int ans = 0;
    rep(bit, 0, L) {
        rep(i, 0, n) {
            q[i] = (b[i] & ((1 << (bit + 1)) - 1));
        }
        sort(q, q + n);
        ll cnt = 0;
        int k = bit;
        rep(i, 0, n) {
            int x = (a[i] & ((1 << (k + 1)) - 1));
            cnt += f((1 << k) - x, (1 << (k + 1)) - 1 - x) + f((1 << (k + 1)) + (1 << k) - x, INF);
        }
        if (cnt % 2 == 1) {
            ans |= (1 << bit);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 2560
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    cin >> n;
    ll max = 0;
    ll ans = 0;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        if(max <= tmp){
            max = tmp;
        }else{
            ans += (max-tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

LL N, K;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> K;

	int a, b, q, r;
	LL ans = 0;

	if(K == 0){
		printf("%lld\n", N*N);
		return 0;
	}

	for(b = K + 1; b<=N; b++){
		for(q = 0; ; q++){
			if(b*q > N){
				break;
			}
			r = N - (b*q);
			if(r >= b){
				r = b - 1;
			}
			if(r >= K){
				ans += (r - K + 1);
			}
		}
	}

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

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

int main(){
	int N, M; cin >> N >> M;
	vector<int> S[M];
	for(int i=0; i<M; i++){
		int k; cin >> k;
		for(int j=0; j<k; j++){
			int s; cin >> s;
			s--;
			S[i].push_back(s);
		}
	}
	int p[M];
	for(int i=0; i<M; i++){
		cin >> p[i];
	}
	int ans = 0;
	for(int i=0; i<(1<<N); i++){
		int f = 0;
		for(int j=0; j<M; j++){
			int cnt = 0;
			for(int t=0; t<S[j].size(); t++){
				if(i & (1<<S[j][t])) cnt++;
			}
			if(cnt % 2 != p[j]) f = 1;
		}
		if(!f) ans++; 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

bool check(string str){
	string str2 = str;
	reverse(str.begin(), str.end());
	if(str == str2)
		return true;
	else
		return false;
}

int main()
{
	string str;
	cin >> str;
	int n = str.length();
	string str1 = str.substr(0, n/2), str2 = str.substr((n+1)/2, n/2);
	if(check(str) && check(str1) && check(str2))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl p(n);
  rep(i, n) cin >> p[i];
  vl sp = p;
  sort(all(sp));
  if(sp == p) {
    cout << "YES" << endl;
    return 0;
  }
  rep(i, n - 1) rep2(j, i + 1, n) {
    swap(p[i], p[j]);
    if(sp == p) {
      cout << "YES" << endl;
      return 0;
    }
    swap(p[i], p[j]);
  }
  cout << "NO" << endl;
}

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

#define ll long long

int main(){
	ll A, B, C, D; cin >> A >> B >> C >> D;
	// cout << A*C << " " << A*D << " " << B*C << " " << B*D << "\n";
	cout << max({A*C, A*D, B*C, B*D}) << "\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    cout << (n+1)/2 -1 << endl;
    return 0;
}

Measured memory_bytes: 3648
import math
A,B,H,M = map(int,input().split( ))
pi = 2*math.pi
time = H*60. + M
theta_A = (time/720.)*pi
theta_B = (M/60.)*pi
theta = abs(theta_A - theta_B)
if theta >= 180:
    theta = pi - theta
C = A**2 + B**2 - 2*A*B*math.cos(theta)
print(math.sqrt(C))

Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, k;
    cin >> n >> k;
    if (n * 500 >= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int>s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  sort(s.begin(),s.end());
  int ans=0;
  for(int i=0;i<n;i++) ans+=s[i];
  if(ans%10!=0) cout<<ans<<endl;
  else{
    for(int i=0;i<n;i++){
      if(s[i]%10!=0){
        cout<<ans-s[i]<<endl;
        break;
      }
      else if(i==n-1) cout<<0<<endl;
    }
  }
}


Measured memory_bytes: 256