akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
ll d[200];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		d[s[0]]++;
	}
	vector<ll>v;
	v.push_back(d['M']);
	v.push_back(d['A']);
	v.push_back(d['R']);
	v.push_back(d['C']);
	v.push_back(d['H']);
	ll ans = 0;
	for (int i = 0; i < 32; i++)
	{
		int c = 0;
		ll t = 1;
		for (int j = 0; j < 5; j++)
		{
			if (i&(1 << j))c++, t *= v[j];
		}
		if (c == 3)ans += t;
	}
	printf("%lld\n", ans);
}

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;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(i%2==1)continue;
        string s1 = s.substr(0,i/2);
        string s2 = s.substr(i/2,i/2);
        if(s1 == s2) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int n;
deque<int> deq;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n) {
        int d;
        cin >> d;
        if (i&1) {
            deq.push_front(d);
        } else {
            deq.push_back(d);
        }
    }

    if (n & 1) {
        reverse(deq.begin(), deq.end());
    }

    REP (i, n) {
        cout <<deq[i] << " \n"[i==n-1];
    }
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int n=s.length();

	int ans=n;
	for(int i=1; i<n; i++){
		if(s[i]!=s[i-1]){
			ans=min(ans, max(i, n-i));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int cnt1 = 0;
    int cnt2 = 0;
    int cnt3 = 0;
    for(int i=0; i<N; i++){
      int tmp = sc.nextInt();
      if(tmp<=A){
        cnt1++;
      }else if(tmp>A && tmp<=B){
        cnt2++;
      }else if(tmp>B){
        cnt3++;
      }
    }
    System.out.println(Math.min(cnt1, Math.min(cnt2,cnt3)));
  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0;
  string s;
  cin >>a>>b>>c;
  c=c-a;
  if(c>=0&&b-c>=0) cout <<"YES\n";
  else cout <<"NO\n";
  return (0);
}


Measured memory_bytes: 256
#include<stdio.h>

int digit_sum(int num);

int main() {
	int n, a, b, cnt, i, temp;

	cnt = 0;
	scanf("%d%d%d", &n, &a, &b);
	for (i = 1; i <= n; i++) {
		temp = digit_sum(i);
		if (a <= temp && temp <= b) cnt += i;
	}
	printf("%d", cnt);
	return 0;
}

int digit_sum(int num) {
	if (num > 9) return num % 10 + digit_sum(num / 10);
	else return num;
}

Measured memory_bytes: 128
n = int(input())
v = list(map(int, input().split()))
tmplist = v
tmplist.sort()
while len(tmplist) != 1:
    mix = ( tmplist.pop(1) + tmplist.pop(0) ) / 2 # ここはpop()する順番が重要
    tmplist.append(mix)
    tmplist.sort()
else:
    print(tmplist[0])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int t = Integer.parseInt(s.next());

        int num = 0;
        int c = 1;
        int time = a;

        while (time < t + 0.5) {
            num += b;
            time += a;
            c++;
        }

        System.out.println(num);
    }
}

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

bool binarySearch(int);
bool flg;
int cnt=0;
int S[MAX],T[MAX];
int i,j,s,t;

int main(){
    scanf("%d",&s);
    for(i=0;i<s;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&t);
    for(j=0;j<t;j++){
        scanf("%d",&T[j]);
    }
    for(j=0;j<t;j++){
        flg=binarySearch(T[j]);
        if(flg)cnt++;
    }

    
    printf("%d\n",cnt);
    return 0;
}
 
 
bool binarySearch(int Tnum){
    int left = 0;
    int right = s;
    while(left < right){
        int mid = (left + right)/2;
        if(S[mid] == Tnum){
            return true;
        }else if(Tnum < S[mid]){
            right = mid;
        }else{
            left = mid + 1;
        }
    }
    return false;
}




Measured memory_bytes: 2332
import Control.Monad
import Text.Printf
drawRect :: Int -> Int -> IO ()
drawRect h w = replicateM_ h (putStrLn $ replicate w '#') >> putStrLn ""
loop = do
    ln <- getLine
    let [h,w] = map read $ words ln :: [Int]
    if h == 0 && w == 0 then
        return ()
    else do
        drawRect h w
        loop

