akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<P> a(n);
    rep(i,n){
      cin>>a[i].second>>a[i].first;
    }
    sort(begin(a),end(a),greater<P>());
    vector<ll> cnt(n+1,0);//各種類の使われた個数
    priority_queue<P,vector<P>,greater<P>> que;
    ll ans=0;
    ll kind=0;
    vector<ll> f(n+1,0);//x種類使った時の満足ポイント
    rep(i,k){
      ans+=a[i].first;
      cnt[a[i].second]++;
      if(cnt[a[i].second]>=2){
        que.push(a[i]);
      }else{
        kind++;
      }
    }
    f[kind]=ans+kind*kind;
    if(k==n||kind==n||que.empty()){
      cout<<f[kind]<<endl;
      return 0;
    }
    FOR(i,k,n){
      if(cnt[a[i].second]!=0){
        continue;
      }
      P x=que.top();
      f[kind+1]=f[kind]-kind*kind+(kind+1)*(kind+1)-x.first+a[i].first;
      kind++;
      que.pop();
      cnt[a[i].second]++;
      cnt[x.second]--;
      if(kind==n){
        break;
      }
    }
    //cout_vec(f);
    cout<<*max_element(begin(f),end(f))<<endl;
}

Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=2500000;
const ll mod=1e9+7;
ll dp[22][MX],n,a[30][30];
ll ok(ll p, ll msk)
{
    if(msk==((1LL<<n)-1LL)) return 1;

    if(~dp[p][msk])return dp[p][msk];
    ll mx=0;
    for(int i=0;i<n;i++)
    {
        if(!(msk&(1LL<<i))&&a[p][i])
        {
            mx=(mx+ok(p+1,msk|(1<<i)))%mod;
        }
    }
    return dp[p][msk]=mx;
}
int main()
{
    FasterIO;
    ll x,y;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    mem(dp,-1);
    ll res=ok(0,0);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 430080
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
5 4
0 1
1 2
2 3
3 4

output:
1
2
3
"""

import sys

sys.setrecursionlimit(int(3e6))
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
        # undirected graph
        init_adj_table[v_to].append(v_from)
    return init_adj_table


def graph_dfs(current, prev):
    global timer
    pre_v[current] = lowest_v[current] = timer
    timer += 1
    # print('time', timer)

    color[current] = VISITED_IN_STACK

    for adj in adj_table[current]:
        if color[adj] is UNVISITED:
            parent_v[adj] = current

            # recursive dfs
            graph_dfs(adj, current)

            lowest_v[current] = min(lowest_v[current], lowest_v[adj])
        elif adj is not prev:
            lowest_v[current] = min(lowest_v[current], pre_v[adj])

    return None


def art_points():
    graph_dfs(dfs_root, -1)

    np = 0
    for v in range(1, vertices):
        parent = parent_v[v]
        if parent is dfs_root:
            np += 1
        elif pre_v[parent] <= lowest_v[v]:
            art_set.add(parent)

    if np > 1:
        art_set.add(dfs_root)

    return art_set


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])
    pre_v, parent_v, lowest_v = ([-1] * vertices for _ in range(3))
    init_adj_table = tuple([] for _ in range(vertices))

    timer = 1
    # root
    dfs_root = 0

    art_set = set()
    color = [UNVISITED] * vertices

    adj_table = generate_adj_table(v_info)

    res = art_points()
    # print('pre', pre_v, 'pr', parent_v, 'lo', lowest_v)
    if not res:
        pass
    else:
        # print(*sorted(art_points()), sep='\n')
        print(*sorted(res), sep='\n')

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

int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    vector <int> a(n);
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    int allxor=a[0];
    for (int i=1; i<a.size(); i++){
        allxor^=a[i];
    }

    vector <int> sol(n);
    for (int i=0; i<a.size(); i++){
        sol[i]=allxor^a[i];
    }
    
    for (int i=0; i<n; i++){
        cout<<sol[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll fizbuzz(ll n){
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    return sum;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll n;
    while(cin>>n){
        cout<<fizbuzz(n)<<endl;
    }
    return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, M, L, Q;
const int NODE_SIZE = 310;

ll d[NODE_SIZE][NODE_SIZE];  //ノード接続関係 兼 最短距離(任意の二点間)

/*==================================================*/

//ワーシャル・フロイド法
void warshall_floyd(){
	// L以下の最短を求める
    REP(k,0,N){
        REP(i,0,N){
            if(d[i][k] > L) continue;
            REP(j,0,N){
            if(d[k][j] > L) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
	REP(i,0,N){
		REP(j,0,N){
			if(d[i][j] <= L) d[i][j] = 1;
			else d[i][j] = inf;
		}
	}
	// 以降は絶対通る
	REP(k,0,N){
		REP(i,0,N){
			if(d[i][k] == inf) continue;
			REP(j,0,N){
				if(d[k][j] == inf) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main(){
	cin >> N >> M >> L;
	REP(i,0,N){
		REP(j,0,N){
			if(i==j) d[i][j] = 0;
			else d[i][j] = inf;
		}
	}
	REP(i,0,M){
		ll a, b;
		cin >> a >> b;
		a--;b--;
		cin >> d[a][b];
		d[b][a] = d[a][b];
	}
	warshall_floyd();
	cin >> Q;
	ll s, t;
	REP(i,0,Q){
		cin >> s >> t;
		s--;t--;
		p((d[s][t] == inf ? -1: d[s][t]-1));
	}
	return 0;
}

Measured memory_bytes: 1280
import sys
import bisect
def main():
    input = sys.stdin.readline
    s = input().rstrip()
    t = input().rstrip()

    letters = set(t)
    indices = dict()
    for l in letters:
        lst = []
        left = 0
        while left < len(s):
            i = s.find(l, left)
            if i < 0: break
            lst.append(i)
            left = i+1
        if not lst:
            print(-1)
            exit()
        indices[l] = lst
    
    offset = 0
    cycle = 0
    for l in t:
        ind = indices[l]
        i = bisect.bisect_left(ind, offset)
        if i < len(ind):
            offset = ind[i] + 1
        else:
            offset = ind[0] + 1
            cycle += 1
        if offset >= len(s):
            offset %= len(s)
            cycle += 1

    print(len(s)*cycle + offset)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47368
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	map<int, ll> M;
	vll DP(N + 1);
	DP[0] = 1;
	int pre = -1;
	REP(i, N)
	{
		int C;
		cin >> C;
		DP[i + 1] = DP[i];
		if (pre != C)
		{
			DP[i + 1] += M[C];
		}
		DP[i + 1] %= MOD;
		M[C] = DP[i + 1];
		pre = C;
	}
	cout << DP[N] << endl;
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b)
{
    if (a > b)
        a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b)
{
    if (a < b)
        a = b;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << max(0ll, a - 2 * b);
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int a = input[0];
			int b = input[1];
			int min, max;
			min = b * 10;
			max = (b + 1) * 10;
			int c = -1;
			for (int i = min; i < max; i++) {
				if (Math.Floor(i * 0.08) == a) { c = i; break; }
			}
			Console.WriteLine(c);
			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[n-i-1])
            ans++;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int main(){
	ll money = 0, amount = 0, ave;
	int temp1, temp2, t = 0;
	char trash;
	while(cin >> temp1 >> trash >> temp2){
		t++;
		money += temp1*temp2;
		amount += temp2;
	}
	ave = (int)(((double)amount/(double)t)+0.5);
	cout << money << endl;
	cout << ave << endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
int main(){
    int n,a,b,c,d;
    cin >> n>>a>>b>>c>>d;
    a -=1,b-=1,c-=1,d-=1;
    string s;
    cin>>s;
    bool ans=true;
    //まず単独で判定    
    for(int i=a;i<c;i++){
        if(s[i]=='#'&& s[i+1]=='#'){
            ans = false;
        }
    }
    for(int i=b;i<d;i++){
        if(s[i]=='#'&& s[i+1]=='#'){
            ans = false;
        }
    }
    if(ans){//ここから両方
        if(b<d&&d<c){
            bool three =false;
            for(int x=b;x<=d;x++){
                if(s[x-1]=='.'&&s[x]=='.'&&s[x+1]=='.'){
                    three = true;
                }
            }
            if(!three){
                ans = false;
            }
        }
    }

    if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

const int N = 3010;
using ll = long long;

int a[N][N];
ll dp[N][N][4];

void update(ll &u, ll v, int w){
    v += w;
    u = std::max(u, v);
}

int main(){
    int r, c, k;
    scanf("%d%d%d", &r, &c, &k);
    for (int i = 0; i < k; ++ i){
        int R, C, v;
        scanf("%d%d%d", &R, &C, &v);
        a[R][C] = v;
    }
    memset(dp, -1, sizeof(dp));
    dp[1][0][0] = 0;
    for (int i = 1; i <= r; ++ i){
        for (int j = 1; j <= c; ++ j){
            for (int k = 0; k <= 3; ++ k){
                if (dp[i - 1][j][k] != -1){
                    update(dp[i][j][0], dp[i - 1][j][k], 0);
                    if (a[i][j]){
                        update(dp[i][j][1], dp[i - 1][j][k], a[i][j]);
                    }
                }
                if (dp[i][j - 1][k] != -1){
                    update(dp[i][j][k], dp[i][j - 1][k], 0);
                    if (a[i][j] && k < 3){
                        update(dp[i][j][k + 1], dp[i][j - 1][k], a[i][j]);
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= 3; ++ i){
        update(ans, dp[r][c][i], 0);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 322140
N = int(input())
List = list(map(int,input().split()))
ans = 1000
stock = 0
for i in range(1,N):
  if List[i] > List[i-1]:
    temp = ans
    ans = temp%List[i-1]
    stock += temp//List[i-1]
  if List[i] < List[i-1]:
    ans += stock*List[i-1]
    stock = 0
if stock != 0:
  ans += stock*List[-1]
print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int main(){
  string s, t;
  cin>>s;
  for(char x: s){
    if(x=='0' || x=='1')t.pb(x);
    if(x=='B' && !t.empty())t.pop_back();
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
loop do
arr = gets.split.map(&:to_i)
h = arr[0]
w = arr[1]
if h != 0 || w != 0 then
for i in 1..h
for j in 1..w
if j != w then
if (j % 2) == (i % 2) then
print "#"
else
print "."
end
else
if (w % 2) == (i % 2) then
puts "#"
else
puts "."
end
end
end
if i == h then
puts ""
end
end
else
exit
end
end


Measured memory_bytes: 6872
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    bool first = true;
    while(true){
        int ans[4];
        int num[4];
        int n;

        cin >> n;
        if(n==0) break;
        if(!first) cout << endl;
        first = false;
        cin >> num[3] >> num[2] >> num[1] >> num[0];
        int all = 0;
        int mic = 100000;
        rep(i,4) all+=num[i];
        rep(i,num[0]+1) rep(j,num[1]+1) rep(k,num[2]+1) rep(l,num[3]+1){
            int kk = 500 * i + 100 * j + 50 * k + 10 * l;
            if(kk < n) continue;
            int retc = kk - n;
            int ret = 0;
            ret += retc / 500;
            retc %= 500;
            ret += retc / 100;
            retc %= 100;
            ret += retc / 50;
            retc %= 50;
            ret += retc / 10;
            int uu = i+j+k+l;
            int r = all - uu + ret;
            if(r < mic){
                mic = r;
                ans[0] = i;ans[1] = j;ans[2] = k;ans[3] = l;
            }
        }
        for(int i=3;i>=0;i--){
            if(ans[i] == 0) continue;
            cout << (i==0?500:i==1?100:i==2?50:10) << " " << ans[i] << endl;
        }
    }
    return 0;
}

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

namespace AtCoder {
    public class Program {
        static void Main() {
            var s = Console.ReadLine();
            int Answer = 753;
            for (int offset = 0; offset < s.Length - 2; offset++) {
                int n = 0;
                for (int i = 0; i < 3; i++) {
                    n += (int)Math.Pow(10, 2 - i) * (s[offset + i] - '0');
                }
                Answer = Math.Min(Answer, Math.Abs(753 - n));
            }
            Console.WriteLine(Answer);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, V, P;
    cin >> N >> M >> V >> P;
    int A[100010];
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    // rep(i, N) cout << A[i] << " ";
    // cout << endl;
    int ok = A[0] + 1;
    int ng = -1;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int id = 0;
        rep(i, N) if(A[id] > A[i] && A[i] >= mid) id = i;
        int score = A[id] + M;
        int v = V;
        int need = 0;
        int same = 0;
        int margin = M * (V - 1);
        int lose = 0;
        priority_queue<int> que;
        rep(i, N) {
            if(i == id) continue;
            if(score < A[i]) {margin -= M; lose++;}
            if(score == A[i]) {same++; que.push(M);}
            if(score > A[i]) {margin -= min(M, score - A[i]); que.push(M - min(M, score - A[i])); }
        }
        while(lose + 1 < P && que.size()) {margin -= que.top(); que.pop(); lose++;}
        //cout << mid << " " << lose << " " << margin << endl;
        if(lose < P && margin <= 0) ok = mid;
        else ng = mid;
    }
    int ans = 0;
    rep(i, N) if(A[i] >= ok) ans++;
    cout << ans << endl;



    return 0;
}
// N = 6, M = 1, V = 5, P = 2
// 0 1 2 3 4 5
// 3 2 2 1 1 0
// 3 2 2 2 2 0 (remain = 4)

Measured memory_bytes: 5864
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
now = 0
res = INF
cnt = 0
for i in range(n):
    now += a[i]
    if i%2 == 0:
        if now <= 0:
            cnt += 1-now
            now = 1
    else:
        if now >= 0:
            cnt += now+1
            now = -1
    # print(i,now,cnt)
res = min(res,cnt)
now = 0
cnt = 0
for i in range(n):
    now += a[i]
    if i%2:
        if now <= 0:
            cnt += -now + 1
            now = 1
    else:
        if now >= 0:
            cnt += now + 1
            now = -1
    # print(i,now,cnt)    
res = min(res,cnt)
print(res)

Measured memory_bytes: 16392
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> m(n), sl(n + 1, 0), sr(n + 1, 0);
  priority_queue<ll> qr;
  priority_queue<ll, vector<ll>, greater<ll>> ql;
  REP(i, n) {
    ll l;
    cin >> l;
    sl[0] += l;
    ql.push(l);
  }
  REP(i, n) cin >> m[i];
  REP(i, n) {
    ll r;
    cin >> r;
    sr[0] += r;
    qr.push(r);
  }

  FOR(i, 1, n + 1) {
    sl[i] = sl[i - 1];
    sl[i] += m[i - 1];
    ql.push(m[i - 1]);
    sl[i] -= ql.top();
    ql.pop();
  }
  reverse(ALL(m));
  FOR(i, 1, n + 1) {
    sr[i] = sr[i - 1];
    sr[i] += m[i - 1];
    qr.push(m[i - 1]);
    sr[i] -= qr.top();
    qr.pop();
  }

  ll ans = -INF;
  REP(i, n + 1) { ans = max(ans, sl[i] - sr[n - i]); }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4852
import sys

def cross(a, b):
	return (a.conjugate() * b).imag
def dot(a, b):
	return (a.conjugate() * b).real

def ccw(a, b, c):
	x = b - a
	y = c - a;
	cr = cross(x, y)
	if cr != 0: return cr
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0

def solve(l, p):
	x = cmp(ccw(l[0][0], l[0][1], p), 0)
	if any([x != cmp(ccw(i[0], i[1], p), 0) for i in l[1:]]):
		print "NO"
	else: print "YES"

for line in sys.stdin:
	t = map(float, line.split())
	if len(t) == 0: continue
	a, b, c, p = map(lambda x, y: complex(x, y), t[0::2], t[1::2])
	solve([(a, b), (b, c), (c, a)], p)

Measured memory_bytes: 5300
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<float> v(n);

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

  sort(v.begin(), v.end());

  float ans = (v[0]+v[1])/2.;
  for (int i = 2; i < n; i++) {
    ans = (ans + v[i])/2.;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    if (4*a*b < (c-a-b)*(c-a-b) && (c-a-b)>=0)
    {
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        list.add(1);

        int tmp = 1;
        while (true) {
            tmp *= 6;
            if (tmp > n) break;
            list.add(tmp);
        }

        tmp = 1;
        while (true) {
            tmp *= 9;
            if (tmp > n) break;
            list.add(tmp);
        }

        boolean[][] dp = new boolean[20][n + 1];
        dp[0][0] = true;
        for (int i = 1; i < dp.length; i++) {
            for (int j = 0; j < list.size(); j++) {
                for (int k = 0; k < dp[0].length; k++) {
                    if (k - list.get(j) >= 0 && dp[i - 1][k - list.get(j)]) {
                        dp[i][k] = true;
                    }
                }
            }
        }

        for (int i = 0; i < dp.length; i++) {
            if (dp[i][n]) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 24532
n=int(input())
a=list(map(int,input().split()))
dp=[[0,0] for i in range(n)]
dp[0][0]=a[0]
dp[1][0]=dp[0][0]+a[1]
dp[1][1]=dp[0][0]-2*a[0]-a[1]
for i in range(2,n):
    dp[i][0]=max(dp[i-1])+a[i]
    dp[i][1]=max(dp[i-1][0]-2*a[i-1]-a[i],dp[i-1][1]+2*a[i-1]-a[i])
print(max(dp[n-1]))

Measured memory_bytes: 99232
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

# # # # unionfind.py # # # #

# usage: uf = Unionfind(n) ; x = uf.root(y); uf.conn(a,b)

class Unionfind:

  def __init__(s,n):
    s.sz = [1] * n
    s.ances = [i for i in range(n)]

  def root(s,x):
    a = []
    y = x
    while s.ances[y] != y:
      a.append(y)
      y = s.ances[y]
    for z in a:
      s.ances[z] = y
    return y

  def conn(s,x,y):
    i = s.root(x)
    j = s.root(y)
    if i==j:
      return
    #k  = [i,j].min
    k  = j if (s.sz[i]<s.sz[j]) else i
    if k==j:
      s.ances[i] = j
    else:
      s.ances[j] = i
    s.sz[k] = s.sz[i] + s.sz[j]

# # # # end unionfind.py # # # #

n,m = inm()
a = inl()
nouse = 2*m-n+2
if n-m==1:
    print('0')
    exit()
if nouse<0:
    print('Impossible')
    exit()
uf = Unionfind(n)
for i in range(m):
    x,y = inm()
    uf.conn(x,y)
g = {}
for i in range(n):
    r = uf.root(i)
    if r not in g:
        g[r] = []
    g[r].append((a[i],i))

import heapq
h = []
for r in g:
    if len(g[r])<=1:
        continue
    g[r].sort()
    x,i = g[r].pop()
    heapq.heappush(h,(-x,r))
sm = 0
for i in range(nouse):
    xm,r = heapq.heappop(h)
    sm -= xm
    if len(g[r])>1:
        y,j = g[r].pop()
        heapq.heappush(h,(-y,r))
print(sum(a)-sm)


Measured memory_bytes: 94392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vi v(n);
	vector<double> d(n);
	rep(i, n) {
		cin >> v[i];
		d[i] = abs(a - (t-v[i]*0.006));
	}
	int ans = (min_element(all(d)) - d.begin())+1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
 
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define so(v) sort(v.begin(),v.end())
#define re(s) reverse(s.begin(),s.end())
#define lb(v,a) lower_bound(v.begin(),v.end(),a)
#define ub(v,a) upper_bound(v.begin(),v.end(),a)
#define mp1(a,b,c) piii(a,pii(b,c))
 
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const ll mod=1e9+7;

int main(){

  ll n,x,a,b,sum;
  cin>>n>>x;
  a=x; b=n-x; sum=n;
  while(a){
    sum+=2*a*(b/a);
    ll t=b%a;
    b=a;
    a=t;
  }
  sum-=b;
  cout<<sum<<endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 100;
int a[N + 5], b[N + 5];
int n;
int main(){
  FASTER;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++){
    if (a[i] > b[i]){
      sum += (a[i] - b[i]);
    }
  }
  cout << sum << '\n';
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(a)  begin(a),end(a)
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef long long unsigned int llu;


/*---------------------------------------------------------------------------------*/


int main(){
   int N,M;
   int sum=0;
   scanf("%d %d",&N,&M);
   int m[M][2] = {};
   int tmp1,tmp2;
   rep(i,M){
     scanf("%d %d",&tmp1,&tmp2);
     m[i][0] = tmp1 -1;
     m[i][1] = tmp2 -1;
   }
   int mtx[N][N] = {};
   int node1,node2;
   int check[N] = {};
   int checksum;


   rep(x,M){
     node1 = m[x][0];
     node2 = m[x][1];
     rep(i,N){
       rep(j,N) mtx[i][j] = 0;
     }
     rep(i,N) check[i] =0;
     checksum = 0;
     rep(j,M){
         mtx[m[j][0]][m[j][1]] = 1;
         mtx[m[j][1]][m[j][0]] = 1;
     }
     mtx[node1][node2] = 0;
     mtx[node2][node1] = 0;
     queue<int> que;
     que.push(0);
     while(!que.empty()){
       tmp1 = que.front();
       que.pop();
       check[tmp1] = 1;
       rep(i,N){
         if(mtx[tmp1][i]==1 && check[i] == 0) que.push(i);
       }
     }
     rep(i,N){
       if(check[i]==1)checksum++;
     }
     if(checksum!=N) sum++;
   }
   printf("%d",sum);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ary[] = {a, b, c};
		Arrays.sort(ary);
		if(ary[2] == ary[0] + ary[1]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)
 const double pi = 3.141592653589793238;
int main()
{
    int n,i,j,t;
    boost;
    int m;
    cin>>n>>m;
    ll sum=0;
    rep(i,0,m)
    {
        cin>>j;
        sum+=j;
    }
    if(sum<=n)cout<<n-sum;
    else cout<<-1;
    return 0;
}



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

using namespace std;

#define ll long long int
#define ull unsigned long long int 
#define Rep(i,n) for(ll i=0;i<n;i++) 
#define rRep(i,n) for(ll i=n;i>=0;i--)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define itr(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define vi vector<int>  
#define vl vector<ll> 
#define vul vector<ull>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define Si set<int> 
#define Mi multiset<int> 
#define Sl set<ll> 
#define Ml multiset<ll>
#define mapi map<int,int>
#define mapl map<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second  
#define INF (ll)1e9;
#define mod (ll)(1e9+7);
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define T ll test;cin >> test;while(test--)

int main(){
    fast;      
    ll n;cin>>n;
    vector<pair<ll,ll>> vv(n);
    ll x,y;
    Rep(i,n){
        cin>>x>>y;
        vv[i]=mp(x,y);
    }
    ll d=0;
    for(int i=0;i<=n-3;i++){
        if(vv[i].ff==vv[i].ss&&vv[i+1].ff==vv[i+1].ss&&vv[i+2].ff==vv[i+2].ss){
            cout<<"Yes"<<endl;
            d=1;
            break;
        }
    }
    if(!d){
        cout<<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: "List[int]"):
    Nmax = sorted(N)
    
    l = [Nmax[0], Nmax[3], Nmax[2], Nmax[1]]
    if ''.join(map(str,l)) == '1974':
        print(YES)
    else:
        print(NO)
    
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = [int(next(tokens)) for _ in range(4)]  # type: "List[int]"
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
#define M 1000000007

int main() {
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for (ll i = k; i <= n + 1; ++i) {
        //cerr << i << ": ";
        //cerr << (n + n - i + 1) * i / 2 << " - ";
        // res %= M;
        //cerr << (i - 1 + 0) * (i) / 2 << endl;
        res += (n + n - i + 1) * i / 2 - (i - 1 + 0) * (i) / 2 + 1;
        res %= M;
    }
    cout << res << endl;
}
 


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

int main() {
	long long n, ans=0, f=10;
	cin >> n;
	if (n % 2 == 0) {
		while (n>=f){
			ans += (n / f);
			f *= 5;
		}
	}
	cout << ans << endl;
	return(0);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = []
check = True
for i in range(n):
    if a[i] % 2 == 0:
        b.append(a[i])
for i in range(len(b)):
    if b[i] % 3 != 0 and b[i] % 5 != 0:
        check = False
if check:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d; cin >> a >> b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d}) << endk;
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


class unionfind {
public:
	int N;
	vector<int> par;
	vector<int> buf;
	unionfind(int n) :N(n) {
		par.resize(N);
		buf.reserve(N);
		for (int i = 0; i < n; ++i)par[i] = i;
	}

	int getpar(int ind) {
		buf.clear();
		while (par[ind] != ind) {
			buf.push_back(ind);
			ind = par[ind];
		}
		for (int i = 1; i < buf.size(); ++i) par[buf[i]] = ind;
		return ind;
	}

	void merge(int ind1, int ind2) {
		int par1 = getpar(ind1);
		int par2 = getpar(ind2);
		par[par1] = par[par2];
	}

	bool same(int ind1, int ind2) { return getpar(ind1) == getpar(ind2); }
};

struct edge {
	int n1;
	int n2;
	ll cost;
};

int main() {
	ll N; cin >> N;
	vector<pair<ll, ll>> p; p.resize(N);
	REP(i, 0, N)cin >> p[i].first >> p[i].second;
	auto cmpx = [&](int i, int j) {return p[i].first < p[j].first; };
	auto cmpy = [&](int i, int j) {return p[i].second < p[j].second; };
	auto cmpedge = [](edge a, edge b) {return a.cost > b.cost; };
	auto dist = [](pair<ll, ll> a, pair<ll, ll> b) {return min(abs(a.first - b.first), abs(a.second - b.second)); };
	vector<int> ix(N), iy(N);
	REP(i, 0, N) ix[i] = i;
	REP(i, 0, N) iy[i] = i;
	sort(ix.begin(), ix.end(), cmpx);
	sort(iy.begin(), iy.end(), cmpy);
	priority_queue<edge, vector<edge>, decltype(cmpedge)> q(cmpedge);
	REP(i, 0, N - 1) q.push(edge{ ix[i],ix[i + 1],dist(p[ix[i]],p[ix[i + 1]]) });
	REP(i, 0, N - 1) q.push(edge{ iy[i],iy[i + 1],dist(p[iy[i]],p[iy[i + 1]]) });
	unionfind u{ (int)N };
	ll ans = 0;
	while (!q.empty()) {
		edge ed = q.top();
		q.pop();
		if (u.same(ed.n1, ed.n2))continue;
		ans += ed.cost;
		u.merge(ed.n1, ed.n2);
	}
	PRI(ans);
	return 0;
}

Measured memory_bytes: 9816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  ll size(int k) {
    return (-data[find(k)]);
  }
};

int main(void){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> G(N);
    vector<pair<int,int>> E(M);
    for (int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        E[i] = make_pair(a-1,b-1);
    }
    reverse(E.begin(),E.end());
    UnionFind uf(N);
    vector<ll> conv(M);

    for (int i=0;i<M;i++){
        int a,b;
        a = E[i].first;
        b = E[i].second;

        ll temp = uf.size(a)*uf.size(b);
        if (uf.unite(a,b)) {
            conv[i] = temp;
        }
        else {
            conv[i] = 0;
        }
        //cout<<conv[i]<<endl;
    }
    reverse(conv.begin(),conv.end());
    ll inconv = 0;
    for (int i=0;i<M;i++){
        inconv += conv[i];
        cout<<inconv<<endl;
    }
    return 0;  
}

Measured memory_bytes: 5632
#include <stdio.h>
  
#define INF 10000000
  
int main(){
  int n,i,j,k,l,t,m[101],c,o;
  int mm[101][101];
   
   
  scanf("%d",&n);
  for(i = 1 ; i < n+1; i++){
    scanf("%d%d",&m[i-1],&m[i]);
  }
   
for( i = 1 ; i <= n ; i++ ){
    mm[i][i] = 0;
  }  
   
  for(l = 2 ; l <n+1 ; l++){
    for(i=1;i<n-l+2;i++) {
        o=i+l-1;
    mm[i][o] = INF;
   
    for(k = i ; k < o ; k++){
t=mm[i][k] + mm[k+1][o] + m[i-1] * m[k] *m[o];
 
        if(t < mm[i][o])
          mm[i][o] = t;
        }
      }
    }
  printf("%d\n",mm[1][n]);
  return 0;
  }



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

using namespace std;

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

    int x;
    if (b < 10) x = a * 10 + b;
    else if (b < 100) x = a * 100 + b;
    else x = a * 1000 + b;

    int s = sqrt(x);
    if (s * s == x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: ABC333
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  if ((a * b) & 1) puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int main(){
	int i,j,k;
	char s[MAX];
	
	scanf("%s",s);
	scanf("%d",&k);
	
	for(i = 0;s[i] != '\0';i++){
		if(s[i]=='a')continue;
		if('z'-(int)s[i]+1 <= k){
			k -= 'z'-(int)s[i]+1;
			s[i] = 'a';
		}
	}
	i--;
	if(k > 0){
		k %= 26;
		s[i] += k;
		s[i]=(s[i]-'a')%26+'a';
	}
	printf("%s\n",s);
	
	return 0;
}

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

int N, M, Q;
std::vector<int> ends[501];

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  std::cin>>N>>M>>Q;
  for (int i = 0; i < M; ++i) {
    int L, R; std::cin>>L>>R;
    ends[L].push_back(R);
  }

  for (int i = 1; i <= N; ++i) {
    std::sort(ends[i].begin(), ends[i].end());
    /*for (int x : ends[i])
      std::cout<<x<<" ";
    std::cout<<"\n";*/
  }

  while (Q--) {
    int P, Q; std::cin>>P>>Q;
    int ans = 0;
    for (int i = P; i <= Q; ++i) {
      int j = -1;
      for (int jump = ends[i].size(); jump >= 1; jump >>= 1)
        while (j+jump < ends[i].size() and ends[i][j+jump] <= Q)
          j += jump;
      //std::cout<<i<<" "<<j<<" "<<"\n";
      ans += j + 1;
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define M 1000010

ll spf[M],mob[M],phi[M];
void seive(){
	rep(i,2,M)if(!spf[i])for(ll j=i;j<M;j+=i)if(!spf[j])spf[j]=i;
	rep(i,1,M){
		if(i==1)mob[i]=1;
		else{
			if(spf[i/spf[i]]==spf[i])mob[i]=0;
			else mob[i]=-1*mob[i/spf[i]];
		}
	}
	rep(i,0,M)phi[i]=i;
	rep(i,2,M)if(phi[i]==i){phi[i]=i-1;for(ll j=2*i;j<M;j+=i)phi[j]=(phi[j]/i)*(i-1);}
}
ll ex(ll a,ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%md;a=(a*a)%md,b/=2;}return ans;} 
inline ll add(ll a,ll b){a=a%md+b%md;if(a>md)a%=md;return a;}
inline ll sub(ll a,ll b){a=a%md-b%md;if(a<0)a+=md;return a;}
inline ll mul(ll a,ll b){return (a*b)%md;}


int main(){
	IOS;
	tihs;
	
	seive();
	ll n,k;cin>>n>>k;
	ll sum=0;
	rep(i,1,k+1){
		ll x=ex(k/i,n);
		(x*=phi[i])%=md;
		(sum+=x)%=md;
	}
	cout<<" "<<sum;
	return 0;
}

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

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define scc(t) scanf("%c", &t)
#define scw(t) cin >> t
#define scs(t) getline(cin, t)
#define fori(t) for (int i = 0; i < t; i++)
#define forij(t, p)             \
    for (int i = 0; i < t; i++) \
        for (int j = 0; j < p; j++)
#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    string s;
    scw(s);

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
        

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x=0, mx=0;
  rep(i, N) {
    if(S[i] == 'I') x++;
    else x--;
    mx = max(mx, x);
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 256
Nlist = list(map(int,input().split()))
counter = 0
if Nlist.count(1) == 1:
    if Nlist.count(9) == 1:
        if Nlist.count(7) == 1:
            if Nlist.count(4) == 1:
                counter = 1
                print("YES")
if counter == 0:
    print("NO")


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

#define int long long
typedef pair<int, int> P;

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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    if(s.equals("SAT")){
      System.out.println(1);
    }else if(s.equals("FRI")){
      System.out.println(2);
    }else if(s.equals("THU")){
      System.out.println(3);
    }else if(s.equals("WED")){
      System.out.println(4);
    }else if(s.equals("TUE")){
      System.out.println(5);
    }else if(s.equals("MON")){
      System.out.println(6);
    }else if(s.equals("SUN")){
      System.out.println(7);
    }






  }



}

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

int main() {
    int N; cin >> N;
    int p[N];
    for(int i=0; i<N; i++) cin >> p[i];

    int a[N]={};
    int b[N]={};

    for(int i=0; i<N; i++) {
	a[i] = 21000*i + 1;
	b[i] = 21000*(N-1-i) + 1;
	    }
    for(int i=0; i<N; i++) {
	a[p[i]-1] += i;
	b[p[i]-1] += i;
    }
    for(int i=0; i<N; i++) {
	if(i!=N-1)
	    cout << a[i] << " ";
	else
	    cout << a[i] << "\n";
    }
    for(int i=0; i<N; i++) {
	if(i!=N-1)
	    cout << b[i] << " ";
	else
	    cout << b[i] << "\n";
    }
    
}


Measured memory_bytes: 896