akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<functional>

using namespace std;

bool func(const pair<pair<long long, long long>, long long> &a, const pair<pair<long long, long long>, long long> &b)
{
	return a.first.first < b.first.first;
}

class comp
{
public:
	bool operator() (const pair<pair<long long, long long>, long long>& a, const pair<pair<long long, long long>, long long> &b) const
	{
		return a.second > b.second;
	}
};

bool func2(const pair<long long, int> &a, const pair<long long, int> &b)
{
	return a.first < b.first;
}

bool func3(const pair<long long, int> &a, const pair<long long, int> &b)
{
	return a.second < b.second;
}

int main()
{
	int n, m;
	int i, j;
	vector<pair<pair<long long, long long>, long long>> interv;
	priority_queue<pair<pair<long long, long long>, long long>, vector<pair<pair<long long, long long>, long long>>, comp> pq;
	vector<pair<long long, int>> person, sol;
	long long input1, input2, input3;
	int ptr = 0;

	//freopen("input.txt", "r", stdin);

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++)
	{
		scanf("%lld %lld %lld", &input1, &input2, &input3);

		interv.push_back(pair<pair<long long, long long>, long long>(pair<long long, long long>(input1 - input3, input2 - input3), input3));
	}

	sort(interv.begin(), interv.end(), func);

	for (i = 0; i < m; i++)
	{
		scanf("%lld", &input1);

		person.push_back(pair<long long,int>(input1,i));
	}

	sort(person.begin(), person.end(), func2);

	for (i = 0; i < m; i++)
	{
		while (ptr < n&&interv[ptr].first.first <= person[i].first)
		{
			pq.push(interv[ptr++]);
		}

		while (!pq.empty() && pq.top().first.second <= person[i].first)
		{
			pq.pop();
		}

		if (pq.empty())
		{
			sol.push_back(pair<long long, int>(-1, person[i].second));
		}

		else
		{
			sol.push_back(pair<long long, int>(pq.top().second, person[i].second));
		}
	}

	sort(sol.begin(), sol.end(), func3);

	for (i = 0; i < m; i++)
	{
		printf("%lld\n", sol[i].first);
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    double r;
    cin>>r;
    printf("%.10f %.10f\n", r*r*M_PI, 2*r*M_PI);
}


Measured memory_bytes: 3216
# coding: utf-8
# Your code here!

N =int(input())
B = list(map(int,input().split()))
count=0
for i in range(N):
    if B[i]< 0:
        B[i] =-B[i]
        count+=1
#print(sum(B))
if count%2 == 0:
    print(sum(B))
else:
    print(sum(B)-2*min(B))

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c, d;
    string s;
    cin >> s;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';

    int i, j, k;
    for (i = 0; i < 2; i++)
    {
        for (j = 0; j < 2; j++)
        {
            for (k = 0; k < 2; k++)
            {
                int tmp = a;
                if (i)
                    tmp += b;
                else
                    tmp -= b;
                if (j)
                    tmp += c;
                else
                    tmp -= c;
                if (k)
                    tmp += d;
                else
                    tmp -= d;
                if (tmp == 7)
                    goto LABEL;
            }
        }
    }
LABEL:
{
}
    string ans = "";
    ans += to_string(a);
    if (i)
        ans += "+";
    else
        ans += "-";
    ans += to_string(b);
    if (j)
        ans += "+";
    else
        ans += "-";
    ans += to_string(c);
    if (k)
        ans += "+";
    else
        ans += "-";
    ans += to_string(d);
    ans += "=7";
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
hlist=list(map(int,input().split()))
kaisulist=[]
kaisu=0
for i in range(n-1):
    if hlist[i]>=hlist[i+1]:
        kaisu+=1
    else:
        kaisulist.append(kaisu)
        kaisu=0
kaisulist.append(kaisu)
print(max(kaisulist))

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

int main(){
  int N,X,X_shin ;
  int m[110] ;
  int i,j,c,d,counter ;

  cin >> N >> X ;

  for(i=0 ; i<N ; i++){
    cin >> m[i] ;
    X = X - m[i] ;
  }

  counter = N ;
  X_shin = X ;


  for(i=0;i<N;i++){
    for(j=0;j<N-1;j++){
      c=m[j] ;
      d=m[j+1] ;
      if(m[j]>m[j+1]){
        m[j] = d ;
        m[j+1] = c ;
      }
    }
  }
  for(i=0;X_shin>0;i++){
    if(X_shin-m[i]<0){break ;}
  	while(1){
      if(X_shin-m[i]<0){break ;}
      X_shin = X_shin - m[i] ;
      counter++ ;
    }
  }
  cout << counter << endl;
}
      


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