main = loop

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
int32_t main()
{
	IOS;
	int t;
	//cin >> t;
	t=1;
	while(t--)
	{
	    int x;
	    cin>>x;
	    if(x){
	        cout<<"0";
	    } else {
	        cout<<"1";
	    }
	}
	return 0;
} 

Measured memory_bytes: 3540
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int inp[1000000];
	
int main() {
	int n,m;
	while(n=in(),m=in()){
		int i;
		for(i=0;i<n;i++){
			inp[i]=in();
		}
		Int max;
		Int sum=0;
		int k;
		for(k=0;k<m;k++){
			sum+=inp[k];
		}
		max=sum;
		for(i=0;i<=n-m;i++){
			if(max<sum)max=sum;
			sum-=inp[i];
			if(i!=n-m)sum+=inp[i+m];
		}
		cout<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <atcoder/math>
//using namespace atcoder;
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

struct E{
	int to,co;
	E(int to,int co):to(to),co(co){}
};

int main(){
	int n,m,s,t;cin >> n >> m >> s >> t;
	--s;--t;
	vector<vector<E>> G1(n),G2(n);
	rep(i,m){
		int a,b,mon,snu;cin >> a >> b >> mon >> snu;
		--a;--b;
		G1[a].emplace_back((E){b,mon});
		G1[b].emplace_back((E){a,mon});
		G2[a].emplace_back((E){b,snu});
		G2[b].emplace_back((E){a,snu});
	}
	vector<ll> forw(n,LINF),back(n,LINF);
	forw[s] = 0;
	back[t] = 0;
	priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
	q.emplace(0,s);
	while(!q.empty()){
		int v = q.top().second;
		ll co = q.top().first;
		q.pop();
		//printf("%lld %d\n",co,v);
		for(E e:G1[v]){
			if(forw[e.to] <= co+e.co) continue;
			forw[e.to] = co+e.co;
			q.emplace(co+e.co,e.to);
		}
	}
	q.emplace(0,t);
	while(!q.empty()){
		int v = q.top().second;
		ll co = q.top().first;
		q.pop();
		for(E e:G2[v]){
			if(back[e.to] <= co+e.co) continue;
			back[e.to] = co+e.co;
			q.emplace(co+e.co,e.to);
		}
	}
	vector<ll> ans(n);
	for(int i = n-1;i >= 0;i--){
		if(i == n-1) ans[i] = ll(1e15) - forw[i] - back[i];
		else{
			ans[i] = max(ans[i+1],ll(1e15)-forw[i]-back[i]);
		}
	}
	rep(i,n) cout << ans[i] << endl;

}

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

int main() {
  ll x;
  cin >> x;
  ll a;
  for (a = 1;; a++) {
    if (a * (a + 1) >= 2 * x) {
      break;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var A = new bool[100002].Select(_ => true).ToArray();
        A[0] = A[1] = false;
        for (int i = 0; i < 100002; i++)
        {
            if (A[i])
            {
                for (int j = i*2; j < 100002; j+=i)
                {
                    A[j] = false;
                }
            }
        }
        var B = new int[100001];
        for (int i = 1; i < 100001; i++)
        {
            B[i] = B[i - 1];
            if (A[i]&&A[(i+1)/2]) B[i]++;
        }
        var Q = int.Parse(ReadLine());
        for (int i = 0; i < Q; i++)
        {
            var lr = ReadLine().Split().Select(int.Parse).ToArray();
            var l = lr[0];
            var r = lr[1];
            WriteLine(B[r]-B[l-1]);
        }
    }
}


Measured memory_bytes: 47136
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

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

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else

void solve() {

    int n,m;
    cin >> n >> m;

    cout << (n - 1) * n / 2 + m * (m - 1) /2;

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++)  << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, K = map(int, input().split())

if N < 0 or K > (N-1)*(N-2)//2:
    print(-1)
else:
    M = (N-1)*(N-2)//2 - K
    print(M+N-1)
    for i in range(1,N):
        print(i,N)
    count = 0
    for i in range(1,N):
        for j in range(i+1,N):
            if count == M:
                sys.exit()
            print(i,j)
            count += 1


Measured memory_bytes: 79624
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int n,k;
	cin>>n>>k;
	vi P(n);
	take(P,0,n);
	sort(all(P));
	int sum=0;
	for(int i=0;i<k;i++) sum+=P[i];
	cout<<sum<<endl;
}		

Measured memory_bytes: 7024
#include<iostream>
#include<cmath>


int main() {
	int a = {};
	int a2 = {};
	int a3 = {};
	std::cin >> a;

	a2 =std::pow(a, 2);
	a3 = std::pow(a, 3);

	a = a + a2 + a3;
	std::cout << a << std::endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
vector<int> g[N];
int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    for (int i = 1; i < n; ++i) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    vector<int> ans(n);
    for (int i = 1; i <= n; ++i) {
        queue<int> q;
        q.push(i);
        vector<int> d(n + 1, N);
        d[i] = 0;
        while (q.size()) {
            int u = q.front();
            q.pop();
            for (int v : g[u])
                if (d[v] == N) {
                    d[v] = d[u] + 1;
                    q.push(v);
                }
        }
        for (int u = 1; u <= n; ++u)
            ans[d[u]]++;
    }
    for (int i = 1; i < n; ++i)
        cout << ans[i] / 2  << "\n";
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    cin >> s; 
    if(int(s[6])-48 <= 4 && int(s[5])-48 == 0){
        cout << "Heisei";
    }
    else{
        cout << "TBD";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    
        double  b,c,d=0;
        int a;
      cin>>a>>b;
     double arr[2*a];
     for(int i=0;i<2*a;i++){
         cin>>arr[i];

     }
for(int i=0;i<((2*a)-1);i=i+2){
   c=((arr[i]*arr[i])+(arr[i+1]*arr[i+1]));
   c=sqrt(c);
  
   if(c<=b){
       d=d+1;
   }
}
      
 cout<<d<<endl;   
}

Measured memory_bytes: 6884
#include <stdio.h>
int main(void){
    int N,M,K;
    scanf("%d %d %d",&N,&M,&K);
    int flag=0;
    for(int i=0;i<=N;i++)for(int j=0;j<=M;j++)if(i*M+j*N-2*i*j==K)flag=1;
    if(flag==1)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long int m(long long int, long long int, long long int);
int main() {
	long long int h, w;
	long long int ans;
	cin >> h >> w;
	if(h % 3 == 0 || w % 3 == 0) {
		ans = 0;
	} else {
		ans = min(h, w);
		for(int i = 1; i < h; i++) {
			ans = min(ans, m(h, w, i));
		}
		for(int i = 1; i < w; i++) {
			ans = min(ans, m(w, h, i));
		}
	}
	cout << ans << endl;

	return 0;
}

long long int m(long long int h, long long int w, long long int i) {
	long long int a[3];
	a[0] = w * i;
	a[1] = (h - i) * (w / 2);
	a[2] = (h - i) * (w - (w / 2));
	sort(a, a + 3);

	return a[2] - a[0];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int w;cin>>w;
  int l = (int)s.size()/w;
  for(int i=0;i<=l;i++){
    if(i*w>=(int)s.size())continue;
    cout<<s[i*w];
  }
  cout<<"\n";
  return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1 << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    vector<ll> sub(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sub[i] = i - A[i];
    }

    unordered_map<ll, ll> mp;
    mp[A[0]]++;
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ans += mp[sub[i]];
        mp[A[i] + i]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21712
import java.util.*;

public class Main {                       
 
  public static void main(String[] args) {                     
      Scanner sc = new Scanner(System.in);
      
      ArrayList<Integer> ans = new ArrayList<Integer>();
      
      while(sc.hasNext()){
          int a = sc.nextInt();
          int b = sc.nextInt();
          ans.add(a+b);       
      }
     
      for(int i = 0;i < ans.size();i++){
          System.out.println(ans.get(i));
      }
    
  }  
      
}

        

Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
 
#define fr(i,a,b) for(int (i)=(int) a;(i)<=(int)(b);++(i))
#define li list<int>
#define ll long long
#define mp make_pair
#define mod 1000000007
#define pb push_back
#define pi pair<int ,int >
#define pr printf
#define vi vector<ll>
#define vpi vector< pi > 
int main()
{
	int n;
	cin>>n;
	int a[n+10];
	set<int> s;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(s.find(a[i])!=s.end())
		{
			s.erase(a[i]);
		}
		else
			s.insert(a[i]);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 5248
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  int sum_a = 0;
  int sum_b = 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  rep(i, n) {
    if (i%2 == 0) {
      sum_a += a.at(i);
    }
    else {
      sum_b += a.at(i);
    }
  }
  cout << sum_a-sum_b << endl;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
using namespace std;



int main() {
	char S[200];
	cin >> S;
	int year, month, day;
	year = 1000 * ((int)S[0] - 48) + 100 * ((int)S[1] - 48) + 10 * ((int)S[2] - 48) + ((int)S[3] - 48);
	month = 10 * ((int)S[5] - 48) + ((int)S[6] - 48);
	day= 10 * ((int)S[8] - 48) + ((int)S[9] - 48);
	if (year < 2019) {
		cout << "Heisei";
	}
	else if (year > 2019) {
		cout << "TBD";
	}
	else {
		if (month > 4) {
			cout << "TBD";
		}
		else if (month < 4) {
			cout << "Heisei";
		}
		else {
			cout << "Heisei";
		}
	}
}

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

int main() {
    int n, d;
    cin >> n >>d;
    int x[n][d];
    rep(i, n) {
        rep(j, d) cin >> x[i][j];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double dist = 0;
            for (int k = 0; k < d; k++) {
                dist += pow(x[i][k] - x[j][k], 2);
            }
            dist = sqrt(dist);
            if(floor(dist) == dist) ans++;
        }
    }

    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b;
  int x = 0;
  int n = 0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  
  while(n < 2){
  	if(a <= b){
    	x += b;
    	b--;
  	}
  	else {
    	x += a;
    	a--;
  	}
  	n++;
  }
  
  printf("%d\n",x);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans[10002];
  for(int i=0;i<10002;i++)ans[i]=0;
  for(int x=1;x<=100;x++){
  	for(int y=1;y<=100;y++){
    	for(int z=1;z<=100;z++){
        	int p=x*x+y*y+z*z+x*y+y*z+z*x;
          	if(p>10000)continue;
          	else ans[p]++;
        }
    }
  }
  for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int r=0;
    rep(i,N){
        if(S[i]=='(') r++;
        else{
            r = max(0,r-1);
        }
    }
    
    int l=0;
    rrep(i,N-1){
        if(S[i]==')') l++;
        else{
            l = max(0,l-1);
        }
    }
    
    string right = "";
    string left = "";
    
    rep(i,r) right += ')';
    rep(i,l) left += '(';
    //cout<<"(())"<<endl;
    cout<<left<<S<<right<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;

int dig(int d){
    int ret = 1;
    d /= 10;
    while(d > 0){
        ret++;
        d /= 10;
    }
    return ret;
}

int main(void){
    int a, b;
    while(cin >> a >> b){
        cout << dig(a+b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
from collections import Counter
n = int(input())
lis = list(map(int, input().split()))

a = Counter(lis[::2])
b = Counter(lis[1::2])

aa = sorted(a.items(), key=lambda x:x[1], reverse=True)
bb = sorted(b.items(), key=lambda x:x[1], reverse=True)

if aa[0][0] == bb[0][0]:
    if len(aa) > 1 and len(bb) > 1:
        res = n - max(aa[0][1]+bb[1][1], aa[1][1]+bb[0][1])
    elif len(aa) == 1 and len(bb) > 1:
        res = n - aa[0][1] - bb[1][1]
    elif len(aa) > 1 and len(bb) == 1:
        res = n - aa[1][1] - bb[0][1]
    else:
        res = n - aa[0][1]
else:
    res = n - aa[0][1] - bb[0][1]

print(res)


Measured memory_bytes: 21184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main(){
        string s;
        cin >> s;
        int n = s.size();
        //cout << n <<endl;
        vector<int> a(n,1);
        rep(i,n-1){
                if(s[i] == 'R' && s[i+1] == 'R'){
                        a[i+1] += a[i]; a[i] = 0;
                }
        }
        rep(i,n-1){
                if(s[n-1-i] =='L' && s[n-i-2] =='L'){
                        a[n-i-2] += a[n-i-1]; a[n-i-1] = 0;
                }
        }
        //rep(i,n) cout << a[i] << " "  ;
        //cout << endl;
        vector<int> ans(n,0);
        if(s[0] == 'R'){
                bool r = true;;
                rep(i,n){
                        if(a[i] > 0 && r){
                                if(i == n-1) ans[i] = a[i];
                                else{
                                        ans[i] = (a[i]+1)/2 + a[i+1]/2;
                                        r = false;
                                }
                        }
                        else if(a[i] > 0 && !r){
                                ans[i] = (a[i]+1)/2 + a[i-1]/2;
                                r = true;
                        }
                }
        }
        else{
                bool l = true;
                rep(i,n){
                        if(a[i] > 0 && l){
                                if(i ==0) ans[i] = a[i];
                                else{
                                        ans[i] = (a[i]+1)/2 + a[i-1]/2;
                                        l = false;
                                }
                        }
                        else if(a[i] > 0 && !l){
                                if(i == n-1) ans[i] = a[i];
                                else{
                                       ans[i] = (a[i]+1)/2 + a[i+1];
                                       l = true;
                                }
                        }
                }
        }

        rep(i,n) cout << ans[i] << " ";
        cout << endl;

        

        return 0;
}


Measured memory_bytes: 1408
# 2020/05/30
# NOMURA プログラミングコンテスト 2020 - A

# Input
h1, m1, h2, m2, k = map(int,input().split())

# Calc
hm1 = h1 * 60 + m1
hm2 = h2 * 60 + m2
ans = hm2 - hm1 - k

# Output
print(ans)


Measured memory_bytes: 9100
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 
mons=0
for i in range(N):
  if B[i]>A[i]:
    mons+=A[i]
    if B[i]>=A[i]+A[i+1]:
      mons+=A[i+1]
      A[i+1]=0
    else:
      mons+=B[i]-A[i]
      A[i+1]-=B[i]-A[i]
  else:
    mons+=B[i]
print(mons)


Measured memory_bytes: 24240
from collections import defaultdict
strN=input()
lenN=len(strN)
N=int(strN)

if N<=9:print(N)
else:
  count = defaultdict(int)
  for i in range(10,N+1):
    a,b=int(str(i)[0]),int(str(i)[-1])
    if b==0:continue
    count[(a,b)] += 1

  ans=0
  for i in range(1,10):
    count[(i,i)] += 1
  count = dict(count)
  for key in count.keys():
    if key[0]<key[1] and count.get((key[1],key[0])):
      ans += count[key] * count[(key[1],key[0])] * 2
    if key[0]==key[1]:
      ans += count[key]**2
  print(ans)

Measured memory_bytes: 9380
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    // 0, 3
    // 3, #2
    map<int, int> mp;
    mp[0] = 3;
    ll ans = 1;
    rep(i,n) {
        ans = (ans*mp[a[i]])%mod;
        --mp[a[i]];
        ++mp[a[i]+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
       
#define ff              first
#define ss              second                            
#define int             long long
#define rep(i,j,k)      for(int i=(j); i<(int)k; ++i)
#define rrep(i,k,j)     for(int i=(int)k-1; i>=(j); --i)
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define endl            "\n"
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed << setprecision(y) << x
#define mk(arr,n,type)  type *arr = new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define PI              3.14159265358979323846264338327950L
#define span(a)         begin(a), end(a)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
       
       
       
       
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif  
}      
// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }    
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }  
//   int x1, y1;
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }   
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }   
// int fact(int n){
//   if(n==0) return 1 ;
//   else return n*fact(n-1); 
// }   

// bool isPrime(int x) {
//   for (int d = 2; d * d <= x; d++) if (x % d == 0) return false;
//   return true;
// }
double pi = 3.141592653589;  

inline void solve() {
  int n; cin >> n;

  map<string, int> hash;

  rep (i, 0, n) {
    string s; cin >> s;
    hash[s]++;
  }
  
  cout << "AC x " << hash["AC"] << endl;
  cout << "WA x " << hash["WA"] << endl;
  cout << "TLE x " << hash["TLE"] << endl;
  cout << "RE x " << hash["RE"] << endl;
}    
int32_t main() {
 //c_p_c();
 //w(x)    
 solve();
 return 0;
}      

Measured memory_bytes: 3612
fun main(args : Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }

    val a = divisors(A).toHashSet()
    val b = divisors(B)

    var answer = 1L
    b.forEach {
        if (a.contains(it) && isPrime(it)) {
            answer++
        }
    }

    println(
            answer
    )
}

// O(√n)
fun isPrime(n: Long) : Boolean {
    for (i in 2..(Math.sqrt(n.toDouble())).toLong()) {
        // iで割れるなら素数でない
        if (n % i == 0L) {
            return false
        }
    }

    return n != 1L
}

// O(√n)
fun divisors(n: Long) : List<Long> {
    val list = mutableListOf<Long>()
    for (i in 1L..(Math.sqrt(n.toDouble())).toLong()) {
        // iで割れるならカウント
        if (n % i == 0L) {
            list.add(i)
            // iの対となるもうひとつの約数も入れる.
            if (i != n / i) {
                list.add(n / i)
            }
        }
    }

    return list
}

Measured memory_bytes: 38368
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 6004;
const int SH = 3000;
int d[2][maxn][2][2];

const int mod = 1e9 + 7;
void udd(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    int n, m;
    cin >> n >> m;
    int res = 0;

    forn (EVEN, 2) {
        int q = 0;
        for (int i = -n; i <= n; ++i)
            forn (f, 2)
                forn (f2, 2)
                    d[q][i + SH][f][f2] = 0;

        for (int i = -n; i <= n; ++i)
            if (abs(i % 2) == EVEN)
                d[q][i + SH][i == -n][i == n] = 1;

        forn (iter, 2 * m) {
            for (int i = -n; i <= n; ++i)
                forn (f, 2)
                    forn (f2, 2)
                        d[q ^ 1][i + SH][f][f2] = 0;

            for (int i = -n; i <= n; ++i) {
                forn (f, 2) {
                    forn (f2, 2) {
                        int cnt = d[q][i + SH][f][f2];
                        if (cnt == 0)
                            continue;
                        for (int di: {-1, 1}) {
                            int ni = i + di;
                            if (ni < -n || ni > n)
                                continue;
                            int nf = f || ni == -n;
                            int nf2 = f2 || ni == n;
                            udd(d[q ^ 1][ni + SH][nf][nf2], cnt);
                        }
                    }
                }
            }
            q ^= 1;
        }
        for (int i = -n; i <= n; ++i) {
            if (EVEN == n % 2)
                udd(res, d[q][i + SH][1][1]);
            udd(res, d[q][i + SH][1][0]);
        }
    }
    cout << res << '\n';
    cerr << "time " << clock() / 1000 << '\n';
}


Measured memory_bytes: 384
def solve():
    n = int(input())

    # ord('B') == 66 (== 0 mod 3)
    # ord('R') == 82 (== 1 mod 3)
    # ord('G') == 71 (== 2 mod 3)
    s = [ord(c) % 3 for c in input()]

    accs = [[0] * (n + 1) for _ in range(3)]
    for i in range(3):
        for j in range(n):
            if i != s[j]:
                accs[i][j + 1] = accs[i][j]
            else:
                accs[i][j + 1] = accs[i][j] + 1

    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                continue
            residual = ({0, 1, 2} - {s[i], s[j]}).pop()
            ans += accs[residual][n] - accs[residual][j]
            if j + j - i + 1 <= n:
                ans -= accs[residual][j + j - i + 1] - accs[residual][j + j - i]
    return ans


print(solve())


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d4x[4] = {0,1,0,-1};
int d4y[4] = {1,0,-1,0};

char in[1010][1010];
int ans[1010][1010];

int main(){
    int H,W;
    cin>>H>>W;
    queue <ip>Q;
    REP(i,H)REP(j,W){
        cin>>in[i][j];
        ans[i][j] = inf;
        if(in[i][j] == '#'){Q.push(make_pair(i,j)); ans[i][j] = 0;}
    }
    REP(i,H)REP(j,W){
        int y = Q.front().first, x= Q.front().second;
        Q.pop();
        rep(i,4){
            int dy = y+d4y[i], dx = x+d4x[i];
            if(in[dy][dx]=='.'&&ans[dy][dx] == inf){
                ans[dy][dx] = ans[y][x]+1;
                Q.push(make_pair(dy,dx));
            }
        }
    }
    int res = 0;
    REP(i,H)REP(j,W)res = max(res,ans[i][j]);
    cout<<res<<endl; return 0;
}


Measured memory_bytes: 13456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int tot = 0;
		for(int i = 0 ; i < n.length() ; i++) {
			tot += Integer.valueOf(String.valueOf(n.charAt(i)));
		}
		if(Integer.valueOf(n) % tot == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


// Modint
struct Mint {
    static const long long mod = (long long)(1e9 + 7);
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, int b) {
    return a.pow(b);
}


int main() {
    int n; std::cin >> n;
    std::vector<long long> c(n);
    for (int i = 0; i < n; i++) std::cin >> c[i];
    std::sort(c.rbegin(), c.rend());
    Mint ans = 0;
    for (int i = 0; i < n; i++) {
        ans += Mint(c[i])*pow(Mint(4), n - 1)*Mint(i + 2);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int N;
long long int K;
long long int A[200005];

int IsPossible(long long int m) {

	int cnt = 0;

	for (int i = 1; i <= N; i++) {
		cnt += ((A[i]+m-1) / m ) -1;
	}

	if (cnt <= K) { return 1; }

	return -1;
}

int main(void) {

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


	long long int left = 0;
	long long int right = 1000000001;

	while (right - left > 1) {
		long long int med = (left + right) / 2;
		if (IsPossible(med) == 1) { right = med; }
		else { left = med; }
	}

	cout << right << endl;

	return 0;
}

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

int main(void){
    int N,M,K;
    cin>>N>>M>>K;
    rep(y,M+1)rep(x,N+1){
        if(x*M+y*N-x*y*2==K){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d ) {
    cout << "Yes" << endl;
  } else {
    if (abs(a - c) > d) {
      if (abs(a - b) > d) {
        cout << "No" << endl;
      } else {
        if (abs(a - b) <= d) {
          if (abs(b - c) <= d) {
            cout << "Yes" << endl;
          } else {
            cout << "No" << endl;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x+=0x9e3779b97f4a7c15; x=(x^(x>>30))*0xbf58476d1ce4e5b9; x=(x^(x>>27))*0x94d049bb133111eb; return x^(x>>31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x+FIXED_RANDOM);
    }
};
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ll n,x,m; cin>>n>>x>>m; unordered_map<int,int,custom_hash>g; 
  ll ans=0; 
  vector<int>v; int i1=-1,i2=-1; 
  rep(i,1,1000000)
  {
    if(g[x]!=0){ i1=g[x]; i2=i-1;  break; } g[x]=i; v.emplace_back(x); x=(x*1ll*x)%m; 
  }
  assert(i1!=-1); 
  ll sum=0; rep(i,i1-1,i2-1) sum+=v[i];      
  if(i1!=1){ rep(i,0,i1-2){ ans+=v[i]; } n-=(i1-1); } 
  ll rem=n%(i2-i1+1); 
  if(rem!=0)
  {
    int c=0; int idx=i1-1; 
    while(c!=rem)
    {
      ans+=v[idx]; idx++; c++; 
    }
  }
  ans+=(n/(i2-i1+1))*1ll*sum; cout<<ans<<"\n"; 
} 

Measured memory_bytes: 5516
//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define endl "\n"
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0);cout<< fixed<< setprecision(10);
#define DEBUG(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define DEBUG2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define DEBUG3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define DEBUG4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 1e5 + 9;

int main()
{
    fastio
    ll n;
    cin>> n;
    vector<ll> a(n+1), s(n+1);
    for(int i=1; i<=n; i++){
        cin>> a[i];
        s[i] = s[i-1] + a[i];
        s[i] %= mod;
    }
    ll ans = 0;
    for(int i=n; i>=2; i--){
        ans += (a[i] * s[i-1]) % mod;
        ans %= mod;
    }
     cout<< ans;
}



Measured memory_bytes: 6376
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		
		while(num > 0){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			
			/*クラメルの公式*/
			double a = 2 * (x1 - x2);
			double b = 2 * (y1 - y2);
			double c = (x1 * x1) + (y1 * y1) - ((x2 * x2) + (y2 * y2));
			double d = 2 * (x1 - x3);
			double e = 2 * (y1 - y3);
			double f = (x1 * x1) + (y1 * y1) - ((x3 * x3) + (y3 * y3));
			
			double px = ((c * e) - (b * f)) / ((a * e) - (b * d));
			double py = ((a * f) - (c * d)) / ((a * e) - (b * d));
			
			/*2点間の距離*/
			double r = Math.sqrt(((x2 - px) * (x2 - px)) + ((y2 - py) * (y2 - py)));
			
			print(px, py, r);
			
			num--;
		}//while
	}
	
	public static void print(double x, double y, double r) {
		BigDecimal x_bd = new BigDecimal(x);
		BigDecimal y_bd = new BigDecimal(y);
		BigDecimal r_bd = new BigDecimal(r);
		
		x_bd = x_bd.setScale(3, BigDecimal.ROUND_HALF_UP);
		y_bd = y_bd.setScale(3, BigDecimal.ROUND_HALF_UP);
		r_bd = r_bd.setScale(3, BigDecimal.ROUND_HALF_UP);
		
		String x_ans = x_bd.toString().format("%.3f", x_bd);
		String y_ans = y_bd.toString().format("%.3f", y_bd);
		String r_ans = r_bd.toString().format("%.3f", r_bd);
		
		System.out.println(x_ans+" "+y_ans+" "+r_ans);
	}
}

Measured memory_bytes: 20832
using System;
public class Class1
{
	public static void Main()
	{
		string dataSet = Console.ReadLine();
		string[] data = dataSet.Split();
		int n = int.Parse(data[0]);
		int m = int.Parse(data[1]);
		int l = int.Parse(data[2]);
		int[,] anm = new int[n, m];
		int[,] bml = new int[m, l];
	
		matrixReader(n, m, anm);
		matrixReader(m, l, bml);
		for (int k = 0; k < n; k++) {
			
			for (int i = 0; i < l; i++) {
				long cnl=0;
				for (int j = 0; j < m; j++) {
					cnl += anm[k, j] * bml[j, i];
				}
				Console.Write(cnl);
				if (i != l-1) {
					Console.Write(" ");
				} else if(i==l-1)
				{
					Console.Write("\r\n");
				}
				
			}
		}
	}
	public static void matrixReader(int row, int column, int[,] matrix)
	{
		for (int i = 0; i < row; i++) {
			string matrixSet = Console.ReadLine();
			string[] number = matrixSet.Split();
			
			for (int j = 0; j < column; j++) {
				matrix[i, j] = int.Parse(number[j]);
			}				
		}
	}
	
		
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> student(n, vector<int>(2));
    for (int i=0; i<n; i++){
        cin >> student[i][0] >> student[i][1];
    }

    vector<vector<int>> distance(n, vector<int>(m));
    
    for (int j=0; j<m; j++){
        int c,d; cin>>c>>d;
        for (int i=0; i<n; i++){
            distance[i][j] = abs(student[i][0] - c) + abs(student[i][1] - d);
        }
    }
    for(int i=0; i<n; i++){
        int ans = min_element(distance[i].begin(), distance[i].end()) - distance[i].begin();
        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,m,k;
  cin >> n >> m >> k;
  vector<int> a(n),b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  int s = 0, ai = -1;
  rep(i,n){
    if(s+a[i]>k) break;
    s += a[i];
    ai = i;
  }
  int ans = ai+1;
  rep(i,m){
    while(s+b[i]>k){
      if(ai<0) break;
      s -= a[ai]; --ai;
    }
    if(s+b[i]>k) break;
    s += b[i];
    ans = max(ans,i+1+ai+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4840