akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#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 EPS 1e-9

int main(){
	int n;cin>>n;
	int tm=0,cx=0,cy=0;
	rep(i,n){
	    int t,x,y;
	    cin>>t>>x>>y;
	    int dt=t-tm,dx=x-cx,dy=y-cy;
	    //cout<<dt<<","<<dx<<","<<dy<<endl;
	    int len=abs(dx)+abs(dy);
	    if(len>dt || len%2!=dt%2){
	        cout<<"No"<<endl;
	        return 0;
	    }
	    tm=t,cx=x,cy=y;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            string S = Console.ReadLine();

            for(int i = 0; i < N; i++)
            {
                if(i == K - 1)
                {
                    Console.Write(S[i].ToString().ToLower());
                }
                else
                {
                    Console.Write(S[i]);
                }
                
            }


            Console.WriteLine();

        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
 
#define N 100000
 
typedef struct {
  int p,k,dep;
  int *l;
} Node;
 
int main(){
  int i,j,n,id;
  Node T[N],tmp;
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
    T[i].p = -1;
    T[i].dep = 0;
  }
  for(i=0; i<n; i++){
    scanf("%d",&id);
    scanf("%d",&T[id].k);
    T[id].l = (int *)malloc(sizeof(int) * T[id].k);
    for(j=0; j<T[id].k; j++){
      scanf("%d",&T[id].l[j]);
      T[T[id].l[j]].p = id;
    }    
  }
 
  for(i=0; i<n; i++){
    tmp = T[i];
    while(1){
      if(tmp.p == -1) break;
      T[i].dep++;
      tmp = T[tmp.p];
    }  
  }
 
 
  for(i=0; i<n; i++){
    if(T[i].dep == 0){
      printf("node %d: parent = %d, depth = %d, root, [", i, T[i].p, T[i].dep);
       
      for(j=0; j<T[i].k-1; j++){
    printf("%d, ", T[i].l[j]);
      }
  
      if(T[i].k != 0) printf("%d]\n",T[i].l[j]);
      else printf("]\n");
    }
    else if(T[i].k != 0 && T[i].p != -1){
      printf("node %d: parent = %d, depth = %d, internal node, [", i, T[i].p, T[i].dep);
      for(j=0; j<T[i].k-1; j++){
    printf("%d, ", T[i].l[j]);
      }
      printf("%d]\n",T[i].l[j]);
    }
    else if(T[i].k == 0){
      printf("node %d: parent = %d, depth = %d, leaf, []\n", i, T[i].p,  T[i].dep);
    }
  }
 
  return 0;
 
}

Measured memory_bytes: 6460
//Created Time:2020年06月07日 星期日 19时59分48秒
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 202
#define ll long long

using namespace std;

char s[N];
ll a[N], d[N];

bool ins(ll x){
	for(int i = 60; ~i && x; --i){
		if(!(x & (1ll << i))) continue;
		if(!d[i]) return d[i] = x, true;
		else x ^= d[i];
	}
	return false;
}

int main(){
	int t; cin >> t;
	while(t--){
		int n; bool ans = false;
		scanf("%d", &n);
		memset(d, 0, sizeof d);
		for(int i = 1; i <= n; ++i)
			scanf("%lld", a + i);
		scanf("%s", s + 1);
		for(int i = n; i; --i){
			bool flag = ins(a[i]);
			if(flag && s[i] == '1'){
				ans = true;
				break;
			}
		}
		if(ans) puts("1");
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k,ans=0; cin >> n >> k;
  REP(i,n) {
    int h;
    cin >> h;
    ans+=h>=k;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
from itertools import product

def main():
    n = int(input())
    adj = [{} for i in range(n)]
    dist = [-1] * n
    for _ in range(n-1):
        u, v, w = [int(i) for i in input().split()]
        adj[u-1][v-1] = w
        adj[v-1][u-1] = w
    dist[0] = 0
    visited = 1
    cand = [0]
    while visited < n:
        pos = cand.pop()
        for i, v in adj[pos].items():
            if dist[i] < 0:
                dist[i] = (dist[pos] + v)%2
                visited += 1
                cand.append(i)
    for d in dist:
        print(d)

if __name__ == '__main__':
    main()



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

#pragma region lib_unionfind_tree
namespace lib {
  /*
    class UnionFind
    usage: Unionfind u(100), u.unite(1, 10), u.find(1, 13)
  */
  class UnionFind {
    public:
    UnionFind() {}
    UnionFind(int n) :
        parent(n, -1), rank(n, 0) {}

    int find(int a) {
      if (parent[a] == -1)
        return a;
      else
        return parent[a] = find(parent[a]);
    }

    void unite(int a, int b) {
      a = find(a);
      b = find(b);

      if (a == b) return;
      if (rank[a] == rank[b]) {
        parent[a] = b;
        rank[b]++;
        return;
      }
      if (rank[a] > rank[b]) swap(a, b);
      parent[a] = b;
    }

    private:
    vector<int> parent, rank;
  };
}  // namespace lib
#pragma endregion

int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);

  lib::UnionFind uf(N);

  while (Q--) {
    int t, u, v;
    scanf("%d%d%d", &t, &u, &v);

    if (t == 0)
      uf.unite(u, v);
    else
      printf("%d\n", static_cast<int>(uf.find(u) == uf.find(v)));
  }

  return 0;
}


Measured memory_bytes: 4600
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int flag = 0;
    for(int i=1; i<n; i++){
        double a = n-i;
        if(a<i){
            flag++;            
        }
    }

    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N, H;
    cin >> N >> H;
    multimap<ll, ll> katanas;
    for (ll i = 0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        katanas.emplace(a, b);
    }

    // aが最大の中でbが最小の刀をとどめ用にする
    auto max_a = katanas.rbegin()->first;
    auto maxa_it = katanas.equal_range(max_a);
    auto last_katana_it = min_element(maxa_it.first, maxa_it.second, [](auto&& a, auto&& b) { return a.second < b.second; });
    auto last_katana = *last_katana_it;
    katanas.erase(last_katana_it);

    // bが最大のaより強い刀を集める
    vector<ll> throw_katanas;
    for (auto&& k : katanas) {
        if (k.second > max_a) {
            throw_katanas.push_back(k.second);
        }
    }

    // それらを強い方から投げる
    sort(begin(throw_katanas), end(throw_katanas), greater<ll>());

    ll ans = 0;
    for (auto k : throw_katanas) {
        ans++;
        if (H <= last_katana.second) {
            H = 0;
        } else {
            H -= k;
        }
        if (H <= 0) {
            cout << ans << endl;
            return;
        }
    }

    // まだ生きていればaで削れるだけ削って投げる
    if (H <= last_katana.second) {
        ans++;
    } else {
        ans += 1 + ((H - last_katana.second) + last_katana.first - 1) / last_katana.first;
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

public class Main{
	static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        private FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

	 int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
	}

	int[] nextIntArrayOne(int n) {
				int[] a = new int[n+1];
				for (int i = 1; i < n+1; i++)
					a[i] = nextInt();
				return a;
	}

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String[] args) {
		FastReader s =new FastReader();
		
		StringBuilder str = new StringBuilder();
		
			int n = s.nextInt();
			if(n >= 30) {
				str.append("Yes\n");
			}else {
				str.append("No\n");
			}
			
		
		System.out.println(str);
	}

	

}



Measured memory_bytes: 32812
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    A, B, C, D = MI()
    left = A + B
    right = C + D

    if left > right:
        print('Left')
    elif left == right:
        print('Balanced')
    else:
        print('Right')


if __name__ == '__main__':
    main()


Measured memory_bytes: 64108
#B

a = [list(map(int,input().split())) for _ in range(3)]
c = [a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2],a[2][0],a[2][1],a[2][2]]
n = int(input())
b = [int(input()) for _ in range(n)]