int main() {
  string s; cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    string s;
    cin>>s;
    set<string>se;
    loop(i,1,s.size()){
      string a,b;
      a=s.substr(0,i);
      b=s.substr(i);
      se.insert(a+b);se.insert(b+a);
      reverse(all(a));
      se.insert(a+b);se.insert(b+a);
      reverse(all(b));
      se.insert(a+b);se.insert(b+a);
      reverse(all(a));
      se.insert(a+b);se.insert(b+a);
    }
    cout<<se.size()<<endl;
  }
}

Measured memory_bytes: 1292
/*
srdhri
agpopa
agsjoi
sagdag
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*
srdhri
agpopa
agsjoi
sagdag
*/
    ios::sync_with_stdio(false);
    int a,b,c,n,s=0;
    cin>>a>>b>>c>>n;
/*
srdhri
agpopa
agsjoi
sagdag
*/
    for(register int i=0;i<=a;i++)
        for(register int j=0;j<=b;j++)
            if(n-i*500-j*100>=0)
                if(n-i*500-j*100<=c*50)
                    s++;
/*
srdhri
agpopa
agsjoi
sagdag
*/
    cout<<s<<endl;
    return 0;
}
/*
srdhri
agpopa
agsjoi
sagdag
*/

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

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e5+5;

int n,m,head[N],tot,vis[N],dis[N],fa[N];
queue <int> q;
struct Edge{
	int next,to;
}e[4*N];

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

void add(int u,int v) {
	e[++tot].next=head[u];
	head[u]=tot;
	e[tot].to=v;
}

void spfa(){
	q.push(1);vis[1]=1;dis[1]=0;
	while(!q.empty()){
		int now=q.front();q.pop();vis[now]=0;
		for(int i=head[now];i;i=e[i].next){
			int p=e[i].to;
			if(dis[p]>dis[now]+1){
				dis[p]=dis[now]+1;fa[p]=now;
				q.push(p);vis[p]=1;
			}
		}
	}
}

signed main()
{
	n=read();m=read();
	Rf(i,2,n) dis[i]=N;
	Rf(i,1,m) {
		R int u=read(),v=read();
		add(u,v);add(v,u);
	}
	spfa();
	R int fl=0;
	Rf(i,1,n) if(dis[i]==N) fl=1;
	if(fl) {
		puts("No");
		return 0;
	}
	puts("Yes");
	Rf(i,2,n) printf("%d\n",fa[i]);


    return 0;
}


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

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

  for (int i = 0; i < 8; i++) {
    string op;
    for (int j = 0; j < 3; j++) {
      if ((i >> j) & 1) {
        op += '+';
      } else {
        op += '-';
      }
    }
    int sum = s[0] - '0';
    for (int j = 0; j < 3; j++) {
      if (op[j] == '+') {
        sum += (s[j+1] - '0');
      } else {
        sum -= (s[j+1] - '0');
      }
    }
    if (sum == 7) {
      for (int j = 0; j < 3; j++) {
        cout << s[j] << op[j];
      }
      cout << s[3] << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    int n = sc.nextInt();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      
	    
	    System.out.println(Math.min(n*a,b));
	}    
}

Measured memory_bytes: 21844
from math import log2

def main():
    N = int(input())
    if N == 0:
        print(0)
        return
    Ans = []
    while N !=  0:
        r = N%2
        Ans.append(r)
        N = -1*( N // 2)
    print(*Ans[::-1],sep="")
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int main(){
    int h,w,n;
    std::cin >> n>>h>>w;
    std::cout << max(0,(n-h+1)*(n-w+1)) << std::endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N,M=map(int,input().split())
divisors=make_divisors(M)
ans=0
for d in divisors:
    if N*d<=M:
        ans=d
    else:
        break
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		int sum=0;
		double sum2=0;
		int count=0;
		
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty()) {
				break;
			}
			StringTokenizer tokenizer = new StringTokenizer(line,",");
			int a = Integer.parseInt(tokenizer.nextToken());
			int b = Integer.parseInt(tokenizer.nextToken());
			
			sum+= a*b;
			sum2+= b;
			count++;
		}
		System.out.println(sum);
		System.out.println(String.format("%.0f", sum2/count));
	}
}

