akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec1(N);
  vector<int> vec2(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec1[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin>>vec2[i];
  }

  for (int i = 0; i < N-1; i++)
  {
    vec1[i+1] += vec1[i];
    vec2[N-2-i] += vec2[N-1-i];
  }
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    chmax(ANS,vec1[i] + vec2[i]);
  }
  cout<<ANS<<endl;
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){

  ll K,A,B;
  cin >> K >> A>>B;
  ll ans=1;
  if((B-A) <= 2){
    ans = 1 + K;
  }
  else if(A > (K-1)){
    ans = 1 + K;
  }
  else{
    ll num=K;
    if(ans < A){
      ans = A;
      num = K - A + 1; 
    }
    ans += (B-A)*(num/2);
  
    if(num%2==1){
      ans++;
      num--;
    }
  }
  cout << ans << endl;




  return 0;

}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    lint n, k,q;
    cin >> n >> k >> q;

    lint ans, tmp;

    vector<lint> a(n+1);
    lint x;
    REP(i, q) { 
        cin >> x;
        a[x] += 1;
    }
    REP(i, n)
    {
        if (k+a[i+1] - q <= 0)
        {
            cout << "No"
                 << "\n";
        }
        else
        {

            cout << "Yes"
                 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    cout << 0 << endl;
  else
    cout << min(a * b, min(a * c, b * c)) << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=700

s=input()
for i in range(3):
    if s[i]=="o":
        ans+=100
print(ans)



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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = new Dictionary<int,bool>();
            for(int i=0;i<N;i++){
                var read = int.Parse(Console.ReadLine());
                if(A.ContainsKey(read)){
                    A[read] = !A[read];
                }else{
                    A.Add(read,true);
                }
            }
            Console.WriteLine(A.Count(x=>x.Value==true));
            
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 100010;

int cnt[N];
int ans, n;

int main(){

	scanf("%d", &n);
	int x;
	For(i, 1, n){
		scanf("%d", &x);
		if(x <= n) cnt[x]++;
		else ++ans;
	}
	For(i, 0, n) if(cnt[i]) ans += cnt[i] >= i ? cnt[i] - i : cnt[i];
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a = [LI() for _ in range(n)]
        t = max(map(lambda x: x[0]*2+x[1], a))
        u = sum(map(sum,a))
        mx = max(map(lambda x: [x[0],-x[1]], a))
        mxi = a.index([mx[0], -mx[1]])
        k = sum(map(lambda x: x[0], a)) - mx[0]
        if k < mx[0]:
            mx0 = mx[0]
            dp = [0] * (mx0+1)
            dp[k] = 1
            for ai in range(n):
                if ai == mxi:
                    continue
                c = a[ai][1]
                for i in range(mx0-c,-1,-1):
                    dp[i+c] |= dp[i]
            mt = 0
            for i in range(mx0,-1,-1):
                if dp[i]:
                    mt = i
                    break
            u += (mx0 - mt)
        return max(t,u)

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9128
#include<cstdio>
#include<cmath>
long long f(long long b, long long n) {
	if( n/2 + 1 <= b && b <= n )
		return n-b+1;
	if( n < b ) return n;
	else return f(b, n/b) + n%b;
}
int main() {
	long long n, s;
	scanf("%lld%lld", &n, &s);
	if( n == s ) {
		printf("%lld\n", n+1);
		return 0;
	}
	else if( n < s ) {
		printf("-1\n");
		return 0;
	}
	long long p = n-s;
	long long lim = sqrt(p);
	for(long long b=1;b<=lim;b++) {
		if( p % b == 0 && f(b+1, n) == s ) {
			printf("%lld\n", b+1);
			return 0;
		}
	}
	for(long long b=lim;b>=1;b--) {
		if( p % b == 0 && f(p/b+1, n) == s ) {
			printf("%lld\n", p/b+1);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		for(int b = 1; b <= X; b++) {
			for(int q = 2; q <= 1000; q++) {
				if(Math.pow(b, q) <= X) {
					ans = (Math.max((int)Math.pow(b,  q), ans));
				}
			}
		}
		System.out.println(ans);
	}
}


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int arr[4];
  char cc;
  for (int i = 0; i < 4; i++) cin >> cc, arr[i] = atoi(&cc);
  int a = arr[0], b = arr[1], c = arr[2], d = arr[3];
  if (a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7"; 
  else if (a-b-c+d ==7) cout << a << "-" << b << "-" << c << "+" << d << "=7"; 
  else if (a-b+c-d ==7) cout << a << "-" << b << "+" << c << "-" << d << "=7"; 
  else if (a-b+c+d ==7) cout << a << "-" << b << "+" << c << "+" << d << "=7";
  else if (a+b-c-d ==7) cout << a << "+" << b << "-" << c << "-" << d << "=7";
  else if (a+b-c+d ==7) cout << a << "+" << b << "-" << c << "+" << d << "=7";
  else if (a+b+c-d ==7) cout << a << "+" << b << "+" << c << "-" << d << "=7";
  else if (a+b+c+d ==7) cout << a << "+" << b << "+" << c << "+" << d << "=7";
}

int main() {
 setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < (int)(n); ++i) cin >> A[i];

  vector<bool> can(2001, false);
  for (int s = 0; s < (int)((1 << n)); ++s) {
    int sum = 0;
    for (int i = 0; i < (int)(n); ++i) if ((s >> i) & 1) sum += A[i];
    can[sum] = true;
  }

  int q;
  cin >> q;
  for (int i = 0; i < (int)(q); ++i) {
    int m;
    cin >> m;
    cout << (can[m] ? "yes" : "no") << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
using namespace std;
const int M=2e5+10;
int n,m,k,a[M],b[M],t;
int main()
{
	cin>>n>>m>>k;
	for (int i=1;i<=n;i++)
	cin>>a[i];
	for (int i=1;i<=m;i++)
	cin>>b[i];
	int sum=0,cn=0;
	while (cn<n)
	{
		if (sum+a[cn+1]<=k) cn++,sum+=a[cn];
		else break;
	}
	int maxm=cn;
	for (int i=1;i<=m;i++)
	{
		while (sum+b[i]>k && cn>0)
			sum-=a[cn],cn--;
		sum+=b[i];
		if (sum>k) break;
		maxm=max(maxm,cn+i);
	}
	cout<<maxm<<endl;
    return 0;
}


Measured memory_bytes: 5132
fun main(args: Array<String>) {
    val (K, S) = readLine()!!.split(" ").map(String::toInt)
    var sum = 0
    for (i in 0..K) {
        for (j in 0..K) {
            if (S - (i + j) in 0..K) {
                sum++
            }
        }
    }
    println(sum)
}

Measured memory_bytes: 37868
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N, M;
    cin >> N;
    vector<int> time(N);
    for(int i= 0; i < N; i++)
        cin >> time.at(i);
    cin >> M;
    vector<vector<int> >drink(M, vector<int>(2));
    for(int i = 0; i < M; i++){
        for(int j = 0; j < 2; j++)
        cin >> drink.at(i).at(j);
    }
    int total = 0;
    for(int i = 0; i < N; i++)
    total += time.at(i);
    for(int i = 0; i < M; i++){
        cout << total - time.at(drink.at(i).at(0) - 1) + drink.at(i).at(1) << endl;;
    }
    return 0; 
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  if (A.at(A.length() - 1) == B.at(0) && B.at(B.length() - 1) == C.at(0))
    printf("YES");
  else
    printf("NO");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int m,h;
  double s,l,S;
  while(1){
    cin >> m >> h;
    if(m==0 && h==0){
      break;
    }
    s=m;
    l=h;
    S=s*sqrt(4*h*h+m*m)+m*m;
    printf("%.6f\n",S);
  }
  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

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

    void solve(){
        String s = in.next();
        if(s.equals("ABC"))
            System.out.println("ARC");
        else System.out.println("ABC");
    }
}


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

#define INF 2000000000

long long int dp[5050][5050],dp_max[5050][5050];
int dp_size[5050];
int p[5050];
long long int c[5050];


int main(){

    int N,K;

    cin >> N >> K;

    for(int i = 1;i <= N;i++){
        cin >> p[i];
    }
    for(int i = 1;i <= N;i++){
        cin >> c[i];
    }

    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= N;j++){
            dp_max[i][j] = -10000000000000000;
        }
    }

    for(int i = 1;i <= N;i++){

        int now = i;
        int count = 1;
        while(true){
            dp[i][count] = dp[i][count-1] + c[p[now]];
            dp_max[i][count] = max(dp_max[i][count-1],dp[i][count]);
            now = p[now];
            if(now == i){
                dp_size[i] = count;
                break;
            }
            count++;
        }

    }
    long long int ans = -10000000000000000;
    for(int i = 1;i <= N;i++){
        if(K <= dp_size[i]){
            ans = max(ans,dp_max[i][K]);
        }else{
            if(dp[i][dp_size[i]] < 0){
                ans = max(ans,dp_max[i][dp_size[i]]);
            }else{
                long long int tmp_ans;
                if(K % dp_size[i] == 0){
                    tmp_ans = dp[i][dp_size[i]] * (K / dp_size[i]);
                    tmp_ans = max(tmp_ans,dp_max[i][dp_size[i]]);
                    tmp_ans = max(tmp_ans,dp[i][dp_size[i]] * (K / dp_size[i] - 1) + dp_max[i][dp_size[i]]);
                    
                }else{
                    tmp_ans = dp[i][dp_size[i]] * (K / dp_size[i]) + dp_max[i][K % dp_size[i]];
                    tmp_ans = max(tmp_ans,dp_max[i][dp_size[i]]);
                    tmp_ans = max(tmp_ans,dp[i][dp_size[i]] * (K / dp_size[i]-1) + dp_max[i][dp_size[i]]);
                    
                }
                ans = max(ans,tmp_ans);
            }
        }
    }

    cout << ans << endl;

/*
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= dp_size[i];j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }

    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= dp_size[i];j++){
            cout << dp_max[i][j] << " ";
        }
        cout << endl;
    }

*/
    return 0;
}

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

vector<int> v;

int check(int x) {
    int now = 1;
    int cnt = 0;
    while(v.back() >= now + x) {
        auto it = lower_bound(v.begin(), v.end(), now);
        bool flag = false;
        int m = 0;
        if(it != v.end() and *it < now + x) flag = true, m = max({1, m, x - abs(now - *it)});
        if(it != v.begin()) {
            it--;
            flag = true, m = max({1, m, x - abs(now - *it)});
        }
        if(!flag)
            return -1;
        else
            now += m;
        cnt++;
    }
    return cnt + 1;
}
main() {
    while(1) {
        int n, m;
        cin >> n >> m;
        v = vector<int>(n);
        rep(i, n) cin >> v[i];
        sort(v.begin(), v.end());
        if(!n) return 0;
        int l = 1, r = 1e9;
        if(check(r) == -1) {
            cout << -1 << endl;
        } else {
            l--;
            while(l < r - 1) {
                int mid = (l + r) / 2;
                int res = check(mid);
                if(res == -1)
                    l = mid;
                else if(res < m)
                    r = mid;
                else
                    l = mid;
            }
            if(check(l) == -1)
                cout << -1 << endl;
            else
                cout << l << endl;
        }
    }
}


Measured memory_bytes: 3656
#include <stdio.h>
int main(void){
    int n,k,l[50],ans=0 ;
    scanf ("%d%d",&n,&k) ;
    for (int i=0; i<n; i++) {
        scanf("%d",&l[i]) ;
    }
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++){
            int tmp=0 ;
            if (l[i]<l[j]){
                tmp = l[i] ;
                l[i] = l[j] ;
                l[j] = tmp ;
            }
        }
    }
    for (int i=0; i<k; i++) {
        ans+=l[i] ;
    }
    printf ("%d\n",ans) ;
    return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
const int siz = 5*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}