for i in range(n):
    if b[i] in c:
        c[c.index(b[i])] = 0
#print(c)
p = sum(c[:3])*sum(c[3:6])*sum(c[6:9])*sum(c[::3])*sum(c[1::3])*sum(c[2::3])*(c[0]+c[4]+c[8])*(c[2]+c[4]+c[6])
if p == 0:
    print("Yes")
else:
    print("No")

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



int main(){
    string s;
    cin >> s;
    string s1, s1r, s2;

    int n = s.size();
    for(int i = 0; i < n; i++){
        if(i <= (n - 2) / 2){
            s1.push_back(s[i]);
            s1r.push_back(s[i]);
        }else if(i >= (n + 1) / 2){
            s2.push_back(s[i]);
        }
    }

    reverse(s1r.begin(),s1r.end());

    if(s1 == s1r && s2 == s1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 2050;
 ll mod = 1e9+7;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = c-(a-b);
  cout << ((ans < 0) ? 0 : ans) << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
    [n,m] <- map read . words <$> getLine
    xs <- replicateM n $ list2tuple . map read . words <$> getLine
    print $ solve xs m

list2tuple :: [Int] -> (Int,Int,Int)
list2tuple [x1,x2,x3] = (x1,x2,x3)

solve :: [(Int,Int,Int)] -> Int -> Int
solve xs m = maximum $ (map . flip ($)) xs $ map (((abs . sum . take m . sortBy (flip compare)) .) . map) fs
    where fs = [(\(x,y,z) -> x+y+z)
               ,(\(x,y,z) -> x+y-z)
               ,(\(x,y,z) -> x-y+z)
               ,(\(x,y,z) -> x-y-z)
               ,(\(x,y,z) -> -x+y+z)
               ,(\(x,y,z) -> -x+y-z)
               ,(\(x,y,z) -> -x-y+z)
               ,(\(x,y,z) -> -x-y-z)
               ]


Measured memory_bytes: 4732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define PI acos(-1)
using namespace std;

int main(){
    int i, j;
    int a, b, C;
    double S, L, h, rad;
    cin >> a >> b >> C;
    rad = C * PI / 180;
    S = a * b * sin(rad) * 0.5;
    L = a + b + sqrt(a*a+b*b-2*a*b*cos(rad));
    h = 2 * S / a;
    printf("%.8f\n%.8f\n%.8f\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#ifdef XLor
  #define dbg(args...) do {cout << #args << " -> "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int n, k, a[maxn];
vector<int> bag[maxn];

bool cmp(int x, int y) { return x > y; }

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int ans = 0, tot = 0;
    vector<int> v;
    for (int i = 0; i <= n && i <= k; i++) {
        tot += a[i];
        if (a[i] < 0) v.push_back(a[i]);
        vector<int> f;
        for (int& x: v) f.push_back(x);
        int c = k - i, sum = tot;
        dbg(tot);
        for (int j = n + 1; j > i && c >= 0; j--, c--) {
            sum += a[j];
            if (a[j] < 0) f.push_back(a[j]);
            sort(f.begin(), f.end());
            int x = sum;
            // for (int& x: f) cout << x << ' '; cout << endl;
            // dbg(x, k, i, c);
            for (int i = 0; i < c && i < (int)f.size(); i++) x -= f[i];
            ans = max(ans, x);
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN=(3e5+10)*3,MOD=1e9+7;
ll res=0,cur=1;
int n,m,k,fac[MAXN],inv[MAXN];

ll quick_pow(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,a=a*a%MOD)
		if(b&1) ret=ret*a%MOD;
	return ret;
}
int C(int a,int b)
{if(a<b||b<0) return 0;return 1ll*fac[a]*inv[b]%MOD*inv[a-b]%MOD;}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	fac[0]=1;
	for(int i=1;i<MAXN;i++)
		fac[i]=1ll*fac[i-1]*i%MOD;
	inv[MAXN-1]=quick_pow(fac[MAXN-1],MOD-2);
	for(int i=MAXN-2;i>=0;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%MOD;
	
	for(int i=n;i<=n+m+k;i++)
		(res+=C(i-1,n-1)*cur%MOD*quick_pow(3,n+m+k-i)%MOD)%=MOD,
		cur=(2*cur-C(i-n,m)+MOD-C(i-n,i-n-k)+MOD)%MOD;
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0) ; cout.tie(0);
#define debug(x) cout << #x << " : " << x << endl;
#define pi 3.14159265359
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using ll = long long int;
using db = double;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
const int MOD = 1e9+9;

void solve()
{
    int n;
    cin >> n;
    cout << (1000-(n%1000))%1000 << endl;
    
}

int main()
{
    fastio;

    ll t = 1;
    // cin >> t;
    while(t--)
       solve();
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	string s[100];
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // StringTokenizer st = new StringTokenizer(br.readLine());
        String s = (br.readLine());
        System.out.println(solver(s));
        
    }
    public static int solver(String s){
        if(s.length()==1)
            return 0;
        int ans=0;
        char cur = s.charAt(0);
        for (int i=1; i<s.length(); i++) {
            if(s.charAt(i)!=cur){
                ans++;
                cur=s.charAt(i);
            }
        }
        return ans;
    }
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi P(N);
  vi Q(N);
  each(x, P) in(x);
  each(x, Q) in(x);

  vi v;
  rep(i, 1, N + 1) {
    v.push_back(i);
  }

  int a, b;
  int cnt = 0;
  do {
    if (v == P) a = cnt;
    if (v == Q) b = cnt;
    cnt++;
  } while (next_permutation(all(v)));
  print(abs(a - b));
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "No" << endl;
    } else if (a != b && b != c && c != a) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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

using i64 = int64_t;

constexpr long double EPS = 1e-15;

int main(){
    long double a, b, c;
    cin >> a >> b >> c;
    cout << (sqrt(a)+sqrt(b) + EPS < sqrt(c) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;


int main(){
	string str,s1_s,s2_s;
	int s1,s2;

	cin>>str;

	s1_s=str[0];
	s1_s+=str[1];
	s2_s=str[2];
	s2_s+=str[3];

	s1=stoi(s1_s);
	s2=stoi(s2_s);

	//YYMM
	if(s1>=0 && s2>0 && s2<=12){
		if(s2>=0 && s1>0 && s1<=12){
			cout<<"AMBIGUOUS";
		}
		else{
			cout<<"YYMM";
		}
	}
	//MMYY
	else if(s2>=0 && s1>0 && s1<=12){
		cout<<"MMYY";
	}
	else{
		cout<<"NA";
	}


	return 0;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b; cin >> a >> b;
    int res;
    if (a >= 0 && b >= 0) {
        if (b >= a) res = b - a;
        else if (b == 0) res = 1 + (a - b);
        else res = 2 + (a - b);
    } else if (a >= 0){
        res = 1 + abs(a + b);
    } else if (b >= 0){
        if (b == 0) res = abs(a + b);
        else res = 1 + abs(a + b);
    } else {
        if (b >= a) res = b - a;
        else res = 2 + (a - b);
    }

    cout << res << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long r){
    cout << r*r << endl;
}

int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
import java.util.*
import javax.print.attribute.IntegerSyntax
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (n, d) = readInts()
    val d2 = d.toLong() * d.toLong()

    println((1..n).count {
        val xx = readInts().map(Int::toLong).map { it * it }
        val x = xx.sum()!!
        x <= d2
    })
}


Measured memory_bytes: 58856
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;

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

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}
 
template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}
 
template<class T>
void write(const T &x){ cout << x << endl; }

int main(){
    auto N = read<ll>();
    
    write( (N + 1) / 2 / (double)N ); 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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


int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

long long cnt;
int i;
int A[1000000];
int n;
vector<int>G;

void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	for (int h = 1;;) {
		if (h > n)break;
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)scanf("%d", &A[i]);
	cnt = 0;

	shellSort(A, n);

	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i)printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++)printf("%d\n",A[i]);

	return 0;
}

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

inline int f(int x){ return x*x; }

int main()
{
    int d;

    while(cin>>d){
        int sum=0;
        for(int i=d; i<600; i+=d) sum += f(i)*d;
        cout << sum << endl;
    }

    return 0;
}

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

const double PI=3.141592653589793;

int main()
{
  int N,M;
  cin>>N>>M;
  cout<<N*M<<endl;
  

  return 0;
  }


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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	ll n;
	cin >> n;
	ll s = 0;
	for(int i  = 1; i <= n; i++){
		if(i%3 && i%5)
			s+=i;
	}
	cout << s << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            int[] heights = new int[10];

            for (int i = 0; i < 10; i++)
            {
                heights[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(heights, (a, b) => b - a);

            for (int i = 0; i < 3; i++)
            {
                sb.AppendLine(heights[i].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9140
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from fractions import*\n"
"n,*a=map(int,open(0).read().split())\n"
"*b,=a=a+[0]\n"
"r=range(n)\n"
"for i in r:a[i]=gcd(a[i],a[i-1]);b[n-i-1]=gcd(b[n-i-1],b[n-i])\n"
"print(max(gcd(a[i-1],b[i+1])for i in r))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 16428
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

let n = Console.ReadLine() |> ParseInt1
let vs = Console.ReadLine() |> ParseIntN
let minv = Array.min vs
let maxv = Array.max vs
[minv..maxv]
|> List.map (fun m -> Array.fold (fun acc v -> acc + (v - m) * (v - m)) 0 vs)
|> List.min
|> printfn "%A"


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

int main() {
  string x;
  cin>>x;
  if(x=="ooo")cout<<1000<<endl;
  else if(x=="oox"||x=="oxo"||x=="xoo")cout<<900<<endl;
  else if(x=="xxo"||x=="xox"||x=="oxx")cout<<800<<endl;
  else cout<<700<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    unsigned long long l[n + 1];
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i - 1] + l[i - 2];
    }
    printf("%lld\n",l[n]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main() {
    int A , B , C , D;
    cin >> A >> B >> C >> D;
    if(A + B > C + D){
        cout << "Left" << endl;
    }
    else if(A + B == C + D){
        cout << "Balanced" << endl;
    }
    else{
        cout << "Right" << endl;
    }
}


Measured memory_bytes: 256
# 繰り返しで求める
# 100 * (1.01 ** n) がX以上になるまでnを増やしていく
import math

def resolve_v1(X: int) -> int:
    n = 1
    balance = math.floor(100 * 1.01)
    while balance < X:
        balance = math.floor(balance * 1.01)
        n += 1
    return n


if __name__ == '__main__':
    X = int(input())
    n = resolve_v1(X)
    print(n)


Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 105

int main(){

    int n;
    cin >> n;
    vector<int> arr(n);
    REP(i,n){
        cin >> arr[i];
    }
    int ans = 0;
    REP(i,n){
        if(arr[i]%2 == 1){
            continue;
        }
        while(arr[i] % 2 != 1){
            arr[i]/=2;
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
 
const ll mod = 998244353;
 
int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vl> dp(c+1,vl(d+1,0));
    dp[a][b] = 1;
    for(ll i = a;i <= c;i++) {
        for(ll j = b;j <= d;j++) {
            if(i == a && j == b) continue;
            dp[i][j] = ((dp[i][j-1]*i)%mod + (dp[i-1][j]*j)%mod - ((i-1)*(j-1)*dp[i-1][j-1])%mod)%mod;
            dp[i][j] += mod;
            dp[i][j] %= mod;
        }
    }
    cout<<dp[c][d]<<endl;
}

Measured memory_bytes: 73600
#include <iostream>
#include <string>
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 5000;
long long dp[2][MAX_N+1]={1};
int main() {
	int N;
	string s;
	cin >> N >> s;
	for(int i=0;i<N;i++) {
		int w = i&1;
		dp[1-w][0] = dp[w][0];
		dp[1-w][1] = dp[w][0];
		for(int j=1;j<=i;j++) {
			dp[1-w][j+1] = dp[w][j];
			dp[1-w][j-1] += dp[w][j] * 2;
			dp[1-w][j-1] %= MOD;
		}
	}
	cout << dp[N&1][s.length()] << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
  int a[3],i,s=0,max=0;
  cin >> a[0] >> a[1] >> a[2];
  for(i=0;i<3;i++) {
    s += a[i];
    if(max<a[i])max=a[i];
  }
  cout << s-max << endl;
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 0, mx = -1, a;
  while (cin >> a) (a > mx) ? mx = a: ans += mx - a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = new ListBuffer[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map(l(1))
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


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

int main() {

  int wide,high;

  while(cin >> high >> wide) {

    if (high == 0 || wide == 0) {
      break;
    }
    
    for (int i = 1; i <= high; i++) {
      for (int j = 1; j <= wide; j++) {
	if (i%2 == 1 && j%2 == 1) {
	  cout << '#' ;
	} else if (i%2 == 0 && j%2 == 0) {
	  cout << '#' ;
	} else if (i%2 == 0 && j%2 == 0) {
	  cout << '.' ;
	} else {
	  cout << '.';
	}
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;

}

Measured memory_bytes: 1152
n = int(input())
s = input()

rc = s.count('R')
gc = s.count('G')
bc = s.count('B')
ans = rc * gc * bc

for i in range(n-1):
  for j in range(i+1,n):
    k = j*2 - i
    if k >= n:
      continue
    if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
      ans -= 1
      
print(ans)      

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    while(x - b >= 0) x -= b;
    OUT(x)

    return 0;
}

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

const ll mod = 998244353;

ll dp[3030][3030][3];
int a[3030];

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

    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            (dp[i + 1][j][0] += dp[i][j][0]) %= mod;
            (dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if (j + a[i] <= k) {
                (dp[i + 1][j + a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i + 1][j + a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}


Measured memory_bytes: 216676
function Main(input) {
  lines = input.split('\n')
  n = lines[0].split(' ')[0] * 1
  m = lines[0].split(' ')[1] * 1
  l = 0
  r = n
  for (i = 1; i < lines.length; i++) {
    ls = lines[i].split(' ')[0] * 1 
    rs = lines[i].split(' ')[1] * 1
    if (l < ls) {
        l = ls
    }
    if (r > rs) {
        r = rs
    }
  }
  console.log(r - l < 0 ? 0 : r - l + 1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	vector<int> v = { a, b, c };
	int d = 0;
	int e = 0;
	for (auto& i : v) {
		if (i == 5) d++;
		if (i == 7) e++;
	}

	if (d == 2 && e == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<cstring>

using namespace std;

const int Max = 1e6 + 5;
typedef long long ll;
int a[Max], b[Max];
int n, m, x, y;

int main(){
	int i, j, flag;
	while(~scanf("%d %d %d %d", &n, &m, &x, &y)){
		for(i = 0; i < n; i++) scanf("%d", &a[i]);
		for(i = 0; i < m; i++) scanf("%d", &b[i]);
		sort(a, a + n, greater<int>());
		sort(b, b + m);
		if(a[0] >= b[0]) flag = 0;
		else{
			if(b[0] > x && b[0] < y) flag = 1;
		}
		if(flag) cout << "No War" << endl;
		else cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int a[1001][1001],n,d1,d2,z=0;

void gao(int o)
{
	int b=0;
	while(o%4==0){o/=4;b++;}
	for(int i=0;i<2*n;i++)
	    for(int j=0;j<2*n;j++)
	        if(o%2==0)
	        {
	        	if((i>>b)%2==1) a[i][j]=1;
			}else if((i>>b)%2!=(j>>b)%2) a[i][j]=1;
}

int main()
{
	memset(a,0,sizeof(a));
	scanf("%d%d%d",&n,&d1,&d2);
	gao(d1);
	gao(d2);
	for(int i=0;i<2*n;i++)
	    for(int j=0;j<2*n;j++)
	        if(!a[i][j])
	        {
	        	if(z==n*n) break;
	        	cout<<i<<' '<<j<<endl;
	            z++;
			}
	return 0;
}

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

int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  vector<int> v(N+1,0);
  v[0]=0;
  for(int i=1;i<N;++i){
    if(S[i-1]=='A' && S[i]=='C') v[i]=1;
  }


  for(int i=1;i<=N;++i){
    v[i]=v[i]+v[i-1];
  }

  for(int i=0;i<Q;++i){
    int l,r;
    cin>>l>>r;
    --l,--r;
    if(r<N && S[r]=='A' && S[r+1]=='C') cout<<v[r+1]-v[l]-1<<endl;
    else cout<<v[r+1]-v[l]<<endl;
  }
}

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

int main(void){
    int n;
    cin >> n;
    int a;
    rep(_,n){
        cin >> a;
        if(a%2==0 && a%3 && a%5){
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
    return 0;
}

Measured memory_bytes: 256
s = input()

ans = 0
carry = 0
for i in range(len(s) - 1, -1, -1):
    c = int(s[i])
    if c + carry < 5:
        ans += c + carry
        carry = 0
    elif c + carry == 5:
        if i > 0 and int(s[i - 1]) >= 5:
            ans += 5
            carry = 1
        else:
            ans += 5
            carry = 0
    else:
        ans += 10 - c - carry
        carry = 1
if carry:
    ans += 1
print(ans)


Measured memory_bytes: 5492
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if len(set(S)) == 2 and S.count(S[0])==2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 5200
unittest
{
	assert( [ "2 2 2 8", "4 6", "1 5", "3 8" ].solve == "19\n17\n15\n14\n13\n12\n10\n8" );
	assert( [ "3 3 3 5", "1 10 100", "2 20 200", "1 10 100" ].solve == "400\n310\n310\n301\n301" );
	assert( [ "10 10 10 20", "7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488", "1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338", "4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736" ].solve == "23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547" );
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = 0L;
	auto y = 0L;
	auto z = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s %s"( x, y, z, k );
	input.popFront;
	auto as = input.front.split.to!( long[] ) ~ long.min / 4;
	input.popFront;
	auto bs = input.front.split.to!( long[] ) ~ long.min / 4;
	input.popFront;
	auto cs = input.front.split.to!( long[] ) ~ long.min / 4;
	as.sort!( ( a, b ) => b < a );
	bs.sort!( ( a, b ) => b < a );
	cs.sort!( ( a, b ) => b < a );
	
	auto anss = new long[ k ];
	auto queue = heapify( [ tuple( as[ 0 ] + bs[ 0 ] + cs[ 0 ], 0L, 0L, 0L ) ] );
	bool[ long ][ long ][ long ] us;
	us[ 0 ][ 0 ][ 0 ] = true;
	foreach( ref ans; anss )
	{
		auto v = queue.front[ 0 ];
		auto ai = queue.front[ 1 ];
		auto bi = queue.front[ 2 ];
		auto ci = queue.front[ 3 ];
		queue.removeFront;
		
		ans = v;
		if( ai + 1 !in us || bi !in us[ ai + 1 ] || ci !in us[ ai + 1 ][ bi ] )
		{
			queue.insert( tuple( as[ ai + 1 ] + bs[ bi ] + cs[ ci ], ai + 1, bi, ci ) );
			us[ ai + 1 ][ bi ][ ci ] = true;
		}
		if( ai !in us || bi + 1 !in us[ ai ] || ci !in us[ ai ][ bi ] )
		{
			queue.insert( tuple( as[ ai ] + bs[ bi + 1 ] + cs[ ci ], ai, bi + 1, ci ) );
			us[ ai ][ bi + 1 ][ ci ] = true;
		}
		if( ai !in us || bi !in us[ ai ] || ci + 1 !in us[ ai ][ bi ] )
		{
			queue.insert( tuple( as[ ai ] + bs[ bi ] + cs[ ci + 1 ], ai, bi, ci + 1 ) );
			us[ ai ][ bi ][ ci + 1 ] = true;
		}
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 4668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	private static ArrayList<String> dataSet = new ArrayList<String>();

	public static void main(String[] args) throws IOException {
		inputDataSet(""); // データセットを読み込み、dataSetに格納する

		int[] typesNum = new int[3];
		for(String line : dataSet) {
			String[] data = line.split(" ");
			int a = Integer.parseInt(data[0]);
			int b = Integer.parseInt(data[1]);
			int c = Integer.parseInt(data[2]);

			Triangle triangle = new Triangle(a, b, c);
			int type = triangle.type(); // 三角形の種類を受け取る
			if(type == -1)break; // 三角形にならない場合、ループを抜ける
			typesNum[triangle.type()]++; // 対応する種類をインクリメント
		}
		
		int triangleNum = typesNum[0] + typesNum[1] + typesNum[2];
		
		System.out.println(String.format("%d %d %d %d",
				triangleNum, typesNum[0], typesNum[1], typesNum[2]));
	}

	// 終端(terminal)まで読み込み、行ごとにdataSetに格納していくメソッド
	public static void inputDataSet(String terminal) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {
			String line = br.readLine(); // 標準入力から読み込む
			if(line == null || line.equals(terminal))break; // 行の終わり、もしくはterminalと一致した場合、終了
			dataSet.add(line); // 読み込んだ行をdataSetに追加
		}
	}
}

class Triangle{
	private int a, b, c;

	// 三角形の3辺をaが最大になるように入力する
	public Triangle(int a, int b, int c) {
		this.a = a;
		this.b = b;
		this.c = c;

		if(this.a < this.b) {
			int temp = this.a;
			this.a = this.b;
			this.b = temp;
		}

		if(this.a < this.c) {
			int temp = this.a;
			this.a = this.c;
			this.c = temp;
		}
	}

	// 三角形の種類を返すメソッド
	public int type(){
		if(a >= b + c)return -1; // 三角形にならない場合、-1を返す
		
		if(a * a == b * b + c * c) {
			return 0; // 直角三角形
		}

		if(a * a < b * b + c * c) {
			return 1; // 鋭角三角形
		}

		return 2; // 鈍角三角形
	}
}



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

using namespace std;
int main(){
  long long N,M;
  cin>>N>>M;
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  vector< vector<long long> > CB(M);
  vector<long long> buf(2);
  for(int i=0; i<M; i++){
    cin>>buf[1]>>buf[0];
    CB[i]=buf;
  }
  sort(A.begin(),A.end());
  sort(CB.begin(),CB.end(),[](const vector<long long>& x,const vector<long long>& y){return x[0]>y[0];});
  int now=0;
  int CBcnt=0;
  long long sum=0;
  for(int i=0; i<A.size(); i++){
    if(now>=M){
      sum+=A[i];
      continue;
    }
    if(CB[now][0]>A[i]){
      sum+=CB[now][0];
    }else{
      sum+=A[i];
    }
    CBcnt++;
    if(now>=M) continue;
    if(CBcnt>=CB[now][1]){
      CBcnt=0;
      now++;
    }
  }
  cout<<sum<<endl;
  return 0;
}

    



Measured memory_bytes: 6528
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

bool isAcgtStr(string str) {
    bool isAcgtStr = true;
    string acgt = "ACGT";
    for (char alphabet : str) {
        if (find(acgt.begin(), acgt.end(), alphabet) == acgt.end()) isAcgtStr = false;
    }
    return isAcgtStr;
}

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

    int ans = 0;
    int length = 0;
    rep(i, S.size()) {
        if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            length++;
            ans = max(ans, length);
        } else {
            length = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*
ll dx[8]={-1,-1,-1,0,0,1,1,1};
ll dy[8]={-1,0,1,-1,1,-1,0,1};
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
int main()
{
     ll t,arr[15],a;
     for(int i=0;i<15;i++)
        arr[i]=0;
     cin>>t;
     for(int i=0;i<t;i++)
     {
         cin>>a;
         if(a>=1 && a<=399)
         {
             arr[0]++;
         }
         else if(a>=400 && a<=799)
         {
             arr[1]++;
         }
         else if(a>=800 && a<=1199)
         {
             arr[2]++;
         }
         else if(a>=1200 && a<=1599)
         {
             arr[3]++;
         }
         else if(a>=1600 && a<=1999)
         {
             arr[4]++;
         }
         else if(a>=2000 && a<=2399)
         {
             arr[5]++;
         }
         else if(a>=2400 && a<=2799)
         {
             arr[6]++;
         }
         else if(a>=2800 && a<=3199)
         {
             arr[7]++;
         }
         else
            arr[8]++;
     }
     int mn=0,mx=0;
     for(int i=0;i<=7;i++)
     {
         mn+=(arr[i]>0);
         mx+=(arr[i]>0);
         //cout<<arr[i]<<endl;
     }
     mn=max(mn,1);
     cout<<mn<<" "<<mx+arr[8]<<endl;
}



Measured memory_bytes: 3648
import numpy as np

n = input()
a = np.array(list(map(int,input().split())))

n = int()
all_sum = int(0)

def calcsum(b,b2):
  sum = int(0)
  for value in b2:
    sum += b * value 
  return sum

for index,value in enumerate(a):
  all_sum += calcsum(value,a[index+1:])
  
print(all_sum)

Measured memory_bytes: 12500