Measured memory_bytes: 16916
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	fmt.Fscan(r, &s)
	fmt.Fscan(r, &t)

	index := -1
	for i := len(s) - len(t); i >= 0; i-- {
		target := s[i : i+len(t)]
		flg := true
		for j := 0; j < len(target); j++ {
			if string(target[j]) != "?" && target[j] != t[j] {
				flg = false
				break
			}
		}
		if flg {
			index = i
			break
		}
	}

	if index >= 0 {
		ans := strings.Replace(s[0:index], "?", "a", -1) + t + strings.Replace(s[index+len(t):], "?", "a", -1)
		fmt.Println(ans)
	} else {
		fmt.Println("UNRESTORABLE")
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
#pragma region template

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#pragma region random

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}

#pragma endregion

#pragma region debug
string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#pragma endregion

#pragma endregion

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<string> s ={"Sunny","Cloudy","Rainy"};
    string t;
    cin>>t;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t)
        {
            cout<<s[(i+1)%3];
        }
    }
    return 0;

}

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



int D=1;
double V[16]; //与えられた点のy座標が入っている
double interpolate(int n, int E) {
	// 補間多項式 L(x) の x=n での値 L(n) を計算する
	// L(x) の作成において，点 (n,V[n]) と (E,V[E]) は使わない
	double sum = 0.0;

	for (int k=0; k<D+3; ++k) {

		if (k == n || k == E) continue;

		double p = V[k];
		for (int i=0; i<D+3; ++i)
		if (i != n && i != E && i != k) {
			p *= (n-i)/(double)(k-i);
		}
		sum += p;
	}
	return sum;
}

bool outlier(int E) {
	for (int i=0; i<D+3; ++i) {
		if (i==E) continue;
		double p = interpolate(i, E);
		if (fabs(p-V[i]) > 0.1) return false;
	}
	return true;
}