signed main()
{
 	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;

		int sum = 0;

		for(int i = 1 ;i<=n ; i++)
		{
			if(i%5 !=0 and i%3 !=0)
			{
				sum += i;
			}
		}

		cout<<sum<<"\n";
	}
}

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

const long long int MOD = 1000000007;


int main() {
    long long int S;
    vector<long long int> DP(2000);
    cin >> S;
    DP[0] = 0;
    DP[1] = 0;
    DP[2] = 1;
    for (int i = 3; i < 2000; i++) {
        for (int j = 0; j < i-2; j++) {
            DP[i] += DP[j]%MOD;
            DP[i] %= MOD;
        }
        DP[i]++;
        DP[i] %= MOD;
    }
    cout << DP[S-1] << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;

int main(void){
    llint n,i,k,ans=0,a,b,c,judge=0,many=0,rest;
    scanf("%lld%lld",&n,&k);

    // if(n/k>100){
    //     many=n/1000;
    //     rest = n;
    //     n=1000;
    // }
    if(n>k){
        many=n/k;
        rest = n;
        n=k;
    }


    for(a=n;a>=1;a--){
        for(i= (2*a%k==0)? 2*a/k: 2*a/k-1 ;i>0;i--){
            judge=0;
            b = k*i-a;
            if(a<b) break;
            if(b<1) break;
            c=b;
            if((c+b)%k==0){
                llint div;
                if(a==b){
                    if(a==c) ans++;
                    if(b!=c) ans+=3;
                    div = c%k==0?c/k-1:c/k;
                    if(div<1) continue;
                    ans+=3*div;
                }else{
                    if(b!=c) ans+=6;
                    if(b==c ) ans+=3;
                    div = c%k==0?c/k-1:c/k;
                    if(div<1) continue;
                    ans+=6*div;
                }
                judge++;
                // printf("%lld %lld %lld %lld %lld\n",a,b,c,ans,div);
            }
        }
        if(k!=2 && judge==1) a-=k-1;
    }

    if(many!=0){
        ans*=pow(many,3);
        for(a=rest;a>=rest-rest%k+1;a--){
            for(i= (2*a%k==0)? 2*a/k: 2*a/k-1 ;i>0;i--){
                judge=0;
                b = k*i-a;
                if(a<b) break;
                if(b<1) break;
                c=b;
                if((c+b)%k==0){
                    llint div;
                    if(a==b){
                        if(a==c) ans++;
                        if(b!=c) ans+=3;
                        div = c%k==0?c/k-1:c/k;
                        if(div<1) continue;
                        ans+=3*div;
                    }else{
                        if(b!=c) ans+=6;
                        if(b==c ) ans+=3;
                        div = c%k==0?c/k-1:c/k;
                        if(div<1) continue;
                        ans+=6*div;
                    }
                    judge++;
                    // printf("%lld %lld %lld %lld %lld\n",a,b,c,ans,div);
                }
            }
            if(k!=2 && judge==1) a-=k-1;
        }

    }


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


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        int num =0;
        for(int i=0;i<S.length();i++) if(S.charAt(i)==T.charAt(i)) num++;
        System.out.println(num);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <vector>

//https://atcoder.jp/contests/abc121/tasks/abc121_b

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    //linjen er opp til 100. det er en linje p[ lengde hundre med hus p[ bare de nevte stedene]]

    int codes;
    std::cin >> codes;

    int codeSize;
    std::cin >> codeSize;

    int constant;
    std::cin >> constant;


    std::vector<int> vec(codeSize);


    for (int u = 0; u < codeSize; u++){  
        std::cin >> vec[u];
    }
 

    int validCodes = 0;
    for (int i = 0; i < codes; i++)
    {
        int result = constant;
 
        for (int u = 0; u < codeSize; u++){  
            int a;
            std::cin >> a;
            result += a * vec[u];
        }

        if (result > 0){  
            validCodes++;
        }
    }

    std::cout << validCodes << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	vector<int> arrNums;
	int nCount, i, iTemp, iSum=0;
	cin >> nCount;
	for (i = 1; i <= 2 * nCount; ++i){
		cin >> iTemp;
		arrNums.push_back(iTemp);
	}
	sort(arrNums.begin(), arrNums.end());
	for (i = 0; i < 2 * nCount; i += 2){
		iSum += arrNums[i];
	}
	cout << iSum << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

using namespace std;
typedef long long int ll;

struct data_t {
	static ll pa, pb;
	ll f, s;
};
ll data_t::pa, data_t::pb;

int solve(const ll a, const ll b, const ll d);
ll getinv(const ll pa, const ll pb, const ll d) {
	for (ll i = 0; i < pb; i++) {
		ll a = (pa*i) % pb;
		if (a == d%pb) { return i; }
	}
	return 1;
}
ll gcd(ll p, ll q) {
	//?????§??¬?´???°???????????????
	if (q == 0) { return p; }
	return gcd(q, p%q);
}

int main(void) {
	ll a, b, d;
	cin >> a >> b >> d;
	while (solve(a,b,d))
		cin >> a >> b >> d;
	return 0;
}

int solve(const ll a, const ll b, const ll d) {

	if (!(a|b|d)){ return 0; }
	ll g = gcd( gcd(a,b), d );

	ll pa, pb, pd;
		pa = a / g;
		pb = b / g;
		pd = d / g;

	//cout << pa << "/" << pb << "/" << pd << endl;
		data_t::pa = pa;
		data_t::pb = pb;

	vector<data_t> v(4);
	v[0].f = getinv(pa, pb, pd);
	v[1].f = v[0].f - pb;
	v[2].s = getinv(pb, pa, pd);
	v[3].s = v[2].f - pa;
	
	for (int i = 0; i < 2; i++)
		v[i].s = (pd - v[i].f*pa) / pb;
	for (int i = 2; i < 4; i++)
		v[i].f = (pd - v[i].s*pb) / pa;
	for (int i = 0; i < 4; i++) {
		v[i].f = abs(v[i].f);
		v[i].s = abs(v[i].s);
	}

	data_t ans = v[0];
	for (int i = 0; i < v.size(); i++) {
		int t1, t2;
			t1 = ans.f + ans.s;
			t2 = v[i].f + v[i].s;
		if ( t1 > t2) {
			ans = v[i];
		} else if ( t1 == t2 ) {
			if (ans.f*pa + ans.s*pb > v[i].f*pa + v[i].s*pb) { ans = v[i]; }
		}
	}
	cout << ans.f << " " << ans.s << endl;
	return 1;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
   
int main() {
  int A, B, C, D;
  double a, b, c;
  cin >> a >> b;
  c = 1.000000000 * a / b;
  C = a / b;
  D = a - b * C;
 
cout << C << " " << D << " ";
  printf("%.8lf\n", c);
 
   
 
 
}


Measured memory_bytes: 3212
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main(String args[]) throws java.lang.Exception,FileNotFoundException
	{
		Scanner sc = new Scanner(System.in);

		// PrintStream obj = new PrintStream(new File("Output.txt"));
		// System.setOut(obj);

		char c = sc.next().charAt(0);

		if(c >= 'A' && c <= 'Z')
		{
			c = 'A';
		}

		else
		{
			c ='a';
		}

		System.out.println(c);

		sc.close();
		System.out.flush();
	}
}

Measured memory_bytes: 26992
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<ii> S(N);
	for (int i=0; i<N; i++) {
		int X,L; cin>>X>>L;
		S[i]={X+L,X-L};
	}
	sort(S.begin(),S.end());
	int ret=0, cur=INT_MIN;
	for (auto s : S)
		if(s.second>=cur)
			cur=s.first, ret++;
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0

A = list(sorted(A, reverse=True))

while True:
    if A != []:
        Alice += A.pop(0)
    else:
        break
    if A != []:
        Bob += A.pop(0)
    else:
        break

print(Alice-Bob)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	long long H[100010];
	int max = 0;
	for (int i = 1; i <= N; i++) {
		cin >> H[i];
		if (max < H[i])max = H[i];
		else if (max - H[i] >= 2) { cout << "No"; return 0; }

	}
	cout << "Yes";

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	if (k <= a) ans = k;
	else if (k <= a + b) ans = a;
	else ans = a - (k - a - b);
	cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>mondai(N,0);
  for(int i=0;i<M;i++){
    int num;
    string kekka;
    cin>>num>>kekka;
    if(kekka=="WA"&&mondai.at(num-1)>=0){
      mondai.at(num-1)++;
    }else if(kekka=="AC"&&mondai.at(num-1)>=0){
      if(mondai.at(num-1)==0)mondai.at(num-1)=200000;
      mondai.at(num-1)*=-1;
    }
  }
  int AC=0;
  int P =0;
for(int i=0;i<N;i++){
  if(mondai.at(i)<0){
    if(mondai.at(i)<-150000)mondai.at(i)=0;
    P+=mondai.at(i)*(-1);
    AC++;
  }
}

  cout<<AC<<" "<<P<<endl;
}


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

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

//to (行き先), weight の順で設定
ll ans = 0;

void dfs(vector<vector<pi > > G, vector<bool > seen, ll idx, ll from = -1){
    seen[idx] = true;

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //同じだったらもう処理しない
        //頂点に戻ってきたら
        //後戻りを許さない
        if(seen[to] == true){
            continue;
        }
 
        dfs(G, seen ,to , idx);
 
    }

    bool f = true;
    for(ll i = 0; i < seen.size(); i++){
        if(seen[i] == false){
            f = false;
            break;
        } 
    }

    if(f == true) ans++;

}