int main() {
	while(cin >> D && D) {
		for(int i=0;i<D+3;i++) {
			cin >> V[i];
		}
		for(int i=0;i<D+3;i++) {
			if(outlier(i)) {
				cout << i << endl;
				break;
			}
		}
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    string S, T; cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}


Measured memory_bytes: 3668
-- RayStark氏のコードを参考にした

local read = io.read
local floor = math.floor
local N = read("*n")
local A = {}
for i = 1, N do
	A[i] = read("*n")
end
table.sort(A)

local A_MAX = A[N]

local cant_div_s = {}
for i = 1, N do
	-- なんでcant_divs[i],(1<=i<=A_MAX)でないか
	-- A[i]にない数字は考えなくて良いから
	cant_div_s[A[i]] = true
end

local last_value = 0
for i = 1, N do
	-- cant_divs全部回したら時間かかるんじゃないのか
	-- []のなかにA[i],(1<=i<=N)を使ってるので1つ目のfor文自体はN回
	if cant_div_s[A[i]] and last_value == A[i] then
		cant_div_s[A[i]] = false
	elseif cant_div_s[A[i]] then
		-- なんでj=1でなく2か
		-- A_MAXまでのA[i]より大きい倍数は倍数だから
		-- TODO: ここがボトルネックになっているためここの最適化したい
		for j = 2, floor(A_MAX / A[i]) do
			cant_div_s[A[i] * j] = false
		end
		-- なんで最後に処理した数字を残しておく必要があるか
		-- Aに同じ数が存在する場合にはじくため
		last_value = A[i]
	end
end

local num = 0
for i = 1, N do
	if cant_div_s[A[i]] then
		num = num + 1
	end
end

print(num)


Measured memory_bytes: 19212
import math
q=int(input())
for i in range(q):
 a,b=map(int,input().split())
 if abs(a-b)<2:print(min(a,b)*2-2)
 else:
  s=int(math.ceil(math.sqrt(a*b)))-1
  if s**2+s<a*b:print(2*s-1)
  else:print(2*s-2)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
	char s;
	int cnt=0,n,m,ave;
	int sum=0,k=0;
	while(cin>>n>>s>>m){
		cnt++;
		k+=m;
		sum+=n*m;
	}
	if((k*10/cnt)%10>=5)ave=k/cnt+1;
	else ave=k/cnt;
	cout<<sum<<endl<<ave<<endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;
class Main {
	public  static void main(String[] args) {

		Scanner sc = new  Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int r_sum = 0;
		int l_sum = 0;
		int lmin = 100;

		for(int i =0;i<N;i++) {
			W[i] = sc.nextInt();
		}

		for(int i=1; i < N;i++) {
			r_sum = W[0];
			l_sum = 0;
			for (int j = 1;j < i; j++) {
				r_sum += W[j];
			}
			for (int z = i;z < N; z++) {
				l_sum += W[z];
			}
			lmin = Math.min(lmin, Math.abs(r_sum - l_sum));
		}
		System.out.println(lmin);

	}
}

Measured memory_bytes: 23892
def main():
    N = int(input())
    xlist = list(map(int, input().split()))
    x_min = min(xlist)
    x_max = max(xlist)
    min_sum_value = 10**15
    
    for p in range(100):
        c = 0
        for i in xlist:
            c += (i - p) ** 2
        if min_sum_value > c:
            min_sum_value = c
    print(min_sum_value)

main()




Measured memory_bytes: 3060
N=int(input())
A= list(map(int,input().split()))
maxi=max(A)
mini=min(A)
p = 1000
q = 0

for i in range(N-1):
    if A[i+1]>A[i]:
        q += p//A[i]
        p %= A[i]        
    elif A[i+1]<A[i]:
        p += q*A[i]
        q = 0
    else:
        pass
    #print(i,p,q)
    
p += q*A[-1]
print(p)

Measured memory_bytes: 9188
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<iterator>

int main(void) {
	int N1, N2, N3, N4;

	std::cin >> N1 >> N2 >> N3 >> N4;
	std::vector<bool> given(10);
	for(int i = 0; i < 10; ++i) {
		given[i] = false;
	}
	given[N1] = true;
	given[N2] = true;
	given[N3] = true;
	given[N4] = true;

	if(given[1] && given[9] && given[7] && given[4]) {
		std::cout << "YES" << std::endl;
	}else{
		std::cout << "NO" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

const ll inf=N*1000000000;

vector<ll> ar;
ll dp[N][3][2];
int vis[N][3][2];

ll func(ll idx,ll two,ll three)
{
    if(idx==-1){
        if(two==0&&three==0){return -inf;}
        return 0;
    }
    if(idx<0){
        return -inf;
    }
    if(idx==0){
        if(two==0&&three==0){return -inf;}
        return ar[0];
    }
    if(vis[idx][two][three]==0){
        ll ans=-inf;
        ans=max(ans,ar[idx]+func(idx-2,two,three));
        if(three==0){
            if(two==0){
                ans=max(ans,ar[idx]+func(idx-4,two,1));
                ans=max(ans,ar[idx]+func(idx-3,1,0));
            }
            else if(two==1){
                ans=max(ans,ar[idx]+func(idx-3,2,0));
            }
        }
        dp[idx][two][three]=ans;
        vis[idx][two][three]=1;
    }
    return dp[idx][two][three];
}




ll even()
{
    ll n=ar.size();

    ll pre[n],suf[n];
    for(ll i=0;i<n;++i){
        if(i<=1){
            pre[i]=ar[i];
        }
        else{
            pre[i]=ar[i]+pre[i-2];
        }
    }
    for(ll i=n-1;i>=0;--i){
        if(i>=n-2){
            suf[i]=ar[i];
        }
        else{
            suf[i]=ar[i]+suf[i+2];
        }
    }
    ll ans=max(pre[n-1],pre[n-2]);
    for(ll i=0;i<n;++i){
        if(i%2==0){continue;}
        if(i+2<n)
        {ans=max(ans,pre[i-1]+suf[i+2]);}
    }
    return ans;
}

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

    ll n;
    cin>>n;
    ar.resize(n);
    for(ll i=0;i<n;++i){cin>>ar[i];}
    if(n%2==0){
        cout<<even();
    }
    else{
        memset(dp,-1,sizeof(dp));
        memset(vis,0,sizeof(vis));
        ll ans=func(n-1,0,0);
        ar.pop_back();
        ans=max(ans,even());
        ar.pop_back();
        ll sum=0;
        for(ll i=0;i<ar.size();++i){
            if(i%2==0){sum+=ar[i];}
        }
        ans=max(ans,sum);
        cout<<ans;
    }

    return (0);
}


Measured memory_bytes: 47708
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int w,h;
    string s;
    cin >> w >> h >> s;
    rep(i,h){
        if(i == 0 || i == h-1){
            rep(j,w){
                if(j == 0 || j == w-1)cout << "+";
                else cout << "-";
            }
        }else{
            rep(j,w){
                if(i == h/2 && j == w/2)cout << s;
                else if(j == 0 || j == w-1)cout << "|";
                else cout << ".";
            }
        }
        cout << endl;
    }

}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for (int i = 0; i < n; ++i)
#define tr(i,n) for(auto i=n.begin();i!=n.end();i++)
#define w(t) while(t--)
#define ll long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fst ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
const ll mod = 1000000007;
void solve()
{
    long long int n;
    cin>>n;
    unsigned long long int arr[n],summ[n];
    fo(i,n)
        cin>>arr[i];
    for(int i=n-1;i>=1;i--)
    {
        if(i==n-1)
        {
            summ[i]=arr[i];
        }
        else
        {
            summ[i]=(summ[i+1]+arr[i])%mod;
        }
    }
    long long int ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans+=((arr[i]*summ[i+1])%mod);
        ans=ans%mod;
    }
 
    cout<<ans%mod;
 
}
 
int main()
{
    fst;
    solve();
}

Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
#define ull unsigned long long int
#define gcu getchar_unlocked
#define pc(x) putchar(x);
#define pcu(x) putchar_unlocked(x);
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007

//ll gcd(ll a, ll b)
//{
//    if(b==0)
//        return a;
//    else
//        return gcd(b,a%b);
//}

//void readint(ll &x)
//    {
//        bool neg=false;
//        ll c;
//        x =0;
//        c=gc();
//        if(c=='-')
//        {
//            neg = true;
//            c=gc();
//        }
//        for(;(c>47 && c<58);c=gc())
//            x = (x<<1) + (x<<3) +c -48;
//        if(neg)
//            x *=-1;
//    }
//
//inline void input(ll *n)
//{
////    register char c=getchar_unlocked();
//    *n=0;
//    for(;(c<'0'||c>'9');c=getchar_unlocked());
//    for(;(c<='9'&&c>='0');c=getchar_unlocked())
//    {
//        *n=((*n)<<1) + ((*n)<<3) + c - 48;
//    }
//}
//
//inline void writeInt (ll n)
//{
//    ll N = n, rev, count = 0;
//    rev = N;
//    if (N == 0) { pc('0'); pc('\n'); return ;}
//    if (N*(-1)>0){pc('-');rev=rev*(-1);N=N*(-1);}
//    while ((rev % 10) == 0) { count++; rev /= 10;}
//    rev = 0;
//    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
//    while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
//    while (count--) pc('0');


//ll power(ll x, unsigned ll y, ll p)
//{
//    ll res = 1;
//    x = x % p;
//
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res*x) % p;
//
//        y = y>>1;
//        x = (x*x) % p;
//    }
//    return res;
//}