int main(){
    ll N, M;
    cin >> N >> M;
    
    //初期化
    vector<vector<pi > > G;
    G.assign(N, vector<pi >());
    vector<bool > seen(N, false);
 
    //グラフ入力
    for(ll i = 0; i < M; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(G ,seen ,0);

    cout << ans << endl;

}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto hw = readln.chomp.split.to!(int[]);
  foreach (i; 0..hw[0]) {
    auto tmp = readln.chomp.split.to!(string[]);
    foreach (j; 0..hw[1]) {
      if (tmp[j] == "snuke" ) {
        writeln(('A' + j).to!char ~ (i+1).to!string);
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
int main(void) {
	// your code goes here
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
     if(abs(x-a)>abs(x-b))
     	printf("B\n");
     	else
     	printf("A\n");
	return 0;
}



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

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

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

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

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

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

	int x; cin >> x;
	if(x == 1){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}


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

typedef long long LL;

LL a, b, c, d;
std::unordered_map<LL, LL> map;

template<class T>
void update(T &x, const T &y) {
	if (x > y) x = y;
}

LL dfs(LL n) {
	// std::cout<<n<<std::endl;
	if (n == 0)
		return 0;
	if (map.count(n))
		return map[n];
	if (n == 1)
		return d;
	LL ans = 6e18;
	if (ans / n >= d)
		update(ans, n * d);
	LL k = n / 2 * 2;
	update(ans, dfs(n / 2) + a + d * (n - k));
	if (n > 2)
		update(ans, dfs(n / 2 + 1) + a + d * (k + 2 - n));
	k = n / 3 * 3;
	update(ans, dfs(n / 3) + b + d * (n - k));
	update(ans, dfs(n / 3 + 1) + b + d * (k + 3 - n));
	k = n / 5 * 5;
	update(ans, dfs(n / 5) + c + d * (n - k));
	update(ans, dfs(n / 5 + 1) + c + d * (k + 5 - n));
	return map[n] = ans;
}

int main() {
	LL n;
	int T;
	for (scanf("%d", &T); T; --T) {
		std::cin >> n >> a >> b >> c >> d;
		map.clear();
		std::cout << dfs(n) << std::endl;
		// for (auto p : map) std::cout << p.first << " " << p.second << std::endl;
	}
}

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

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	bool ok[100]={};
	rep(i,k){
		int d; scanf("%d",&d);
		rep(j,d){
			int a; scanf("%d",&a); a--;
			ok[a]=true;
		}
	}
	printf("%d\n",count(ok,ok+n,false));
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<utility>
#include<vector>
class combination_mod
{
private:
	std::vector<long long>factorial_mod;
	long long divisor;
public:
	combination_mod(long long div, long long sup_n) :divisor(div), factorial_mod(std::vector<long long>(sup_n + 1))
	{
		factorial_mod[0] = 1;
		for (long long i = 1; i <= sup_n; i++)
		{
			factorial_mod[i] = factorial_mod[i - 1] * i % divisor;
		}
	}
	long long operator()(long long n, long long r)
	{
		long long numerator = factorial_mod[n];
		long long denominator = factorial_mod[r] * factorial_mod[n - r] % divisor;
		long long index = divisor - 2, power = 1;
		while (index > 0)
		{
			if (index & 1 == 1)
			{
				power *= denominator;
				power %= divisor;
			}
			denominator *= denominator;
			denominator %= divisor;
			index >>= 1;
		}
		return numerator * power % divisor;
	}
};
int main()
{
	const long long divisor = 998244353;
	const long long sup_n = 300000;
	combination_mod cm(divisor, sup_n);
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for (long long x = 0; x <= n; x++)
	{
		if ((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if (0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for (auto i : pairs)
	{
		ans += cm(n, i.first) * cm(n, i.second) % divisor;
		ans %= divisor;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 6912
from itertools import product

n = int(input())

pow6 = [pow(6, i + 1) for i in range(6)]
pow9 = [pow(9, i) for i in range(6)][::-1]

ans = n
for l in product(range(6), repeat=6):
    cnt = sum(l)
    num = n - sum(pi * li for pi, li in zip(pow6, l))
    if num >= 0:
        tmp = 0
        while num > 0:
            if pow9[tmp] > num:
                tmp += 1
            elif pow9[tmp] <= num:
                num -= pow9[tmp]
                cnt += 1
        ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 74892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int n = s.size();
    if(s[n-1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
}



Measured memory_bytes: 3616
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector <int> water;
    vector <int> sugar;
    int alim = F/(A*100);
    int blim = F/(B*100);
    int clim = F/C;
    int dlim = F/D;
    for(int i = 0; i <= alim; i++){
        for(int l = 0; l <= blim; l++){
            if(i*A*100+l*B*100 <= F)
                water.push_back(i*A*100+l*B*100);
        }
    }
    for(int i = 0; i <= clim; i++){
        for(int l = 0; l <= dlim; l++){
            if(i*C+l*D <= F)
                sugar.push_back(i*C+l*D);
        }
    }
    double conc = 0.0;
    int w = 0;
    int s = 0;
    for(int i = 0; i < water.size(); i++){
        for(int l = 0; l < sugar.size(); l++){
            int sum = water[i]+sugar[l];
            if(sum<=F && sugar[l]<=((double)water[i]/100*E)){
                double temp = (100.0*sugar[l])/(sum);
                if(temp >= conc){
                    w = water[i];
                    s = sugar[l];
                    conc = temp;
                }
            }
        }
    }
    cout << (w+s) << " " << s << "\n";
    return 0;
}

Measured memory_bytes: 1400
# B - Polygon


def main():
    s1 = input()
    s2 = input()
    ret = solve(s1, s2)
    print(ret)


def solve(s1, s2):
    N = int(s1)
    L = [int(x) for x in s2.split()]
    if(max(L) < sum(L) - max(L)):
        return "Yes"
    else:
        return "No"


main()


Measured memory_bytes: 2940
s = input()
g = 0
p = 0
ans = 0
for i in s:
    if i == "g":
        if p < g:
            ans += 1
            p += 1
        else:
            g += 1
    else:
        if p < g:
            p += 1
        else:
            ans -= 1
            g += 1
print(ans)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}


template<typename T>
struct Edge {
	int from, to;
	T cost;
	Edge () {}
	Edge (int from, int to, T cost ) : from(from), to(to), cost(cost) {}
	Edge (int to, T cost) : from(-1), to(to), cost(cost) {}
};

template<typename T>
vector < T > BellmanFord(int V, vector < Edge < T > > &edges, int s)
{
	constexpr T INF = numeric_limits < T >::max();
	vector < T > d(V, INF);
	d[s] = 0;
	for ( int i = 0; i < V; i++ ) {
		for ( auto &e : edges ) {
			if ( d[e.from] != INF && d[e.to] > d[e.from] + e.cost ) {
				d[e.to] = d[e.from] + e.cost;
				if ( i == V - 1 ) return ( vector < T > () );
			}
		}
	}
	return ( d );
}

vector<Edge<double>>edges;

double pdist(double x1, double y1, double x2, double y2) {
	return (sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
}

int main() {
	double sx, sy, tx, ty;	
	cin >> sx >> sy >> tx >> ty;
	int N; cin >> N;
	int V; V = N + 2;
	vector<double> X(V), Y(V), R(V);

	X[0] = sx, Y[0] = sy, R[0] = 0;
	X[N+1] = tx, Y[N+1] = ty, R[N+1] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> R[i];
	}
	
	for (int i = 0; i < V; i++) {
		for (int j = i + 1; j < V; j++) {
			double dist = max(0.0, pdist(X[i], Y[i], X[j], Y[j]) - R[i] - R[j]);
			edges.emplace_back(i, j, dist);
			edges.emplace_back(j, i, dist);
		}
	}
	vector<double> ans = BellmanFord(V, edges, 0);
	
	cout << fixed << setprecision(10) << ans[N+1] << endl;

	return (0);
}

Measured memory_bytes: 18796
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def longest_increasing_subsequence(seq):
    side = 'left'
    N = len(seq)
    INF = 10**18
    dp = np.full_like(seq, INF)
    for x in seq:
        i = np.searchsorted(dp, x, side)
        dp[i] = x
    return np.searchsorted(dp, INF - 1, side)

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8[:], )

    cc = CC('my_module')
    cc.export('longest_increasing_subsequence',
              signature)(longest_increasing_subsequence)
    cc.compile()

from my_module import longest_increasing_subsequence

x1, y1, x2, y2 = map(int, readline().split())
N = int(readline())
XY = np.array(read().split(), np.int64)

X = XY[::2]
Y = XY[1::2]

if x1 > x2:
    x1, x2 = x2, x1
    y1, y2 = y2, y1
if y1 > y2:
    y1, y2 = -y1, -y2
    Y = -Y

X -= x1
Y -= y1
x = x2 - x1
y = y2 - y1

cond = (X >= 0) & (X<=x) & (Y>=0) & (Y<=y)
X = X[cond]
Y = Y[cond]
ind = np.argsort(X)
X = X[ind]
Y = Y[ind]

n = longest_increasing_subsequence(Y)

answer = x+y
answer -= (0.2 - 0.1 * np.pi/2) * n
if n == min(x,y) + 1:
    answer += 0.1 * np.pi / 2
answer *= 100
print(answer)

Measured memory_bytes: 52904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;  
  vector<double> A(N);


  for(int k=0;k<N;k++){
    cin >> A.at(k);
  }
  
  sort(A.begin(), A.end());
  
  for(int k=0;k<N-1;k++){
    A.at(k+1)=(A.at(k)+A.at(k+1))/2;
    
  }

  
  cout << A.at(N-1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long N = sc.nextLong();
		long M = sc.nextLong();
		long ans = 0;

		if (N == 1 && M == 1) {
			ans = 1;
		} else if (N == 1) {
			ans = M - 2;
		} else if (M == 1) {
			ans = N - 2;
		} else {
			ans = (N - 2) * (M - 2);
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>

int main() {
    int n; std::cin >> n;
    std::vector<std::vector<std::pair<int, int>>> tst(n);
    for (int i = 0; i < n; i++) {
        int k; std::cin >> k;
        for (int j = 0; j < k; j++) {
            int x, y; std::cin >> x >> y;
            tst[i].emplace_back(x - 1, y);
        }
    }

    int answer = 0;
    const int max_mask = 1 << n;
    for (int mask = 0; mask < max_mask; mask++) {
        bool verdict = true;
        int total = 0;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                total += 1;
                for (auto& p: tst[i]) {
                    int hmm = (mask & (1 << p.first)) ? 1 : 0;

                    if (hmm ^ p.second) {
                        verdict = false;
                    }
                }
            }
        }

        answer = std::max(answer, total * verdict);
    }

    std::cout << answer << "\n";
    return 0;
}

Measured memory_bytes: 256
k=int(input())
#n,p=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#素因数分解した結果を2次元配列にして返す

all_list=[]

def rec(d,val):
    global all_list
    all_list.append(val)
    if d==10:
        return
    for j in range(-1,2,1):
        add=val%10+j
        if add>=0 and add<=9:
            rec(d+1,val*10+add)

for i in range(1,10):
    rec(1,i)
all_list.sort()
print(all_list[k-1])

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

using namespace std;

using ll = long long;
using ld = long double;

struct MinimumBoundingBox {
    const double INF = numeric_limits<double>::max();
    const double NINF = numeric_limits<double>::lowest();

    int n;
    vector<double> x, y;
    vector<char> d;

    MinimumBoundingBox(int _n) : n(_n), x(n), y(n), d(n) {}

    void input() {
        for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> d[i];
    }

    ld solve() {
        double min_v = f(0), lb = 0, ub = 1e9;
        for (int i = 0; i < 200; ++i) {
            const double t1 = (2.0 * lb + ub) / 3.0;
            const double t2 = (lb + 2.0 * ub) / 3.0;

            min_v = min(min_v, f(t1));
            min_v = min(min_v, f(t2));

            if (f(t1) > f(t2)) lb = t1;
            else ub = t2;
        }
        return min_v;
    }

    double f(const double t) {
        pair<double, double> dx(INF, NINF), dy(INF, NINF);
        for (int i = 0; i < n; ++i) {
            double vx = x[i], vy = y[i];

            if (d[i] == 'R') vx += t;
            else if (d[i] == 'L') vx -= t;
            else if (d[i] == 'U') vy += t;
            else if (d[i] == 'D') vy -= t;

            dx.first = min(dx.first, vx);
            dx.second = max(dx.second, vx);
            dy.first = min(dy.first, vy);
            dy.second = max(dy.second, vy);
        }
        return (dx.second - dx.first) * (dy.second - dy.first);
    }
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(10) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    MinimumBoundingBox mbb(n);
    mbb.input();
    cout << mbb.solve() << endl;

    return 0;
}


Measured memory_bytes: 1920
#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()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  int ans = inf;
  rep(i, n) {
    int cur = 0;
    while(A[i]%2==0) {
      cur++;
      A[i] /= 2;
    }
    ans = min(cur, ans);
  }
  cout << ans << "\n";
  return 0;
}


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

int main(){
  int N;cin>>N;
  vector<int> V(N);
  rep(i,N)cin>>V[i];
  rep(i,N){
    int c;cin>>c;V[i]-=c;
  }
  int ans = 0;
  rep(i,N){
    if(V[i]>0)ans+=V[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s;
	cin >> s;
	if(s=="AAA" || s=="BBB")
		cout << "No" << endl;
	else 
		cout << "Yes" << endl;
}

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

int main(){
	int n,m;
	while(cin>>n>>m){
	int a[n],b[m];
	int asum,bsum;
	asum=bsum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		asum+=a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
		bsum+=b[i];
	}
	
	double sa=1.0*(asum-bsum)/2;
	int flag=0;
//	cout<<"sa"<<" "<<sa<<endl;
	for(int i=0;i<=n;i++){
			if(flag)continue;
		for(int j=0;j<m;j++){
			if(flag)continue;
			if((double)(a[i]-b[j])==sa){
				 cout<< a[i] << " " << b[j]<<endl;
				flag=1;
			}
			if(i==n){
				cout<<-1<<endl;
				flag=1;
			}
			
			
		}
	}
	}
		
	
}

Measured memory_bytes: 1160