int main()
{
    SPEED
    ll n,x,i;
    cin>>n>>x;
    ll a[n],s[n+1];
    s[0]=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    cout<<upper_bound(s,s+n+1,x)-s<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	
	int ans=INT_MAX;
	for(int i=-100;i<=100;i++){
	    int sum=0;
	    for(int j=0;j<n;j++){
	        sum+=(arr[j]-i)*(arr[j]-i);
	    }
	    ans=min(ans,sum);
	}
	
	cout<<ans;
	return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

vector<vector<int>>graph;
int p, q;

void dfs(int n, vector<bool> &seen,int &ans){
    bool flag = true;
    int m = seen.size();
    rep(i, 0, m)if(!seen[i]&&i!=n)flag = false;
    if(flag){
        ans++;
        return;
    }
    seen[n] = true;
    for(auto i:graph[n]){
        if(seen[i])continue;
        dfs(i, seen, ans);
    }
    seen[n]=false;
}
int main(){
    cin >> p >> q;
    graph.assign(p, vector<int>());
    rep(i, 0, q){
        int a, b;
        cin >> a >> b;
        a--,b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<bool>seen(p,false);
    int ans = 0;
    dfs(0, seen, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
using namespace std;

int erase(vector<vector<int>>& field) {
    int H = field.size(), W = 5;
    int score = 0;

    for(int i = 0; i < H; ++i) {
        int target = 0, right = 0;
        int count = 0;
        for(int j = 1; j < W; ++j) {
            if(field[i][j] == field[i][j - 1]) ++count;
            else count = 0;
            if(count > 1) {
                target = field[i][j];
                right = j;
            }
        }

        for(int j = right; j >= 0; --j) {
            if(field[i][j] != target) break;
            score += target;
            field[i][j] = 0;
        }
    }

    return score;
}

void fall(vector<vector<int>>& field) {
    int H = field.size(), W = 5;
    for(int j = 0; j < W; ++j) {
        for(int i = H - 1; i > 0; --i) {
            if(field[i][j] != 0) continue;
            for(int k = i - 1; k >= 0; --k) {
                if(field[k][j] == 0) continue;
                swap(field[i][j], field[k][j]);
                break;
            }
        }
    }
}

int main() {
    int H, W = 5;
    while(cin >> H, H) {
        vector<vector<int>> field(H, vector<int>(W));
        for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) cin >> field[i][j];

        int score = 0;
        while(int add = erase(field)) {
            score += add;
            fall(field);
        }

        cout << score << endl;
    }
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int ALPH_SIZE = 26;
string ALPH_S[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

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

    if((int)s.size() < ALPH_SIZE) {
        for(int i = 0; i < ALPH_SIZE; ++i) {
            string c = ALPH_S[i];
            if((int)s.find(c) == -1) {
                cout << s << c << endl;
                return 0;
            }
        }
    }

    int n = ALPH_SIZE;
    int p;
    char c = '-';
    bool found = false;
    for(int i = n-1; i > 0; --i) {
        if(s[i-1] > s[i]) {
            continue;
        }
        p = i;
        c = s[i-1];
        found = true;
        break;
    }

    if(!found) {
        cout << -1 << endl;
        return 0;
    }

    for(int i = n-1;; --i) {
        if(s[i] > c) {
            cout << s.substr(0, p-1) << s[i] << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S/3600;
        int m = (S-h*3600)/60;
        int s = ((S-h*3600)-m*60);
         
        System.out.println(h+":"+m+":"+s);
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}
 
 

Measured memory_bytes: 17228
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  string s;
  cin >> s;
  ll wht_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == '.') wht_cnt++;
  }
  ll ans = wht_cnt;
  for (int i = 0; i < N; i++) {
    if (s[i] == '#') {
      wht_cnt++;
    } else {
      wht_cnt--;
    }
    ans = min(wht_cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (int N, K; cin >> N >> K&&N;) {
		vector<int> S(K);
		rep(i, 0, K)cin >> S[i];
		rep(i, 0, N)rep(j, 0, K) {
			int B; cin >> B;
			S[j] -= B;
		}
		if (*min_element(all(S)) >= 0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
n, m, x = map(int,input().split())
books = []
for _ in range(n):
    books.append(list(map(int,input().split())))
price = float('inf')

for i in range(2**n):
    prtmp = 0
    skill = [0] * m
    for j in range(n):
        if i >> j & 1:
            prtmp += books[j][0]
            for s in range(m):
                skill[s] += books[j][s+1]
    clear = True
    for s in skill:
        if s < x:
            clear = False
            break
    if clear:
        price = min(price,prtmp)

print(-1 if price == float('inf') else price)


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n==3 || n==5 || n==7) cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n, x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    count = 0

    if a[0] > x:
        count += a[0] - x
        a[0] -= count

    for i in range(n - 1):
        summed = a[i] + a[i + 1]

        if summed > x:
            diff = summed - x
            count += diff
            a[i + 1] -= diff

    print(count)


Measured memory_bytes: 14060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>mp;
  rep(i,n)mp[a[i]]++;
  ll ans=0;
  for(auto x:mp)ans+=(x.second*(x.second-1))/2;
  rep(i,n){
    ll v=ans;
    v-=(mp[a[i]]*(mp[a[i]]-1))/2;
    v+=((mp[a[i]]-1)*(mp[a[i]]-2))/2;
    cout<<v<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxN = 5005;
int dp[maxN][maxN];

signed main() {
  int n = read();
  string s = readString();
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (s[i] == s[j])
        dp[i][j] = dp[i + 1][j + 1] + 1;
    }
  }
  int ans = 0;
  REP(i, n) REP(j, n) {
    if (i >= j)
      continue;
    int now = min(dp[i][j], j - i);
    chmax(ans, now);
  }
  print(ans);
}


Measured memory_bytes: 198912
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main() {
  char str[200] ,key[11], end[] = "END_OF_TEXT";
  int c = 0, i;
  scanf("%s", key);
  for(i = 0; i < strlen(key); i++) {
    key[i] = tolower(key[i]);
  }
  while(1) {
    scanf("%s", str); 
    if(strcmp(str,end) == 0) break;
    for(i = 0; i < strlen(key); i++) {
      if(isupper(str[i])) {
        str[i] = tolower(str[i]);
      }
    }
    if(strcmp(str,key) == 0) {
      c++;
    }
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 548
import collections

#入力の取得
n = int(input())
v = list(map(int, input().split()))
odd = []
even = []

#奇数番と偶数番のリストに分割
for i in range(n):
    if i % 2 == 1:
        even.append(v[i])
    else:
        odd.append(v[i])

#それぞれのリストで一番多い数字を調べる
e = collections.Counter(even)
o = collections.Counter(odd)
v_count = collections.Counter(v)
even_max = e.most_common()[0][1]
odd_max = o.most_common()[0][1]
v_max = v_count.most_common()[0][1]

#それぞれのリストで二番目に多い数字を調べる
if e.most_common()[0][1] == int(n/2): #リスト参照でエラー回避の為の条件分岐
    even_max2 = 0
elif o.most_common()[0][1] == int(n/2):
    odd_max2 = 0
else:
    even_max2 = e.most_common()[1][1]
    odd_max2 = o.most_common()[1][1]

if e.most_common()[0][0] == o.most_common()[0][0]:#それぞれのリストで一番多い数字がかぶっていた場合
    if v_max == n: #全部同じ数字だった場合はn/2が答え
        print(int(n/2))

    elif (even_max - even_max2) <= (odd_max - odd_max2):#奇数と偶数リストのどちらを2番目に大きい数字に変えたほうがいいか　変えることによる回数増加が小さい方を採用
        print(n - even_max2 - odd_max) #偶数の方で2番目を使う
    else:
        print(n - even_max - odd_max2) #奇数の方で2番目を使う

else:
    print(n - even_max - odd_max) #それぞれ一番多い数字に他の数字を変換する　(n/2 - even_max) + (n/2 - odd_max)


Measured memory_bytes: 29908
'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。

'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

# import numpy as np


def main():
    '''メイン処理'''
    k, s = map(int, input().split())

    counter = 0
    # x,y,zは全て0～kの値を取る。 x+y+z = sを満たす。
    for x in range(k+1):
        if x > s:
            # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
            break

        for y in range(k+1):
            if x+y > s:
                # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
                break
            
            # 3重ループではTLEになる。x+y+z = s なので、z=s-x-yとなるzがあればカウントする
            z = s-x-y
            if z >= 0 and z <= k:
                counter += 1

    print(counter)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <ccomplex>

using namespace std;

int main(void){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  complex<double> z1(x1, y1), z2(x2, y2), z3, z4;
  complex<double> a(0, 1), b(0, -1);

  //cout << z1.real() << "+" << z1.imag() << "i" << endl;
  //cout << z2.real() << "+" << z2.imag() << "i" << endl;
  
  z3 = (z1 - z2)*b + z2;
  z4 = (z2 - z1)*a + z1;
  
  //cout << z3.real() << "+" << z3.imag() << "i" << endl;
  //cout << z4.real() << "+" << z4.imag() << "i" << endl;

  cout << z3.real() << " " << z3.imag() << " " << z4.real() << " " << z4.imag() << endl; 
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
	template <typename T> inline void writesp(T x) { write(x); putchar(' '); }
	template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
}
using namespace IO;
const int N = 2e5 + 5;
int n, m, k, a[N], b[N];
ll suma[N], sumb[N];
int main(){
	read(n); read(m); read(k);
	for (int i = 1; i <= n; i++) read(a[i]); 
	
	for (int i = 1; i <= m; i++) read(b[i]); 
	
	for (int i = 1; i <= n; i++) suma[i] = suma[i - 1] + a[i];
	for (int i = 1; i <= m; i++) sumb[i] = sumb[i - 1] + b[i];
	
	int ans = 0;
	int npos = m;
	for (int i = 0; i <= n; i++)
	{
		while (npos >= 0 && suma[i] + sumb[npos] > k) npos--;
		if (suma[i] + sumb[npos] <= k) chkmax(ans, i + npos);
	}
	
	writeln(ans);
  return 0;
}

Measured memory_bytes: 8312
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
ll mod=998244353;
ll p=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    if(s== "ABC") cout<<"ARC";
    else cout<<"ABC";
    

    
    return 0;
}



Measured memory_bytes: 3648
#include<stdio.h>

main()
{
    char S[5];
    int i,j,t=0;
    gets(S);
    for(i=0;i<3;i++)
        for(j=i+1;j<4;j++)
        {
            if(S[i]==S[j])
                t++;
        }
        if(t==2)
            printf("Yes");
        else
            printf("No");
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <string>
#include <sstream>
#include <cstdio>

using namespace std;

bool debug = false;

double toint(string str){
  istringstream iss(str);
  double ret;

  iss >> ret;
  return ret;
}

int main(void){
  stack<double> st;
  string str;
  string tmp = "";
  while(getline(cin, str)){
     for(int i=0;i<str.size();i++){
      if(debug) cout << i << ":" << str[i] << endl;
      if(('0' <= str[i] && str[i] <= '9') || str[i] == '.' ||
	 (str[i] == '-' && '0' <= str[i+1] && str[i+1] <= '9')){
	tmp += str[i];
      }else if(str[i] == ' '){
	if(!tmp.empty()){
	  st.push(toint(tmp));
	  if(debug) cout << "pushed " << tmp << endl;
	  tmp.clear();
	}
      }else{
	double arg1, arg2;
	arg2 = st.top(); st.pop();
	arg1 = st.top(); st.pop();
	if(str[i] == '+'){
	  st.push(arg1 + arg2);
	}else if(str[i] == '-'){
	  st.push(arg1 - arg2);
	}else if(str[i] == '*'){
	  st.push(arg1 * arg2);
	}else{
	  st.push(arg1 / arg2);
	}
      }
    }
    if(!st.empty()){
      printf("%.7f\n", st.top());
    }if(!tmp.empty()){
      printf("%.7f\n", toint(tmp));
      tmp.clear();
    }
    while(!st.empty()) st.pop();
  }
  
}

Measured memory_bytes: 0
def main():
    N = int(input())  # total doll 1 <= N <= 100
    for d in range(20):
        for c in range(25):
            total = d * 7 + c * 4
            if total == N:
                print('Yes')
                return

    print('No')


if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll sum(ll l, ll r) { return (r - l + 1) * (l + r) / 2; }

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

  // ll a[n + 2];
  // a[0] = 0;
  // rep(i, n + 2) a[i + 1] = a[i] + i;

  ll ans = 0;
  for (int i = k; i <= n + 1; ++i) {
    // ll mn = a[i], mx = a[n + 1] - a[n + 1 - i];
    ll mn = sum(0, i - 1);
    ll mx = sum(n - i + 1, n);
    ans += (mx - mn + 1) % mod;
    // ans %= mod;
  }
  ans %= mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, v[22], c[22], ans = 0;

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &v[i]);
	}
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &c[i]);
		if(v[i] > c[i])ans += v[i] - c[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    int ans = (B/A);
    if(ans>C)
    {
        cout<<C<<endl;
        return 0;
    }
    else 
    {
       cout<<ans<<endl;
        return 0;
    }
}


Measured memory_bytes: 3616
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class BinaryIndexedTree:
    # 1-indexed
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
    
    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def sum(self, i):
        res = 0
        while i:
            res += self.data[i]
            i -= i & -i
        return res
    
    def bisect_left(self, w):
        if w <= 0:
            return 0
        i = 0
        k = 1 << (self.n.bit_length() - 1)
        while 0 < k:
            if i + k <= self.n and self.data[i + k] < w:
                w -= self.data[i + k]
                i += k
            k >>= 1
        return i + 1


def solve():
    N, K = map(int, rl().split())
    a = tuple(int(rl()) for _ in range(N))
    
    b = [0]
    acc = 0
    for i in range(N):
        acc += a[i]
        b.append(acc - (i + 1) * K)
    
    compress = {bi: idx for idx, bi in enumerate(sorted(b))}
    bit = BinaryIndexedTree(N + 1)
    
    ans = 0
    for bi in b:
        ans += bit.sum(compress[bi] + 1)
        bit.add(compress[bi], 1)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 87512
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <utility>
static const int MAXN = 53;

int n, m;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%d%d", &a[i], &b[i]);
    for (int i = 0; i < m; ++i) scanf("%d%d", &c[i], &d[i]);

    for (int i = 0; i < n; ++i) {
        std::pair<int, int> ans(4e8, -1);
        for (int j = 0; j < m; ++j)
            ans = std::min(ans, std::make_pair(std::abs(c[j] - a[i]) + std::abs(d[j] - b[i]), j));
        printf("%d\n", ans.second + 1);
    }

    return 0;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	int N,K;
	cin>>N>>K;
	vec(p,N);
	vin(p);
	sort(all(p));
	int ans = 0;
	rep(i,K){
		ans+=p[i];
	}
	cout<<ans<<_n;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3632